RecruitController.php 129 KB

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