AdminExhibitorsController.php
7.5 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* 参展预登记(参观申请)
* Author : xiaojie
* DateTime: 2018/11/30 15:32
*/
namespace app\portal\controller;
use app\portal\model\ExhibitorsModel;
use cmf\controller\AdminBaseController;
/**
* Class AdminExhibitorsController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'参观申请',
* 'action' =>'default',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 30,
* 'icon' =>'th',
* 'remark' =>'参观申请'
* )
*/
class AdminExhibitorsController extends AdminBaseController
{
protected $category = [
1 => '模具加工及模具零配件',
2 => '自动化及机器人',
3 => '产品',
4 => '金属制品',
5 => '汽车及零部件制造',
6 => '家电及厨卫',
7 => '家具及土木行业',
8 => '机床、数控设备、通用机械',
9 => '医疗器械',
10 => '刀具、工具、材料',
11 => '计算机、通信、消费类电子产品(含手机、智能穿戴、办公室设备及安防产品等)'
];
protected $objective = [
1 => '了解市场概况,寻找新技术、新产品',
2 => '拜访客户',
3 => '采购/下订单',
4 => '参加会议活动',
5 => '评估是否参展',
6 => '开发新的供应商',
7 => '其他',
];
protected $interest = [
1 => '金属切削机床',
2 => '钣金机床',
3 => '冲床、冲压及钣金自动化',
4 => '精密机械零件',
5 => '特殊钢及材料',
6 => '模具及金属制品',
7 => '数字化测量',
8 => '3D打印及软件',
9 => '工控系统及传动',
10 => '机器人及应用',
11 => '刀具工具及硬质合金'
];
protected $understand = [
1 => '主办方的邀请函',
2 => '参展商的邀请函',
3 => '多年参观',
4 => '电子邮件',
5 => '报纸/杂志广告',
6 => '网站/搜索引擎',
7 => '微博/微信',
8 => '朋友/同事/同行推荐',
9 => '行业协会/商会',
10 => '其他',
];
/**
* 参观申请
* @adminMenu(
* 'name' => '参观申请',
* 'parent' => 'portal/AdminExhibitors/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '参观申请',
* 'param' => ''
* )
*/
public function index()
{
$exhibitordModel = new ExhibitorsModel();
$param = $this->request->param();
$map = $this->search($param,'create_time','name|mobile|company_name');
$list = $exhibitordModel
->where($map)
->order('id DESC')
->paginate(30)->each(function ($item){
if($item['category']){
$item['category_list'] = '';
foreach ($item['category'] as $k=>$v){
$item['category_list'] = $item['category_list'] . '/' . $this->category[$v];
$item['category_list'] = trim($item['category_list'],'/');
}
}
if($item['understand']){
$item['understand_list'] = '';
foreach ($item['understand'] as $k=>$v){
$item['understand_list'] = $item['understand_list'] . '/' . $this->understand[$v];
$item['understand_list'] = trim($item['understand_list'],'/');
}
}
});
$this->assign('list',$list);
$this->assign('page',$list->render());
return $this->fetch();
}
/**
* 编辑参观申请
* @adminMenu(
* 'name' => '编辑参观申请',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑参观申请',
* 'param' => ''
* )
*/
public function edit()
{
$exhibitordModel = new ExhibitorsModel();
$id = $this->request->param('id','','intval');
$info = $exhibitordModel->where('id',$id)->find();
$this->assign('category_list',$this->category);
$this->assign('objective_list',$this->objective);
$this->assign('interest_list',$this->interest);
$this->assign('understand_list',$this->understand);
$this->assign('info',$info);
return $this->fetch();
}
/**
* 编辑参观申请提交
* @adminMenu(
* 'name' => '编辑参观申请提交',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑参观申请提交',
* 'param' => ''
* )
*/
public function editPost()
{
$param = $this->request->param();
$exhibitordModel = new ExhibitorsModel();
if(!in_array(7,$param['objective'])){
$param['objective_data'] = '';
}else{
if(empty($param['objective_data'])){
$this->error('请填写此行目的');
}
}
if(!in_array(10,$param['understand'])){
$param['understand_data'] = '';
}else{
if(empty($param['understand_data'])){
$this->error('请填写得知方式');
}
}
$res = $exhibitordModel->isUpdate(true)->save($param);
if($res){
$this->success('保存成功');
}
$this->error('请稍后重试');
}
/**
* 删除
* @adminMenu(
* 'name' => '删除',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除',
* 'param' => ''
* )
*/
public function delete()
{
$exhibitordModel = new ExhibitorsModel();
$res = $this->del($exhibitordModel);
if($res){
$this->success('删除成功');
}
$this->error('请稍后重试');
}
/**
* 参展登记导出
*/
public function export()
{
$exhibitordModel = new ExhibitorsModel();
$data = $exhibitordModel
->field('name,mobile,company_name,post,category,understand,create_time')
->select()->each(function ($item){
if($item['category']){
$item['category_list'] = '';
foreach ($item['category'] as $k=>$v){
$item['category_list'] = $item['category_list'] . '/' . $this->category[$v];
$item['category_list'] = trim($item['category_list'],'/');
}
unset($item['category']);
}
if($item['understand']){
$item['understand_list'] = '';
foreach ($item['understand'] as $k=>$v){
$item['understand_list'] = $item['understand_list'] . '/' . $this->understand[$v];
$item['understand_list'] = trim($item['understand_list'],'/');
}
unset($item['understand']);
}
$item['create_time'] = date('Y-m-d',$item['create_time']);
})->toArray();
$this->exportExcel(array('联系人','手机号','企业名称','职务','申请时间','所属行业','消息来源'), $data, '参观申请', './', true);
}
}