IndexController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. $info = Presentation::find($id);
  73. $form = new ValidateForm(new Presentation);
  74. $form->text('name', '宣讲会标题')->rules('required|max:100', array('required'=>'标题不能为空。','max'=>'标题长度不能大于100。'))->setMustMark();
  75. $form->text('time', '宣讲时间段')->rules('required', array('required'=>'时间段不能为空。'))->setMustMark();
  76. $form->text('address', '宣讲会地址')->rules('required', array('required'=>'宣讲会地址不能为空。'))->setMustMark();
  77. $form->text('contact_info', '联系方式')->rules('required', array('required'=>'联系方式不能为空。'))->setMustMark();
  78. $display_option = [
  79. 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
  80. 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
  81. ];
  82. $form->switch('status', '是否显示')->states($display_option)->default('1')->setMustMark();
  83. return $form;
  84. }
  85. protected function form()
  86. {
  87. $form = new ValidateForm(new Presentation);
  88. $form->text('name', '宣讲会标题')->rules('required|max:100', array('required'=>'标题不能为空。','max'=>'标题长度不能大于100。'))->setMustMark();
  89. $form->text('time', '宣讲时间段')->rules('required', array('required'=>'时间段不能为空。'))->setMustMark();
  90. $form->text('address', '宣讲会地址')->rules('required', array('required'=>'宣讲会地址不能为空。'))->setMustMark();
  91. $form->text('contact_info', '联系方式')->rules('required', array('required'=>'联系方式不能为空。'))->setMustMark();
  92. $display_option = [
  93. 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
  94. 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
  95. ];
  96. $form->switch('status', '是否显示')->states($display_option)->default('1')->setMustMark();
  97. return $form;
  98. }
  99. public function store(Request $request){
  100. $verify = $this->form()->getValidateInput();
  101. $data = [
  102. 'name' => $verify['name'],
  103. 'time' => $verify['time'],
  104. 'address' => $verify['address'],
  105. 'contact_info' => $verify['contact_info'],
  106. 'status' => $verify['status']
  107. ];
  108. try {
  109. Presentation::create($data);
  110. DB::commit();
  111. }catch (\Exception $e) {
  112. DB::rollback();
  113. return admin_toastr($e->getMessage(), 'error');
  114. }
  115. }
  116. public function update($id)
  117. {
  118. return $this->editForm($id)->update($id);
  119. }
  120. public function destroy($id)
  121. {
  122. if ($this->form()->destroy($id)) {
  123. $data = [
  124. 'status' => true,
  125. 'message' => trans('admin.delete_succeeded'),
  126. ];
  127. } else {
  128. $data = [
  129. 'status' => false,
  130. 'message' => trans('admin.delete_failed'),
  131. ];
  132. }
  133. return response()->json($data);
  134. }
  135. public function appointList(Content $content, Request $request)
  136. {
  137. Permission::check('health_appoint_list');
  138. $id = $request->id;
  139. $presentation = Presentation::find($id);
  140. if (empty($presentation)) {
  141. return back();
  142. }
  143. $search_data = $request->all();
  144. $where = [];
  145. $where[] = ['pid','=',$presentation->id];
  146. if (isset($search_data['id'])) {
  147. foreach ($search_data as $k => $v) {
  148. if ($k == 'realname') {
  149. $where[] = [$k, 'like', "%$v%"];
  150. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  151. $where[] = [$k, '=', $v];
  152. }
  153. }
  154. }
  155. $perpage = 20;
  156. $list = PresentationAppoint::where($where)
  157. ->select('*')
  158. ->orderBy('updated_at','desc')
  159. ->paginate($perpage);
  160. foreach ($list as $k => $v){
  161. if($v->sex == 1){
  162. $list[$k]['sex'] = '男';
  163. }else{
  164. $list[$k]['sex'] = '女';
  165. }
  166. if($v->fresh == 0){
  167. $list[$k]['fresh'] = '否';
  168. }else{
  169. $list[$k]['fresh'] = '是';
  170. }
  171. if($v->status == 0){
  172. $list[$k]['status'] = '未下载';
  173. }else{
  174. $list[$k]['status'] = '已下载';
  175. }
  176. }
  177. return $content
  178. ->header('报名管理')
  179. ->description('人员信息列表')
  180. ->body(view('admin.health.appoint_list')->with([
  181. 'list' => $list,
  182. 'search_data' => $search_data,
  183. 'recruit' => $presentation
  184. ]));
  185. }
  186. public function qjwjInfoList(Content $content, Request $request){
  187. Permission::check('qjwjInfoList');
  188. $search_data = $request->all();
  189. $where = [];
  190. foreach ($search_data as $k => $v) {
  191. if ($k == 'realname') {
  192. $where[] = [$k, 'like', "%$v%"];
  193. } elseif (in_array($k,['sex','education'])) {
  194. $where[] = [$k, '=', $v];
  195. }
  196. }
  197. $perpage = 20;
  198. $list = QjwjAppoint::where($where)
  199. ->select('*')
  200. ->orderBy('updated_at','desc')
  201. ->paginate($perpage);
  202. foreach ($list as $k => $v){
  203. $v->native_place_cn = get_district_cn($v->native_place);
  204. $v->education = get_category($v->education);
  205. $v->pro_type = get_category_major($v->pro_type);
  206. if($v->sex == 1){
  207. $list[$k]['sex'] = '男';
  208. }else{
  209. $list[$k]['sex'] = '女';
  210. }
  211. if($v->status == 0){
  212. $list[$k]['status'] = '未下载';
  213. }else{
  214. $list[$k]['status'] = '已下载';
  215. }
  216. }
  217. return $content
  218. ->header('信息管理')
  219. ->description('泉籍卫技人员信息列表')
  220. ->body(view('admin.health.qjwj_appoint_list')->with([
  221. 'list' => $list,
  222. 'search_data' => $search_data
  223. ]));
  224. }
  225. public function qjwjStatus(Request $request){
  226. $info = QjwjAppoint::where(['id' => $request->id])->first();
  227. if($info){
  228. $info->status = 1;
  229. $info->save();
  230. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  231. }else{
  232. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  233. }
  234. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  235. }
  236. public function jyyxInfoList(Content $content, Request $request){
  237. Permission::check('jyyxInfoList');
  238. $search_data = $request->all();
  239. $where = [];
  240. foreach ($search_data as $k => $v) {
  241. if ($k == 'realname') {
  242. $where[] = [$k, 'like', "%$v%"];
  243. }
  244. }
  245. $perpage = 20;
  246. $list = JyyxAppoint::where($where)
  247. ->select('*')
  248. ->orderBy('updated_at','desc')
  249. ->paginate($perpage);
  250. foreach ($list as $k => $v){
  251. if($v->status == 0){
  252. $list[$k]['status'] = '未下载';
  253. }else{
  254. $list[$k]['status'] = '已下载';
  255. }
  256. }
  257. return $content
  258. ->header('信息管理')
  259. ->description('就业意向人员信息列表')
  260. ->body(view('admin.health.jyyx_appoint_list')->with([
  261. 'list' => $list,
  262. 'search_data' => $search_data
  263. ]));
  264. }
  265. public function jyyxStatus(Request $request){
  266. $info = JyyxAppoint::where(['id' => $request->id])->first();
  267. if($info){
  268. $info->status = 1;
  269. $info->save();
  270. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  271. }else{
  272. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  273. }
  274. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  275. }
  276. public function postInfoList(Content $content, Request $request){
  277. Permission::check('postInfoList');
  278. $search_data = $request->all();
  279. $where = [];
  280. foreach ($search_data as $k => $v) {
  281. if ($k == 'realname') {
  282. $where[] = [$k, 'like', "%$v%"];
  283. } elseif (in_array($k,['sex','education'])) {
  284. $where[] = ['post_appoint.'.$k, '=', $v];
  285. }
  286. }
  287. $perpage = 20;
  288. $list = PostAppoint::where($where)
  289. ->leftJoin("jobs","jobs.id",'=','post_appoint.job_id')
  290. ->select('post_appoint.*','jobs.jobs_name','jobs.company_name')
  291. ->orderBy('updated_at','desc')
  292. ->paginate($perpage);
  293. foreach ($list as $k => $v){
  294. $v->native_place_cn = get_district_cn($v->native_place);
  295. $v->education = get_category($v->education);
  296. if($v->sex == 1){
  297. $list[$k]['sex'] = '男';
  298. }else{
  299. $list[$k]['sex'] = '女';
  300. }
  301. if($v->status == 0){
  302. $list[$k]['status'] = '未下载';
  303. }else{
  304. $list[$k]['status'] = '已下载';
  305. }
  306. }
  307. return $content
  308. ->header('信息管理')
  309. ->description('投递岗位人员信息列表')
  310. ->body(view('admin.health.post_appoint_list')->with([
  311. 'list' => $list,
  312. 'search_data' => $search_data
  313. ]));
  314. }
  315. public function postStatus(Request $request){
  316. Permission::check('postInfoList');
  317. $info = PostAppoint::where(['id' => $request->id])->first();
  318. if($info){
  319. $info->status = 1;
  320. $info->save();
  321. return response()->json(['status' => 1, 'msg' => '跳转下载中!', 'data' => 'ok', 'url' => $info->attachment]);
  322. }else{
  323. return response()->json(['status' => 0, 'msg' => '找不到记录!', 'data' => 'fail']);
  324. }
  325. //return "/storage/recruit/word/" . $recruit->name_en . '/' .$appoint->audit .$word_url;
  326. }
  327. }