IndexController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <?php
  2. namespace App\Admin\Controllers\Health;
  3. use App\Admin\Extensions\Form\ValidateForm;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\PostAppoint;
  6. use App\Models\Presentation;
  7. use App\Models\PresentationAppoint;
  8. use Encore\Admin\Auth\Permission;
  9. use Encore\Admin\Grid;
  10. use Encore\Admin\Layout\Content;
  11. use Encore\Admin\Facades\Admin;
  12. use Illuminate\Http\Request;
  13. use Illuminate\Support\Facades\DB;
  14. use App\Models\QjwjAppoint;
  15. use App\Models\JyyxAppoint;
  16. class IndexController extends Controller
  17. {
  18. /**
  19. * 宣讲会管理
  20. * @param Content $content
  21. * @return Content
  22. */
  23. public function index(Content $content)
  24. {
  25. Permission::check('presentation');
  26. return $content
  27. ->header('宣讲会管理')
  28. ->description('')
  29. ->body($this->grid());
  30. }
  31. protected function grid()
  32. {
  33. $grid = new Grid(new Presentation);
  34. $grid->model()->orderBy('created_at', 'DESC');
  35. $grid->model()->paginate(20);
  36. if (Admin::user()->can('recruit_manager_create')) {
  37. $grid->disableCreateButton(false);
  38. }
  39. $grid->perPages([10, 20, 30, 40, 50, 100]);
  40. $grid->id('ID');
  41. $grid->name('名称');
  42. $grid->time('时间');
  43. $grid->address('地址');
  44. $grid->contact_info('联系方式');
  45. $grid->column('status', '状态')->display(function ($status) {
  46. return $status ? '显示' : '隐藏';
  47. });
  48. $grid->created_at('创建时间');
  49. $grid->actions(function ($actions) {
  50. $actions->append('<a href="/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/health/presentation_appoint_list?id=' . $actions->row['id'] . '" class="btn btn-primary btn-xs" >报名管理</a>');
  51. $actions->disableEdit(false);
  52. $actions->disableDelete(false);
  53. $actions->disableView();
  54. });
  55. return $grid;
  56. }
  57. public function create(Content $content)
  58. {
  59. return $content
  60. ->header('宣讲会创建')
  61. ->description('带*号必填项')
  62. ->body($this->form());
  63. }
  64. public function edit($id, Content $content)
  65. {
  66. return $content
  67. ->header('宣讲会编辑')
  68. ->description('')
  69. ->body($this->editForm($id)->edit($id));
  70. }
  71. protected function editForm($id)
  72. {
  73. $info = Presentation::find($id);
  74. $form = new ValidateForm(new Presentation);
  75. $form->text('name', '宣讲会标题')->rules('required|max:100', ['required' => '标题不能为空。', 'max' => '标题长度不能大于100。'])->setMustMark();
  76. $form->text('time', '宣讲时间段')->rules('required', ['required' => '时间段不能为空。'])->setMustMark();
  77. $form->text('address', '宣讲会地址')->rules('required', ['required' => '宣讲会地址不能为空。'])->setMustMark();
  78. $form->text('contact_info', '联系方式')->rules('required', ['required' => '联系方式不能为空。'])->setMustMark();
  79. $display_option = [
  80. 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
  81. 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
  82. ];
  83. $form->switch('status', '是否显示')->states($display_option)->default('1')->setMustMark();
  84. return $form;
  85. }
  86. protected function form()
  87. {
  88. $form = new ValidateForm(new Presentation);
  89. $form->text('name', '宣讲会标题')->rules('required|max:100', ['required' => '标题不能为空。', 'max' => '标题长度不能大于100。'])->setMustMark();
  90. $form->text('time', '宣讲时间段')->rules('required', ['required' => '时间段不能为空。'])->setMustMark();
  91. $form->text('address', '宣讲会地址')->rules('required', ['required' => '宣讲会地址不能为空。'])->setMustMark();
  92. $form->text('contact_info', '联系方式')->rules('required', ['required' => '联系方式不能为空。'])->setMustMark();
  93. $display_option = [
  94. 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
  95. 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
  96. ];
  97. $form->switch('status', '是否显示')->states($display_option)->default('1')->setMustMark();
  98. return $form;
  99. }
  100. public function store(Request $request)
  101. {
  102. $verify = $this->form()->getValidateInput();
  103. $data = [
  104. 'name' => $verify['name'],
  105. 'time' => $verify['time'],
  106. 'address' => $verify['address'],
  107. 'contact_info' => $verify['contact_info'],
  108. 'status' => $verify['status'],
  109. ];
  110. try {
  111. Presentation::create($data);
  112. DB::commit();
  113. } catch (\Exception $e) {
  114. DB::rollback();
  115. return admin_toastr($e->getMessage(), 'error');
  116. }
  117. }
  118. public function update($id)
  119. {
  120. return $this->editForm($id)->update($id);
  121. }
  122. public function destroy($id)
  123. {
  124. if ($this->form()->destroy($id)) {
  125. $data = [
  126. 'status' => true,
  127. 'message' => trans('admin.delete_succeeded'),
  128. ];
  129. } else {
  130. $data = [
  131. 'status' => false,
  132. 'message' => trans('admin.delete_failed'),
  133. ];
  134. }
  135. return response()->json($data);
  136. }
  137. public function appointList(Content $content, Request $request)
  138. {
  139. Permission::check('health_appoint_list');
  140. $id = $request->id;
  141. $presentation = Presentation::find($id);
  142. if (empty($presentation)) {
  143. return back();
  144. }
  145. $search_data = $request->all();
  146. $where = [];
  147. $where[] = ['pid', '=', $presentation->id];
  148. if (isset($search_data['id'])) {
  149. foreach ($search_data as $k => $v) {
  150. if ($k == 'realname') {
  151. $where[] = [$k, 'like', "%$v%"];
  152. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  153. $where[] = [$k, '=', $v];
  154. }
  155. }
  156. }
  157. $perpage = 20;
  158. $list = PresentationAppoint::where($where)
  159. ->select('*')
  160. ->orderBy('updated_at', 'desc')
  161. ->paginate($perpage);
  162. foreach ($list as $k => $v) {
  163. if ($v->sex == 1) {
  164. $list[$k]['sex'] = '男';
  165. } else {
  166. $list[$k]['sex'] = '女';
  167. }
  168. if ($v->fresh == 0) {
  169. $list[$k]['fresh'] = '否';
  170. } else {
  171. $list[$k]['fresh'] = '是';
  172. }
  173. if ($v->status == 0) {
  174. $list[$k]['status'] = '未下载';
  175. } else {
  176. $list[$k]['status'] = '已下载';
  177. }
  178. }
  179. return $content
  180. ->header('报名管理')
  181. ->description('人员信息列表')
  182. ->body(view('admin.health.appoint_list')->with([
  183. 'list' => $list,
  184. 'search_data' => $search_data,
  185. 'recruit' => $presentation,
  186. ]));
  187. }
  188. public function qjwjInfoList(Content $content, Request $request)
  189. {
  190. Permission::check('qjwjInfoList');
  191. $search_data = $request->all();
  192. $where = [];
  193. foreach ($search_data as $k => $v) {
  194. if ($k == 'realname') {
  195. $where[] = [$k, 'like', "%$v%"];
  196. } elseif (in_array($k, ['sex', 'education'])) {
  197. $where[] = [$k, '=', $v];
  198. }
  199. }
  200. $perpage = 20;
  201. $list = QjwjAppoint::where($where)
  202. ->select('*')
  203. ->orderBy('updated_at', 'desc')
  204. ->paginate($perpage);
  205. foreach ($list as $k => $v) {
  206. $v->native_place_cn = get_district_cn($v->native_place);
  207. $v->education = get_category($v->education);
  208. $v->pro_type = get_category_major($v->pro_type);
  209. if ($v->sex == 1) {
  210. $list[$k]['sex'] = '男';
  211. } else {
  212. $list[$k]['sex'] = '女';
  213. }
  214. if ($v->status == 0) {
  215. $list[$k]['status'] = '未下载';
  216. } else {
  217. $list[$k]['status'] = '已下载';
  218. }
  219. }
  220. return $content
  221. ->header('信息管理')
  222. ->description('泉籍卫技人员信息列表')
  223. ->body(view('admin.health.qjwj_appoint_list')->with([
  224. 'list' => $list,
  225. 'search_data' => $search_data,
  226. ]));
  227. }
  228. public function qjwjStatus(Request $request)
  229. {
  230. $info = QjwjAppoint::where(['id' => $request->id])->first();
  231. if ($info) {
  232. $info->status = 1;
  233. $info->save();
  234. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  235. } else {
  236. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  237. }
  238. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  239. }
  240. public function jyyxInfoList(Content $content, Request $request)
  241. {
  242. Permission::check('jyyxInfoList');
  243. $search_data = $request->all();
  244. $where = [];
  245. foreach ($search_data as $k => $v) {
  246. if ($k == 'realname') {
  247. $where[] = [$k, 'like', "%$v%"];
  248. }
  249. }
  250. $perpage = 20;
  251. $list = JyyxAppoint::where($where)
  252. ->select('*')
  253. ->orderBy('updated_at', 'desc')
  254. ->paginate($perpage);
  255. foreach ($list as $k => $v) {
  256. if ($v->status == 0) {
  257. $list[$k]['status'] = '未下载';
  258. } else {
  259. $list[$k]['status'] = '已下载';
  260. }
  261. }
  262. return $content
  263. ->header('信息管理')
  264. ->description('就业意向人员信息列表')
  265. ->body(view('admin.health.jyyx_appoint_list')->with([
  266. 'list' => $list,
  267. 'search_data' => $search_data,
  268. ]));
  269. }
  270. public function jyyxStatus(Request $request)
  271. {
  272. $info = JyyxAppoint::where(['id' => $request->id])->first();
  273. if ($info) {
  274. $info->status = 1;
  275. $info->save();
  276. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  277. } else {
  278. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  279. }
  280. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  281. }
  282. public function postInfoList(Content $content, Request $request)
  283. {
  284. Permission::check('postInfoList');
  285. $search_data = $request->all();
  286. $where = [];
  287. foreach ($search_data as $k => $v) {
  288. if ($k == 'realname') {
  289. $where[] = [$k, 'like', "%$v%"];
  290. } elseif (in_array($k, ['sex', 'education'])) {
  291. $where[] = ['post_appoint.' . $k, '=', $v];
  292. }
  293. }
  294. $perpage = 20;
  295. $list = PostAppoint::where($where)
  296. ->leftJoin("jobs", "jobs.id", '=', 'post_appoint.job_id')
  297. ->select('post_appoint.*', 'jobs.jobs_name', 'jobs.company_name')
  298. ->orderBy('updated_at', 'desc')
  299. ->paginate($perpage);
  300. foreach ($list as $k => $v) {
  301. $v->native_place_cn = get_district_cn($v->native_place);
  302. $v->education = get_category($v->education);
  303. if ($v->sex == 1) {
  304. $list[$k]['sex'] = '男';
  305. } else {
  306. $list[$k]['sex'] = '女';
  307. }
  308. if ($v->status == 0) {
  309. $list[$k]['status'] = '未下载';
  310. } else {
  311. $list[$k]['status'] = '已下载';
  312. }
  313. }
  314. return $content
  315. ->header('信息管理')
  316. ->description('投递岗位人员信息列表')
  317. ->body(view('admin.health.post_appoint_list')->with([
  318. 'list' => $list,
  319. 'search_data' => $search_data,
  320. ]));
  321. }
  322. public function postStatus(Request $request)
  323. {
  324. Permission::check('postInfoList');
  325. $info = PostAppoint::where(['id' => $request->id])->first();
  326. if ($info) {
  327. $info->status = 1;
  328. $info->save();
  329. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  330. } else {
  331. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  332. }
  333. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  334. }
  335. public function presentationAppointList(Content $content,Request $request)
  336. {
  337. $search_data = $request->all();
  338. $where = [
  339. ['pid', '=', $search_data['id']],
  340. ];
  341. foreach ($search_data as $k => $v) {
  342. if ($k == 'realname') {
  343. $where[] = [$k, 'like', "%$v%"];
  344. } elseif (in_array($k, ['sex', 'education'])) {
  345. $where[] = [$k, '=', $v];
  346. }
  347. }
  348. $perpage = 20;
  349. $list = PresentationAppoint::where($where)
  350. ->orderBy('updated_at', 'desc')
  351. ->paginate($perpage);
  352. foreach ($list as $k => $v) {
  353. if ($v->fresh == 1) {
  354. $list[$k]['fresh'] = '是';
  355. } else {
  356. $list[$k]['fresh'] = '否';
  357. }
  358. if ($v->sex == 1) {
  359. $list[$k]['sex'] = '男';
  360. } else {
  361. $list[$k]['sex'] = '女';
  362. }
  363. if ($v->status == 0) {
  364. $list[$k]['status'] = '未下载';
  365. } else {
  366. $list[$k]['status'] = '已下载';
  367. }
  368. if (empty($v->attachment)) {
  369. $list[$k]['is_attachment'] = '未上传';
  370. } else {
  371. $list[$k]['is_attachment'] = '已上传';
  372. }
  373. }
  374. return $content
  375. ->header('报名管理')
  376. ->description('招聘会报名的人员信息管理')
  377. ->body(view('admin.health.presentation_appoint_list')->with([
  378. 'list' => $list,
  379. 'search_data' => $search_data,
  380. ]));
  381. }
  382. public function presentationStatus(Request $request)
  383. {
  384. $info = PresentationAppoint::where(['id' => $request->id])->first();
  385. if ($info && $info->attachment) {
  386. $info->status = 1;
  387. $info->save();
  388. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  389. } else {
  390. return response()->json(['status' => 0, 'msg' => '用户未上传简历!', 'data' => 'fail']);
  391. }
  392. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  393. }
  394. }