|
@@ -0,0 +1,52 @@
|
|
|
|
+<?php
|
|
|
|
+class renjiazhuangClassModel extends Model
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ public function baseCarList() {
|
|
|
|
+ $sqlStr = 'select * from xinhu_rjz_car_list';
|
|
|
|
+ $rows = $this->db->getall($sqlStr);
|
|
|
|
+ return $rows;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 车辆管理
|
|
|
|
+ public function getCarList()
|
|
|
|
+ {
|
|
|
|
+ $data = $this->baseCarList();
|
|
|
|
+ $arr = [];
|
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
|
+
|
|
|
|
+ $arr[] = array('name' => $v['car_num'].'【'.$v['car_type'].'】', 'value'=>$v['car_num']);
|
|
|
|
+ }
|
|
|
|
+ return $arr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getCarListByType($carType)
|
|
|
|
+ {
|
|
|
|
+ $sqlStr = 'select id, car_num, car_type, car_state from xinhu_rjz_car_list where car_type = "'.$carType.'"';
|
|
|
|
+ $rows = $this->db->getall($sqlStr);
|
|
|
|
+ return $rows;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public function getCarCon($cartype='') {
|
|
|
|
+
|
|
|
|
+ if(strlen($cartype) > 0) {
|
|
|
|
+ $where = " and car_type = '" . $cartype . "'";
|
|
|
|
+ }
|
|
|
|
+ // option表选项id
|
|
|
|
+ $optionTablePid = 1146;
|
|
|
|
+ $table = '[Q]option a left join [Q]rjz_car_list b on a.`name` = b.car_type';
|
|
|
|
+ $where = "pid = $optionTablePid $where";
|
|
|
|
+ $fields = "a.`name` as car_type, count(b.id) car_con, count(case when car_state = '正常' then 1 end) car_free_con";
|
|
|
|
+ $rows = $this->db->getone($table, $where, $fields);
|
|
|
|
+ return $rows;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function updateCarState($carname, $carstate) {
|
|
|
|
+ if ($carname) {
|
|
|
|
+ $res = $this->db->update('[Q]rjz_car_list','`car_state`="'.$carstate.'"','`car_num` = "'.$carname.'"');
|
|
|
|
+ return returnsuccess($res);
|
|
|
|
+ }
|
|
|
|
+ return returnerror('车牌号为空');
|
|
|
|
+ }
|
|
|
|
+}
|