| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 | 
							- <?php
 
- namespace App\Admin\Controllers\Jobfair;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\AuditReason;
 
- use App\Models\Company;
 
- use App\Models\Jobfair\Jobfair;
 
- use App\Models\Jobfair\JobfairJob;
 
- use App\Models\Jobfair\JobfairPutJob;
 
- use App\Models\Pms;
 
- use App\Models\Subsite;
 
- use Encore\Admin\Controllers\HasResourceActions;
 
- use Encore\Admin\Facades\Admin;
 
- use Encore\Admin\Form;
 
- use Encore\Admin\Grid;
 
- use Encore\Admin\Layout\Content;
 
- use Encore\Admin\Show;
 
- use Illuminate\Http\Request;
 
- use App\Admin\Exports\Jobfair\PutJobsExport;
 
- use Illuminate\Support\Facades\Cache;
 
- class JobfairPutJobsController extends Controller
 
- {
 
-     use HasResourceActions;
 
-     /**
 
-      * Index interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function index(Content $content,Request $request)
 
-     {
 
-         $company_id = isset($request->company_id) ? $request->company_id : false;
 
-         $grid=$this->grid($company_id)->render();
 
-         return $content
 
-             ->header('参会职位')
 
-             ->description('')
 
-             ->body(view('admin.jobfair.put_jobs')->with(['grid'=>$grid]));
 
-     }
 
-     /**
 
-      * Show interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function show($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('参会职位详情')
 
-             ->description('')
 
-             ->body($this->detail($id));
 
-     }
 
-     /**
 
-      * Edit interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function edit($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('参会职位编辑')
 
-             ->description('')
 
-             ->body($this->form()->edit($id));
 
-     }
 
-     /**
 
-      * Create interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function create(Content $content)
 
-     {
 
-         return $content
 
-             ->header('参会职位创建')
 
-             ->description('description')
 
-             ->body($this->form());
 
-     }
 
-     /**
 
-      * Make a grid builder.
 
-      *
 
-      * @return Grid
 
-      */
 
-     protected function grid($company_id)
 
-     {
 
-         $grid = new Grid(new JobfairPutJob);
 
-         $grid->model()->when(get_subsite_id()>0, function ($query) {
 
-             $query->whereHas('jobfair_company',function($query){
 
-                 $query->whereHas('subsites', function ($query) {
 
-                     $query->where('subsite_id', get_subsite_id())->where('subsites.effective', 1);
 
-                 });
 
-             });
 
-         })
 
-             ->when($company_id==true,function ($query) use ($company_id){
 
-                 $query->where('company_id',$company_id);
 
-             })->whereHas('jobs')
 
-             ->orderBy('jobfair_id', 'desc')
 
-             ->orderBy('updated_at', 'desc');
 
-         $grid->jobs_name('职位名称')->display(function ($jobs_name) {
 
-             return '<a href="'.route('jobfair.show.quarters',$this->id) .'" target="_blank">'.$jobs_name.'</a>';
 
-         })->width(200);
 
-         $grid->company_name('发布公司')->display(function ($company_name) {
 
-             return '<a href="'. route('jobs.company',['id'=>$this->company_id]).'" target="_blank">'.$company_name.'</a>';
 
-         })->width(200);
 
-         $grid->column('jobfairs.title', '招聘会标题')->display(function ($title) {
 
-             return "<a href='".  route('jobfair.show.com',$this->jobfair_id)."' target='_blank'>".$title."</a>";
 
-         })->width(200);
 
-         $grid->audit('审核状态')->display(function () {
 
-             if ($this->jobs->audit==1) {
 
-                 return'<span style="color: #009900">审核通过</span>';
 
-             } elseif ($this->jobs->audit==3) {
 
-                 return'<span style="color:#666666">审核未通过</span>';
 
-             } else {
 
-                 return'<span style="color:#FF6600">等待审核</span>';
 
-             }
 
-         });
 
-         $grid->amount('人数')->display(function ($amount){
 
-             return $amount ? $amount : '若干';
 
-         });
 
-         $grid->district_cn('工作地区')->width(150);
 
-         if(get_subsite_open()){
 
-             $grid->column('jobfairs.subsite_id', '所属分站')->display(function ($subsite_id) {
 
-                 if ($subsite_id) {
 
-                     $Subsite = Subsite::find($subsite_id);
 
-                     return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
 
-                 }
 
-                 return '总站';
 
-             });
 
-         }
 
-         $grid->created_at('创建时间');
 
-         $grid->actions(function ($actions) use ($grid) {
 
-             if (Admin::user()->can('jobfair_put_jobs_delete')) {
 
-                 $actions->disableDelete(false);
 
-             }
 
-         });
 
-         if (Admin::user()->can('jobfair_put_jobs_delete')) {
 
-             $grid->tools(function ($tools) {
 
-                 $tools->batch(function ($batch) {
 
-                     $batch->disableDelete(false);
 
-                 });
 
-             });
 
-             $grid->disableRowSelector(false);
 
-         }
 
-         if (Admin::user()->can('jobfair_put_jobs_export')) {
 
-             $grid->disableExport(false); //显示导出按钮
 
-             $grid->exporter(new PutJobsExport()); //传入自己在第1步创建的导出类
 
-         }
 
- //        $grid->tools(function ($tools) {
 
- //            if (Admin::user()->can('jobfair_put_jobs_audit')) {
 
- //                $but = <<<EOT
 
- //<div class="btn-group" data-toggle="buttons">
 
- //    <label class="btn btn-google btn-sm" id="Audit_Put_Jobs" title="审核职位">
 
- //        <i class="fa fa-audio-description"></i>
 
- //        <input type="radio" class="user-gender">审核职位
 
- //    </label>
 
- //</div>
 
- //EOT;
 
- //                $tools->append($but);
 
- //            }
 
- //        });
 
-         $grid->filter(function ($filter) {
 
-             // 去掉默认的id过滤器
 
-             $filter->disableIdFilter();
 
-             $filter->column(1/2, function ($filter) {
 
-                 $filter->like('jobs_name', '职位名称');
 
-                 $filter->equal('jobfair_id', '招聘会')->select(Jobfair::select('title', 'id')->when(get_subsite_id()>0,function ($query){
 
-                     $query->whereHas('subsites', function ($query) {
 
-                         $query->where('subsite_jobfairs.subsite_id', get_subsite_id())->where('subsites.effective', 1);
 
-                     });
 
-                 })->pluck('title', 'id')->all());
 
-                 $filter->where(function ($query) {
 
-                     switch ($this->input) {
 
-                         case 3:
 
-                             $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
 
-                             break;
 
-                         case 7:
 
-                             $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
 
-                             break;
 
-                         case 30:
 
-                             $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
 
-                             break;
 
-                     }
 
-                 }, '刷新时间', 'updated_at')->select([
 
-                     3=>'三天内',
 
-                     7=>'一周内',
 
-                     30=>'一月内',
 
-                 ]);
 
-                 if(get_subsite_id() == 0 && get_subsite_open()){
 
-                     $filter->equal('jobfairs.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
 
-                 }
 
-             });
 
-             $filter->column(1/2, function ($filter) {
 
-                 $filter->like('company_name', '公司名称');
 
-                 $filter->where(function ($query) {
 
-                     switch ($this->input) {
 
-                         case 1:
 
-                             $query->whereHas('jobs',function ($query){
 
-                                 $query->where('audit',1);
 
-                             });
 
-                             break;
 
-                         case 2:
 
-                             $query->whereHas('jobs',function ($query){
 
-                                 $query->where('audit',2);
 
-                             });
 
-                             break;
 
-                         case 3:
 
-                             $query->whereHas('jobs',function ($query){
 
-                                 $query->where('audit',3);
 
-                             });
 
-                             break;
 
-                     }
 
-                 }, '审核状态', 'audit')->select([
 
-                     1=>'审核通过',
 
-                     2=>'等待审核',
 
-                     3=>'审核未通过',
 
-                 ]);
 
-                 $filter->where(function ($query) {
 
-                     switch ($this->input) {
 
-                         case 1:
 
-                             $query->whereHas('jobs',function ($query){
 
-                                 $query->where('display','1')->where('audit',1);
 
-                             });
 
-                             break;
 
-                         case 2:
 
-                             $query->whereHas('jobs',function ($query){
 
-                                 $query->where('display','2')->orWhere('audit','<>',1);
 
-                             });
 
-                             break;
 
-                     }
 
-                 }, '显示状态', 'display')->select([
 
-                     1=>'显示',
 
-                     2=>'关闭',
 
-                 ]);
 
-             });
 
-         });
 
-         return $grid;
 
-     }
 
-     /**
 
-      * Make a show builder.
 
-      *
 
-      * @param mixed $id
 
-      * @return Show
 
-      */
 
-     protected function detail($id)
 
-     {
 
-         $show = new Show(JobfairPutJob::findOrFail($id));
 
-         $show->id('ID');
 
-         $show->jobs_name('职位名称')->as(function ($jobs_name) {
 
-             return $jobs_name;
 
-         });
 
-         $show->company_name('发布公司')->as(function ($company_name) {
 
-             return $company_name;
 
-         });
 
-         $show->jobfairs()->title('招聘会标题')->as(function ($jobfairs) {
 
-             return $jobfairs->title;
 
-         });
 
-         $show->audit('审核状态')->as(function () {
 
-             if ($this->jobs->audit==1) {
 
-                 return '审核通过';
 
-             } elseif ($this->jobs->audit==3) {
 
-                 return '审核未通过';
 
-             } else {
 
-                 return '等待审核';
 
-             }
 
-         });
 
-         $show->display('显示状态')->as(function () {
 
-             if ($this->jobs->audit==1 && $this->jobs->display==1) {
 
-                 return '显示';
 
-             } else {
 
-                 return '关闭';
 
-             }
 
-         });
 
-         $show->amount('人数')->as(function ($amount) {
 
-             return $amount;
 
-         });
 
-         $show->district('工作地区')->as(function ($district_cn) {
 
-             return $district_cn;
 
-         });
 
-         $show->jobfairs()->subsite('所属分站')->as(function ($jobfairs) {
 
-             if ($jobfairs->subsite_id) {
 
-                 $Subsite = Subsite::find($jobfairs->subsite_id);
 
-                 return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
 
-             }
 
-             return '总站';
 
-         });
 
-         $show->jobs_content('职位描述')->setEscape(false);
 
-         $show->created_at('创建时间');
 
-         $show->updated_at('更新时间');
 
-         return $show;
 
-     }
 
-     /**
 
-      * Make a form builder.
 
-      *
 
-      * @return Form
 
-      */
 
-     protected function form()
 
-     {
 
-         $form = new Form(new JobfairPutJob);
 
-         $form->display('ID');
 
-         $form->display('Created at');
 
-         $form->display('Updated at');
 
-         return $form;
 
-     }
 
-     public function auditPutJobs(Request $request)
 
-     {
 
-         $id = $request->id;
 
-         $form = new \Encore\Admin\Widgets\Form();
 
-         $form->action(route('jobfair.auditPutR'));
 
-         $form->disableReset();
 
-         $form->hidden('id', 'ID')->default($id);
 
-         $form->radio('audit', '审核')->options([1=>'审核通过',3=>'审核未通过'])->default(1);
 
-         $form->textarea('remark', '备注');
 
-         $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
 
-         return json_encode(['html'=>$form->render(),'detail'=>'审核职位']);
 
-     }
 
-     public function auditPutR(Request $request)
 
-     {
 
-         $id = $request->id;
 
-         $audit = $request->audit;
 
-         $remark = $request->remark;
 
-         $pms_notice = $request->pms_notice;
 
-         $arr = array_filter(explode(',', $id));
 
-         if (empty($id)) {
 
-             admin_toastr('数据异常', 'error');
 
-             return back();
 
-         }
 
-         $job_ids = JobfairPutJob::whereIn('id', $arr)->pluck('job_id');
 
-         $result = JobfairJob::whereIn('id', $job_ids)->update(['audit'=>$audit]);
 
-         foreach ($arr as $k => $v){
 
-             $job = JobfairPutJob::where('id', $v)->first();
 
-             Cache::put($job->jobfair_id.'-'.$job->company_id, time(),72000);
 
-         }
 
-         $data=[];
 
-         foreach ($arr as $k => $v) {
 
-             $data[$k]['type'] = 12;
 
-             $data[$k]['type_id'] = $v;
 
-             $data[$k]['status'] = $audit;
 
-             $data[$k]['reason'] = $remark;
 
-             $data[$k]['audit_man'] = Admin::user()->username;
 
-             $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
 
-             $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
 
-         }
 
-         AuditReason::insert($data);
 
-         if ($pms_notice) {
 
-             if ($audit==3) {
 
-                 $stat='审核不通过';
 
-             } elseif ($audit==1) {
 
-                 $stat = '审核通过';
 
-             } else {
 
-                 $stat='待审核';
 
-             }
 
-             $reus=JobfairPutJob::whereIn('id', $arr)->get();
 
-             $ds = [];
 
-             foreach ($reus as $k => $v) {
 
-                 $ds[$k]['utype'] = 1;
 
-                 $ds[$k]['msgtype'] = 1;
 
-                 $ds[$k]['msgfromuid'] = Admin::user()->id;
 
-                 $ds[$k]['msgfrom'] = Admin::user()->username;
 
-                 $ds[$k]['msgtoname'] = $v->company_name ? $v->company_name : 'admin';
 
-                 $ds[$k]['msgtouid'] = $v->company_id ? $v->company_id : 0;
 
-                 $ds[$k]['message'] =  $remark ? '参会职位(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '参会职位(id:'.array_values($arr)[$k].')'.$stat;
 
-                 $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
 
-                 $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
 
-             }
 
-             Pms::insert($ds);
 
-         }
 
-         if ($result) {
 
-             admin_toastr('审核成功', 'success');
 
-         } else {
 
-             admin_toastr('审核失败', 'error');
 
-         }
 
-         return back();
 
-     }
 
- }
 
 
  |