Talent.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\VerifyApi;
  5. use app\common\api\TalentLogApi;
  6. use app\common\api\TalentState;
  7. use app\enterprise\model\Talent as TalentModel;
  8. use app\common\api\TalentConditionApi;
  9. use app\common\api\DictApi;
  10. /**
  11. * Description of Talent
  12. *
  13. * @author sgq
  14. */
  15. class Talent extends AdminController {
  16. public function selectNeedCheckData() {
  17. $params = $this->request->param();
  18. return json(VerifyApi::getPublicList($params));
  19. }
  20. public function common_check() {
  21. $request = $this->request;
  22. $params = $request->param();
  23. $id = $params["id"];
  24. $info = VerifyApi::getTalentInfoById($id);
  25. if ($info["checkState"] == 2) {
  26. return view("talentInfo_base_check", ["info" => $info]);
  27. } else {
  28. return view("talentInfo_common_check", ["info" => $info]);
  29. }
  30. }
  31. public function cancel_verify() {
  32. $params = $this->request->param();
  33. $ids = $params["ids"];
  34. $msg = $params["msg"];
  35. if ($msg == "") {
  36. return json(["msg" => "请填写审核不通过的原因"]);
  37. }
  38. $ids_arr = array_filter(explode(",", $ids));
  39. $counts = 0;
  40. foreach ($ids_arr as $id) {
  41. $ti = VerifyApi::getOne($id);
  42. $data["id"] = $id;
  43. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  44. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  45. TalentLogApi::write(1, $id, [TalentState::BASE_VERIFY_FAIL], $msg, 1);
  46. TalentModel::update($data);
  47. $counts++;
  48. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  49. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  50. TalentLogApi::write(1, $id, [TalentState::FST_VERIFY_FAIL], $msg, 1);
  51. TalentModel::update($data);
  52. $counts++;
  53. } else {
  54. //return json(["msg" => "不在审核范围"]);
  55. }
  56. }
  57. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  58. }
  59. public function base_verify() {
  60. return view();
  61. }
  62. public function base_verify_list() {
  63. $request = $this->request;
  64. return json(VerifyApi::getList($request));
  65. }
  66. /**
  67. * 部门初审
  68. * @auth {{/talentInfo/gotoIndex/-1}}
  69. */
  70. public function dept_fst_verify() {
  71. return view();
  72. }
  73. /**
  74. * 初审
  75. * @auth {{/talentInfo/gotoIndex/1}}
  76. */
  77. public function fst_verify() {
  78. return view();
  79. }
  80. /**
  81. * 初审-审核
  82. * @auth {{/talentInfo/firstCheck}}
  83. */
  84. public function fst_check() {
  85. }
  86. /**
  87. * 初审-修改驳回字段
  88. * @auth {{/talentInfo/updateFieldsAndFiles}}
  89. */
  90. public function updateFieldsAndFiles() {
  91. }
  92. /**
  93. * 初审-审核不通过
  94. * @auth {{/talentInfo/setNotPass}}
  95. */
  96. public function dis_pass() {
  97. }
  98. /**
  99. * 部门审核
  100. * @auth {{/talentInfo/gotoIndex/2}}
  101. */
  102. public function dept_verify() {
  103. return view();
  104. }
  105. /**
  106. * 复审
  107. * @auth {{/talentInfo/gotoIndex/3}}
  108. */
  109. public function re_verify() {
  110. return view();
  111. }
  112. /**
  113. * 复审-撤销复核
  114. * @auth {{/talentInfo/cancleThirdCheck}}
  115. */
  116. public function cancel_check() {
  117. }
  118. /**
  119. * 预备人才库
  120. * @auth {{/talentInfo/gotoIndex/4}}
  121. */
  122. public function pre_list() {
  123. return view();
  124. }
  125. /**
  126. * 预备人才库-公示
  127. * @auth {{/talentInfo/preparePublic}}
  128. */
  129. public function pre_public() {
  130. }
  131. /**
  132. * 预备人才库-核查征信
  133. * @auth {{/talentInfo/prepareHczx}}
  134. */
  135. public function pre_hczx() {
  136. }
  137. /**
  138. * 预备人才库-征信通过
  139. * @auth {{/talentInfo/hczxPass}}
  140. */
  141. public function pre_zx_pass() {
  142. }
  143. /**
  144. * 预备人才库-征信失信
  145. * @auth {{/talentInfo/hczxReject}}
  146. */
  147. public function pre_zx_reject() {
  148. }
  149. /**
  150. * 预备人才库-公示再审核
  151. * @auth {{/talentInfo/prepareCheck}}
  152. */
  153. public function pre_check() {
  154. }
  155. /**
  156. * 预备人才库-公示通过
  157. * @auth {{/talentInfo/publicPass}}
  158. */
  159. public function pre_public_pass() {
  160. }
  161. /**
  162. * 预备人才库-公布
  163. * @auth {{/talentInfo/preparePublish}}
  164. */
  165. public function pre_publish() {
  166. }
  167. /**
  168. * 预备人才库-发证
  169. * @auth {{/talentInfo/prepareCertification}}
  170. */
  171. public function pre_certification() {
  172. }
  173. /**
  174. * 预备人才库-撤销公布
  175. * @auth {{/talentInfo/prepareCanclePublish}}
  176. */
  177. public function pre_cancel_publish() {
  178. }
  179. /**
  180. * 预备人才库-公示预览
  181. * @auth {{/talentInfo/publicExportBefore}}
  182. */
  183. public function pre_public_preview() {
  184. }
  185. /**
  186. * 预备人才库-公布预览
  187. * @auth {{/talentInfo/publishExportBefore}}
  188. */
  189. public function pre_publish_preview() {
  190. }
  191. /**
  192. * 基本条件审核-提交未保存
  193. * @param \think\Request $request
  194. * @param type $talent_info
  195. * @return type json
  196. */
  197. private function baseCheck(\think\Request $request, $talent_info) {
  198. $params = $request->param();
  199. if ($params["checkState"] == 3) {
  200. //审核成功
  201. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //初审成功
  202. } else {
  203. //审核驳回并记录需要修改的字段和上传文件
  204. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  205. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  206. }
  207. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  208. if (!$log)
  209. return json(["msg" => "日志数据异常,保存失败"]);
  210. if ($log["active"] == 0) {
  211. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  212. } else {
  213. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  214. }
  215. $data["id"] = $talent_info["id"];
  216. $data["modify_files"] = $params["files"];
  217. $data["modify_fields"] = $params["fields"];
  218. TalentModel::update($data);
  219. return json(["code" => 200, "msg" => "保存成功"]);
  220. }
  221. /**
  222. * 基本条件审核-提交审核
  223. * @param type $talent_info
  224. * @return type json
  225. */
  226. private function baseSubmitCheck($talent_info) {
  227. return $this->commonSubmitCheck($talent_info, 1);
  228. }
  229. /**
  230. * 初审-提交未保存
  231. * @param \think\Request $request
  232. * @param type $talent_info
  233. * @return type json
  234. */
  235. private function fstCheck(\think\Request $request, $talent_info) {
  236. $params = $request->param();
  237. if ($params["checkState"] == 3) {
  238. //审核成功
  239. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  240. } else {
  241. //审核驳回并记录需要修改的字段和上传文件
  242. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  243. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  244. }
  245. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  246. if (!$log)
  247. return json(["msg" => "日志数据异常,保存失败"]);
  248. if ($log["active"] == 0) {
  249. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  250. } else {
  251. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  252. }
  253. $data["id"] = $talent_info["id"];
  254. $data["modify_files"] = $params["files"];
  255. $data["modify_fields"] = $params["fields"];
  256. TalentModel::update($data);
  257. return json(["code" => 200, "msg" => "保存成功"]);
  258. }
  259. /**
  260. * 初审-提交审核
  261. * @param type $talent_info
  262. * @return type json
  263. */
  264. private function fstSubmitCheck($talent_info) {
  265. $nowProcess = 2;
  266. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  267. if (!$log || $log["active"] == 1)
  268. return json(["msg" => "日志数据异常,审核失败"]);
  269. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  270. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  271. }
  272. $data["id"] = $talent_info["id"];
  273. $data["checkState"] = $log["new_state"];
  274. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  275. TalentModel::update($data);
  276. TalentLogApi::setActive($log["id"], 1);
  277. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  278. $companyIds = array_filter(explode(",", $condition["companyIds"]));
  279. if ($log["new_state"] == TalentState::FST_VERIFY_PASS) {
  280. TalentLogApi::writeDeptLogs($talent_info["id"], $companyIds, TalentState::FST_VERIFY_PASS);
  281. }
  282. return json(["code" => 200, "msg" => "审核成功"]);
  283. }
  284. /**
  285. * 部门审核-提交未保存
  286. * @param \think\Request $request
  287. * @param type $talent_info
  288. * @return type json
  289. */
  290. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  291. $params = $request->param();
  292. if ($params["checkState"] == 3) {
  293. //审核成功
  294. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  295. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  296. } else {
  297. //审核驳回并记录需要修改的字段和上传文件
  298. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  299. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  300. }
  301. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  302. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  303. if (!$dept_log)
  304. return json(["msg" => "未匹配日志,审核失败"]);
  305. if ($dept_log["active"] == 1)
  306. return json(["msg" => "您的部门已经审核过了"]);
  307. $data["id"] = $talent_info["id"];
  308. $data["modify_files"] = $params["files"];
  309. $data["modify_fields"] = $params["fields"];
  310. TalentModel::update($data);
  311. //修改日志
  312. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  313. return json(["code" => 200, "msg" => "保存成功"]);
  314. }
  315. /**
  316. * 部门审核-提交审核
  317. * @param type $talent_info
  318. * @return type json
  319. */
  320. private function deptSubmitCheck($talent_info, $companys) {
  321. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  322. $over = 0; //完成度
  323. $error = 0; //失败数
  324. $nowProcess = 3;
  325. if (!$dept_log)
  326. return json(["msg" => "未匹配日志,审核失败"]);
  327. if ($dept_log["active"] == 1)
  328. return json(["msg" => "您的部门已经审核过了"]);
  329. $over++;
  330. if ($dept_log["new_state"] == TalentState::DEPT_VERIFY_REJECT) {
  331. $error++;
  332. }
  333. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  334. for ($i = 0; $i < count($logs); $i++) {
  335. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  336. if ($logs["new_state"] == TalentState::DEPT_VERIFY_REJECT) {
  337. $error++;
  338. }
  339. }
  340. if ($over == count($companys)) {
  341. //全部已审核
  342. $checkState = TalentState::DEPT_VERIFY_REJECT;
  343. if ($error == 0) {
  344. $checkState = TalentState::DEPT_VERIFY_PASS;
  345. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  346. }
  347. $data["id"] = $talent_info["id"];
  348. $data["checkState"] = $checkState;
  349. $data["first_dept_check_time"] = null;
  350. TalentModel::update($data);
  351. TalentLogApi::write(1, $talent_info["id"], $checkState, "部门审核结束", 1);
  352. }
  353. TalentLogApi::setActive($dept_log["id"], 1);
  354. return json(["code" => 200, "msg" => "审核成功"]);
  355. }
  356. /**
  357. * 复审-提交未保存
  358. * @param \think\Request $request
  359. * @param type $talent_info
  360. * @param type json
  361. */
  362. private function reCheck(\think\Request $request, $talent_info) {
  363. $params = $request->param();
  364. if ($params["checkState"] == 3) {
  365. //审核成功
  366. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  367. } else if ($params["checkState"] == 2) {
  368. //审核驳回并记录需要修改的字段和上传文件
  369. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  370. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  371. } else {
  372. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  373. }
  374. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  375. if (!$log)
  376. return json(["msg" => "日志数据异常,保存失败"]);
  377. if ($log["active"] == 0) {
  378. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  379. } else {
  380. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  381. }
  382. $data["id"] = $talent_info["id"];
  383. $data["modify_files"] = $params["files"];
  384. $data["modify_fields"] = $params["fields"];
  385. TalentModel::update($data);
  386. return json(["code" => 200, "msg" => "保存成功"]);
  387. }
  388. /**
  389. * 复审-提交审核
  390. * @param type $talent_info
  391. * @return type json
  392. */
  393. private function reSubmitCheck($talent_info) {
  394. return $this->commonSubmitCheck($talent_info, 4);
  395. }
  396. private function commonSubmitCheck($talent_info, $nowProcess) {
  397. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  398. if (!$log || $log["active"] == 1)
  399. return json(["msg" => "日志数据异常,审核失败"]);
  400. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  401. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  402. }
  403. $data["id"] = $talent_info["id"];
  404. $data["checkState"] = $log["new_state"];
  405. TalentModel::update($data);
  406. TalentLogApi::setActive($log["id"], 1);
  407. return json(["code" => 200, "msg" => "审核成功"]);
  408. }
  409. public function check() {
  410. //公共调度方法
  411. $request = $this->request;
  412. $params = $request->param();
  413. $check = $params["checkState"];
  414. $check_msg = trim($params["checkMsg"]);
  415. $files = $params["files"];
  416. $fields = $params["fields"];
  417. $id = $params["id"];
  418. $talent_info = VerifyApi::getOne($id);
  419. $checkState = $talent_info["checkState"];
  420. if (!$talent_info) {
  421. return json(["msg" => "数据错误"]);
  422. }
  423. if (!$check) {
  424. return json(["msg" => "请选择审核状态"]);
  425. }
  426. if (!$check_msg) {
  427. return json(["msg" => "请填写审核说明"]);
  428. }
  429. if ($checkState == TalentState::FST_SUBMIT) {
  430. return $this->baseCheck($request, $talent_info);
  431. } else if ($checkState == TalentState::SCND_SUBMIT) {
  432. return $this->fstCheck($request, $talent_info);
  433. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  434. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  435. $companys = array_filter(explode(",", $condition["companyIds"]));
  436. if ($companys) {
  437. if (!in_array($this->user["companyId"], $companys))
  438. return json(["msg" => "你的部门不在并审部门列表"]);
  439. return $this->deptCheck($request, $talent_info, $companys);
  440. } else {
  441. return $this->reCheck($request, $talent_info);
  442. }
  443. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  444. return $this->reCheck($request, $talent_info);
  445. } else {
  446. return json(["msg" => "不在审核范围内,保存失败"]);
  447. }
  448. }
  449. public function submitCheck() {
  450. //公共调度方法
  451. $id = $this->request->param("id");
  452. $talent_info = VerifyApi::getOne($id);
  453. $checkState = $talent_info["checkState"];
  454. if (!$talent_info) {
  455. return json(["msg" => "数据错误"]);
  456. }
  457. if ($checkState == TalentState::FST_SUBMIT) {
  458. return $this->baseSubmitCheck($talent_info);
  459. } else if ($checkState == TalentState::SCND_SUBMIT) {
  460. return $this->fstSubmitCheck($talent_info);
  461. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  462. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  463. $companys = array_filter(explode(",", $condition["companyIds"]));
  464. if ($companys) {
  465. if (!in_array($this->user["companyId"], $companys))
  466. return json(["msg" => "你的部门不在并审部门列表"]);
  467. return $this->deptSubmitCheck($talent_info, $companys);
  468. } else {
  469. return $this->reSubmitCheck($talent_info);
  470. }
  471. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  472. return $this->reSubmitCheck($talent_info);
  473. } else {
  474. return json(["msg" => "不在审核范围内,审核失败"]);
  475. }
  476. }
  477. public function validateIsCheck() {
  478. $params = $this->request->param();
  479. $id = $params["id"];
  480. $talent_info = VerifyApi::getOne($id);
  481. if ($talent_info) {
  482. $checkState = $talent_info["checkState"];
  483. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  484. $process = 0;
  485. if (in_array($checkState, [2, 6, 7, 9])) {
  486. switch ($checkState) {
  487. case 2:
  488. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  489. $fields = DictApi::getTalentFields(1);
  490. $field_tmp = [];
  491. foreach ($fields as $key => $field) {
  492. $field_tmp[] = ["key" => $key, "value" => $field];
  493. }
  494. $where[] = ["project", "=", 1];
  495. $where[] = ["step", "=", 1];
  496. $where[] = ["active", "=", 1];
  497. $where[] = ["type", "=", $enterprise["type"]];
  498. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  499. $process = 1;
  500. break;
  501. case 6:
  502. $process = 2;
  503. break;
  504. case 7:
  505. $fields = DictApi::getTalentFields(3);
  506. $process = 3;
  507. break;
  508. case 9:
  509. $fields = DictApi::getTalentFields(3);
  510. $process = 4;
  511. break;
  512. }
  513. if ($checkState != 2) {
  514. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  515. $fields = DictApi::getTalentFields(2);
  516. $field_tmp = [];
  517. foreach ($fields as $key => $field) {
  518. $field_tmp[] = ["key" => $key, "value" => $field];
  519. }
  520. $where = [];
  521. $whr = [];
  522. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  523. $where[] = ["project", "=", 1];
  524. $where[] = ["step", "=", 2];
  525. $where[] = ["active", "=", 1];
  526. $where[] = ["type", "=", $enterprise["type"]];
  527. if ($condition && $condition["bindFileTypes"]) {
  528. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  529. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  530. } else {
  531. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  532. }
  533. }
  534. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  535. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  536. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  537. } else {
  538. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  539. }
  540. }
  541. }
  542. public function commonExport() {
  543. $params = $this->request->param();
  544. $fields = $params["export"];
  545. if (!$fields)
  546. return json(["msg" => "请选择要导出的数据"]);
  547. $names = DictApi::getTalentFields(3);
  548. $names["industryFieldNew"] = "产业领域";
  549. $names["enterpriseName"] = "单位名称";
  550. $names["enterpriseTag"] = "单位标签";
  551. $names["street"] = "所属镇街";
  552. $names["checkState"] = "审核状态";
  553. $list = VerifyApi::getExportDatas($fields);
  554. foreach ($fields as $field) {
  555. $columns[] = $names[$field];
  556. }
  557. $datas = [];
  558. for ($i = 0; $i < count($list); $i++) {
  559. $data = [];
  560. for ($n = 0; $n < count($fields); $n++) {
  561. $data[] = $list[$i][$fields[$n]];
  562. }
  563. $datas[] = $data;
  564. }
  565. if ($datas) {
  566. export($columns, $datas);
  567. }
  568. }
  569. }