소스 검색

重写合同到期人员导出名单

zmw 1 년 전
부모
커밋
4557696572
1개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 14 2
      app/enterprise/controller/TalentBasicChange.php

+ 14 - 2
app/enterprise/controller/TalentBasicChange.php

@@ -363,11 +363,14 @@ class TalentBasicChange extends EnterpriseController {
         $where[] = ["ti.delete", "=", 0];
         $where[] = ["ti.active", "=", 1];
         $where[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
+        if (session("user")["usertype"] == 2) {
+            $where[] = ["ti.enterprise_id", "=", session("user")["uid"]];
+        }
         $now = date("Y-m-d",time());
         $count = Talent::alias("ti")->field("ti.id,ti.name,ti.card_number,ti.labor_contract_rangetime")->leftJoin("un_talent_basic_change tbc","ti.id = tbc.talentId")->where($where)->whereRaw("trim(SUBSTRING_INDEX(ti.labor_contract_rangetime,'-',-3)) < '{$now}' and tbc.id is null")->count();
+
         if($count > 0){
             $columns = [
-                'id',
                 '姓名',
                 '证件号码',
                 '劳动合同时间'
@@ -375,7 +378,16 @@ class TalentBasicChange extends EnterpriseController {
             $setting = [];
             $setting["freeze"] = "A2";
             $setting["filter"] = sprintf("A1:%s1", getExcelColumnByIndex(count($columns) - 1));
-            $datas = Talent::alias("ti")->field("ti.id,ti.name,ti.card_number,ti.labor_contract_rangetime")->leftJoin("un_talent_basic_change tbc","ti.id = tbc.talentId")->where($where)->whereRaw("trim(SUBSTRING_INDEX(ti.labor_contract_rangetime,'-',-3)) < '{$now}' and tbc.id is null")->select()->toArray();
+            $lists = Talent::alias("ti")->field("ti.id,ti.name,ti.card_number,ti.labor_contract_rangetime")->leftJoin("un_talent_basic_change tbc","ti.id = tbc.talentId")->where($where)->whereRaw("trim(SUBSTRING_INDEX(ti.labor_contract_rangetime,'-',-3)) < '{$now}' and tbc.id is null")->select()->toArray();
+            $datas = [];
+            foreach ($lists as $v){
+                $item = [
+                    $v['name'],
+                    $v['card_number'],
+                    $v['labor_contract_rangetime']
+                ];
+                array_push($datas,$item);
+            }
             export($columns, $datas, "合同到期列表导出", $setting);
         }else{
             echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";