AdminResumeController.php 9.6 KB
<?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\ArtModel;
use app\portal\model\BannerModel;
use app\portal\model\HireModel;
use app\portal\model\OrderModel;
use app\portal\model\ResumeModel;
use cmf\controller\AdminBaseController;
use FontLib\Table\Type\post;
use think\Db;
use think\Loader;

/**
 * Class AdminResumeController
 * @package app\portal\controller
 * @adminMenuRoot(
 *     'name'   =>'简历管理',
 *     'action' =>'default',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 30,
 *     'icon'   =>'th',
 *     'remark' =>'简历管理'
 * )
 */
class AdminResumeController extends AdminBaseController
{
    /**
     * 简历列表
     * @adminMenu(
     *     'name'   => '简历列表',
     *     'parent' => 'portal/AdminResume/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '简历列表',
     *     'param'  => ''
     * )
     */
    public function index(){
        $data = $this->request->param();
        $final = $this->adminIndex($data);
        $arr = array();
        if(!empty($final['where_arr']['create_time'])){
            $where_coo['r.create_time'] = $final['where_arr']['create_time'];
            $arr['create_time'] = $final['where_arr']['create_time'];
        }
        if(!empty($data['address'])){
            $arr['address'] = $data['address'];
            $where_coo['r.address'] = array('like',"%".$data['address']."%");
            $this->assign('address',$data['address']);
        }
        if(!empty($data['name'])){
            $arr['name'] = $data['name'];
            $where_coo['m.name'] = array('like',"%".$data['name']."%");
            $this->assign('name',$data['name']);
        }
        if(!empty($data['select'])){
            $arr['select'] = $data['select'];
            $where_coo['r.select_id'] = $data['select'];
            $this->assign('select',$data['select']);
        }
        $where_coo['r.status'] = array('neq',9);
        $coo_list = Db::name('Resume')->alias('r')
            ->where($where_coo)
            ->join("Select s",'s.id = r.select_id')
            ->join("Member m",'m.id = r.user_id')
            ->field('r.* , s.name as select_name ,m.name as member_name ')
            ->order('r.create_time desc')
            ->paginate(10,false,['query'=>$arr]);

        $this->assign('list',$coo_list);
        $where_sel['type'] = 2;
        $where_sel['status'] = array('neq',9);
        $sel = Db::name('Select')->where($where_sel)->select()->toArray();
        $this->assign('sel',$sel);
        return $this->fetch();
    }






    /**
     * 查看简历
     * @adminMenu(
     *     'name'   => '查看简历',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '查看简历',
     *     'param'  => ''
     * )
     */
    public function view()
    {
        $where_coo['r.id'] = $this->request->param('id');
        $where_coo['r.status'] = array('neq',9);
        $list = Db::name('Resume')->alias('r')
            ->where($where_coo)
            ->join("Select s",'s.id = r.select_id')
            ->join("Member m",'m.id = r.user_id')
            ->field('r.* , s.name as select_name ,m.name as member_name ')
            ->order('r.create_time desc')
            ->find();
        $list['create_time'] = date('Y-m-d H:i:s',$list['create_time']);
        $list['update_time'] = date('Y-m-d H:i:s',$list['update_time']);
        $this->assign('list',$list);
//        雇佣事项
        $where_select['type'] = 2;
        $where_select['status'] = array('neq',9);
        $select = Db::name('Select')->where($where_select)->select()->toArray();
        $this->assign('select',$select);
        return $this->fetch();
    }

    //    聘用信息审核
    public function operation(){
        $data = $this->request->param();
//        拒绝
        if($data['type'] == 4){
//            判断是否重复提交
            $where_log['type'] = 2;
            $where_log['compareId'] = $data['id'];
            $isSet = Db::name('Refund')->where($where_log)->find();
            if($isSet){
                $this->apiResponse('0','请勿重复操作!');
            }
            $add_log['type'] = 2;
            $add_log['compareId'] = $data['id'];
            $add_log['content'] = $data['refund'];
            $add_log['create_time'] = time();
            $add_log['update_time'] = time();
            $res_refund = Db::name('Refund')->where($add_log)->insertGetId($add_log);
            if(!$res_refund){
                $this->apiResponse('0','操作失败');
            }
        }
        $model = new ResumeModel();
        $up_order['id'] = $data['id'];
        $up_order['status'] = $data['type'];
        $up_order['update_time'] = time();
        $res = $model->isUpdate(true)->save($up_order);
        if($res){
//            发送模板消息

            $this->apiResponse('1','操作成功');
        }else{
            $this->apiResponse('0','操作失败');
        }
    }

    /**
     * 编辑简历
     * @adminMenu(
     *     'name'   => '编辑简历',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑简历',
     *     'param'  => ''
     * )
     */
    public function edit()
    {
//            添加数据
        $data = $this->request->post();
        unset($data['create_time']);
        unset($data['update_time']);
        unset($data['member_name']);
        $validate = Loader::validate('Resume');
        if(!$validate->scene('')->check($data)){
            $mes = $validate->getError();
            $this->error("$mes");
        }
        $model = new ResumeModel();
        $final = $model->isUpdate(true)->save($data);
        if($final){
            $this->success('成功',url('index'));
        }else{
            $this->error('失败');
        }
    }

    /**
     * 查看简历列表
     * @adminMenu(
     *     'name'   => ' 查看简历列表',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => ' 查看简历列表',
     *     'param'  => ''
     * )
     */
    public function toList()
    {
        $data = $this->request->param();
        $final = $this->adminIndex($data);
        $arr = array();
        if(!empty($final['where_arr']['create_time'])){
            $where_hire['l.create_time'] = $final['where_arr']['create_time'];
            $arr['create_time'] = $final['where_arr']['create_time'];
        }
        if(!empty($data['name'])){
            $arr['name'] = $data['name'];
            $where_hire['m.name'] = array('like',"%".$data['name']."%");
            $this->assign('name',$data['name']);
        }
        if(!empty($data['tel'])){
            $arr['tel'] = $data['tel'];
            $where_hire['m.tel'] = array('like',"%".$data['tel']."%");
            $this->assign('tel',$data['tel']);
        }
        $where_coo['o.status'] = array('neq',9);
        $where_coo['o.id'] = $data['id'];
        $coo_list = Db::name('Order')->alias('o')
            ->where($where_coo)
            ->join("Member m",'m.id = o.user_id')
            ->field('m.name,m.tel,o.order_sn,o.hire_id,o.id')
            ->find();
        $final['parent'] = $coo_list;
//        查询关联表,获取分配人信息
        $where_hire['l.hire_id'] = $coo_list['hire_id'];
        $where_hire['l.status'] = array('neq',9);
        $log = Db::name('CompareLog')->alias('l')
            ->where($where_hire)
            ->join('Resume r','r.id = l.resume_int')
            ->join("Member m",'m.id = r.user_id')
            ->field("m.name,m.tel,m.id as user_id , l.id ,l.status,l.create_time,l.update_time,l.start,l.common_time")
            ->paginate(1,false,['query'=>$arr]);
//            ->select()->toArray();
        $final['log'] = $log;
        $this->assign('list',$final);
        $this->assign('page',$log->render());
        return $this->fetch('tolist');
    }


    /**
     * 删除聘用信息
     * @adminMenu(
     *     'name'   => '删除聘用信息',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '删除聘用信息',
     *     'param'  => ''
     * )
     */
    public function del(){
        $ids = $this->request->post();
        $id = $this->request->param('id');
        if($ids){
            $add_del['id'] = array('in',$ids['ids']);
        }else if($id){
            $add_del['id'] = $id;
        }else{
            $this->error('删除失败');
        }
        $add_del['status'] = 9;
        $model = new ResumeModel();
        $del = $model->isUpdate(true)->allowField(true)->save($add_del);
        if($del){
            $this->success('删除成功',url('index'));
        }else{
            $this->error('删除失败');
        }
    }
}