|
@@ -884,30 +884,47 @@ class PhOrders extends Auth
|
|
$id = input('id',0);
|
|
$id = input('id',0);
|
|
$orders = Db::name('ph_orders')
|
|
$orders = Db::name('ph_orders')
|
|
->where('id',$id)
|
|
->where('id',$id)
|
|
- ->field('sign,sn')
|
|
|
|
|
|
+ ->field('sign,sn,name,gender,age,contact,phone')
|
|
->find();
|
|
->find();
|
|
$todos = Db::name('ph_todo')
|
|
$todos = Db::name('ph_todo')
|
|
->where('order_id',$id)
|
|
->where('order_id',$id)
|
|
->whereIn('status',[1,2])
|
|
->whereIn('status',[1,2])
|
|
- ->column('sign');
|
|
|
|
|
|
+ ->field('sign,worker_id')
|
|
|
|
+ ->select();
|
|
$protocol = Db::name("ph_protocol")->where('org_id',$this->orgId)->value('content');
|
|
$protocol = Db::name("ph_protocol")->where('org_id',$this->orgId)->value('content');
|
|
$phpWord = new PhpWord();
|
|
$phpWord = new PhpWord();
|
|
$section = $phpWord->addSection();
|
|
$section = $phpWord->addSection();
|
|
Html::addHtml($section, $protocol);
|
|
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']){
|
|
if ($orders['sign']){
|
|
$section->addImage($orders['sign'], ['width' => 120, 'height' => 110]);
|
|
$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();
|
|
$table = $section->addTable();
|
|
$length = count($todos) > 4 ? ceil(count($todos) / 4) : 1;
|
|
$length = count($todos) > 4 ? ceil(count($todos) / 4) : 1;
|
|
for ($i = 0; $i < $length; $i++) {
|
|
for ($i = 0; $i < $length; $i++) {
|
|
$table->addRow(1, 4); // 添加1行4列
|
|
$table->addRow(1, 4); // 添加1行4列
|
|
$imgs = array_slice($todos, $i * 4, 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 = $table->addCell(1000); // 单元格宽度,单位为EMU
|
|
- $cell->addImage($v2, [
|
|
|
|
|
|
+ $cell->addImage($v2['sign'], [
|
|
'width' => 120,
|
|
'width' => 120,
|
|
'height' => 110
|
|
'height' => 110
|
|
]);
|
|
]);
|
|
@@ -922,5 +939,24 @@ class PhOrders extends Auth
|
|
$objWriter->save('php://output');
|
|
$objWriter->save('php://output');
|
|
exit;
|
|
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;
|
|
|
|
+ }
|
|
}
|
|
}
|