123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <?php
- namespace app\enterprise\controller;
- use app\enterprise\common\EnterpriseController;
- use app\enterprise\api\TalentApi;
- use app\enterprise\model\Talent as TalentModel;
- use think\facade\Db;
- /**
- * Description of Talent
- *
- * @author sgq
- */
- class Talent extends EnterpriseController {
- public function index() {
- return view();
- }
- public function list() {
- $res = TalentApi::getList($this->request);
- return json($res);
- }
- public function add() {
- $request = $this->request;
- $param = $request->param();
- $id = isset($param["id"]) ? $param["id"] : 0;
- if ($request->isPost()) {
- if ($id) {
- if (!$info = self::chkIsOwner($id, $this->user["uid"]))
- return json(["msg" => "没有对应的人才认定申报信息"]);
- $data["id"] = $id;
- }
- $data["enterprise_id"] = $this->user["uid"];
- $data["talent_type"] = $param["talent_type"];
- $data["tax_insurance_month"] = $param["tax_insurance_month"];
- $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
- $data["name"] = $param["name"];
- $data["card_type"] = $param["card_type"];
- $data["card_number"] = $param["card_number"];
- $data["sex"] = $param["sex"];
- $data["birthday"] = $param["birthday"];
- $data["nationality"] = $param["nationality"];
- $data["province"] = $param["province"];
- $data["city"] = $param["city"];
- $data["county"] = $param["county"];
- $data["nation"] = $param["nation"];
- $data["politics"] = $param["politics"];
- $headimg = $request->file("photo");
- $upload = new \app\common\api\UploadApi();
- $headimgurl = $upload->uploadOne($headimg, "talent/photo");
- $data["headimgurl"] = $headimgurl;
- TalentModel::save($data);
- }
- $where = [];
- $info = [];
- $enterprise_info = \app\admin\model\Enterprise::find($this->user["uid"]);
- if (isset($param["id"])) {
- $where[] = ["id", "=", $param["id"]];
- $where[] = ["enterprise_id", "=", $this->user["uid"]];
- $info = TalentModel::where($where)->findOrEmpty();
- }
- $checkState = 0;
- $info["enterprise"] = $enterprise_info;
- return view("first", ["year" => date("Y"), "checkState" => $checkState, "row" => $info]);
- }
- public function edit() {
- $param = $this->request->param();
- if (!isset($param["id"]))
- return json(["msg" => "错误的打开方式"]);
- $info = Db::table("new_talent_info")->findOrEmpty($param["id"]);
- if ($info["checkState"] == 0) {
- return redirect("/enterprise/talent/add/id/" . $info["id"]);
- }
- $enterprise_info = \app\admin\model\Enterprise::find($info["enterprise_id"]);
- $info["enterprise"] = $enterprise_info;
- return view("", ["year" => date("Y"), "checkState" => $checkState, "enterprise" => $enterprise_info]);
- }
- public function submit() {
- $id = $this->request->param("id");
- if (!$info = self::chkIsOwner($id, $this->user["uid"]))
- return json(["msg" => "没有对应的人才认定申报信息"]);
- switch ($info["checkState"]) {
- case 0:
- $no_empty = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics"];
- $return = [];
- foreach ($no_empty as $key) {
- if (!$info[$key]) {
- $return[] = sprintf("请填写“%s”", self::dict($key));
- }
- }
- if (in_array($info["talent_type"], [1, 2]) && !$info["tax_insurance_month"])
- $return[] = sprintf("请填写“%s”", self::dict("tax_insurance_month"));
- if ($info["talent_type"] == 3 && !$info["labor_contract_rangetime"])
- $return[] = sprintf("请填写“%s”", self::dict("labor_contract_rangetime"));
- if (count($return) > 0)
- return json(["msg" => implode("<br>", $return)]);
- $where = [];
- $where[] = ["step", "=", 1];
- $where[] = ["project", "=", 1];
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["must", "=", 1];
- $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
- $ft_ids = array_column($filetypes, "id");
- $whr = [];
- $whr[] = ["typeId", "in", $ft_ids];
- $whr[] = ["mainId", "=", $info["id"]];
- $upload_type_counts = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->count();
- if ($upload_type_counts != $filetypes)
- return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
- break;
- }
- }
- static private function chkIsOwner($id, $uid) {
- $where[] = ["id", "=", $id];
- $where[] = ["enterprise_id", "=", $uid];
- $info = TalentModel::where($where)->findOrEmpty()->toArray();
- return $info;
- }
- static private function dict($key) {
- $value = "";
- switch ($key) {
- case "talent_type":
- $value = "人才类型";
- break;
- case "tax_insurance_month":
- $value = "在我市缴交社会保险或个人所得税月份";
- break;
- case "labor_contract_rangetime":
- $value = "劳动合同起止时间";
- break;
- case "name":
- $value = "姓名";
- break;
- case "card_type":
- $value = "证件类型";
- break;
- case "card_number":
- $value = "证件号码";
- break;
- case "sex":
- $value = "性别";
- break;
- case "birthday":
- $value = "出生日期";
- break;
- case "nationality":
- $value = "国籍/地区";
- break;
- case "province":
- $value = "籍贯省";
- break;
- case "city":
- $value = "籍贯市";
- break;
- case "county":
- $value = "籍贯县";
- break;
- case "nation":
- $value = "民族";
- break;
- case "politics":
- $value = "政治面貌";
- break;
- case "talent_arrange":
- $value = "";
- break;
- case "talent_condition":
- $value = "";
- break;
- case "highest_degree":
- $value = "";
- break;
- case "graduate_school":
- $value = "";
- break;
- case "major":
- $value = "";
- break;
- case "professional":
- $value = "";
- break;
- case "bank":
- $value = "";
- break;
- case "bank_number":
- $value = "";
- break;
- case "bank_branch_name":
- $value = "";
- break;
- case "bank_account":
- $value = "";
- break;
- case "study_abroad":
- $value = "";
- break;
- case "abroad_school":
- $value = "";
- break;
- case "abroad_major":
- $value = "";
- break;
- case "phone":
- $value = "";
- break;
- case "email":
- $value = "";
- break;
- case "apply_year":
- $value = "";
- break;
- case "import_way":
- $value = "";
- break;
- case "fst_work_time":
- $value = "";
- break;
- case "cur_entry_time":
- $value = "";
- break;
- case "position":
- $value = "";
- break;
- case "source":
- $value = "";
- break;
- case "fujian_highcert_pubtime":
- $value = "";
- break;
- case "fujian_highcert_exptime":
- $value = "";
- break;
- case "quanzhou_highcert_pubtime":
- $value = "";
- break;
- case "quanzhou_highcert_exptime":
- $value = "";
- break;
- }
- return $value;
- }
- }
|