RoomOrder.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace app\school\controller\project_appointment;
use app\common\controller\DoubleBase;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
use app\school\model\project_appointment\Building as BuildingModel;
use app\school\model\project_appointment\Floor as FloorModel;
use app\school\model\project_appointment\Room as RoomModel;
use app\school\model\project_appointment\RoomOrder as RoomOrderModel;
/**
* 房间管理
*/
class RoomOrder extends DoubleBase
{
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new RoomOrderModel();
}
/**
* 预约审核index
* @return array|\think\response\Json
* @author cdd
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams(null,true);
$params = json_decode($this->request->get('filter'),true);
$newwhere = [];
if(isset($params['room_name'])) {
$newwhere['r.room_name'] = ['like',"%".$params['room_name']."%"];
}
if(isset($params['username']) && !empty($params['username'])) {
$newwhere['u.username'] = ['like',"%".$params['username']."%"];
}
$list = $this->model
->field('o.*,r.room_name,u.username')
->alias('o')
->join('project_room r','o.room_id = r.id','inner')
->join('user u','o.user_id = u.id','left')
->where(['r.school_id' => SCHOOL_ID])
->where($newwhere)
->order('o.createtime', $order)
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
public function verify()
{
$params = $this->request->param();
$info = $this->model->find($params['id']);
$info->status = $params['status'];
if(!$info->save()) {
$this->error('审核失败');
}
$this->success('成功');
}
}