<?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); } }