zgg 1 ngày trước cách đây
mục cha
commit
4eb9510428
2 tập tin đã thay đổi với 64 bổ sung7 xóa
  1. 43 7
      application/admin/controller/PhOrders.php
  2. 21 0
      application/common.php

+ 43 - 7
application/admin/controller/PhOrders.php

@@ -884,30 +884,47 @@ class PhOrders extends Auth
         $id = input('id',0);
         $orders = Db::name('ph_orders')
             ->where('id',$id)
-            ->field('sign,sn')
+            ->field('sign,sn,name,gender,age,contact,phone')
             ->find();
         $todos = Db::name('ph_todo')
             ->where('order_id',$id)
             ->whereIn('status',[1,2])
-            ->column('sign');
+            ->field('sign,worker_id')
+            ->select();
         $protocol = Db::name("ph_protocol")->where('org_id',$this->orgId)->value('content');
         $phpWord = new PhpWord();
         $section = $phpWord->addSection();
         Html::addHtml($section, $protocol);
-        $section->addText('客户签名:', ['name' => 'Arial', 'size' => 26, 'bold' => true]);
+        $style = ['name' => '宋体', 'size' => 10.5];
+        $gender = $orders['gender'] == 1 ? '男' : '女';
+        $section->addText('甲方姓名:'.$orders['name'].'  性别:'.$gender.'  年龄:'.$orders['age'].'  联系人:'.$orders['contact'].'  电话:'.$orders['phone'],$style);
+        foreach ($todos as $todo){
+            $worker = Db::name('worker')
+                ->alias('a')
+                ->join('user b','a.user_id = b.id')
+                ->where('a.id',$todo['worker_id'])
+                ->field('a.gender,a.card,b.real_name,b.mobile')
+                ->find();
+            $gender = $worker['gender'] == 1 ? '男' : '女';
+            $age = $this->getAgeByIdCard($worker['card']);
+            $section->addText('乙方姓名:'.$worker['real_name'].'  性别:'.$gender.'  年龄:'.$age.'  电话:'.$worker['mobile'],$style);
+        }
+        $section->addText('丙方:'.getCompany($this->orgId),$style);
+        $section->addTextBreak(1);
+        $section->addText('客户签名:', ['name' => '宋体', 'size' => 26, 'bold' => true]);
         if ($orders['sign']){
             $section->addImage($orders['sign'], ['width' => 120, 'height' => 110]);
         }
-        $section->addText('护工签名:', ['name' => 'Arial', 'size' => 26, 'bold' => true]);
+        $section->addText('护工签名:', ['name' => '宋体', 'size' => 26, 'bold' => true]);
         $table = $section->addTable();
         $length = count($todos) > 4 ? ceil(count($todos) / 4) : 1;
         for ($i = 0; $i < $length; $i++) {
             $table->addRow(1, 4); // 添加1行4列
             $imgs = array_slice($todos, $i * 4, 4);
-            foreach ($imgs as $index => $v2) {
-                if ($v2 != '') {
+            foreach ($imgs as $v2) {
+                if ($v2['sign'] != '') {
                     $cell = $table->addCell(1000); // 单元格宽度,单位为EMU
-                    $cell->addImage($v2, [
+                    $cell->addImage($v2['sign'], [
                         'width' => 120,
                         'height' => 110
                     ]);
@@ -922,5 +939,24 @@ class PhOrders extends Auth
         $objWriter->save('php://output');
         exit;
     }
+    public function getAgeByIdCard($idCard) {
+        if (strlen($idCard) != 18) {
+            return '身份证号错误';
+        }
+
+        // 提取出生年月日
+        $birthDate = substr($idCard, 6, 8);
+        $birthYear = substr($birthDate, 0, 4);
+        $birthMonth = substr($birthDate, 4, 2);
+        $birthDay = substr($birthDate, 6, 2);
 
+        // 创建日期对象
+        $birthday = new \DateTime("$birthYear-$birthMonth-$birthDay");
+        $today = new \DateTime();
+
+        // 计算年龄
+        $age = $today->diff($birthday)->y;
+
+        return $age;
+    }
 }

+ 21 - 0
application/common.php

@@ -1715,3 +1715,24 @@ function getPhNotify($orgId,$url,$type)
     }
     return $url.$notify;
 }
+
+/*
+ * 根据orgId获取项目公司
+ * $orgId
+ * */
+function getCompany($orgId)
+{
+    switch ($orgId){
+        case 115:
+        case 116:
+            $company = '湖南吉立物业管理有限公司张家界永定分公司';
+            break;
+        case 100:
+            $company = '湖南吉立物业管理有限公司';
+            break;
+        default:
+            $company = '湖南吉立物业管理有限公司萍乡分公司';
+            break;
+    }
+    return $company;
+}