JobfairJobController.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. <?php
  2. namespace App\Admin\Controllers\Jobfair;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\AuditReason;
  5. use App\Models\Category;
  6. use App\Models\CategoryDistrict;
  7. use App\Models\CategoryJobs;
  8. use App\Models\Jobfair\JobfairJob;
  9. use App\Models\Jobfair\JobfairJobsContact;
  10. use App\Models\Jobfair\JobfairPutJob;
  11. use App\Models\Jobfairout\JobfairoutPutJob;
  12. use App\Models\Pms;
  13. use Encore\Admin\Controllers\HasResourceActions;
  14. use Encore\Admin\Facades\Admin;
  15. use Encore\Admin\Form;
  16. use Encore\Admin\Grid;
  17. use Encore\Admin\Layout\Content;
  18. use Encore\Admin\Show;
  19. use Illuminate\Support\MessageBag;
  20. use Illuminate\Http\Request;
  21. use Illuminate\Support\Facades\Input;
  22. use Illuminate\Support\Facades\Cache;
  23. class JobfairJobController extends Controller
  24. {
  25. use HasResourceActions;
  26. /**
  27. * Index interface.
  28. *
  29. * @param Content $content
  30. * @return Content
  31. */
  32. public function index(Content $content)
  33. {
  34. return $content
  35. ->header('招聘会职位库')
  36. ->description('为了统计数据,职位库审核不再同步已结束招聘会的参会职位,请及时审核!')
  37. ->body(view('admin.jobfair.jobs')->with(['grid'=>$this->grid()]));
  38. }
  39. /**
  40. * Show interface.
  41. *
  42. * @param mixed $id
  43. * @param Content $content
  44. * @return Content
  45. */
  46. public function show($id, Content $content)
  47. {
  48. return $content
  49. ->header('招聘会职位详情')
  50. ->description('')
  51. ->body($this->detail($id));
  52. }
  53. /**
  54. * Edit interface.
  55. *
  56. * @param mixed $id
  57. * @param Content $content
  58. * @return Content
  59. */
  60. public function edit($id, Content $content)
  61. {
  62. $js = <<<ETO
  63. $(document).ready(function() {
  64. $('.radio-inline,.iCheck-helper').click(function() {
  65. var val = $(this).closest(".radio-inline").find("input:radio").val();
  66. if (val == '0') {
  67. $("input[name=wage]").parents('.form-group').hide();
  68. }
  69. else if (val == '1') {
  70. $("input[name=wage]").parents('.form-group').show();
  71. }
  72. });
  73. });
  74. ETO;
  75. Admin::script($js);
  76. return $content
  77. ->header('招聘会职位编辑')
  78. ->description('')
  79. ->body($this->editForm($id)->edit($id));
  80. }
  81. /**
  82. * Create interface.
  83. *
  84. * @param Content $content
  85. * @return Content
  86. */
  87. public function create(Content $content)
  88. {
  89. return $content
  90. ->header('招聘会职位创建')
  91. ->description('')
  92. ->body($this->form());
  93. }
  94. /**
  95. * Make a grid builder.
  96. *
  97. * @return Grid
  98. */
  99. protected function grid()
  100. {
  101. $grid = new Grid(new JobfairJob);
  102. $grid->model()
  103. ->with('company')
  104. ->where('type',1)
  105. ->when(get_subsite_id()>0, function ($query) {
  106. $query->whereHas('company', function ($query) {
  107. $query->where('companys.subsite_id', get_subsite_id());
  108. });
  109. })
  110. ->orderByRaw("FIELD(audit, 2,1,3)")->orderBy('updated_at', 'desc');
  111. $grid->jobs_name('职位名称')->width(200);
  112. $grid->company_name('发布公司')->display(function ($company_name) {
  113. return '<a href="'.route('jobs.company',['id'=>$this->company_id]) .'" target="_blank">'.$company_name.'</a>';
  114. })->width(200);
  115. $grid->audit('审核状态')->display(function ($audit) {
  116. if ($audit==1) {
  117. return'<span style="color: #009900">审核通过</span>';
  118. } elseif ($audit==3) {
  119. return'<span style="color:#666666">审核未通过</span>';
  120. } else {
  121. return'<span style="color:#FF6600">等待审核</span>';
  122. }
  123. });
  124. $grid->amount('人数')->display(function ($amount) {
  125. return $amount ? $amount : '若干';
  126. });
  127. $grid->sex_cn('性别');
  128. $grid->education_cn('学历')->display(function ($education_cn) {
  129. return $education_cn ? $education_cn : '不限';
  130. });
  131. $grid->wage_cn('待遇')->width(100);
  132. $grid->district_cn('工作地区');
  133. if(get_subsite_open()){
  134. $grid->subsite('所属分站')->display(function () {
  135. if(isset($this->company->subsites)){
  136. return $this->company->subsites->sitename;
  137. }else{
  138. return '总站';
  139. }
  140. });
  141. }
  142. $grid->created_at('创建时间');
  143. $grid->updated_at('更新时间');
  144. $grid->actions(function ($actions) use ($grid) {
  145. if (Admin::user()->can('jobfair_jobs_delete')) {
  146. $actions->disableDelete(false);
  147. }
  148. if (Admin::user()->can('jobfair_jobs_edit')) {
  149. $actions->disableEdit(false);
  150. }
  151. if (Admin::user()->can('company_manager_bussiness')) {
  152. $actions->append("<button class='btn btn-primary btn-xs business' id=" . $actions->row['company_id'] . ">业务</button>");
  153. }
  154. if (Admin::user()->can('jobfair_jobs_audit')) {
  155. $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
  156. }
  157. });
  158. if (Admin::user()->can('jobfair_jobs_delete')) {
  159. $grid->tools(function ($tools) {
  160. $tools->batch(function ($batch) {
  161. $batch->disableDelete(false);
  162. });
  163. });
  164. $grid->disableRowSelector(false);
  165. }
  166. $grid->tools(function ($tools) {
  167. if (Admin::user()->can('jobfair_jobs_audit')) {
  168. $but = <<<EOT
  169. <div class="btn-group" data-toggle="buttons">
  170. <label class="btn btn-google btn-sm" id="Audit_Jobs" title="审核职位">
  171. <i class="fa fa-audio-description"></i>
  172. <input type="radio" class="user-gender">审核职位
  173. </label>
  174. </div>
  175. EOT;
  176. $tools->append($but);
  177. }
  178. });
  179. $grid->filter(function ($filter) {
  180. // 去掉默认的id过滤器
  181. $filter->disableIdFilter();
  182. $filter->column(1/2, function ($filter) {
  183. $filter->like('jobs_name', '职位名称');
  184. $filter->like('company_name', '公司名称');
  185. $filter->equal('sex', '性别')->select([
  186. 0=>'不限',
  187. 1=>'男',
  188. 2=>'女',
  189. ]);
  190. });
  191. $filter->column(1/2, function ($filter) {
  192. $filter->equal('audit', '审核状态')->select([
  193. 1=>'审核通过',
  194. 2=>'等待审核',
  195. 3=>'审核未通过',
  196. ]);
  197. $filter->where(function ($query) {
  198. switch ($this->input) {
  199. case 3:
  200. $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
  201. break;
  202. case 7:
  203. $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
  204. break;
  205. case 30:
  206. $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
  207. break;
  208. }
  209. }, '刷新时间', 'updated_at')->select([
  210. 3=>'三天内',
  211. 7=>'一周内',
  212. 30=>'一月内',
  213. ]);
  214. });
  215. });
  216. return $grid;
  217. }
  218. /**
  219. * Make a show builder.
  220. *
  221. * @param mixed $id
  222. * @return Show
  223. */
  224. protected function detail($id)
  225. {
  226. $show = new Show(JobfairJob::findOrFail($id));
  227. $show->id('ID');
  228. $show->jobs_name('职位名称');
  229. $show->company_name('发布公司')->as(function ($company_name) {
  230. return $company_name;
  231. });
  232. $show->audit('审核状态')->as(function ($audit) {
  233. if ($audit==1) {
  234. return '审核通过';
  235. } elseif ($audit==3) {
  236. return '审核未通过';
  237. } else {
  238. return '等待审核';
  239. }
  240. });
  241. $show->display('显示状态')->as(function ($audit) {
  242. if ($audit==1) {
  243. return '显示';
  244. } else {
  245. return '关闭';
  246. }
  247. });
  248. $show->amount('人数');
  249. $show->sex_cn('性别');
  250. $show->education_cn('学历');
  251. $show->wage_cn('待遇');
  252. $show->district_cn('工作地区');
  253. $show->jobs_content('职位描述')->setEscape(false);
  254. $show->created_at('创建时间');
  255. $show->updated_at('更新时间');
  256. return $show;
  257. }
  258. protected function editForm($id)
  259. {
  260. $form = new Form(new JobfairJob);
  261. $form->tab('职位信息', function (Form $form) use ($id) {
  262. $form->display('id');
  263. $jobsData = JobfairJob::where('id', $id)->select('age', 'tag', 'topclass', 'category', 'subclass', 'district', 'wage', 'wage_min', 'wage_max','syq','syqxz_min','ygxs','updated_at')->first()->toArray();
  264. $age = explode('-', $jobsData['age']);
  265. if ($jobsData['district']) {
  266. $district = string_to_array('.', $jobsData['district']);
  267. }
  268. $form->text('jobs_name', '职位名称')->rules(['required'], ['required'=>'请填写职位名称'])->setMustMark();
  269. $form->display('company_name', '企业名称');
  270. // $form->radio('display', '在招状态')->options([1=>'在招',2=>'关闭']);
  271. $form->radio('audit', '审核状态')->options([0=>'未审核',1=>'审核通过',2=>'审核中',3=>'审核未通过']);
  272. $jobsNature = Category::categoryType('AIX_jobs_nature');
  273. $form->radio('nature', '职位性质')->options($jobsNature);
  274. $form->select('ygxs', '用工形式')->options(Category::categoryType('AIX_ygxs'))->rules(['required'], ['required' => '请填写用工形式',])->setMustMark();
  275. $form->text('hour_money', '小时工薪资')->default($jobsData['wage_min'])->setMustMark();
  276. $form->hidden('wage_min_value', '系统最低工资')->default(config('aix.companyset.comset.com_set.wage_min'));
  277. $techlevel = Category::categoryType('AIX_techlevel');
  278. $techlevel['0'] = '不限';
  279. $form->select('techlevel', '技能等级')->options($techlevel)->setMustMark();
  280. $form->select('topclass', '职位大类')->options(CategoryJobs::List()->pluck('name', 'id'))->load('category', admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位大类'))->setMustMark();
  281. $form->select('category', '职位中类')->options(CategoryJobs::category($jobsData['topclass']))->load('subclass', admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位中类'))->setMustMark();
  282. $form->select('subclass', '职位小类')->options(CategoryJobs::category($jobsData['category']))->rules('required', array('required'=>'请选择职位小类'))->setMustMark();
  283. if (!empty($district)) {
  284. $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default($district[0])->setMustMark();
  285. $form->select('city', '所属城市')->options(CategoryDistrict::categoryDis($district[0]))->setWidth(3)->load('area', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default($district[1])->setMustMark();
  286. $form->select('area', '所属县区')->default(isset($district[2])?$district[2]:0)->options(CategoryDistrict::categoryDis($district[1]))->setWidth(3)->default(isset($district[2]) ? $district[2] : '')->setMustMark();
  287. } else {
  288. $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default(0)->setMustMark();
  289. $form->select('city', '所属城市')->setWidth(3)->load('area', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default(0)->setMustMark();
  290. $form->select('area', '所属县区')->setWidth(3)->default(0)->setMustMark();
  291. }
  292. if ($jobsData['wage'] == 0) {
  293. $form->hidden('wage');
  294. $form->number('wage_min', '最低薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->help("请填写大于".config('aix.companyset.comset.com_set.wage_min')."的10的倍数")
  295. ->rules(['required'], ['required'=>'请选择最小薪资'])->setMustMark();
  296. $form->number('wage_max', '最高薪资')->help("请填写大于最低薪资的10的倍数")->rules(['required'], ['required'=>'请填写最大薪资'])->setMustMark();
  297. } else {
  298. $option = Category::categoryType('AIX_wage');
  299. $option[-1] ='面议';
  300. $form->select('wage', '薪资待遇')->options($option)->default($jobsData['wage'])->rules(['required'], ['required'=>'请选择薪资待遇'])->setMustMark();
  301. $form->hidden('wage_min');
  302. $form->hidden('wage_max');
  303. }
  304. $form->select('syq', '试用期时间')->options(Category::categoryType('zs_syq'))->default($jobsData['syq'])->rules(['required'], ['required'=>'请选择试用期时间'])->setMustMark();
  305. $form->number('syqxz_min', '试用期薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->default($jobsData['syqxz_min'])->help("请填写大于" . config('aix.companyset.comset.com_set.wage_min') . "的10的倍数")->setMustMark();
  306. $education = Category::categoryType('AIX_education');
  307. $education['0']='不限';
  308. $form->radio('education', '学历要求')->options($education);
  309. $experience = Category::categoryType('AIX_experience');
  310. $experience['0']="不限";
  311. $form->radio('experience', '工作经验')->options($experience);
  312. $form->radio('sex', '性别要求')->options([0=>'不限',1=>'男',2=>'女']);
  313. $form->number('min_age', '最低年龄')->default(isset($age[0])?$age[0]:'')->min(16)->max(65)->help('最低年龄不能低于国家规定用工年龄');
  314. $form->number('max_age', '最高年龄')->default(isset($age[1])?$age[1]:'')->min(16)->max(65)->help('最高年龄不能高于65周岁');
  315. $form->number('amount', '招聘人数')->min(1)->max(99)->rules(['required'], ['required'=>'请输入招聘人数'])->help('请填写招聘人数1~99')->setMustMark();
  316. $form->multipleSelect('tag', '职位亮点')->options(Category::categoryType('AIX_jobtag'))->default(explode(',', $jobsData['tag']));
  317. $form->textarea('jobs_content', '职位描述')->attribute(['maxlength'=>2000])->rules(['required'], ['required'=>"请填写职位描述"])->setMustMark();
  318. })->tab('联系人', function (Form $form) {
  319. $form->text("contact.contact", '联系人')->setWidth(3)->rules(['required'], ['required'=>"请填写联系人"])->setMustMark();
  320. $form->radio('contact.contact_show', '联系人是否公开')->options([0=>'不公开',1=>'公开']);
  321. $form->text('contact.mobile', '联系电话')->setWidth(3)->rules(['required'], ['required'=>"请填写联系电话"])->setMustMark();
  322. $form->radio('contact.telephone_show', '联系电话是否公开')->options([0=>'不公开',1=>'公开']);
  323. $form->text('contact.landline_tel', '固定电话')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)'); //这个字段引起问题
  324. $form->radio('contact.landline_tel_show', '固定电话是否公开')->options([0=>'不公开',1=>'公开']);
  325. $form->text('contact.email', 'Email')->setWidth(3)->rules(['required'], ['required'=>"请填写Email"])->setMustMark();
  326. $form->radio('contact.email_show', 'Email是否公开')->options([0=>'不公开',1=>'公开']);
  327. $form->text('contact.address', '联系地址')->setWidth(3)->rules(['required'], ['required'=>"请填写联系地址"])->setMustMark();
  328. });
  329. $form->ignore('province');
  330. $form->ignore('city');
  331. $form->ignore('area');
  332. $form->ignore('tag');
  333. $form->ignore('min_age');
  334. $form->ignore('max_age');
  335. $form->ignore('wage_min_value');
  336. $form->saving(function ($form) {
  337. $minage = Input::get('min_age');
  338. $maxage = Input::get('max_age');
  339. if ($maxage && $minage) {
  340. if ($maxage <= $minage) {
  341. $error = new MessageBag([
  342. 'title' => '提示',
  343. 'message' => '最高年龄不能小最低年龄',
  344. ]);
  345. return back()->with(compact('error'));
  346. }
  347. }
  348. if ($form->wage == -1) {
  349. $form->wage_min = 0;
  350. $form->wage_max = 0;
  351. $form->wage_cn = '面议';
  352. } else {
  353. if ($form->wage!=0) {
  354. $wage = explode('~', format_wage(get_category($form->wage)));
  355. if (isset($wage[1])) {
  356. $form->wage_max = $wage[1];
  357. $form->wage_cn = $wage[0].'~'.$wage[1].'/月';
  358. }else{
  359. $form->wage_min = $wage[0];
  360. $form->wage_cn = $wage[0].'以上/月';
  361. }
  362. } else {
  363. if ($form->wage_min == 0 || $form->wage_max == 0) {
  364. $error = new MessageBag([
  365. 'title' => '提示',
  366. 'message' => '最低薪资和最高薪资不能为0',
  367. ]);
  368. return back()->with(compact('error'));
  369. }
  370. if ($form->wage_min < config('aix.companyset.comset.com_set.wage_min')) {
  371. $error = new MessageBag([
  372. 'title' => '提示',
  373. 'message' => '最低薪资请填写大于'.config('aix.companyset.comset.com_set.wage_min'),
  374. ]);
  375. return back()->with(compact('error'));
  376. }
  377. if ($form->wage_min%10 != 0) {
  378. $error = new MessageBag([
  379. 'title' => '提示',
  380. 'message' => '薪资请填写10的倍数',
  381. ]);
  382. return back()->with(compact('error'));
  383. }
  384. if ($form->wage_max%10 != 0) {
  385. $error = new MessageBag([
  386. 'title' => '提示',
  387. 'message' => '薪资请填写10的倍数',
  388. ]);
  389. return back()->with(compact('error'));
  390. }
  391. if (isset($form->wage_max) && $form->wage_max && $form->wage_max < $form->wage_min) {
  392. $error = new MessageBag([
  393. 'title' => '提示',
  394. 'message' => '最高薪资不能低于最低薪资',
  395. ]);
  396. return back()->with(compact('error'));
  397. }
  398. $form->wage_cn = $form->wage_min.'~'.$form->wage_max.'/月';
  399. }
  400. }
  401. if ($form->min_age && $form->min_age < 16) {
  402. $error = new MessageBag([
  403. 'title' => '提示',
  404. 'message' => '最低年龄不能小于16岁',
  405. ]);
  406. return back()->with(compact('error'));
  407. }
  408. $tag = Input::get('tag');
  409. $tag = array_filter($tag);
  410. if(count($tag) > 6){
  411. $error = new MessageBag([
  412. 'title' => '提示',
  413. 'message' => '职位亮点最多可选择6个',
  414. ]);
  415. return back()->with(compact('error'));
  416. }
  417. if ($form->max_age && $form->min_age > 65) {
  418. $error = new MessageBag([
  419. 'title' => '提示',
  420. 'message' => '最高年龄不能大于65岁',
  421. ]);
  422. return back()->with(compact('error'));
  423. }
  424. $hour_money = Input::get('hour_money');
  425. if (($form->ygxs == 363) && $hour_money == "") {
  426. $error = new MessageBag([
  427. 'title' => '提示',
  428. 'message' => '请填写小时工薪资',
  429. ]);
  430. return back()->with(compact('error'));
  431. }
  432. if ($form->ygxs == 363 && $hour_money < 16.5) {
  433. $error = new MessageBag([
  434. 'title' => '提示',
  435. 'message' => '小时工薪资不能少于16.5元',
  436. ]);
  437. return back()->with(compact('error'));
  438. }
  439. if (($form->syq != 367 && $form->wage != -1)&& $form->syqxz_min == 0) {
  440. $error = new MessageBag([
  441. 'title' => '提示',
  442. 'message' => '试用期薪资不能为0',
  443. ]);
  444. return back()->with(compact('error'));
  445. }
  446. if (($form->syq != 367 && $form->wage != -1) && $form->syqxz_min % 10 != 0) {
  447. $error = new MessageBag([
  448. 'title' => '提示',
  449. 'message' => '试用期薪资请填写10的倍数',
  450. ]);
  451. return back()->with(compact('error'));
  452. }
  453. if (($form->syq != 367 && $form->wage != -1) && $form->syqxz_min < config('aix.companyset.comset.com_set.wage_min')) {
  454. $error = new MessageBag([
  455. 'title' => '提示',
  456. 'message' => '试用期薪资请填写大于' . config('aix.companyset.comset.com_set.wage_min'),
  457. ]);
  458. return back()->with(compact('error'));
  459. }
  460. if ($form->wage != 0) {
  461. $wage = explode('~', format_wage(get_category($form->wage)));
  462. if (isset($wage[1])) {
  463. $form->wage_max = $wage[1];
  464. }
  465. $form->wage_min = $wage[0];
  466. }
  467. if($form->wage_min > 0 && ($form->syq != 367 && $form->wage != -1) && $form->ygxs != 363){
  468. if($form->syqxz_min < $form->wage_min * 0.8){
  469. $error = new MessageBag([
  470. 'title' => '提示',
  471. 'message' => '试用期薪资不能低于最低工资的80%('.$form->wage_min * 0.8.'元)',
  472. ]);
  473. return back()->with(compact('error'));
  474. }
  475. }
  476. if ($form->ygxs == 363) {
  477. $form->wage = 0;
  478. $form->wage_max = $hour_money;
  479. $form->wage_min = $hour_money;
  480. $form->wage_cn = $hour_money.'/小时';
  481. }
  482. });
  483. $form->ignore('hour_money');
  484. $form->saved(function (Form $form) use ($id) {
  485. $province = \Illuminate\Support\Facades\Request::input('province');
  486. $city = \Illuminate\Support\Facades\Request::input('city');
  487. $area = \Illuminate\Support\Facades\Request::input('area');
  488. $age[] = \Illuminate\Support\Facades\Request::input('min_age');
  489. $age[] = \Illuminate\Support\Facades\Request::input('max_age');
  490. $age = implode('-', $age);
  491. $nature_cn = get_category(\Illuminate\Support\Facades\Request::input('nature'));
  492. $sex_cn = \Illuminate\Support\Facades\Request::input('sex') == 0 ? '不限' : (\Illuminate\Support\Facades\Request::input('sex') == 1 ? '男' :'女');
  493. $education_cn = get_category(\Illuminate\Support\Facades\Request::input('education'));
  494. $experience_cn = get_category(\Illuminate\Support\Facades\Request::input('experience'));
  495. $district = $province.'.'.$city.'.'.$area;
  496. JobfairJob::where('id', $id)->update([
  497. 'district'=>$district,
  498. 'age'=>$age,
  499. 'wage_cn'=>$form->wage_cn,
  500. 'nature_cn'=>$nature_cn,
  501. 'sex_cn'=>$sex_cn,
  502. 'education_cn'=>$education_cn,
  503. 'experience_cn'=>$experience_cn,
  504. ]);
  505. $tag = \Illuminate\Support\Facades\Request::input('tag');
  506. if ($tag) {
  507. $tag = array_filter($tag);
  508. $tag = implode(',', $tag);
  509. JobfairJob::where('id', $id)->update(['tag'=>$tag,'tag_cn'=>get_tag_cn($tag)]);
  510. }
  511. //修改参展职位(审核时同步 暂且注释)
  512. // $put_jobs = JobfairPutJob::whereHas('jobfairs',function ($query){
  513. // $query->where('holddate_end','>=',time());
  514. // })->where(['job_id'=>$id])->get();
  515. // //修改参展职位
  516. // if($put_jobs->isNotEmpty()){
  517. // $jobfairJob = JobfairJob::find($id);
  518. // foreach ($put_jobs as $val){
  519. // $val['jobs_name'] = $jobfairJob['jobs_name'];
  520. // $val['company_id'] = $jobfairJob['company_id'];
  521. // $val['company_name'] = $jobfairJob['company_name'];
  522. // $val['company_audit'] = $jobfairJob['company_audit'];
  523. // $val['stick'] = $jobfairJob['stick'];
  524. // $val['nature'] = $jobfairJob['nature'];
  525. // $val['nature_cn'] = $jobfairJob['nature_cn'];
  526. // $val['sex'] = $jobfairJob['sex'];
  527. // $val['sex_cn'] = $jobfairJob['sex_cn'];
  528. // $val['age'] = $jobfairJob['age'];
  529. // $val['amount'] = $jobfairJob['amount'];
  530. // $val['topclass'] = $jobfairJob['topclass'];
  531. // $val['category'] = $jobfairJob['category'];
  532. // $val['subclass'] = $jobfairJob['subclass'];
  533. // $val['category_cn'] = $jobfairJob['category_cn'];
  534. // $val['trade'] = $jobfairJob['trade'];
  535. // $val['trade_cn'] = $jobfairJob['trade_cn'];
  536. // $val['scale'] = $jobfairJob['scale'];
  537. // $val['scale_cn'] = $jobfairJob['scale_cn'];
  538. // $val['district'] = $jobfairJob['district'];
  539. // $val['district_cn'] = $jobfairJob['district_cn'];
  540. // $val['tag'] = $jobfairJob['tag'];
  541. // $val['tag_cn'] = $jobfairJob['tag_cn'];
  542. // $val['education'] = $jobfairJob['education'];
  543. // $val['education_cn'] = $jobfairJob['education_cn'];
  544. // $val['experience'] = $jobfairJob['experience'];
  545. // $val['experience_cn'] = $jobfairJob['experience_cn'];
  546. // $val['wage'] = $jobfairJob['wage'];
  547. // $val['wage_min'] = $jobfairJob['wage_min'];
  548. // $val['wage_max'] = $jobfairJob['wage_max'];
  549. // $val['wage_cn'] = $jobfairJob['wage_cn'];
  550. // $val['audit'] = $jobfairJob['audit'];
  551. // $val['display'] = $jobfairJob['display'];
  552. // $val['click'] = $jobfairJob['click'];
  553. // $val['robot'] = $jobfairJob['robot'];
  554. // $val['map_x'] = $jobfairJob['map_x'];
  555. // $val['map_y'] = $jobfairJob['map_y'];
  556. // $val['map_zoom'] = $jobfairJob['map_zoom'];
  557. // $val['add_mode'] = $jobfairJob['add_mode'];
  558. // $val['is_entrust'] = $jobfairJob['is_entrust'];
  559. // $val['department'] = $jobfairJob['department'];
  560. // $val['major'] = $jobfairJob['major'];
  561. // $val['major_cn'] = $jobfairJob['major_cn'];
  562. // $val['zcid'] = $jobfairJob['zcid'];
  563. // $val['zc_cn'] = $jobfairJob['zc_cn'];
  564. // $val['zc_name'] = $jobfairJob['zc_name'];
  565. // $val->save();
  566. // }
  567. // }
  568. });
  569. //自定义时间筛选JS
  570. $filter_script = <<<SCRIPT
  571. let wage_min_value = $(".wage_min_value").val();
  572. let ygxs_select = $("select[name='ygxs']");
  573. if(ygxs_select.val()==363){
  574. $("#wage_min").val(wage_min_value);
  575. $("#hour_money").parent().parent().parent().show();
  576. $("select[name='wage']").parent().parent().hide();
  577. $("#wage_min").parent().parent().parent().hide();
  578. $("#wage_max").parent().parent().parent().hide();
  579. $("select[name='syq']").parent().parent().hide();
  580. $("#syqxz_min").parent().parent().parent().hide();
  581. }else{
  582. $("#hour_money").parent().parent().parent().hide();
  583. $("#wage_min").parent().parent().parent().show();
  584. $("#wage_max").parent().parent().parent().show();
  585. $("select[name='syq']").parent().parent().show();
  586. $("#syqxz_min").parent().parent().parent().show();
  587. }
  588. ygxs_select.on('change',function(){
  589. if($(this).val() == 363){
  590. $("#hour_money").parent().parent().parent().show();
  591. $("select[name='wage']").parent().parent().hide();
  592. $("#wage_min").parent().parent().parent().hide();
  593. $("#wage_max").parent().parent().parent().hide();
  594. $("select[name='syq']").parent().parent().hide();
  595. $("#syqxz_min").parent().parent().parent().hide();
  596. $("#hour_money").val(0);
  597. }else{
  598. $("#hour_money").parent().parent().parent().hide();
  599. $("select[name='wage']").parent().parent().show();
  600. $("#wage_min").parent().parent().parent().show();
  601. $("#wage_max").parent().parent().parent().show();
  602. $("select[name='syq']").parent().parent().show();
  603. $("#hour_money").val(0);
  604. $("#wage_min").val(wage_min_value);
  605. $("#wage_max").val(0);
  606. }
  607. });
  608. let syq_select = $("select[name='syq']");
  609. let wage_select = $("select[name='wage']");
  610. if(syq_select.val()==367 || wage_select.val()==-1){
  611. $("#syqxz_min").val(wage_min_value);
  612. $("#syqxz_min").parent().parent().parent().hide();
  613. }else{
  614. if(ygxs_select.val() != 363){
  615. $("#syqxz_min").parent().parent().parent().show();
  616. }
  617. }
  618. syq_select.on('change',function(){
  619. if($(this).val() == 367 || wage_select.val() == -1){
  620. $("#syqxz_min").val(wage_min_value);
  621. $("#syqxz_min").parent().parent().parent().hide();
  622. }else{
  623. if(ygxs_select.val() != 363){
  624. $("#syqxz_min").parent().parent().parent().show();
  625. }
  626. }
  627. });
  628. wage_select.on('change',function(){
  629. if($(this).val() == -1){
  630. $("#syqxz_min").val(wage_min_value);
  631. $("#syqxz_min").parent().parent().parent().hide();
  632. }else{
  633. if(ygxs_select.val() != 363){
  634. $("#syqxz_min").parent().parent().parent().show();
  635. }
  636. }
  637. });
  638. SCRIPT;
  639. Admin::script($filter_script);
  640. return $form;
  641. }
  642. /**
  643. * Make a form builder.
  644. *
  645. * @return Form
  646. */
  647. protected function form()
  648. {
  649. $form = new Form(new JobfairJob);
  650. $form->display('ID');
  651. $form->display('Created at');
  652. $form->display('Updated at');
  653. return $form;
  654. }
  655. public function update($id)
  656. {
  657. return $this->editForm($id)->update($id);
  658. }
  659. public function auditJobs(Request $request)
  660. {
  661. $id = $request->id;
  662. $form = new \Encore\Admin\Widgets\Form();
  663. $form->action(route('jobfairjobs.auditr'));
  664. $form->disableReset();
  665. $form->hidden('id', 'ID')->default($id);
  666. $form->radio('audit', '审核')->options([1=>'审核通过',3=>'审核未通过'])->default(1);
  667. $form->textarea('remark', '备注');
  668. $form->html('<label style="color: grey">职位库审核不再同步已结束招聘会的参会职位,请及时审核!</label>');
  669. $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
  670. return json_encode(['html'=>$form->render(),'detail'=>'审核职位']);
  671. }
  672. public function auditR(Request $request)
  673. {
  674. $id = $request->id;
  675. $audit = $request->audit;
  676. $remark = $request->remark;
  677. $pms_notice = $request->pms_notice;
  678. $arr = array_filter(explode(',', $id));
  679. if (empty($id)) {
  680. admin_toastr('数据异常', 'error');
  681. return back();
  682. }
  683. $result = JobfairJob::whereIn('id', $arr)->update(['audit'=>$audit]);
  684. if($audit == 1){
  685. //同步参展职位
  686. $put_jobs = JobfairPutJob::whereHas('jobfairs',function ($query){
  687. $query->where('holddate_end','>=',time());
  688. })->whereIn('job_id',$arr)->get();
  689. if($put_jobs->isNotEmpty()){
  690. foreach ($put_jobs as $val){
  691. $jobfairJob = JobfairJob::find($val->job_id);
  692. $val['jobs_name'] = $jobfairJob['jobs_name'];
  693. $val['company_id'] = $jobfairJob['company_id'];
  694. $val['company_name'] = $jobfairJob['company_name'];
  695. $val['company_audit'] = $jobfairJob['company_audit'];
  696. $val['stick'] = $jobfairJob['stick'];
  697. $val['nature'] = $jobfairJob['nature'];
  698. $val['nature_cn'] = $jobfairJob['nature_cn'];
  699. $val['sex'] = $jobfairJob['sex'];
  700. $val['sex_cn'] = $jobfairJob['sex_cn'];
  701. $val['age'] = $jobfairJob['age'];
  702. $val['amount'] = $jobfairJob['amount'];
  703. $val['topclass'] = $jobfairJob['topclass'];
  704. $val['category'] = $jobfairJob['category'];
  705. $val['subclass'] = $jobfairJob['subclass'];
  706. $val['category_cn'] = $jobfairJob['category_cn'];
  707. $val['trade'] = $jobfairJob['trade'];
  708. $val['trade_cn'] = $jobfairJob['trade_cn'];
  709. $val['scale'] = $jobfairJob['scale'];
  710. $val['scale_cn'] = $jobfairJob['scale_cn'];
  711. $val['district'] = $jobfairJob['district'];
  712. $val['district_cn'] = $jobfairJob['district_cn'];
  713. $val['tag'] = $jobfairJob['tag'];
  714. $val['tag_cn'] = $jobfairJob['tag_cn'];
  715. $val['education'] = $jobfairJob['education'];
  716. $val['education_cn'] = $jobfairJob['education_cn'];
  717. $val['experience'] = $jobfairJob['experience'];
  718. $val['experience_cn'] = $jobfairJob['experience_cn'];
  719. $val['wage'] = $jobfairJob['wage'];
  720. $val['wage_min'] = $jobfairJob['wage_min'];
  721. $val['wage_max'] = $jobfairJob['wage_max'];
  722. $val['wage_cn'] = $jobfairJob['wage_cn'];
  723. $val['negotiable'] = $jobfairJob['negotiable'];
  724. $val['audit'] = $jobfairJob['audit'];
  725. $val['display'] = $jobfairJob['display'];
  726. $val['click'] = $jobfairJob['click'];
  727. $val['robot'] = $jobfairJob['robot'];
  728. $val['map_x'] = $jobfairJob['map_x'];
  729. $val['map_y'] = $jobfairJob['map_y'];
  730. $val['map_zoom'] = $jobfairJob['map_zoom'];
  731. $val['add_mode'] = $jobfairJob['add_mode'];
  732. $val['is_entrust'] = $jobfairJob['is_entrust'];
  733. $val['department'] = $jobfairJob['department'];
  734. $val['major'] = $jobfairJob['major'];
  735. $val['major_cn'] = $jobfairJob['major_cn'];
  736. $val['zcid'] = $jobfairJob['zcid'];
  737. $val['zc_cn'] = $jobfairJob['zc_cn'];
  738. $val['zc_name'] = $jobfairJob['zc_name'];
  739. $val['syq'] = $jobfairJob['syq'];
  740. $val['syqxz_min'] = $jobfairJob['syqxz_min'];
  741. $val['ygxs'] = $jobfairJob['ygxs'];
  742. $val['techlevel'] = $jobfairJob['techlevel'];
  743. $val->save();
  744. }
  745. }
  746. $cache_jobs = JobfairPutJob::whereIn('job_id', $arr)->whereHas('jobfairs',function ($query){
  747. $query->where([
  748. ['holddate_start', '<', strtotime("+60 minute")],
  749. ['holddate_end', '>', time()]
  750. ]);
  751. })->get();
  752. foreach ($cache_jobs as $v){
  753. Cache::put($v->jobfair_id.'-'.$v->company_id, time(),72000);
  754. }
  755. }
  756. $data=[];
  757. foreach ($arr as $k => $v) {
  758. $data[$k]['type'] = 11;
  759. $data[$k]['type_id'] = $v;
  760. $data[$k]['status'] = $audit;
  761. $data[$k]['reason'] = $remark;
  762. $data[$k]['audit_man'] = Admin::user()->username;
  763. $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
  764. $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
  765. }
  766. AuditReason::insert($data);
  767. if ($pms_notice) {
  768. if ($audit==3) {
  769. $stat='审核不通过';
  770. } elseif ($audit==1) {
  771. $stat = '审核通过';
  772. } else {
  773. $stat='待审核';
  774. }
  775. $reus=JobfairJob::whereIn('id', $arr)->get();
  776. $ds = [];
  777. foreach ($reus as $k => $v) {
  778. $ds[$k]['utype'] = 1;
  779. $ds[$k]['msgtype'] = 1;
  780. $ds[$k]['msgfromuid'] = Admin::user()->id;
  781. $ds[$k]['msgfrom'] = Admin::user()->username;
  782. $ds[$k]['msgtoname'] = $v->company_name ? $v->company_name : 'admin';
  783. $ds[$k]['msgtouid'] = $v->company_id ? $v->company_id : 0;
  784. $ds[$k]['message'] = $remark ? '招聘会职位(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '招聘会职位(id:'.array_values($arr)[$k].')'.$stat;
  785. $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
  786. $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
  787. }
  788. Pms::insert($ds);
  789. }
  790. if ($result) {
  791. admin_toastr('审核成功', 'success');
  792. } else {
  793. admin_toastr('审核失败', 'error');
  794. }
  795. return back();
  796. }
  797. public function destroy($id)
  798. {
  799. $ids = array();
  800. if ($id) {
  801. $ids = explode(',', $id);
  802. }
  803. if (!$ids) {
  804. return admin_toastr('请勾选需要删除的职位', 'error');
  805. }
  806. \DB::beginTransaction();
  807. try {
  808. JobfairoutPutJob::whereIn('job_id', $ids)->delete();
  809. JobfairPutJob::whereIn('job_id', $ids)->delete();
  810. JobfairJob::whereIn('id', $ids)->delete();
  811. JobfairJobsContact::whereIn('pid', $ids)->delete();
  812. $data = [
  813. 'status' => true,
  814. 'message' => '删除成功!',
  815. ];
  816. \DB::commit();
  817. return response()->json($data);
  818. } catch (\Exception $e) {
  819. \DB::rollback();
  820. $data = [
  821. 'status' => false,
  822. 'message' => '删除失败!',
  823. ];
  824. return response()->json($data);
  825. }
  826. }
  827. }