<?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\BannerModel; use cmf\controller\AdminBaseController; use think\Db; use think\Loader; /** * Class AdminSelectController * @package app\portal\controller * @adminMenuRoot( * 'name' =>'选择内容管理', * 'action' =>'default', * 'parent' =>'', * 'display'=> true, * 'order' => 30, * 'icon' =>'th', * 'remark' =>'选择内容管理' * ) */ class AdminSelectController extends AdminBaseController { /** * 雇佣事项列表 * @adminMenu( * 'name' => '雇佣事项列表', * 'parent' => 'portal/AdminSelect/default', * 'display'=> true, * 'hasView'=> true, * 'order' => 10000, * 'icon' => '', * 'remark' => '雇佣事项列表', * 'param' => '' * ) */ public function index() { $data = $this->request->param(); $final = $this->adminIndex($data); $where_else = $final['where_arr']; $where_else['status'] = array('neq',9); if(!empty($data['type'])){ if($data['type'] != 0){ $final['page_arr']['type'] = $data['type']; $where_else['type'] = $data['type']; $this->assign('type',$data['type']); } } $coo_list = Db::name('Select')->where($where_else)->order('score desc , create_time desc') ->paginate(10,false,['query'=>$final['page_arr']]); $page = $coo_list->render(); $this->assign('page',$page); $this->assign('list',$coo_list); return $this->fetch('index'); } /** * 添加雇佣事项 * @adminMenu( * 'name' => '添加雇佣事项', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> true, * 'order' => 10000, * 'icon' => '', * 'remark' => '添加雇佣事项', * 'param' => '' * ) */ public function add() { if($data = $this->request->param()){ // 添加数据 $data['create_time'] = time(); $data['update_time'] = time(); $final = Db::name('Select')->insertGetId($data); if($final){ $this->success('成功',url('index')); }else{ $this->error('失败'); } }else{ return $this->fetch('add'); } } /** * 查看雇佣事项 * @adminMenu( * 'name' => '查看雇佣事项', * 'parent' => 'banner', * 'display'=> false, * 'hasView'=> true, * 'order' => 10000, * 'icon' => '', * 'remark' => '查看雇佣事项', * 'param' => '' * ) */ public function view() { $where_find['id'] = $this->request->param('id'); $list = Db::name('Select')->where($where_find)->find(); $this->assign('list',$list); return $this->fetch('view'); } /** * 编辑雇佣事项 * @adminMenu( * 'name' => '编辑雇佣事项', * 'parent' => 'banner', * 'display'=> false, * 'hasView'=> true, * 'order' => 10000, * 'icon' => '', * 'remark' => '编辑雇佣事项', * 'param' => '' * ) */ public function edit() { // 添加数据 $data = $this->request->post(); // 修改 $add['type'] = $data['type']; $add['name'] = $data['name']; $add['score'] = $data['score']; $add['update_time'] = time(); $where_add['id'] = $data['id']; $final = Db::name('Select')->where($where_add)->update($add); if($final){ $this->success('成功',url('index')); }else{ $this->error('失败'); } } /** * 删除雇佣事项 * @adminMenu( * 'name' => '删除雇佣事项', * 'parent' => 'banner', * 'display'=> false, * 'hasView'=> true, * 'order' => 10000, * 'icon' => '', * 'remark' => '删除雇佣事项', * 'param' => '' * ) */ public function del(){ $ids = $this->request->post(); $id = $this->request->param('id'); if($ids){ $where_select['id'] = array('in',$ids['ids']); }else if($id){ $where_select['id'] = $id; }else{ $this->error('删除失败'); } $add_del['status'] = 9; $add_del['update_time'] = time(); $del = Db::name('Select')->where($where_select)->update($add_del); if($del){ $this->success('删除成功',url('index')); }else{ $this->error('删除失败'); } } }