AdminAddRentController.php
4.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\AddRentModel;
use app\portal\model\ChangeRentModel;
use app\portal\model\ConditionModel;
use app\portal\model\VehicleModel;
use cmf\controller\AdminBaseController;
use app\portal\model\PortalPostModel;
use app\portal\service\PostService;
use app\portal\model\PortalCategoryModel;
use think\Db;
use app\admin\model\ThemeModel;
use think\Loader;
class AdminAddRentController extends AdminBaseController
{
/**
* 增加器械申请
* @adminMenu(
* 'name' => '增加器械申请',
* 'parent' => 'portal/AdminRentStatus/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '增加器械申请',
* 'param' => ''
* )
*/
public function index()
{
$data = $this->request->param();
$name_arr = array();
$return = $this->adminIndex($data);
$ret = $return['page_arr'];
if(!empty($return['where_arr']['create_time'])){
$where_change['a.create_time'] = $return['where_arr']['create_time'];
}
// 商品名
if(!empty($data['keyword'])){
$where_change['v.name'] = array('like','%'.$data['keyword'].'%');
$ret['keyword'] = $data['keyword'];
$this->assign('keyword',$data['keyword']);
}
// 店铺名
if(!empty($data['store'])){
$ret['store'] = $data['store'];
$where_change['a.store_id'] = $data['store'];
$this->assign('store_id',$data['store']);
}
$where_change['a.status'] = array('neq',9);
$list = Db::name('AddRent')->alias('a')
->where($where_change)
->join('Store s','s.id = a.store_id')
->join('Vehicle v','v.id = a.vehicle_id')
->field('v.name , s.store_name,s.id as store_id ,a.*')
->order('a.create_time desc')
->paginate(10,false,['query'=>$ret]);
$where_store['status'] = array('neq',9);
$store= Db::name('Store')
->where($where_store)
->select()->toArray();
$page = $list->render();
$this->assign('page', $page);
$this->assign('list', $list);
$this->assign('store', $store);
return $this->fetch();
}
/**
* 增加申请审核
* @adminMenu(
* 'name' => '增加申请审核',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '增加申请审核',
* 'param' => ''
* )
*/
public function agree()
{
$data = $this->request->param();
$model = new AddRentModel();
$where_status['id'] = $data['id'];
$where_status['status'] = 2;
$status = $model->where($where_status)->find();
if($status){
$update['status'] = $data['status'];
$res = $model->where($where_status)->update($update);
if($res){
$this->apiResponse('1','操作成功');
}else{
$this->apiResponse('0','操作失败');
}
}else{
$this->apiResponse('0','状态错误');
}
}
/**
* 删除增加申请
* @adminMenu(
* 'name' => '删除申请',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除申请',
* 'param' => ''
* )
*/
public function del()
{
$model = new AddRentModel();
$this->adminDel($model);
}
}