RecruitController.php 134 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754
  1. <?php
  2. namespace App\Admin\Controllers\Recruit;
  3. use App\Http\Controllers\Controller;
  4. use App\Admin\Extensions\Form\ValidateForm;
  5. use App\Models\Member;
  6. use App\Models\Pms;
  7. use App\Models\Recruit;
  8. use App\Models\RecruitAppointDetail;
  9. use App\Models\RecruitAppointExpandSpecial;
  10. use App\Models\RecruitPost;
  11. use App\Models\RecruitAppointInfo;
  12. use App\Models\RecruitSubjoin;
  13. use App\Models\RecruitAppointLog;
  14. use App\Models\RecruitTicketField;
  15. use App\Models\RecruitSupplement;
  16. use dir\Dir;
  17. use Encore\Admin\Grid;
  18. use Encore\Admin\Form;
  19. use Encore\Admin\Show;
  20. use Encore\Admin\Layout\Content;
  21. use Encore\Admin\Facades\Admin;
  22. use Encore\Admin\Auth\Permission;
  23. use Illuminate\Http\Request;
  24. use Illuminate\Support\Facades\DB;
  25. use Illuminate\Support\Facades\Storage;
  26. use App\Models\Admin\AdminUser;
  27. use PhpOffice\PhpWord\TemplateProcessor;
  28. use Chumper\Zipper\Zipper;
  29. use App\Models\RecruitTicket;
  30. use App\Services\Common\SmsService;
  31. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  32. use PhpOffice\PhpSpreadsheet\IOFactory;
  33. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  34. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  35. use PhpOffice\PhpWord\Settings;
  36. use App\Jobs\TicketJob;
  37. class RecruitController extends Controller
  38. {
  39. private $smsService;
  40. public function __construct(SmsService $smsService)
  41. {
  42. $this->smsService = $smsService;
  43. }
  44. /**
  45. * 招考报名首页
  46. * @param Content $content
  47. * @return Content
  48. */
  49. public function index(Content $content)
  50. {
  51. return $content
  52. ->header('招考报名管理')
  53. ->description('')
  54. ->body($this->grid());
  55. }
  56. /**
  57. * 新增招考报名表单页.
  58. *
  59. * @param Content $content
  60. * @return Content
  61. */
  62. public function create(Content $content)
  63. {
  64. Permission::check('recruit_manager_create');
  65. return $content
  66. ->header('新增招聘场次')
  67. ->description('新增')
  68. ->body(view('admin.recruit.index')->with(['grid' => $this->form()->render(), 'id' => '0']));
  69. }
  70. /**
  71. * Edit interface.
  72. *
  73. * @param mixed $id
  74. * @param Content $content
  75. * @return Content
  76. */
  77. public function edit($id, Content $content)
  78. {
  79. Permission::check('recruit_manager_edit');
  80. $grid = $this->form()->edit($id)->render();
  81. return $content
  82. ->header('招考管理')
  83. ->description('编辑')
  84. ->body(view('admin.recruit.index')->with(['grid' => $grid, 'id' => $id]));
  85. }
  86. /**
  87. * Show interface.
  88. *
  89. * @param mixed $id
  90. * @param Content $content
  91. * @return Content
  92. */
  93. public function show($id, Content $content)
  94. {
  95. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/recruit/index');
  96. }
  97. public function detail($id)
  98. {
  99. $show = new Show(Recruit::findOrFail($id));
  100. // $recruit = Recruit::findOrFail($id);
  101. $show->title('标题');
  102. $show->created_at('创建时间');
  103. return $show;
  104. }
  105. /**
  106. * 获得招考场次的岗位
  107. * @param Request $request
  108. * @return \Illuminate\Http\JsonResponse
  109. */
  110. public function getRecruitPost(Request $request)
  111. {
  112. $id = $request->id;
  113. $recruit = Recruit::find($id);
  114. $post = RecruitPost::where('recruit_id', $id)->get();
  115. return response()->json(['post' => $post, 'recruit' => $recruit], '200');
  116. }
  117. /**
  118. * Make a grid builder.
  119. *
  120. * @return Grid
  121. */
  122. protected function grid()
  123. {
  124. $grid = new Grid(new Recruit);
  125. $grid->model()->orderBy('created_at', 'DESC');
  126. $grid->model()->paginate(20);
  127. if (Admin::user()->can('recruit_manager_create')) {
  128. $grid->disableCreateButton(false);
  129. }
  130. $grid->perPages([10, 20, 30, 40, 50, 100]);
  131. $grid->id('ID');
  132. $grid->name('招考场次名称');
  133. $grid->column('current','当前阶段')->display(function ($current) {
  134. switch ($current){
  135. case '1':
  136. return '报名';
  137. break;
  138. case '2':
  139. return '审核';
  140. break;
  141. case '3':
  142. return '笔试';
  143. break;
  144. case '4':
  145. return '上机测试';
  146. break;
  147. case '5':
  148. return '面试';
  149. break;
  150. case '6':
  151. return '复试';
  152. break;
  153. case '7':
  154. return '体检';
  155. break;
  156. case '8':
  157. return '政审';
  158. break;
  159. case '9':
  160. return '公示';
  161. break;
  162. case '0':
  163. return '已结束';
  164. break;
  165. }
  166. });
  167. $grid->column('status','状态')->display(function ($status) {
  168. return $status ? '显示' : '隐藏';
  169. });
  170. $grid->filter(function ($filter) {
  171. $filter->disableIdFilter();
  172. $filter->where(function ($query) {
  173. $query->where('simple', '=', "{$this->input}");
  174. }, '类型', 'simple')->radio([0 => '招考',1 => '招聘']);
  175. });
  176. $grid->created_at('创建时间');
  177. $grid->actions(function ($actions) {
  178. $actions->append('<a href="/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/recruit/appoint_list?id=' . $actions->row['id'] . '" class="btn btn-primary btn-xs" >报名管理</a>');
  179. $actions->disableEdit(false);
  180. $actions->disableDelete(false);
  181. $actions->disableView();
  182. });
  183. return $grid;
  184. }
  185. /**
  186. * 新增/修改招考场次的表单
  187. *
  188. * @return Form
  189. */
  190. protected function form()
  191. {
  192. $form = new ValidateForm(new Recruit);
  193. $form->tab('基础信息', function ($form) {
  194. $form->text('name', '招考场次名称')->rules('required|between:4,61', [
  195. 'required' => '请填写招考场次名称',
  196. 'between' => '招考场次名称长度为2~30个字符'
  197. ])->setWidth(5)->setMustMark();
  198. $form->text('company', '招聘主体')->rules('required|between:4,61', [
  199. 'required' => '请填写招聘主体',
  200. 'between' => '招聘主体长度为2~30个字符'
  201. ])->setWidth(5)->setMustMark();
  202. $form->text('name_en', '英文标识')->setWidth(5)->help('同一个招聘单位,发布的招聘场次若不在同一天,允许一样,若为空则自动生成');
  203. $form->image('small_img', '缩略图')->uniqueName()->setWidth(3);
  204. $form->radio('simple', '类型')->options([0 => '招聘', 1 => '招考'])->default(0)->setMustMark();
  205. $form->switch('status', '状态')->default(1)->setMustMark();
  206. $form->switch('show_report', '显示报名人数')->default(0)->setMustMark();
  207. $form->radio('current', '当前进展')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示',0 => '已结束'])->default(1)->setMustMark();
  208. $form->checkbox('step', '招考流程')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示'])->default([1, 2])->setMustMark();
  209. $form->datetimeRange('apply_start', 'apply_end', '报名日期')->rules('required', array('required' => '报名日期必须设置'))->setMustMark();
  210. $form->datetimeRange('audit_start', 'audit_end', '审核日期');
  211. $form->datetimeRange('preliminary_start', 'preliminary_end', '笔试时间');
  212. $form->datetimeRange('computer_start', 'computer_end', '上机时间');
  213. $form->datetimeRange('interview_start', 'interview_end', '面试时间');
  214. $form->datetimeRange('reexamine_start', 'reexamine_end', '复试时间');
  215. $form->datetimeRange('health_start', 'health_end', '体检时间');
  216. $form->datetimeRange('political_start', 'political_end', '政审时间');
  217. $form->datetimeRange('publicity_start', 'publicity_end', '公示时间');
  218. $form->editor('introduction', '招考正文')->rules('required', array('required' => '招考正文不能为空。'))->setMustMark();
  219. $form->text('contact', '联系人');
  220. $form->text('phone', '联系电话');
  221. $form->text('host_address', '联系地址');
  222. //$form->switch('predetermined_status', '是否允许报名')->states($display_option)->default(1)->setMustMark();
  223. $form->number('ordid', '排序')->default(0);
  224. $form->multipleFile('addFile', '附件')->move('storage/app/public/recruit/' . time());
  225. })->tab('报名表单与条件', function ($form) {
  226. $form->checkbox('forms', '报名表单模块')->options(['basic' => '基础信息模块','expand_special' => '扩展模块-加分','detail' => '详情介绍模块','identification' => '身份证明上传模块','education_certification' => '学历证明上传模块','other_certification' => '其他证明上传模块', 'remark' => '备注模块','internship' => '实习专场'])->default(['basic'])->setMustMark();
  227. $form->text('limit_times', '报名次数限制')->rules('required|regex:/^\d+$/', [
  228. 'required' => '报名限制次数必须填写',
  229. 'regex' => '次数必须为数字'
  230. ])->default(1)->help('同一个场次允许同时报名几个岗位,直接输入数字即可');
  231. $form->text('post_times', '审核次数限制')->rules('required|regex:/^\d+$/', [
  232. 'required' => '审核限制次数必须填写',
  233. 'regex' => '次数必须为数字'
  234. ])->default(1)->help('允许提交审核的次数,直接输入数字即可');
  235. $form->datetimeRange('supplement_start', 'supplement_end', '材料补登时间');
  236. $form->radio('pay_switch', '缴费报名')->options([0 => '否', 1 => '是'])->default(0);
  237. $form->radio('special_condition_type', '加分条件样式')->options([0 => '手输', 1 => '下拉选择'])->default(0);
  238. $form->text('special_condition_value', '加分条件值')->default("")->help('下拉选择项请用英文,隔开');
  239. })->tab('笔试', function ($form) {
  240. $form->switch('pen_comfirm', '笔试确认')->help("打开后将会在设置时间段内开启笔试确认功能,有且仅当确认了才能打印准考证参加笔试")->default(0)->setMustMark();
  241. $form->datetimeRange('pen_comfirm_start', 'pen_comfirm_end', '确认笔试时间')->help("设置该时间后,仅在该时间段内才可以确认参加笔试");
  242. $form->radio('pen_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  243. $form->text('pen_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  244. $form->listbox('pen_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('pen'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  245. $form->switch('pen_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  246. $form->switch('pen_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  247. $form->datetimeRange('pen_health_start', 'pen_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  248. })->tab('上机', function ($form) {
  249. $form->radio('computer_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  250. $form->text('computer_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  251. $form->listbox('computer_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('computer'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  252. $form->switch('computer_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  253. $form->switch('computer_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  254. $form->datetimeRange('computer_health_start', 'computer_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  255. })->tab('面试', function ($form) {
  256. $form->radio('face_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  257. $form->text('face_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  258. $form->listbox('face_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('face'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  259. $form->switch('face_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  260. $form->switch('face_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  261. $form->datetimeRange('face_health_start', 'face_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  262. })->tab('复试', function ($form) {
  263. $form->radio('reexamine_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  264. $form->text('reexamine_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  265. $form->listbox('reexamine_field', '模板字段')->options(RecruitTicketField::ticketFieldData('reexamine'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  266. });
  267. return $form;
  268. }
  269. /**
  270. * Make a form builder.
  271. *
  272. * @return Form
  273. */
  274. public function store(Request $request)
  275. {
  276. $verify = $this->form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  277. $postCode = $request->input('postcode', []);
  278. $postName = $request->input('postname', []);
  279. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  280. return admin_toastr('请填写招考岗位', 'error');
  281. }
  282. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  283. return admin_toastr('请填写招考岗位名称', 'error');
  284. }
  285. $data = [];
  286. $data['name'] = $verify['name'];
  287. $data['company'] = $verify['company'];
  288. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  289. if(array_key_exists('small_img',$verify)){
  290. $data['small_img'] = $verify['small_img'];
  291. }else{
  292. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  293. }
  294. $data['status'] = $verify['status'];
  295. $data['show_report'] = $verify['show_report'];
  296. $data['current'] = $verify['current'];
  297. $data['step'] = implode(',',array_filter($verify['step']));
  298. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  299. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  300. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  301. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  302. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  303. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  304. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  305. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  306. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  307. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  308. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  309. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  310. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  311. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  312. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  313. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  314. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  315. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  316. $data['supplement_start'] = $verify['supplement_start'] ? $verify['supplement_start'] : null;
  317. $data['supplement_end'] = $verify['supplement_end'] ? $verify['supplement_end'] : null;
  318. $data['introduction'] = $verify['introduction'];
  319. $data['host_address'] = $verify['host_address'];
  320. $data['contact'] = $verify['contact'];
  321. $data['phone'] = $verify['phone'];
  322. $data['ordid'] = $verify['ordid'];
  323. $data['limit_times'] = $verify['limit_times'];
  324. $data['post_times'] = $verify['post_times'];
  325. $data['pay_switch'] = $verify['pay_switch'];
  326. $data['forms'] = implode(',',array_filter($verify['forms']));
  327. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  328. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  329. $data['pen_ticket_status'] = 0;
  330. $data['pen_comfirm'] = $verify['pen_comfirm'];
  331. $data['pen_comfirm_start'] = $verify['pen_comfirm_start'] ? $verify['pen_comfirm_start'] : null;
  332. $data['pen_comfirm_end'] = $verify['pen_comfirm_end'] ? $verify['pen_comfirm_end'] : null;
  333. $data['pen_epidemic'] = $verify['pen_epidemic'];
  334. $data['pen_health'] = $verify['pen_health'];
  335. $data['pen_health_start'] = $verify['pen_health_start'] ? $verify['pen_health_start'] : null;
  336. $data['pen_health_end'] = $verify['pen_health_end'] ? $verify['pen_health_end'] : null;
  337. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  338. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  339. $data['computer_ticket_status'] = 0;
  340. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  341. $data['face_ticket_type'] = $verify['face_ticket_type'];
  342. $data['face_ticket_content'] = $verify['face_ticket_content'];
  343. $data['face_ticket_status'] = 0;
  344. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  345. $data['face_epidemic'] = $verify['face_epidemic'];
  346. $data['face_health'] = $verify['face_health'];
  347. $data['face_health_start'] = $verify['face_health_start'] ? $verify['face_health_start'] : null;
  348. $data['face_health_end'] = $verify['face_health_end'] ? $verify['face_health_end'] : null;
  349. $data['reexamine_ticket_type'] = $verify['reexamine_ticket_type'];
  350. $data['reexamine_ticket_content'] = $verify['reexamine_ticket_content'];
  351. $data['reexamine_ticket_status'] = 0;
  352. $data['reexamine_field'] = implode(',',$verify['reexamine_field']);
  353. $fileCharater = $request->input('addFile');
  354. DB::beginTransaction();//检查数据库事务
  355. try {
  356. $recruit = Recruit::create($data);
  357. $recruit_id = $recruit->id;
  358. //添加招聘岗位
  359. $postcode_array = $request->postcode;
  360. $postname_array = $request->postname;
  361. $postnumber_array = $request->postnumber;
  362. $limit_array = $request->postlimit;
  363. $countnum = count($postcode_array);
  364. for ($i = 0; $i < $countnum; $i++) {
  365. $data = array();
  366. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  367. $data['code'] = $postcode_array[$i];
  368. $data['name'] = $postname_array[$i];
  369. $data['number'] = $postnumber_array[$i];
  370. $data['limit'] = $limit_array[$i];
  371. $data['status'] = 1;
  372. $data['recruit_id'] = $recruit_id;
  373. RecruitPost::create($data);
  374. }
  375. }
  376. if (!empty($fileCharater)) {
  377. foreach ($fileCharater as $f => $fv) {
  378. $picpath = 'recruit/' . date('Ymd', time()) . '/';
  379. //获取文件的扩展名
  380. $ext = $fv->getClientOriginalExtension();
  381. //获取文件的绝对路径
  382. $path = $fv->getRealPath();
  383. //定义文件名
  384. $filename = time() . rand(100, 999) . '.' . $ext;
  385. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  386. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  387. $data = $picpath . $filename;
  388. $create_arr = [
  389. 'recruit_id' => $recruit_id,
  390. 'subjoin_name' => $fv->getClientOriginalName(),
  391. 'subjoin_path' => $data,
  392. 'subjoin_addtime' => time()
  393. ];
  394. RecruitSubjoin::create($create_arr);
  395. }
  396. }
  397. DB::commit();//检查数据库事务
  398. } catch (\Exception $e) {
  399. DB::rollback();
  400. return admin_toastr($e->getMessage(), 'error');
  401. }
  402. }
  403. /**
  404. * 更新报名场次信息
  405. * @param $id
  406. * @param Request $request
  407. */
  408. public function update($id, Request $request)
  409. {
  410. $verify = $this->Form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  411. $postCode = $request->input('postcode', []);
  412. $postName = $request->input('postname', []);
  413. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  414. return admin_toastr('请填写招考岗位', 'error');
  415. }
  416. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  417. return admin_toastr('请填写招考岗位名称', 'error');
  418. }
  419. $recruit_id = $id;
  420. $data = [];
  421. $data['name'] = $verify['name'];
  422. $data['company'] = $verify['company'];
  423. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  424. if(array_key_exists('small_img',$verify)){
  425. $data['small_img'] = $verify['small_img'];
  426. }else{
  427. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  428. }
  429. $data['status'] = $verify['status'];
  430. $data['show_report'] = $verify['show_report'];
  431. $data['current'] = $verify['current'];
  432. $data['step'] = implode(',',array_filter($verify['step']));
  433. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  434. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  435. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  436. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  437. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  438. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  439. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  440. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  441. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  442. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  443. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  444. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  445. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  446. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  447. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  448. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  449. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  450. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  451. $data['supplement_start'] = $verify['supplement_start'] ? $verify['supplement_start'] : null;
  452. $data['supplement_end'] = $verify['supplement_end'] ? $verify['supplement_end'] : null;
  453. $data['introduction'] = $verify['introduction'];
  454. $data['host_address'] = $verify['host_address'];
  455. $data['contact'] = $verify['contact'];
  456. $data['phone'] = $verify['phone'];
  457. $data['ordid'] = $verify['ordid'];
  458. $data['limit_times'] = $verify['limit_times'];
  459. $data['post_times'] = $verify['post_times'];
  460. $data['pay_switch'] = $verify['pay_switch'];
  461. $data['forms'] = implode(',',array_filter($verify['forms']));
  462. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  463. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  464. $data['pen_ticket_status'] = 0;
  465. $data['pen_ticket_field'] = implode(',',$verify['pen_ticket_field']);
  466. $data['pen_comfirm'] = $verify['pen_comfirm'];
  467. $data['pen_comfirm_start'] = $verify['pen_comfirm_start'] ? $verify['pen_comfirm_start'] : null;
  468. $data['pen_comfirm_end'] = $verify['pen_comfirm_end'] ? $verify['pen_comfirm_end'] : null;
  469. $data['pen_epidemic'] = $verify['pen_epidemic'];
  470. $data['pen_health'] = $verify['pen_health'];
  471. $data['pen_health_start'] = $verify['pen_health_start'] ? $verify['pen_health_start'] : null;
  472. $data['pen_health_end'] = $verify['pen_health_end'] ? $verify['pen_health_end'] : null;
  473. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  474. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  475. $data['computer_ticket_status'] = 0;
  476. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  477. $data['face_ticket_type'] = $verify['face_ticket_type'];
  478. $data['face_ticket_content'] = $verify['face_ticket_content'];
  479. $data['face_ticket_status'] = 0;
  480. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  481. $data['face_epidemic'] = $verify['face_epidemic'];
  482. $data['face_health'] = $verify['face_health'];
  483. $data['face_health_start'] = $verify['face_health_start'] ? $verify['face_health_start'] : null;
  484. $data['face_health_end'] = $verify['face_health_end'] ? $verify['face_health_end'] : null;
  485. $data['reexamine_ticket_type'] = $verify['reexamine_ticket_type'];
  486. $data['reexamine_ticket_content'] = $verify['reexamine_ticket_content'];
  487. $data['reexamine_ticket_status'] = 0;
  488. $data['reexamine_field'] = implode(',',$verify['reexamine_field']);
  489. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  490. $fileCharater = $request->input('addFile');
  491. DB::beginTransaction();//检查数据库事务
  492. try {
  493. $res = Recruit::where('id', $recruit_id)->update($data);
  494. $postcode_array = $request->postcode;
  495. $postname_array = $request->postname;
  496. $postnumber_array = $request->postnumber;
  497. $limit_array = $request->postlimit;
  498. $postid_arr = $request->postid_arr;
  499. $countnum = count($postcode_array);
  500. if ($countnum > 0) {
  501. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  502. if (count($postid_arr) == 0) {//没有提交岗位代表删除岗位
  503. RecruitPost::where('recruit_id', $recruit_id)->delete();
  504. } else {
  505. foreach ($ids as $key => $value) {
  506. if (!in_array($value, $postid_arr)) {
  507. $post_is_create = RecruitAppointInfo::where('post_id', $value)->first();
  508. if (empty($post_is_create)) {
  509. //有报名信息的岗位不能删除
  510. RecruitPost::destroy($value);
  511. }
  512. }
  513. }
  514. }
  515. for ($i = 0; $i < $countnum; $i++) {
  516. $data = array();
  517. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  518. if (isset($postid_arr[$i])) {
  519. $post_id = $postid_arr[$i];
  520. $data['code'] = $postcode_array[$i];
  521. $data['name'] = $postname_array[$i];
  522. $data['number'] = $postnumber_array[$i];
  523. $data['limit'] = $limit_array[$i];
  524. $data['recruit_id'] = $recruit_id;
  525. RecruitPost::where('id', $post_id)->update($data);
  526. } else {
  527. $data['code'] = $postcode_array[$i];
  528. $data['name'] = $postname_array[$i];
  529. $data['number'] = $postnumber_array[$i];
  530. $data['limit'] = $limit_array[$i];
  531. $data['recruit_id'] = $recruit_id;
  532. RecruitPost::create($data);
  533. }
  534. }
  535. }
  536. } else {
  537. RecruitPost::where('recruit_id', $recruit_id)->delete();
  538. }
  539. $fileCharater = $request->file('addFile');
  540. if (!empty($fileCharater)) {
  541. RecruitSubjoin::where('recruit_id', $recruit_id)->delete();
  542. foreach ($fileCharater as $f => $fv) {
  543. $picpath = 'zhaokaopic/' . date('Ymd', time()) . '/';
  544. //获取文件的扩展名
  545. $ext = $fv->getClientOriginalExtension();
  546. //获取文件的绝对路径
  547. $path = $fv->getRealPath();
  548. //定义文件名
  549. $filename = time() . rand(100, 999) . '.' . $ext;
  550. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  551. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  552. $data = $picpath . $filename;
  553. $create_arr = [
  554. 'recruit_id' => $recruit_id,
  555. 'subjoin_name' => $fv->getClientOriginalName(),
  556. 'subjoin_path' => $data,
  557. 'subjoin_addtime' => time()
  558. ];
  559. RecruitSubjoin::create($create_arr);
  560. }
  561. }
  562. DB::commit();
  563. return admin_toastr('操作成功!', 'success');
  564. } catch (\Exception $e) {
  565. DB::rollback();
  566. return admin_toastr($e->getMessage(), 'error');
  567. }
  568. }
  569. /**
  570. * 删掉指定招考场次
  571. * @param $id
  572. */
  573. public function destroy($id)
  574. {
  575. Permission::check('recruit_manager_del');
  576. $info = Recruit::find($id);
  577. if($info){
  578. if($info->delete()){
  579. //RecruitAppointInfo::where('recruit_id', $id)->delete(); //todo保留
  580. return response()->json(['status' => 1, 'message' => '删除成功!'], '200');
  581. }else{
  582. return response()->json(['status' => 0, 'message' => '删除失败!'], '200');
  583. }
  584. }else{
  585. return response()->json(['status' => 0, 'message' => '找不到记录!'], '200');
  586. }
  587. //Recruit::find($id)->delete();
  588. }
  589. /**
  590. * 报名管理
  591. * @param Content $content
  592. * @param Request $request
  593. * @return Content|\Illuminate\Http\RedirectResponse
  594. */
  595. public function appointList(Content $content, Request $request)
  596. {
  597. Permission::check('recruit_appoint_list');
  598. $id = $request->id;
  599. $recruit = Recruit::find($id);
  600. if (empty($recruit)) {
  601. return back();
  602. }
  603. $search_data = $request->all();
  604. $where = [];
  605. $where[] = ['audit','>',0];
  606. if (isset($search_data['id']) || session('manage_search_data')['id']) {
  607. if (isset($search_data['page'])) {
  608. if (session('search_data')) {
  609. $where = session('managewhere');
  610. unset($search_data['page']);
  611. $search_data = session('manage_search_data');
  612. }
  613. }
  614. foreach ($search_data as $k => $v) {
  615. if ($k == 'realname') {
  616. $where[] = [$k, 'like', "%$v%"];
  617. } elseif ($k == 'id') {
  618. $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
  619. } elseif($k == 'print_bs'){
  620. $where[] = ['recruit_ticket.ex_type', '=', 1];
  621. $where[] = ['recruit_ticket.ex_status', '=', $v];
  622. } elseif($k == 'print_js'){
  623. $where[] = ['recruit_ticket.ex_type', '=', 2];
  624. $where[] = ['recruit_ticket.ex_status', '=', $v];
  625. } elseif($k == 'print_ms'){
  626. $where[] = ['recruit_ticket.ex_type', '=', 3];
  627. $where[] = ['recruit_ticket.ex_status', '=', $v];
  628. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  629. $where[] = [$k, '=', $v];
  630. }
  631. }
  632. session(['managewhere' => $where]);
  633. session(['manage_search_data' => $search_data]);
  634. session()->save();
  635. }
  636. $session_data = session('search_data');
  637. if(isset($session_data['perpage'])){
  638. $perpage = $session_data['perpage'];
  639. }else{
  640. $perpage = 20;
  641. }
  642. $list = RecruitAppointInfo::where($where)
  643. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  644. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  645. ->select('recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  646. ->orderBy('recruit_appoint_info.updated_at','desc')
  647. ->paginate($perpage);
  648. foreach ($list as $k => $v){
  649. if($v->sex == 0){
  650. $list[$k]['sex'] = '女';
  651. }else{
  652. $list[$k]['sex'] = '男';
  653. }
  654. switch ($v->political_affiliation){
  655. case '01':
  656. $list[$k]['political_affiliation'] = '中共党员';
  657. break;
  658. case '02':
  659. $list[$k]['political_affiliation'] = '中共预备党员';
  660. break;
  661. case '03':
  662. $list[$k]['political_affiliation'] = '共青团员';
  663. break;
  664. case '04':
  665. $list[$k]['political_affiliation'] = '民革党员';
  666. break;
  667. case '05':
  668. $list[$k]['political_affiliation'] = '民盟盟员';
  669. break;
  670. case '06':
  671. $list[$k]['political_affiliation'] = '民建会员';
  672. break;
  673. case '07':
  674. $list[$k]['political_affiliation'] = '民进会员';
  675. break;
  676. case '08':
  677. $list[$k]['political_affiliation'] = '农工党党员';
  678. break;
  679. case '09':
  680. $list[$k]['political_affiliation'] = '致公党党员';
  681. break;
  682. case '10':
  683. $list[$k]['political_affiliation'] = '九三学社社员';
  684. break;
  685. case '11':
  686. $list[$k]['political_affiliation'] = '台盟盟员';
  687. break;
  688. case '12':
  689. $list[$k]['political_affiliation'] = '无党派人士';
  690. break;
  691. case '13':
  692. $list[$k]['political_affiliation'] = '群众';
  693. break;
  694. }
  695. $list[$k]['pen_print'] = 0;
  696. $list[$k]['computer_print'] = 0;
  697. $list[$k]['face_print'] = 0;
  698. $list[$k]['reexamine_print'] = 0;
  699. $tickets = RecruitTicket::where('appoint_id',$v->id)->get();
  700. if($tickets){
  701. foreach ($tickets as $tk => $tv){
  702. if($tv->ex_type == 1){
  703. $list[$k]['pen_print'] = $tv->ex_status;
  704. }
  705. if($tv->ex_type == 2){
  706. $list[$k]['computer_print'] = $tv->ex_status;
  707. }
  708. if($tv->ex_type == 3){
  709. $list[$k]['face_print'] = $tv->ex_status;
  710. }
  711. if($tv->ex_type == 4){
  712. $list[$k]['reexamine_print'] = $tv->ex_status;
  713. }
  714. }
  715. }
  716. }
  717. $post_data = RecruitPost::where('recruit_id',$id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  718. return $content
  719. ->header('报名管理')
  720. ->description('招考人员信息列表')
  721. ->body(view('admin.recruit.appoint_list')->with([
  722. 'list' => $list,
  723. 'search_data' => $search_data,
  724. 'recruit' => $recruit,
  725. 'post' => $post_data
  726. ]));
  727. }
  728. /**
  729. * 查看报名详细信息
  730. * @param Request $request
  731. * @return \Illuminate\Http\JsonResponse
  732. * @throws \Throwable
  733. */
  734. public function getUserinfo(Request $request)
  735. {
  736. Permission::check('recruit_getUserinfo');
  737. $id = $request->id;
  738. $data = RecruitAppointInfo::where('recruit_appoint_info.id',$id)
  739. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  740. ->join('recruit_appoint_expand_special', 'recruit_appoint_info.id', '=', 'recruit_appoint_expand_special.recruit_appoint_id', 'left')
  741. ->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left')
  742. ->select('recruit_appoint_info.*', 'recruit_post.name', 'recruit_post.code', 'recruit_appoint_detail.train', 'recruit_appoint_detail.rewards_and_punishments', 'recruit_appoint_detail.introduce', 'recruit_appoint_expand_special.point_apply', 'recruit_appoint_expand_special.condition', 'recruit_appoint_expand_special.material')
  743. ->first();
  744. $recruit = Recruit::where('id',$data->recruit_id)->first();
  745. $recruit->forms = explode(',', $recruit->forms);
  746. $data->family = json_decode($data->family);
  747. if ($data->family) {
  748. foreach ($data->family as $k => $v) {
  749. $v->political_affiliation = RecruitAppointInfo::$political_affiliation[$v->political_affiliation];
  750. }
  751. }
  752. //layer相册层
  753. $photos = [
  754. 'material'=>[],
  755. 'identification'=>[],
  756. 'education_certification'=>[],
  757. 'other_certification'=>[],
  758. ];
  759. if(in_array('expand_special',$recruit->forms)){
  760. if(json_decode($data->material)){
  761. $data->material = json_decode($data->material);
  762. $photo_data = [];
  763. foreach ($data->material as $k => $v) {
  764. if($v->status){
  765. $photo_data[] = [
  766. 'alt' => $v->name,
  767. 'pid' => $v->uid,
  768. 'src' => $v->response->path,
  769. ];
  770. }
  771. }
  772. $photos['material'] = [
  773. 'title' => '申请加分佐证材料',
  774. 'id' => 1,
  775. 'start' => 0,
  776. 'data' =>$photo_data
  777. ];
  778. }else{
  779. $data->material = [];
  780. }
  781. }
  782. if(in_array('identification',$recruit->forms) || in_array('internship',$recruit->forms)){
  783. if(json_decode($data->identification)){
  784. $data->identification = json_decode($data->identification);
  785. $photo_data = [];
  786. foreach ($data->identification as $k => $v) {
  787. if($v->status){
  788. $photo_data[] = [
  789. 'alt' => $v->name,
  790. 'pid' => $v->uid,
  791. 'src' => $v->response->path,
  792. ];
  793. }
  794. }
  795. $photos['identification'] = [
  796. 'title' => '身份证明',
  797. 'id' => 1,
  798. 'start' => 0,
  799. 'data' =>$photo_data
  800. ];
  801. }else{
  802. $data->identification = [];
  803. }
  804. }
  805. if(in_array('education_certification',$recruit->forms) || in_array('internship',$recruit->forms)){
  806. if(json_decode($data->education_certification)){
  807. $data->education_certification = json_decode($data->education_certification);
  808. $photo_data = [];
  809. foreach ($data->education_certification as $k => $v) {
  810. if($v->status){
  811. $photo_data[] = [
  812. 'alt' => $v->name,
  813. 'pid' => $v->uid,
  814. 'src' => $v->response->path,
  815. ];
  816. }
  817. }
  818. $photos['education_certification'] = [
  819. 'title' => '学历证明',
  820. 'id' => 1,
  821. 'start' => 0,
  822. 'data' =>$photo_data
  823. ];
  824. }else{
  825. $data->education_certification = [];
  826. }
  827. }
  828. if(in_array('other_certification',$recruit->forms) || in_array('internship',$recruit->forms)){
  829. if(json_decode($data->other_certification)){
  830. $data->other_certification = json_decode($data->other_certification);
  831. $photo_data = [];
  832. foreach ($data->other_certification as $k => $v) {
  833. if($v->status){
  834. $photo_data[] = [
  835. 'alt' => $v->name,
  836. 'pid' => $v->uid,
  837. 'src' => $v->response->path,
  838. ];
  839. }
  840. }
  841. $photos['other_certification'] = [
  842. 'title' => '其他证明',
  843. 'id' => 1,
  844. 'start' => 0,
  845. 'data' =>$photo_data
  846. ];
  847. }else{
  848. $data->other_certification = [];
  849. }
  850. }
  851. $html = view('admin.recruit.manageajax_userinfo')->with(['appointinfo' => $data,'recruit' => $recruit,'photos'=>$photos])->render();
  852. return response()->json(['code' => 1, 'data' => $html]);
  853. }
  854. /**
  855. * 第一阶段(报名审核)
  856. * @param Request $request
  857. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  858. * @throws \Throwable
  859. */
  860. public function ajax_audit(Request $request)
  861. {
  862. Permission::check('recruit_ajax_audit');
  863. $ids = $request->ids;
  864. $view_data['ids'] = $ids;
  865. return response(['data' => view('admin.recruit.ajax_audit')->with($view_data)->render(), 'status' => 1], '200');
  866. }
  867. /**
  868. * 材料补登审核
  869. * @param Request $request
  870. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  871. * @throws \Throwable
  872. */
  873. public function ajax_supplement(Request $request)
  874. {
  875. Permission::check('recruit_ajax_supplement');
  876. $ids = $request->ids;
  877. $view_data['ids'] = $ids;
  878. $info = RecruitSupplement::where('appoint_id',$ids)->where('type','supplement')->first();
  879. if(!$info){
  880. $view_data['switch'] = 0;
  881. $view_data['photos'] = [
  882. 'identification'=>[],
  883. 'household_register' => [],
  884. 'education_certification'=>[],
  885. 'family_planning'=>[],
  886. 'manage' => []
  887. ];
  888. }else{
  889. $view_data['switch'] = 1;
  890. $photos = [
  891. 'identification'=>[],
  892. 'household_register' => [],
  893. 'education_certification'=>[],
  894. 'family_planning'=>[],
  895. 'manage' => []
  896. ];
  897. $info->identification = json_decode($info->identification);
  898. $photo_data = [];
  899. if(is_array($info->identification)){
  900. foreach ($info->identification as $k => $v) {
  901. if($v->status){
  902. $photo_data[] = [
  903. 'alt' => $v->name,
  904. 'pid' => $v->uid,
  905. 'src' => $v->response->path,
  906. ];
  907. }
  908. }
  909. }
  910. $photos['identification'] = [
  911. 'title' => '身份证明',
  912. 'id' => 1,
  913. 'start' => 0,
  914. 'data' =>$photo_data
  915. ];
  916. $info->household_register = json_decode($info->household_register);
  917. $photo_data = [];
  918. if(is_array($info->household_register)){
  919. foreach ($info->household_register as $k => $v) {
  920. if($v->status){
  921. $photo_data[] = [
  922. 'alt' => $v->name,
  923. 'pid' => $v->uid,
  924. 'src' => $v->response->path,
  925. ];
  926. }
  927. }
  928. }
  929. $photos['household_register'] = [
  930. 'title' => '户口簿',
  931. 'id' => 1,
  932. 'start' => 0,
  933. 'data' =>$photo_data
  934. ];
  935. $info->education_certification = json_decode($info->education_certification);
  936. $photo_data = [];
  937. if(is_array($info->education_certification)){
  938. foreach ($info->education_certification as $k => $v) {
  939. if($v->status){
  940. $photo_data[] = [
  941. 'alt' => $v->name,
  942. 'pid' => $v->uid,
  943. 'src' => $v->response->path,
  944. ];
  945. }
  946. }
  947. }
  948. $photos['education_certification'] = [
  949. 'title' => '教育证明',
  950. 'id' => 1,
  951. 'start' => 0,
  952. 'data' =>$photo_data
  953. ];
  954. // $info->family_planning = json_decode($info->family_planning);
  955. // $photo_data = [];
  956. // foreach ($info->family_planning as $k => $v) {
  957. // if($v->status){
  958. // $photo_data[] = [
  959. // 'alt' => $v->name,
  960. // 'pid' => $v->uid,
  961. // 'src' => $v->response->path,
  962. // ];
  963. // }
  964. // }
  965. // $photos['family_planning'] = [
  966. // 'title' => '计生证明',
  967. // 'id' => 1,
  968. // 'start' => 0,
  969. // 'data' =>$photo_data
  970. // ];
  971. $info->manage = json_decode($info->manage);
  972. $photo_data = [];
  973. if(is_array($info->manage)){
  974. foreach ($info->manage as $k => $v) {
  975. if($v->status){
  976. $photo_data[] = [
  977. 'alt' => $v->name,
  978. 'pid' => $v->uid,
  979. 'src' => $v->response->path,
  980. ];
  981. }
  982. }
  983. }
  984. $photos['manage'] = [
  985. 'title' => '综治证明',
  986. 'id' => 1,
  987. 'start' => 0,
  988. 'data' =>$photo_data
  989. ];
  990. $view_data['info'] = $info;
  991. $view_data['photos'] = $photos;
  992. }
  993. return response(['data' => view('admin.recruit.ajax_supplement')->with($view_data)->render(), 'status' => 1], '200');
  994. }
  995. /**
  996. * 健康信息审核
  997. * @param Request $request
  998. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  999. * @throws \Throwable
  1000. */
  1001. public function ajax_health(Request $request)
  1002. {
  1003. Permission::check('recruit_ajax_health');
  1004. $ids = $request->ids;
  1005. $type = $request->type;
  1006. $view_data['ids'] = $ids;
  1007. $info = RecruitSupplement::where('appoint_id',$ids)->where("type",$type)->first();
  1008. $view_data['type'] = $type;
  1009. if(!$info){
  1010. $view_data['switch'] = 0;
  1011. $view_data['photos'] = [];
  1012. }else{
  1013. $view_data['switch'] = 1;
  1014. $photos = [
  1015. 'health_code'=>[],
  1016. 'trip_code' => []
  1017. ];
  1018. $info->health_code = json_decode($info->health_code);
  1019. $photo_data = [];
  1020. if(is_array($info->health_code)){
  1021. foreach ($info->health_code as $k => $v) {
  1022. if($v->status){
  1023. $photo_data[] = [
  1024. 'alt' => $v->name,
  1025. 'pid' => $v->uid,
  1026. 'src' => $v->response->path,
  1027. ];
  1028. }
  1029. }
  1030. }
  1031. $photos['health_code'] = [
  1032. 'title' => '健康码',
  1033. 'id' => 1,
  1034. 'start' => 0,
  1035. 'data' =>$photo_data
  1036. ];
  1037. $info->trip_code = json_decode($info->trip_code);
  1038. $photo_data = [];
  1039. if(is_array($info->trip_code)){
  1040. foreach ($info->trip_code as $k => $v) {
  1041. if($v->status){
  1042. $photo_data[] = [
  1043. 'alt' => $v->name,
  1044. 'pid' => $v->uid,
  1045. 'src' => $v->response->path,
  1046. ];
  1047. }
  1048. }
  1049. }
  1050. $photos['trip_code'] = [
  1051. 'title' => '行程码',
  1052. 'id' => 1,
  1053. 'start' => 0,
  1054. 'data' =>$photo_data
  1055. ];
  1056. $view_data['info'] = $info;
  1057. $view_data['photos'] = $photos;
  1058. }
  1059. return response(['data' => view('admin.recruit.ajax_health')->with($view_data)->render(), 'status' => 1], '200');
  1060. }
  1061. /**
  1062. * 报名记录审核处理
  1063. * @param Request $request
  1064. * @return \Illuminate\Http\JsonResponse
  1065. */
  1066. public function appoint_audit(Request $request)
  1067. {
  1068. $ids = $request->ids;
  1069. if (!is_array($ids)) {
  1070. $ids = explode(",", $ids);
  1071. }
  1072. if (empty($ids)) {
  1073. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1074. }
  1075. $audit = $request->audit;
  1076. $exam_flow_path = $request->exam_flow_path;
  1077. $reason = $request->reason;
  1078. if(empty($audit)){
  1079. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1080. }
  1081. if($audit == '3' && empty($exam_flow_path)){
  1082. return response()->json(['status' => 0, 'msg' => '请选择审核后的考试流程!'], '200');
  1083. }
  1084. if($audit != '3' && empty($reason)){
  1085. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1086. }
  1087. $message = [];
  1088. switch ($audit){
  1089. case '1':
  1090. //撤回至未审核
  1091. foreach ($ids as $k => $v){
  1092. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1093. if(!$appointinfo || intval($appointinfo->audit) === 1){
  1094. continue;
  1095. }
  1096. //设置该报名的各个状态
  1097. $appointinfo_data = [
  1098. 'current' => 1,
  1099. 'audit' => 1,
  1100. 'pen_audit' => -1,
  1101. 'computer_audit' => -1,
  1102. 'face_audit' => -1,
  1103. 'reexamine_audit' => -1,
  1104. 'inspect_audit' => -1,
  1105. 'political_audit' => -1,
  1106. 'employ_audit' => -1
  1107. ];
  1108. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1109. //写日志
  1110. $log = [
  1111. 'type' => 2,
  1112. 'step' => 1,
  1113. 'appoint_id' => $v,
  1114. 'uid' => Admin::user()->id,
  1115. 'log' => '撤回至未审核状态,原因是:'.$reason
  1116. ];
  1117. RecruitAppointLog::create($log);
  1118. $message[$v] = '您此次的报名需要重新审核,原因是:'.$reason;
  1119. }
  1120. break;
  1121. case '2':
  1122. //审核未通过
  1123. foreach ($ids as $k => $v){
  1124. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1125. if(!$appointinfo || intval($appointinfo->audit) === 2){
  1126. continue;
  1127. }
  1128. //设置该报名的各个状态
  1129. $appointinfo_data = [
  1130. 'current' => 1,
  1131. 'audit' => 2,
  1132. 'pen_audit' => -1,
  1133. 'computer_audit' => -1,
  1134. 'face_audit' => -1,
  1135. 'reexamine_audit' => -1,
  1136. 'inspect_audit' => -1,
  1137. 'political_audit' => -1,
  1138. 'employ_audit' => -1
  1139. ];
  1140. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1141. //写日志
  1142. $log = [
  1143. 'type' => 2,
  1144. 'step' => 1,
  1145. 'appoint_id' => $v,
  1146. 'uid' => Admin::user()->id,
  1147. 'log' => '审核未通过,原因是:'.$reason
  1148. ];
  1149. RecruitAppointLog::create($log);
  1150. $message[$v] = '您此次报名审核未通过,原因是:'.$reason;
  1151. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1152. }
  1153. break;
  1154. case '3':
  1155. //审核通过
  1156. foreach ($ids as $k => $v){
  1157. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1158. if(!$appointinfo || intval($appointinfo->audit) === 3){
  1159. continue;
  1160. }
  1161. $recruit = Recruit::where('id',$appointinfo->recruit_id)->first();
  1162. $step = explode(',',$recruit->step);
  1163. $step_str = [
  1164. 'pen' => '未设置此条报名记录的笔试信息',
  1165. ];
  1166. if(in_array('3',$step)){
  1167. //场次有设置笔试
  1168. if(in_array('pen',$exam_flow_path)){
  1169. $step_str['pen'] = '该场次需要笔试,已设置此条报考需要参与笔试';
  1170. $pen_audit = -1;
  1171. }else{
  1172. $step_str['pen'] = '该场次需要笔试,此条报考可跳过笔试';
  1173. $pen_audit = 3;
  1174. }
  1175. }else{
  1176. $step_str['pen'] = '该场次不需要笔试';
  1177. $pen_audit = 3;
  1178. }
  1179. if(in_array('4',$step)){
  1180. //场次有设置上机
  1181. if(in_array('computer',$exam_flow_path)){
  1182. $step_str['computer'] = '该场次需要上机,已设置此条报考需要参与上机';
  1183. $computer_audit = -1;
  1184. }else{
  1185. $step_str['computer'] = '该场次需要上机,此条报考可跳过上机';
  1186. $computer_audit = 3;
  1187. }
  1188. }else{
  1189. $step_str['computer'] = '该场次不需要上机';
  1190. $computer_audit = 3;
  1191. }
  1192. if(in_array('5',$step)){
  1193. //场次有设置上机
  1194. if(in_array('face',$exam_flow_path)){
  1195. $step_str['face'] = '该场次需要面试,已设置此条报考需要参与面试';
  1196. $face_audit = -1;
  1197. }else{
  1198. $step_str['face'] = '该场次需要面试,此条报考可跳过面试';
  1199. $face_audit = 3;
  1200. }
  1201. }else{
  1202. $step_str['face'] = '该场次不需要面试';
  1203. $face_audit = 3;
  1204. }
  1205. if(in_array('6',$step)){
  1206. //场次有设置复试
  1207. if(in_array('reexamine',$exam_flow_path)){
  1208. $step_str['reexamine'] = '该场次需要复试,已设置此条报考需要参与复试';
  1209. $reexamine_audit = -1;
  1210. }else{
  1211. $step_str['reexamine'] = '该场次需要复试,此条报考可跳过复试';
  1212. $reexamine_audit = 3;
  1213. }
  1214. }else{
  1215. $step_str['reexamine'] = '该场次不需要复试';
  1216. $reexamine_audit = 3;
  1217. }
  1218. //设置该报名的各个状态
  1219. $appointinfo_data = [
  1220. 'current' => 2,//审核成功后进入考试流程
  1221. 'audit' => 3,
  1222. 'pen_audit' => $pen_audit,
  1223. 'computer_audit' => $computer_audit,
  1224. 'face_audit' => $face_audit,
  1225. 'reexamine_audit' => $reexamine_audit,
  1226. 'inspect_audit' => -1,
  1227. 'political_audit' => -1,
  1228. 'employ_audit' => -1
  1229. ];
  1230. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1231. $reason = $reason ?? '符合报考条件';
  1232. //写日志
  1233. $log = [
  1234. 'type' => 2,
  1235. 'step' => 1,
  1236. 'appoint_id' => $v,
  1237. 'uid' => Admin::user()->id,
  1238. 'log' => '审核通过,原因是:' . $reason,
  1239. 'admin_log' => implode(';',$step_str)
  1240. ];
  1241. RecruitAppointLog::create($log);
  1242. $message[$v] = '您此次报名审核已通过,原因是:' . $reason;
  1243. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1244. $this->fetch_word(['recruit_id'=>$appointinfo->recruit_id,'appoint_id'=>$appointinfo->id]);
  1245. }
  1246. break;
  1247. }
  1248. //站内信
  1249. foreach ($ids as $key => $val) {
  1250. if(array_key_exists($val,$message)){
  1251. $user_info = Member::where('id', $appointinfo->uid)->first();
  1252. Pms::write_pmsnotice($user_info->id, $user_info->username, $message[$val]);
  1253. }else{
  1254. continue;
  1255. }
  1256. }
  1257. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1258. }
  1259. /**
  1260. * 材料补登审核处理
  1261. * @param Request $request
  1262. * @return \Illuminate\Http\JsonResponse
  1263. */
  1264. public function supplement(Request $request)
  1265. {
  1266. Permission::check('ajax_supplement');
  1267. $ids = $request->ids;
  1268. if (empty($ids)) {
  1269. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1270. }
  1271. $status = $request->status;
  1272. $reason = $request->reason;
  1273. if(empty($status)){
  1274. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1275. }
  1276. if($status == -1 && empty($reason)){
  1277. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1278. }
  1279. if($status == -1){
  1280. $info = RecruitSupplement::where('appoint_id', $ids)->where('type','supplement')->first();
  1281. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1282. //写日志
  1283. $log = [
  1284. 'type' => 2,
  1285. 'step' => 1,
  1286. 'appoint_id' => $ids,
  1287. 'uid' => Admin::user()->id,
  1288. 'log' => '材料补登审核未通过,原因是:'.$reason
  1289. ];
  1290. RecruitAppointLog::create($log);
  1291. $info->status = -1;
  1292. $info->msg = $reason;
  1293. $info->save();
  1294. $appointinfo->political_audit = 0;
  1295. $appointinfo->save();
  1296. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1297. }
  1298. if($status == 1){
  1299. $reason = $reason ?? '符合报考条件';
  1300. $info = RecruitSupplement::where('appoint_id', $ids)->where('type','supplement')->first();
  1301. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1302. //写日志
  1303. $log = [
  1304. 'type' => 2,
  1305. 'step' => 1,
  1306. 'appoint_id' => $ids,
  1307. 'uid' => Admin::user()->id,
  1308. 'log' => '审核通过,原因是:' . $reason
  1309. ];
  1310. RecruitAppointLog::create($log);
  1311. $info->status = 1;
  1312. $info->msg = $reason;
  1313. $info->save();
  1314. $appointinfo->political_audit = 1;
  1315. $appointinfo->save();
  1316. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1317. }
  1318. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1319. }
  1320. /**
  1321. * 健康信息处理
  1322. * @param Request $request
  1323. * @return \Illuminate\Http\JsonResponse
  1324. */
  1325. public function health(Request $request)
  1326. {
  1327. Permission::check('ajax_health');
  1328. $ids = $request->ids;
  1329. if (empty($ids)) {
  1330. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1331. }
  1332. $type = $request->type;
  1333. $status = $request->h_status;
  1334. $reason = $request->reason;
  1335. if(empty($status)){
  1336. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1337. }
  1338. if($status == -1 && empty($reason)){
  1339. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1340. }
  1341. if($status == -1){
  1342. $info = RecruitSupplement::where('appoint_id', $ids)->where('type',$type)->first();
  1343. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1344. //写日志
  1345. $log = [
  1346. 'type' => 2,
  1347. 'step' => 1,
  1348. 'appoint_id' => $ids,
  1349. 'uid' => Admin::user()->id,
  1350. 'log' => '健康信息审核未通过,原因是:'.$reason
  1351. ];
  1352. RecruitAppointLog::create($log);
  1353. $info->h_status = -1;
  1354. $info->h_msg = $reason;
  1355. $info->save();
  1356. $appointinfo->health_audit = 0;
  1357. $appointinfo->save();
  1358. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1359. }
  1360. if($status == 1){
  1361. $reason = $reason ?? '健康信息审核通过,请及时打印准考证';
  1362. $info = RecruitSupplement::where('appoint_id', $ids)->where('type',$type)->first();
  1363. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1364. //写日志
  1365. $log = [
  1366. 'type' => 2,
  1367. 'step' => 1,
  1368. 'appoint_id' => $ids,
  1369. 'uid' => Admin::user()->id,
  1370. 'log' => '审核通过,原因是:' . $reason
  1371. ];
  1372. RecruitAppointLog::create($log);
  1373. $info->h_status = 1;
  1374. $info->h_msg = $reason;
  1375. $info->save();
  1376. $appointinfo->health_audit = 1;
  1377. $appointinfo->save();
  1378. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1379. }
  1380. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1381. }
  1382. public function fetchWord(Request $request)
  1383. {
  1384. $recruit_id = $request->recruit_id;
  1385. $appoint_id = $request->appoint_id;
  1386. if(!empty($recruit_id) && !empty($appoint_id)){
  1387. $url = $this->fetch_word(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id]);
  1388. return response()->json(['status' => 1, 'msg' => '生成Word简历成功!', 'data' => 'ok', 'url' => $url]);
  1389. }else{
  1390. return response()->json(['status' => 0, 'msg' => '参数缺失!', 'data' => 'fail']);
  1391. }
  1392. }
  1393. /**
  1394. * 查看审核日志
  1395. * @param Request $request
  1396. * @return \Illuminate\Http\JsonResponse
  1397. */
  1398. public function showLog(Request $request)
  1399. {
  1400. Permission::check('recruit_show_log');
  1401. $id = $request->id;
  1402. $logs = RecruitAppointLog::where('appoint_id', $id)->orderBy('created_at', 'desc')->get()->toArray();
  1403. $str = "";
  1404. if ($logs) {
  1405. $str .= "<table class='table'><tr style='background:#F0F8FD'><td>审核时间</td><td>操作级别</td><td>记录类型</td><td>触发操作的人员</td><td>审核描述</td></tr>";
  1406. foreach ($logs as $k => $v) {
  1407. switch ($v['type']){
  1408. case '1':
  1409. $level = '系统级操作';
  1410. $user = '系统';
  1411. break;
  1412. case '2':
  1413. $level = '审核系列操作';
  1414. $admin = AdminUser::where('id',$v['uid'])->first();
  1415. $user = $admin->name;
  1416. break;
  1417. case '3':
  1418. $level = '用户自行操作';
  1419. $member = Member::where('id',$v['uid'])->first();
  1420. $user = $member->username;
  1421. break;
  1422. }
  1423. switch ($v['step']){
  1424. case '1':
  1425. $step = '报名及审核';
  1426. break;
  1427. case '2':
  1428. $step = '笔试';
  1429. break;
  1430. case '3':
  1431. $step = '面试';
  1432. break;
  1433. case '4':
  1434. $step = '上机';
  1435. break;
  1436. case '5':
  1437. $step = '复审';
  1438. break;
  1439. case '6':
  1440. $step = '体检';
  1441. break;
  1442. case '7':
  1443. $step = '政审';
  1444. break;
  1445. case '8':
  1446. $step = '录用';
  1447. break;
  1448. }
  1449. $str .= "<tr><td>" . $v['created_at'] . "</td><td>" . $level . "</td><td>" . $step . "</td><td>" . $user . "</td><td>" . $v['log'] . "</td></tr>\r\n";
  1450. }
  1451. $str .= "</table>";
  1452. } else {
  1453. $str = "抱歉,暂未有审核记录";
  1454. }
  1455. return response()->json(['code' => 1, 'data' => $str]);
  1456. }
  1457. /**
  1458. * 生成word版简历
  1459. * @param null $data
  1460. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1461. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1462. * @throws \PhpOffice\PhpWord\Exception\Exception
  1463. */
  1464. public function fetch_word($data = null)
  1465. {
  1466. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1467. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1468. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1469. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example.docx');
  1470. //通过setValue 方法给模板赋值
  1471. $templateProcessor->setValue('title', $recruit->name);
  1472. $templateProcessor->setValue('realname', $appoint->realname);
  1473. $templateProcessor->setValue('realname', $appoint->realname);
  1474. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1475. $templateProcessor->setValue('birthday', $appoint->birthday);
  1476. $templateProcessor->setValue('nation', $appoint->nation);
  1477. $templateProcessor->setValue('native_place', $appoint->native_place);
  1478. $templateProcessor->setValue('card', $appoint->card);
  1479. switch ($appoint->political_affiliation){
  1480. case '01':
  1481. $templateProcessor->setValue('political_affiliation', '中共党员');
  1482. break;
  1483. case '02':
  1484. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1485. break;
  1486. case '03':
  1487. $templateProcessor->setValue('political_affiliation', '共青团员');
  1488. break;
  1489. case '04':
  1490. $templateProcessor->setValue('political_affiliation', '民革党员');
  1491. break;
  1492. case '05':
  1493. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1494. break;
  1495. case '06':
  1496. $templateProcessor->setValue('political_affiliation', '民建会员');
  1497. break;
  1498. case '07':
  1499. $templateProcessor->setValue('political_affiliation', '民进会员');
  1500. break;
  1501. case '08':
  1502. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1503. break;
  1504. case '09':
  1505. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1506. break;
  1507. case '10':
  1508. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1509. break;
  1510. case '11':
  1511. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1512. break;
  1513. case '12':
  1514. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1515. break;
  1516. case '13':
  1517. $templateProcessor->setValue('political_affiliation', '群众');
  1518. }
  1519. $templateProcessor->setValue('join_time', $appoint->join_time);
  1520. $templateProcessor->setValue('house_register', $appoint->house_register);
  1521. switch ($appoint->edu_type){
  1522. case '1':
  1523. $templateProcessor->setValue('edu_type', '全日制');
  1524. break;
  1525. case '2':
  1526. $templateProcessor->setValue('edu_type', '在职教育');
  1527. break;
  1528. }
  1529. $templateProcessor->setValue('education', $appoint->education);
  1530. $templateProcessor->setValue('school', $appoint->school);
  1531. $templateProcessor->setValue('degree', $appoint->degree);
  1532. $templateProcessor->setValue('pro', $appoint->pro);
  1533. $templateProcessor->setValue('mobile', $appoint->mobile);
  1534. $templateProcessor->setValue('email', $appoint->email);
  1535. $templateProcessor->setValue('address', $appoint->address);
  1536. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1537. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1538. $templateProcessor->setValue('work', $appoint->work);
  1539. $templateProcessor->setValue('titles', $appoint->titles);
  1540. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1541. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1542. $forms = explode(',', $recruit->forms);
  1543. if(in_array('expand_special',$forms)){
  1544. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint->id)->first();
  1545. $templateProcessor->cloneBlock('special_block',1);
  1546. $templateProcessor->setValue('point_apply', $special->point_apply == 0 ? '否' : '是');
  1547. $templateProcessor->setValue('condition', $special->condition);
  1548. if($material = json_decode($special->material)){
  1549. foreach ($material as $k => $v){
  1550. $templateProcessor->setImageValue('material#'.($k+1),['src' => 'https://www.jucai.gov.cn/'.$v->url]);
  1551. }
  1552. }
  1553. }else{
  1554. $templateProcessor->cloneBlock('special_block',0);
  1555. }
  1556. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1557. if(in_array('detail',$forms)){
  1558. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1559. $templateProcessor->cloneBlock('detail_block',1);
  1560. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1561. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1562. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1563. }else{
  1564. $templateProcessor->cloneBlock('detail_block',0);
  1565. }
  1566. if($family = json_decode($appoint->family,true)){
  1567. $templateProcessor->cloneRow('family_relation',count($family));
  1568. $i = 1;
  1569. foreach ($family as $k => $v){
  1570. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1571. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1572. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1573. switch ($v['political_affiliation']){
  1574. case '01':
  1575. $political_affiliation = '中共党员';
  1576. break;
  1577. case '02':
  1578. $political_affiliation = '中共预备党员';
  1579. break;
  1580. case '03':
  1581. $political_affiliation = '共青团员';
  1582. break;
  1583. case '04':
  1584. $political_affiliation = '民革党员';
  1585. break;
  1586. case '05':
  1587. $political_affiliation = '民盟盟员';
  1588. break;
  1589. case '06':
  1590. $political_affiliation = '民建会员';
  1591. break;
  1592. case '07':
  1593. $political_affiliation = '民进会员';
  1594. break;
  1595. case '08':
  1596. $political_affiliation = '农工党党员';
  1597. break;
  1598. case '09':
  1599. $political_affiliation = '致公党党员';
  1600. break;
  1601. case '10':
  1602. $political_affiliation = '九三学社社员';
  1603. break;
  1604. case '11':
  1605. $political_affiliation = '台盟盟员';
  1606. break;
  1607. case '12':
  1608. $political_affiliation = '无党派人士';
  1609. break;
  1610. case '13':
  1611. $political_affiliation = '群众';
  1612. }
  1613. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1614. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1615. $i++;
  1616. }
  1617. }
  1618. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1619. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1620. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1621. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1622. }
  1623. $word_url = "/{$filename}.docx";
  1624. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1625. $appoint->save();
  1626. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1627. return "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1628. }
  1629. }
  1630. /**
  1631. * 生成word版简历
  1632. * @param null $data
  1633. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1634. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1635. * @throws \PhpOffice\PhpWord\Exception\Exception
  1636. */
  1637. public function fetch_word_internship($data = null)
  1638. {
  1639. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1640. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1641. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1642. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example_internship.docx');
  1643. //通过setValue 方法给模板赋值
  1644. $templateProcessor->setValue('title', $recruit->name);
  1645. $templateProcessor->setValue('realname', $appoint->realname);
  1646. $templateProcessor->setValue('realname', $appoint->realname);
  1647. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1648. $templateProcessor->setValue('birthday', $appoint->birthday);
  1649. $templateProcessor->setValue('nation', $appoint->nation);
  1650. $templateProcessor->setValue('native_place', $appoint->native_place);
  1651. $templateProcessor->setValue('card', $appoint->card);
  1652. switch ($appoint->political_affiliation){
  1653. case '01':
  1654. $templateProcessor->setValue('political_affiliation', '中共党员');
  1655. break;
  1656. case '02':
  1657. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1658. break;
  1659. case '03':
  1660. $templateProcessor->setValue('political_affiliation', '共青团员');
  1661. break;
  1662. case '04':
  1663. $templateProcessor->setValue('political_affiliation', '民革党员');
  1664. break;
  1665. case '05':
  1666. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1667. break;
  1668. case '06':
  1669. $templateProcessor->setValue('political_affiliation', '民建会员');
  1670. break;
  1671. case '07':
  1672. $templateProcessor->setValue('political_affiliation', '民进会员');
  1673. break;
  1674. case '08':
  1675. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1676. break;
  1677. case '09':
  1678. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1679. break;
  1680. case '10':
  1681. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1682. break;
  1683. case '11':
  1684. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1685. break;
  1686. case '12':
  1687. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1688. break;
  1689. case '13':
  1690. $templateProcessor->setValue('political_affiliation', '群众');
  1691. }
  1692. $templateProcessor->setValue('join_time', $appoint->join_time);
  1693. $templateProcessor->setValue('house_register', $appoint->house_register);
  1694. $templateProcessor->setValue('education', $appoint->education);
  1695. $templateProcessor->setValue('school', $appoint->school);
  1696. $templateProcessor->setValue('pro', $appoint->pro);
  1697. $templateProcessor->setValue('adjust', $appoint->adjust == 0 ? '否' : '是');
  1698. $templateProcessor->setValue('mobile', $appoint->mobile);
  1699. $templateProcessor->setValue('email', $appoint->email);
  1700. $templateProcessor->setValue('address', $appoint->address);
  1701. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1702. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1703. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1704. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1705. $forms = explode(',', $recruit->forms);
  1706. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1707. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1708. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1709. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1710. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1711. if($family = json_decode($appoint->family,true)){
  1712. $templateProcessor->cloneRow('family_relation',count($family));
  1713. $i = 1;
  1714. foreach ($family as $k => $v){
  1715. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1716. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1717. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1718. switch ($v['political_affiliation']){
  1719. case '01':
  1720. $political_affiliation = '中共党员';
  1721. break;
  1722. case '02':
  1723. $political_affiliation = '中共预备党员';
  1724. break;
  1725. case '03':
  1726. $political_affiliation = '共青团员';
  1727. break;
  1728. case '04':
  1729. $political_affiliation = '民革党员';
  1730. break;
  1731. case '05':
  1732. $political_affiliation = '民盟盟员';
  1733. break;
  1734. case '06':
  1735. $political_affiliation = '民建会员';
  1736. break;
  1737. case '07':
  1738. $political_affiliation = '民进会员';
  1739. break;
  1740. case '08':
  1741. $political_affiliation = '农工党党员';
  1742. break;
  1743. case '09':
  1744. $political_affiliation = '致公党党员';
  1745. break;
  1746. case '10':
  1747. $political_affiliation = '九三学社社员';
  1748. break;
  1749. case '11':
  1750. $political_affiliation = '台盟盟员';
  1751. break;
  1752. case '12':
  1753. $political_affiliation = '无党派人士';
  1754. break;
  1755. case '13':
  1756. $political_affiliation = '群众';
  1757. }
  1758. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1759. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1760. $i++;
  1761. }
  1762. }
  1763. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1764. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1765. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1766. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1767. }
  1768. $word_url = "/{$filename}.docx";
  1769. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1770. $appoint->save();
  1771. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1772. return "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1773. }
  1774. }
  1775. /**
  1776. * 将报名资料导出成ZIP压缩包
  1777. * @param Request $request
  1778. * @return \Illuminate\Http\JsonResponse
  1779. * @throws \Exception
  1780. */
  1781. public function out_zip(Request $request)
  1782. {//TODO 数据太大,无法压缩,得做成异步
  1783. Permission::check('recruit_out_excel');
  1784. $recruit_id = $request->id;
  1785. $recruit = Recruit::find($recruit_id);
  1786. if (empty($recruit)) {
  1787. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1788. }
  1789. $data = $request->all();
  1790. $where = [];
  1791. $where[] = ['audit','>',0];
  1792. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1793. $param = parse_url($data['where']);
  1794. parse_str($param['query'],$param);
  1795. if (is_array($param)) {
  1796. unset($param['id']);
  1797. foreach ($param as $k => $v) {
  1798. if ($k == 'realname') {
  1799. $where[] = [$k, 'like', "%$v%"];
  1800. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1801. $where[] = [$k, '=', $v];
  1802. }
  1803. }
  1804. }
  1805. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1806. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1807. if(in_array('expand_special',explode(',', $recruit->forms))){
  1808. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1809. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1810. $select = array_merge($select,$special_select);
  1811. }
  1812. if(in_array('detail',explode(',', $recruit->forms))){
  1813. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1814. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1815. $select = array_merge($select,$detail_select);
  1816. }
  1817. $list = $model->select($select)
  1818. ->orderBy('recruit_appoint_info.updated_at','desc')
  1819. ->get();
  1820. if(!is_dir(base_path() . "/storage/app/public/recruit/zip")){
  1821. Storage::makeDirectory("public/recruit/zip");
  1822. }
  1823. if (file_exists(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip')) {
  1824. unlink(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip');
  1825. }
  1826. if($list){
  1827. // foreach ($list as $key => $value){
  1828. // $path = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}/";
  1829. // if(!is_dir($path)){
  1830. // Storage::makeDirectory("public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}");
  1831. // }
  1832. // if(in_array('expand_special',explode(',', $recruit->forms))){
  1833. // $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$value->id)->first();
  1834. // $material = json_decode($special['material'],true);
  1835. // if($material){
  1836. // foreach ($material as $k => $v){
  1837. // $old_path = base_path() . "/public/" . $v['url'];
  1838. // if (file_exists($old_path)) {
  1839. // $basename = basename($old_path);
  1840. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1841. // copy($old_path, $new_path); //拷贝到新目录
  1842. // }
  1843. // }
  1844. // }
  1845. // }
  1846. // if(in_array('identification',explode(',', $recruit->forms))){
  1847. // $identification = json_decode($value->identification,true);
  1848. // if($identification){
  1849. // foreach ($identification as $k => $v){
  1850. // $old_path = base_path() . "/public/" . $v['url'];
  1851. // if (file_exists($old_path)) {
  1852. // $basename = basename($old_path);
  1853. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1854. // copy($old_path, $new_path); //拷贝到新目录
  1855. // }
  1856. // }
  1857. // }
  1858. // }
  1859. // if(in_array('education_certification',explode(',', $recruit->forms))){
  1860. // $education_certification = json_decode($value->education_certification,true);
  1861. // if($education_certification){
  1862. // foreach ($education_certification as $k => $v){
  1863. // $old_path = base_path() . "/public/" . $v['url'];
  1864. // if (file_exists($old_path)) {
  1865. // $basename = basename($old_path);
  1866. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1867. // copy($old_path, $new_path); //拷贝到新目录
  1868. // }
  1869. // }
  1870. // }
  1871. // }
  1872. // if(in_array('other_certification',explode(',', $recruit->forms))){
  1873. // $other_certification = json_decode($value->other_certification,true);
  1874. // if($other_certification){
  1875. // foreach ($other_certification as $k => $v){
  1876. // $old_path = base_path() . "/public/" . $v['url'];
  1877. // if (file_exists($old_path)) {
  1878. // $basename = basename($old_path);
  1879. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1880. // copy($old_path, $new_path); //拷贝到新目录
  1881. // }
  1882. // }
  1883. // }
  1884. // }
  1885. // copy(base_path() . "/public/" . $value->word_url, $path . basename($value->word_url));
  1886. // }
  1887. $savename = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}.zip";
  1888. $zipper = new Zipper();
  1889. $folder = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/";//$public_path 被压缩的文件名
  1890. $zipper->make($savename)->add($folder)->close();//public_path($reduce_path) 压缩之后的文件名
  1891. // header("Content-Type: application/zip");
  1892. // header("Content-Transfer-Encoding: Binary");
  1893. // header("Content-Length: " . filesize($savename));
  1894. // header("Content-Disposition: attachment; filename=\"" . $savename . "\"");
  1895. //
  1896. // readfile($savename);
  1897. // exit;
  1898. return response()->json(['status' => 1, 'msg' => "/zip/{$recruit->name}.zip" ], 200);
  1899. }else{
  1900. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  1901. }
  1902. }
  1903. /**
  1904. * 准考证生成界面
  1905. *
  1906. * @param Content $content
  1907. * @param Request $request
  1908. * @return Content
  1909. */
  1910. public function ticket(Content $content, Request $request)
  1911. {
  1912. $recruit_id = $request->id;
  1913. $recruit = Recruit::find($recruit_id);
  1914. return $content
  1915. ->header('准考证管理')
  1916. ->description('')
  1917. ->body(view('admin.recruit.ticket')->with(['recruit'=>$recruit]));
  1918. }
  1919. /**
  1920. * 导出excel汇总表
  1921. * @param Content $content
  1922. * @param Request $request
  1923. * @return \Illuminate\Http\JsonResponse
  1924. * @throws \PhpOffice\PhpSpreadsheet\Exception
  1925. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  1926. */
  1927. public function out_excel(Content $content, Request $request)
  1928. {
  1929. Permission::check('recruit_out_excel');
  1930. $id = $request->id;
  1931. $recruit = Recruit::find($id);
  1932. if (empty($recruit)) {
  1933. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1934. }
  1935. $data = $request->all();
  1936. $where = [];
  1937. $where[] = ['audit','>',0];
  1938. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1939. $param = parse_url($data['where']);
  1940. parse_str($param['query'],$param);
  1941. if (is_array($param)) {
  1942. unset($param['id']);
  1943. foreach ($param as $k => $v) {
  1944. if ($k == 'realname') {
  1945. $where[] = [$k, 'like', "%$v%"];
  1946. } elseif ($k == 'id') {
  1947. $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
  1948. } elseif($k == 'print_bs'){
  1949. $where[] = ['recruit_ticket.ex_type', '=', 1];
  1950. $where[] = ['recruit_ticket.ex_status', '=', $v];
  1951. } elseif($k == 'print_js'){
  1952. $where[] = ['recruit_ticket.ex_type', '=', 2];
  1953. $where[] = ['recruit_ticket.ex_status', '=', $v];
  1954. } elseif($k == 'print_ms'){
  1955. $where[] = ['recruit_ticket.ex_type', '=', 3];
  1956. $where[] = ['recruit_ticket.ex_status', '=', $v];
  1957. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1958. $where[] = [$k, '=', $v];
  1959. }
  1960. }
  1961. }
  1962. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1963. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1964. if(in_array('expand_special',explode(',', $recruit->forms))){
  1965. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1966. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1967. $select = array_merge($select,$special_select);
  1968. }
  1969. if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1970. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1971. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1972. $select = array_merge($select,$detail_select);
  1973. }
  1974. $list = $model->select($select)
  1975. ->orderBy('recruit_appoint_info.updated_at','desc')
  1976. ->get();
  1977. if(count($list)){
  1978. $spreadsheet = new Spreadsheet();
  1979. $sheet = $spreadsheet->getActiveSheet();
  1980. if(in_array('internship',explode(',', $recruit->forms))){
  1981. $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1982. }else{
  1983. $header = ['姓名','性别','生日','头像','民族','籍贯','报考岗位','政治面貌','入党时间','职称或职业资格','现工作单位及职务','户籍所在地','学历','学校','学位','所学专业','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1984. }
  1985. if(in_array('expand_special',explode(',', $recruit->forms))){
  1986. $special = ['是否申请加分','符合哪一项加分条件','加分佐证材料'];
  1987. $header = array_merge($header,$special);
  1988. }
  1989. if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1990. $detail = ['个人简历','培训学习经历','奖惩情况','个人介绍'];
  1991. }else{
  1992. $detail = ['个人简历'];
  1993. }
  1994. $header = array_merge($header,$detail);
  1995. $header[] = '家庭成员及其社会关系';
  1996. if(in_array('identification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1997. $header[] = '身份证明';
  1998. }
  1999. if(in_array('education_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  2000. $header[] = '学历证明';
  2001. }
  2002. if(in_array('other_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  2003. $header[] = '其他证明';
  2004. }
  2005. $header[] = '审核状态';
  2006. $header[] = '审核意见';
  2007. // if(in_array('3',explode(',', $recruit->step))){
  2008. // $header = array_merge($header,['笔试准考证打印','笔试审核状态','笔试结果']);
  2009. // }
  2010. // if(in_array('4',explode(',', $recruit->step))){
  2011. // $header = array_merge($header,['上机准考证打印','上机审核状态','上机结果']);
  2012. // }
  2013. // if(in_array('5',explode(',', $recruit->step))){
  2014. // $header = array_merge($header,['面试准考证打印','面试审核状态','面试结果']);
  2015. // }
  2016. // if(in_array('6',explode(',', $recruit->step))){
  2017. // $header = array_merge($header,['复试准考证打印','复试审核状态','复试结果']);
  2018. // }
  2019. // if(in_array('7',explode(',', $recruit->step))){
  2020. // $header = array_merge($header,['体检审核状态','体检结果']);
  2021. // }
  2022. // if(in_array('8',explode(',', $recruit->step))){
  2023. // $header = array_merge($header,['政审状态','政审结果']);
  2024. // }
  2025. $header[] = 'word简历的下载地址';
  2026. foreach ($header as $key => $value) {
  2027. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  2028. }
  2029. $row = 2;
  2030. $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  2031. $length = count($list);//算出该数组的长度
  2032. $last = $list[$length-1];//取出最后一个数组的值,复制给新变量,-1是因为第一个数组元素下表为0
  2033. unset($list[$length-1]);//将最后一个数组注销
  2034. $list[] = $last;//再将新变量加入到数组里
  2035. $data = [];
  2036. foreach ($list as $k => $v) {
  2037. switch ($v->political_affiliation) {
  2038. case '01':
  2039. $political_affiliation = '中共党员';
  2040. break;
  2041. case '02':
  2042. $political_affiliation = '中共预备党员';
  2043. break;
  2044. case '03':
  2045. $political_affiliation = '共青团员';
  2046. break;
  2047. case '04':
  2048. $political_affiliation = '民革党员';
  2049. break;
  2050. case '05':
  2051. $political_affiliation = '民盟盟员';
  2052. break;
  2053. case '06':
  2054. $political_affiliation = '民建会员';
  2055. break;
  2056. case '07':
  2057. $political_affiliation = '民进会员';
  2058. break;
  2059. case '08':
  2060. $political_affiliation = '农工党党员';
  2061. break;
  2062. case '09':
  2063. $political_affiliation = '致公党党员';
  2064. break;
  2065. case '10':
  2066. $political_affiliation = '九三学社社员';
  2067. break;
  2068. case '11':
  2069. $political_affiliation = '台盟盟员';
  2070. break;
  2071. case '12':
  2072. $political_affiliation = '无党派人士';
  2073. break;
  2074. case '13':
  2075. $political_affiliation = '群众';
  2076. break;
  2077. default:
  2078. $political_affiliation = '未知';
  2079. break;
  2080. }
  2081. if(in_array('internship',explode(',', $recruit->forms))){
  2082. $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  2083. $item = [
  2084. $v->realname,
  2085. $v->sex == 0 ? '女' : '男',
  2086. $v->birthday,
  2087. "https://www.jucai.gov.cn" . $v->avatar,
  2088. $v->nation,
  2089. $v->native_place,
  2090. $v->code . $v->name,
  2091. $political_affiliation,
  2092. $v->join_time,
  2093. $v->house_register,
  2094. $v->education,
  2095. $v->school,
  2096. $v->pro,
  2097. $v->adjust == 0 ? '否' : '是',
  2098. $v->address,
  2099. '\''.$v->card,
  2100. $v->mobile,
  2101. $v->email,
  2102. $v->concat_name,
  2103. $v->concat_mobile
  2104. ];
  2105. }else{
  2106. $item = [
  2107. $v->realname,
  2108. $v->sex == 0 ? '女' : '男',
  2109. $v->birthday,
  2110. "https://www.jucai.gov.cn" . $v->avatar,
  2111. $v->nation,
  2112. $v->native_place,
  2113. $v->code . $v->name,
  2114. $political_affiliation,
  2115. $v->join_time,
  2116. $v->titles,
  2117. $v->work,
  2118. $v->house_register,
  2119. $v->education,
  2120. $v->school,
  2121. $v->degree,
  2122. $v->pro,
  2123. $v->address,
  2124. '\''.$v->card,
  2125. $v->mobile,
  2126. $v->email,
  2127. $v->concat_name,
  2128. $v->concat_mobile
  2129. ];
  2130. }
  2131. if (in_array('expand_special', explode(',', $recruit->forms))) {
  2132. $material = json_decode($v->material, true);
  2133. $materials = [];
  2134. if($material){
  2135. foreach ($material as $key => $value) {
  2136. array_push($materials, "https://www.jucai.gov.cn" . $value['response']['path']);
  2137. }
  2138. }
  2139. $special = [
  2140. $v->point_apply == 0 ? '否' : '是',
  2141. $v->condition,
  2142. implode("\r\n", $materials)
  2143. ];
  2144. $item = array_merge($item, $special);
  2145. }
  2146. if (in_array('detail', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2147. $detail = [
  2148. $v->resume,
  2149. $v->train,
  2150. $v->rewards_and_punishments,
  2151. $v->introduce
  2152. ];
  2153. } else {
  2154. $detail = [$v->resume];
  2155. }
  2156. $item = array_merge($item, $detail);
  2157. $family = json_decode($v->family, true);
  2158. $familys = [];
  2159. foreach ($family as $val){
  2160. switch ($val['political_affiliation']) {
  2161. case '01':
  2162. $political_affiliation = '中共党员';
  2163. break;
  2164. case '02':
  2165. $political_affiliation = '中共预备党员';
  2166. break;
  2167. case '03':
  2168. $political_affiliation = '共青团员';
  2169. break;
  2170. case '04':
  2171. $political_affiliation = '民革党员';
  2172. break;
  2173. case '05':
  2174. $political_affiliation = '民盟盟员';
  2175. break;
  2176. case '06':
  2177. $political_affiliation = '民建会员';
  2178. break;
  2179. case '07':
  2180. $political_affiliation = '民进会员';
  2181. break;
  2182. case '08':
  2183. $political_affiliation = '农工党党员';
  2184. break;
  2185. case '09':
  2186. $political_affiliation = '致公党党员';
  2187. break;
  2188. case '10':
  2189. $political_affiliation = '九三学社社员';
  2190. break;
  2191. case '11':
  2192. $political_affiliation = '台盟盟员';
  2193. break;
  2194. case '12':
  2195. $political_affiliation = '无党派人士';
  2196. break;
  2197. case '13':
  2198. $political_affiliation = '群众';
  2199. break;
  2200. default:
  2201. $political_affiliation = '未知';
  2202. break;
  2203. }
  2204. $familys[] = "称谓:" . $val['relation'] . ";姓名:".$val['realname'] . ';生日:'.$val['birthday'].';政治面貌:'.$political_affiliation.';职业:'.$val['work'];
  2205. }
  2206. $item[] = implode("\r\n", $familys);
  2207. if (in_array('identification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2208. $identification = json_decode($v->identification, true);
  2209. $identifications = [];
  2210. foreach ($identification as $val){
  2211. if(array_key_exists('path', $val['response'])){
  2212. array_push($identifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2213. }
  2214. }
  2215. array_push($item, implode("\r\n", $identifications));
  2216. }
  2217. if (in_array('education_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2218. $education_certification = json_decode($v->education_certification, true);
  2219. $education_certifications = [];
  2220. foreach ($education_certification as $val){
  2221. if(array_key_exists('path', $val['response'])){
  2222. array_push($education_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2223. }
  2224. }
  2225. array_push($item, implode("\r\n", $education_certifications));
  2226. }
  2227. if (in_array('other_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2228. $other_certification = json_decode($v->other_certification, true);
  2229. $other_certifications = [];
  2230. if($other_certification){
  2231. foreach ($other_certification as $val){
  2232. if(array_key_exists('path', $val['response'])){
  2233. array_push($other_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2234. }
  2235. }
  2236. }
  2237. array_push($item, implode("\r\n", $other_certifications));
  2238. }
  2239. switch (intval($v->audit)){
  2240. case 1:
  2241. $item[] = '审核中';
  2242. $item[] = '';
  2243. break;
  2244. case 2:
  2245. case 3:
  2246. $log = RecruitAppointLog::where('appoint_id', $v->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  2247. if ($log) {
  2248. $log_arr = explode(',',$log->log);
  2249. $item[] = $log_arr[0];
  2250. $item[] = $log_arr[1];
  2251. } else {
  2252. $item[] = '';
  2253. $item[] = '';
  2254. }
  2255. break;
  2256. default:
  2257. $item[] = '';
  2258. $item[] = '';
  2259. break;
  2260. }
  2261. if(empty($v->word_url)){
  2262. $item[] = "暂无";
  2263. }else{
  2264. $item[] = "https://www.jucai.gov.cn/" . $v->word_url;
  2265. }
  2266. array_push($data,$item);
  2267. }
  2268. foreach($data as $k => $v){
  2269. for ($i = 0;$i<count($v);$i++){
  2270. if($i == 18 || $i == 19 || $i == 22){
  2271. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2272. }else{
  2273. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2274. }
  2275. }
  2276. $row++;
  2277. }
  2278. $file_name = $recruit->name . date("Y-m-d",time());
  2279. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2280. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2281. header('Cache-Control: max-age=0');
  2282. // If you're serving to IE 9, then the following may be needed
  2283. header('Cache-Control: max-age=1');
  2284. // If you're serving to IE over SSL, then the following may be needed
  2285. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2286. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2287. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2288. header('Pragma: public'); // HTTP/1.0
  2289. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2290. $writer->save('php://output');
  2291. }else{
  2292. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  2293. }
  2294. }
  2295. /**
  2296. * 座位贴
  2297. * @param Content $content
  2298. * @param Request $request
  2299. * @return Content
  2300. */
  2301. public function seat_sticker(Content $content, Request $request){
  2302. $recruit_id = $request->id;
  2303. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  2304. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  2305. ->select('recruit_appoint_info.*','recruit_ticket.*')
  2306. ->orderBy('recruit_ticket.ex_room','asc')
  2307. ->orderByRaw('recruit_ticket.ex_seat+0 asc')
  2308. ->get();
  2309. $data = [];
  2310. foreach ($list as $k => $v){
  2311. $place = $v->ex_place == null ? 'empty' : $v->ex_place;
  2312. if(!array_key_exists($place,$data)){
  2313. $data[$place] = [];
  2314. }
  2315. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  2316. if(!array_key_exists($room,$data[$place])){
  2317. $data[$place][$room] = [];
  2318. }
  2319. $item = [
  2320. 'avatar' => $v->avatar,
  2321. 'seat' => $v->ex_seat,
  2322. 'realname' => $v->realname,
  2323. 'number' => $v->ex_number
  2324. ];
  2325. array_push($data[$place][$room],$item);
  2326. }
  2327. //dd($data);
  2328. return $content->body(view('admin.recruit.seat_sticker')->with(['data' => $data]));
  2329. }
  2330. public function sign_table(Content $content, Request $request){
  2331. $recruit_id = $request->id;
  2332. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  2333. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  2334. ->select('recruit_appoint_info.*','recruit_ticket.*')
  2335. ->orderBy('recruit_ticket.ex_room','asc')
  2336. ->orderByRaw('recruit_ticket.ex_seat+0 asc')
  2337. ->get();
  2338. $data = [];
  2339. foreach ($list as $k => $v){
  2340. $place = $v->ex_place == null ? 'empty' : $v->ex_place;
  2341. if(!array_key_exists($place,$data)){
  2342. $data[$place] = [];
  2343. }
  2344. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  2345. if(!array_key_exists($room,$data[$place])){
  2346. $data[$place][$room] = [];
  2347. }
  2348. $item = [
  2349. 'avatar' => $v->avatar,
  2350. 'seat' => $v->ex_seat,
  2351. 'realname' => $v->realname
  2352. ];
  2353. array_push($data[$place][$room],$item);
  2354. }
  2355. return $content->body(view('admin.recruit.sign_table')->with(['data' => $data]));
  2356. }
  2357. /**
  2358. * 上传成绩页面
  2359. *
  2360. * @access public
  2361. */
  2362. public function ajax_record(Request $request)
  2363. {
  2364. $recruit_id = $request->input('recruit_id');
  2365. if(!$recruit_id){
  2366. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2367. }
  2368. $recruit = Recruit::where('id',$recruit_id)->first();
  2369. if(empty($recruit)){
  2370. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2371. }
  2372. $view_data = [
  2373. 'recruit' => $recruit
  2374. ];
  2375. return response(['data' => view('admin.recruit.ajax_record')->with($view_data)->render(), 'status' => 1], '200');
  2376. }
  2377. public function update_record(Request $request)
  2378. {
  2379. $data = $request->all();
  2380. if(!array_key_exists('recruit_id',$data) || !$data['recruit_id']){
  2381. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2382. }
  2383. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  2384. if(empty($recruit)){
  2385. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2386. }
  2387. if(array_key_exists('pen_data',$data)){
  2388. $ticket_url = base_path() . "/storage/app/public/recruit/ticket/" . uniqid() . '.xlsx';
  2389. if(move_uploaded_file($_FILES['pen_data']['tmp_name'],$ticket_url)){
  2390. $spreadsheet = IOFactory::load($ticket_url);
  2391. $sheet = $spreadsheet->getActiveSheet();
  2392. $rowCount = $sheet->getHighestRow();
  2393. $record = [];
  2394. for($row = 2;$row<=$rowCount;$row++){
  2395. $record[$sheet->getCell("A{$row}")->getValue()] = [
  2396. 'id' => $sheet->getCell("A{$row}")->getValue(),
  2397. 'realname' => $sheet->getCell("B{$row}")->getValue(),
  2398. 'card' => $sheet->getCell("C{$row}")->getValue(),
  2399. 'ex_number' => $sheet->getCell("E{$row}")->getValue(),
  2400. 'record' => $sheet->getCell("F{$row}")->getValue(),
  2401. 'next' => $sheet->getCell("G{$row}")->getValue()
  2402. ];
  2403. }
  2404. Recruit::where('id',$data['recruit_id'])->update(['pen_status' => 1]);
  2405. $record = new TicketJob($data['recruit_id'],'pen_result',$record);
  2406. dispatch($record);
  2407. return response()->json(['status' => 1, 'msg' => '成绩上传成功'], 200);
  2408. }else{
  2409. return response()->json(['status' => 0, 'msg' => '成绩上传失败'], 200);
  2410. }
  2411. }else{
  2412. return response()->json(['status' => 0, 'msg' => '笔试成绩不存在'], 200);
  2413. }
  2414. }
  2415. public function create_record_template(Request $request){
  2416. $recruit_id = $request->input('recruit_id');
  2417. if(!$recruit_id){
  2418. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2419. }
  2420. $recruit = Recruit::where('id',$recruit_id)->first();
  2421. if(empty($recruit)){
  2422. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2423. }
  2424. $type = $request->input('type','pen');
  2425. switch ($type){
  2426. case 'pen':
  2427. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)
  2428. ->where('recruit_appoint_info.audit',3)
  2429. ->where('recruit_appoint_info.pen_audit',-1)
  2430. ->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')
  2431. ->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  2432. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2433. $data = [];
  2434. foreach ($list as $k => $v){
  2435. $item = [
  2436. $v->id,
  2437. $v->realname,
  2438. $v->card,
  2439. $post_data[$v->post_id],
  2440. $v->ex_number
  2441. ];
  2442. array_push($data,$item);
  2443. }
  2444. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  2445. $sheet = $spreadsheet->getActiveSheet();
  2446. $row = 2;
  2447. foreach($data as $k => $v){
  2448. for ($i = 0;$i<count($v);$i++){
  2449. if($i == 2 || $i == 4){
  2450. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2451. }else{
  2452. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2453. }
  2454. }
  2455. $row++;
  2456. }
  2457. $file_name = $recruit->company . "_成绩表模板";
  2458. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2459. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2460. header('Cache-Control: max-age=0');
  2461. // If you're serving to IE 9, then the following may be needed
  2462. header('Cache-Control: max-age=1');
  2463. // If you're serving to IE over SSL, then the following may be needed
  2464. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2465. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2466. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2467. header('Pragma: public'); // HTTP/1.0
  2468. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2469. $writer->save('php://output');
  2470. break;
  2471. case 'face':
  2472. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)
  2473. ->where('recruit_appoint_info.audit',3)
  2474. ->where('recruit_appoint_info.face_audit',-1)
  2475. ->where(function($query){
  2476. $query->where('recruit_appoint_info.pen_audit',1)
  2477. ->orWhere('recruit_appoint_info.pen_audit',3);
  2478. })
  2479. ->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  2480. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2481. $data = [];
  2482. foreach ($list as $k => $v){
  2483. $item = [
  2484. $v->id,
  2485. $v->realname,
  2486. $v->card,
  2487. $post_data[$v->post_id],
  2488. $v->ex_number
  2489. ];
  2490. array_push($data,$item);
  2491. }
  2492. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  2493. $sheet = $spreadsheet->getActiveSheet();
  2494. $row = 2;
  2495. foreach($data as $k => $v){
  2496. for ($i = 0;$i<count($v);$i++){
  2497. if($i == 2 || $i == 4){
  2498. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2499. }else{
  2500. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2501. }
  2502. }
  2503. $row++;
  2504. }
  2505. $file_name = $recruit->company . "_成绩表模板";
  2506. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2507. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2508. header('Cache-Control: max-age=0');
  2509. // If you're serving to IE 9, then the following may be needed
  2510. header('Cache-Control: max-age=1');
  2511. // If you're serving to IE over SSL, then the following may be needed
  2512. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2513. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2514. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2515. header('Pragma: public'); // HTTP/1.0
  2516. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2517. $writer->save('php://output');
  2518. break;
  2519. }
  2520. }
  2521. public function ticket_template(Request $request)
  2522. {
  2523. }
  2524. public function create_ticket(Request $request)
  2525. {
  2526. $data = $request->only('recruit_id','type','channel','content','keys');
  2527. //dd($data);
  2528. }
  2529. public function test(Request $request){
  2530. $list = RecruitSupplement::where('recruit_supplement.status',1)
  2531. ->join('recruit_appoint_info', 'recruit_supplement.appoint_id', '=' , 'recruit_appoint_info.id', 'left')
  2532. ->select('recruit_appoint_info.*')
  2533. ->get();
  2534. $post_data = RecruitPost::where('recruit_id',5)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2535. $header = ['姓名','性别','年龄','联系电话','身份证号码','岗位'];
  2536. $spreadsheet = new Spreadsheet();
  2537. $sheet = $spreadsheet->getActiveSheet();
  2538. foreach ($header as $key => $value) {
  2539. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  2540. }
  2541. foreach($list as $k => $v){
  2542. $sheet->setCellValueByColumnAndRow(1, $k+2, $v->realname);
  2543. $sheet->setCellValueByColumnAndRow(2, $k+2, $v->sex == 0 ? '女' : '男');
  2544. $time = explode('-',$v->birthday);
  2545. $sheet->setCellValueByColumnAndRow(3, $k+2, 2021-$time[0]);
  2546. $sheet->setCellValueExplicitByColumnAndRow(4, $k+2, $v->mobile, DataType::TYPE_STRING);
  2547. $sheet->setCellValueExplicitByColumnAndRow(5, $k+2, $v->card, DataType::TYPE_STRING);
  2548. $sheet->setCellValueByColumnAndRow(6, $k+2, $post_data[$v->post_id]);
  2549. }
  2550. $file_name = '名单';
  2551. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2552. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2553. header('Cache-Control: max-age=0');
  2554. // If you're serving to IE 9, then the following may be needed
  2555. header('Cache-Control: max-age=1');
  2556. // If you're serving to IE over SSL, then the following may be needed
  2557. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2558. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2559. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2560. header('Pragma: public'); // HTTP/1.0
  2561. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2562. $writer->save('php://output');
  2563. dd($list);
  2564. // $ids = [6,7,121,47,181,66,108,138,21,212,177,130,114,27,63,31,51];
  2565. // $data = RecruitAppointInfo::whereIn('id',$ids)->get();
  2566. // $post_data = RecruitPost::where('recruit_id',1)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2567. //
  2568. //
  2569. // foreach ($data as $k => $v){
  2570. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_face_ticket.docx");
  2571. // $templateProcessor->setValue('realname', $v->realname);
  2572. // $templateProcessor->setValue('card', $v->card);
  2573. // $templateProcessor->setValue('post', $post_data[$v->post_id]);
  2574. // $name = 'jjhc';
  2575. // $date = '2020-11-30';
  2576. // if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face")){
  2577. // Storage::makeDirectory("public/recruit/ticket/word/{$date}/{$name}/face");
  2578. // }
  2579. // $filename = $v->realname . '_' . $v->card . '_' . $post_data[$v->post_id];
  2580. // $word_url = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face/" . $filename . '.docx';
  2581. // $templateProcessor->saveAs($word_url);//另存为
  2582. // }
  2583. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_pen_ticket.docx");
  2584. //
  2585. //
  2586. // $templateProcessor->setImageValue('avatar',['path' => 'https://www.jucai.gov.cn/storage/-1ae05561c7f32869.jpg', 'width' => 200, 'height' => 150]);
  2587. // $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/ticket/template/test.docx");//另存为
  2588. //shell_exec('libreoffice6.4 --headless --convert-to pdf:writer_pdf_Export ' . base_path() . "/storage/app/public/recruit/ticket/template/test.docx " . base_path() ."/storage/app/public/recruit/ticket/template/test.pdf");
  2589. //libreoffice --headless --convert-to pdf:writer_pdf_Export /data/wwwroot/jucai/storage/app/public/recruit/word/2020-11-30/jjhc/pen/*.docx --outdir /data/wwwroot/jucai/storage/app/public/recruit/pdf/2020-11-30/jjhc/pen
  2590. }
  2591. public function batchFetchWord(Request $request)
  2592. {
  2593. set_time_limit(0);
  2594. ini_set('memory_limit',-1);
  2595. $recruit_id = $request->recruit_id;
  2596. $audit = $request->audit;
  2597. if(!empty($recruit_id)){
  2598. $where = [['recruit_id','=',$recruit_id]];
  2599. $where[] = ['word_url','=',''];
  2600. if (!empty($audit)) {
  2601. if ($audit == 3) {
  2602. $where[] = ['audit','=',3];
  2603. } else {
  2604. $where[] = ['audit','!=',0];
  2605. $where[] = ['audit','!=',3];
  2606. }
  2607. } else {
  2608. $where[] = ['audit','!=',0];
  2609. }
  2610. $list = RecruitAppointInfo::where($where)->pluck('id')->all();
  2611. if (!empty($list)) {
  2612. foreach ($list as $appoint_id) {
  2613. $this->fetch_word(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id]);
  2614. }
  2615. }
  2616. return response()->json(['status' => 1, 'msg' => '生成Word简历成功!', 'data' => 'ok']);
  2617. }else{
  2618. return response()->json(['status' => 0, 'msg' => '参数缺失!', 'data' => 'fail']);
  2619. }
  2620. }
  2621. }