IndexController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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\ArticleCategory;
  6. use App\Models\PostAppoint;
  7. use App\Models\Presentation;
  8. use App\Models\PresentationAppoint;
  9. use Encore\Admin\Auth\Permission;
  10. use Encore\Admin\Form;
  11. use Encore\Admin\Grid;
  12. use Encore\Admin\Layout\Content;
  13. use Encore\Admin\Facades\Admin;
  14. use Illuminate\Http\Request;
  15. use Illuminate\Support\Facades\DB;
  16. use App\Models\QjwjAppoint;
  17. use App\Models\JyyxAppoint;
  18. class IndexController extends Controller
  19. {
  20. /**
  21. * 宣讲会管理
  22. * @param Content $content
  23. * @return Content
  24. */
  25. public function index(Content $content)
  26. {
  27. Permission::check('presentation');
  28. return $content
  29. ->header('宣讲会管理')
  30. ->description('')
  31. ->body($this->grid());
  32. }
  33. protected function grid()
  34. {
  35. $grid = new Grid(new Presentation);
  36. $grid->model()->orderBy('created_at', 'DESC');
  37. $grid->model()->paginate(20);
  38. if (Admin::user()->can('recruit_manager_create')) {
  39. $grid->disableCreateButton(false);
  40. }
  41. $grid->perPages([10, 20, 30, 40, 50, 100]);
  42. $grid->id('ID');
  43. $grid->name('名称');
  44. $grid->time('时间');
  45. $grid->address('地址');
  46. $grid->contact_info('联系方式');
  47. $grid->column('status','状态')->display(function ($status) {
  48. return $status ? '显示' : '隐藏';
  49. });
  50. $grid->created_at('创建时间');
  51. $grid->actions(function ($actions) {
  52. $actions->append('<a href="/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/health/presentation_appoint_list?id=' . $actions->row['id'] . '" class="btn btn-primary btn-xs" >报名管理</a>');
  53. $actions->disableEdit(false);
  54. $actions->disableDelete(false);
  55. $actions->disableView();
  56. });
  57. return $grid;
  58. }
  59. public function create(Content $content)
  60. {
  61. return $content
  62. ->header('宣讲会创建')
  63. ->description('带*号必填项')
  64. ->body($this->form());
  65. }
  66. public function edit($id, Content $content)
  67. {
  68. return $content
  69. ->header('宣讲会编辑')
  70. ->description('')
  71. ->body($this->editForm($id)->edit($id));
  72. }
  73. protected function editForm($id){
  74. $info = Presentation::find($id);
  75. $form = new ValidateForm(new Presentation);
  76. $form->text('name', '宣讲会标题')->rules('required|max:100', array('required'=>'标题不能为空。','max'=>'标题长度不能大于100。'))->setMustMark();
  77. $form->text('time', '宣讲时间段')->rules('required', array('required'=>'时间段不能为空。'))->setMustMark();
  78. $form->text('address', '宣讲会地址')->rules('required', array('required'=>'宣讲会地址不能为空。'))->setMustMark();
  79. $form->text('contact_info', '联系方式')->rules('required', array('required'=>'联系方式不能为空。'))->setMustMark();
  80. $display_option = [
  81. 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
  82. 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
  83. ];
  84. $form->switch('status', '是否显示')->states($display_option)->default('1')->setMustMark();
  85. return $form;
  86. }
  87. protected function form()
  88. {
  89. $form = new ValidateForm(new Presentation);
  90. $form->text('name', '宣讲会标题')->rules('required|max:100', array('required'=>'标题不能为空。','max'=>'标题长度不能大于100。'))->setMustMark();
  91. $form->text('time', '宣讲时间段')->rules('required', array('required'=>'时间段不能为空。'))->setMustMark();
  92. $form->text('address', '宣讲会地址')->rules('required', array('required'=>'宣讲会地址不能为空。'))->setMustMark();
  93. $form->text('contact_info', '联系方式')->rules('required', array('required'=>'联系方式不能为空。'))->setMustMark();
  94. $display_option = [
  95. 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
  96. 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
  97. ];
  98. $form->switch('status', '是否显示')->states($display_option)->default('1')->setMustMark();
  99. return $form;
  100. }
  101. public function store(Request $request){
  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 == 0){
  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. Permission::check('qjwjInfoList');
  190. $search_data = $request->all();
  191. $where = [];
  192. if (isset($search_data['id'])) {
  193. foreach ($search_data as $k => $v) {
  194. if ($k == 'realname') {
  195. $where[] = [$k, 'like', "%$v%"];
  196. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  197. $where[] = [$k, '=', $v];
  198. }
  199. }
  200. }
  201. $perpage = 20;
  202. $list = QjwjAppoint::where($where)
  203. ->select('*')
  204. ->orderBy('updated_at','desc')
  205. ->paginate($perpage);
  206. foreach ($list as $k => $v){
  207. $v->native_place_cn = get_district_cn($v->native_place);
  208. $v->education = get_category($v->education);
  209. $v->pro_type = get_category_major($v->pro_type);
  210. if($v->sex == 0){
  211. $list[$k]['sex'] = '女';
  212. }else{
  213. $list[$k]['sex'] = '男';
  214. }
  215. if($v->status == 0){
  216. $list[$k]['status'] = '未下载';
  217. }else{
  218. $list[$k]['status'] = '已下载';
  219. }
  220. }
  221. return $content
  222. ->header('信息管理')
  223. ->description('泉籍卫技人员信息列表')
  224. ->body(view('admin.health.qjwj_appoint_list')->with([
  225. 'list' => $list,
  226. 'search_data' => $search_data
  227. ]));
  228. }
  229. public function qjwjStatus(Request $request){
  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. Permission::check('jyyxInfoList');
  242. $search_data = $request->all();
  243. $where = [];
  244. if (isset($search_data['id'])) {
  245. foreach ($search_data as $k => $v) {
  246. if ($k == 'realname') {
  247. $where[] = [$k, 'like', "%$v%"];
  248. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  249. $where[] = [$k, '=', $v];
  250. }
  251. }
  252. }
  253. $perpage = 20;
  254. $list = JyyxAppoint::where($where)
  255. ->select('*')
  256. ->orderBy('updated_at','desc')
  257. ->paginate($perpage);
  258. foreach ($list as $k => $v){
  259. if($v->status == 0){
  260. $list[$k]['status'] = '未下载';
  261. }else{
  262. $list[$k]['status'] = '已下载';
  263. }
  264. }
  265. return $content
  266. ->header('信息管理')
  267. ->description('就业意向人员信息列表')
  268. ->body(view('admin.health.jyyx_appoint_list')->with([
  269. 'list' => $list,
  270. 'search_data' => $search_data
  271. ]));
  272. }
  273. public function jyyxStatus(Request $request){
  274. $info = JyyxAppoint::where(['id' => $request->id])->first();
  275. if($info){
  276. $info->status = 1;
  277. $info->save();
  278. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  279. }else{
  280. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  281. }
  282. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  283. }
  284. public function postInfoList(Content $content, Request $request){
  285. Permission::check('postInfoList');
  286. $search_data = $request->all();
  287. $where = [];
  288. if (isset($search_data['id'])) {
  289. foreach ($search_data as $k => $v) {
  290. if ($k == 'realname') {
  291. $where[] = [$k, 'like', "%$v%"];
  292. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  293. $where[] = [$k, '=', $v];
  294. }
  295. }
  296. }
  297. $perpage = 20;
  298. $list = PostAppoint::where($where)
  299. ->leftJoin("jobs","jobs.id",'=','post_appoint.job_id')
  300. ->select('post_appoint.*','jobs.jobs_name','jobs.company_name')
  301. ->orderBy('updated_at','desc')
  302. ->paginate($perpage);
  303. foreach ($list as $k => $v){
  304. $v->native_place_cn = get_district_cn($v->native_place);
  305. $v->education = get_category($v->education);
  306. if($v->sex == 0){
  307. $list[$k]['sex'] = '女';
  308. }else{
  309. $list[$k]['sex'] = '男';
  310. }
  311. if($v->status == 0){
  312. $list[$k]['status'] = '未下载';
  313. }else{
  314. $list[$k]['status'] = '已下载';
  315. }
  316. }
  317. return $content
  318. ->header('信息管理')
  319. ->description('投递岗位人员信息列表')
  320. ->body(view('admin.health.post_appoint_list')->with([
  321. 'list' => $list,
  322. 'search_data' => $search_data
  323. ]));
  324. }
  325. public function postStatus(Request $request){
  326. $info = PostAppoint::where(['id' => $request->id])->first();
  327. if($info){
  328. $info->status = 1;
  329. $info->save();
  330. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  331. }else{
  332. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  333. }
  334. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  335. }
  336. }