From 92e9f241b75cd426f2fe5e5dbd09fbbe228bad73 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 26 Dec 2023 17:53:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E7=B4=84=E7=B0=BD=E5=9B=9E=E5=AF=AB?= =?UTF-8?q?=E5=85=A5t8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/cont/sign_list.php | 6 +- wms/contract-repair/contract-download.php | 55 +++++----- wms/contract-repair/js/alpine.js | 35 +++++- wms/contract/api/postContractData.php | 124 +++++++++++++++++++++- wms/contract/api/testT8API.php | 38 +++++++ wms/contract/conn.php | 85 ++++++++------- wms/contract/connt8.php | 15 +++ wms/header.php | 2 +- 8 files changed, 282 insertions(+), 78 deletions(-) create mode 100644 wms/contract/api/testT8API.php create mode 100644 wms/contract/connt8.php diff --git a/wms/cont/sign_list.php b/wms/cont/sign_list.php index feba52e0..9b111a85 100644 --- a/wms/cont/sign_list.php +++ b/wms/cont/sign_list.php @@ -75,8 +75,10 @@ form_key, status, f_return_content('payment_kind',payment_kind ) payment_kind FROM $table where 1=1 $where ORDER BY vol_no"; -// echo $sql; $data = mysqli_query($link, $sql); +echo '
';
+print_r($sql);
+echo '
'; ?> @@ -225,7 +227,7 @@ if ($data) : $oneself = ($row['salesman'] == $user_id) ? 1 : 0; ?> - + diff --git a/wms/contract-repair/contract-download.php b/wms/contract-repair/contract-download.php index f4c132fd..2d0015ba 100644 --- a/wms/contract-repair/contract-download.php +++ b/wms/contract-repair/contract-download.php @@ -70,32 +70,27 @@ if (!empty($_GET['apply_key'])) { $noteArr = array(1, 1, 1, 1, 1); $qty = $contract_maintance[0]['num']; // echo $qty; - // foreach ($contract_maintance as $idx => $amount) { - // $isset = false; - // if ($amount['payment_kind'] == 5 || $amount['payment_kind'] == 6) { - // if ($amount['pay_scale'] >= 0) { - // $install_total_price = $install_total_price + $amount['pay_amount']; - // $installArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; - // } - // } - // if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) { - // if ($amount['pay_scale'] > 0) { - // $buy_total_price = $buy_total_price + $amount['pay_amount']; - // foreach ($buyArr as $buy) { - // if ($buy['installment'] == $amount['pay_kind']) { - // $isset = true; - // } - // } - // if (!$isset) { { - // $buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; - // } - // if ($amount['pay_kind'] == 2) { - // $buyNo2Pay = true; - // } - // } - // } - // } - // } + foreach ($contract_maintance as $idx => $amount) { + $isset = false; + + if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) { + if ($amount['pay_scale'] > 0) { + $buy_total_price = $buy_total_price + $amount['pay_amount']; + foreach ($buyArr as $buy) { + if ($buy['installment'] == $amount['pay_kind']) { + $isset = true; + } + } + // if (!$isset) { { + // $buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; + // } + // if ($amount['pay_kind'] == 2) { + // $buyNo2Pay = true; + // } + // } + } + } + } $sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL"; $sql_str = "SELECT contract_apply_files.*, contract_new_apply.id as apply_id FROM contract_apply_files LEFT JOIN contract_new_apply ON contract_apply_files.contract_id = contract_new_apply.id WHERE contract_new_apply.mid = :mid AND contract_apply_files.deleted_at IS NULL"; $stmt = $conn->prepare($sql_str); @@ -119,7 +114,7 @@ if (!empty($_GET['apply_key'])) {
@@ -453,11 +448,11 @@ if (!empty($_GET['apply_key'])) { const totalInstallPrice = ; const totalBuyPrice = ; // const secondPayDeadline = ; - // const buyfill1 = ; + const buyfill1 = ; // const installfill1 = ""; // const installfill2 = ""; - // const buyArr = [...]; - // const installArr = [...]; + const buyArr = [...]; + const installArr = [...]; let install_pay_text = '付款方式:
'; let buy_pay_text = '' const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七'] diff --git a/wms/contract-repair/js/alpine.js b/wms/contract-repair/js/alpine.js index 06d5dc7b..8ab51dfd 100644 --- a/wms/contract-repair/js/alpine.js +++ b/wms/contract-repair/js/alpine.js @@ -6,6 +6,8 @@ const contractDownload = () => { this.buystandarData = this.deepClone(this.buydata); this.buyonstandardViewData = this.deepClone(this.buydata); }, + buyfill1: buyfill1, + css: `table { background - color: #fff; border: none; margin - top: 30px; font - family: '標楷體'; width: 600px; } table tr: nth - child(even), table tr: nth - child(odd) { background - color: #fff; } table tr { font - size: 12pt; width: 100 %; } table tr h2 { font - size: 18pt; } table tr td { width: 100 %; height: 100 %; line - height: 2; display: flex; } table tr td.center { display: flex; justify - content: center; align - items: center; } table tr td.list { width: 100 %; height: 100 %; white - space: nowrap; display: flex; } table tr td.list span { width: 60px; min - height: 100 %; display: block; } table tr td.list > p { display: block; text - align: justify; } table tr td.list div { max - width: calc(100 % - 60px); white - space: normal; } table tr td.list div.text - justify { display: flex; width: 100 %; justify - content: space - between; } table tr.date td > div { width: 100 %; text - align: right; } table tr.date td > div.text - justify { display: flex; justify - content: space - between; } table td, table th { padding: 8px; }`, data: { illustrate: { @@ -45,6 +47,22 @@ const contractDownload = () => { ] } }, + deepClone: function (obj) { + let clone = Array.isArray(obj) ? [] : {}; + for (let key in obj) { + if (obj.hasOwnProperty(key)) { + if (typeof obj[key] === 'object' && obj[key] !== null) { + clone[key] = this.deepClone(obj[key]); + if (clone[key].text != undefined) { + + } else { + clone[key] = obj[key]; + } + } + } + } + return clone; + }, buydata: { }, @@ -129,7 +147,22 @@ const contractDownload = () => { return; } - } + }, + isBuyShow: true, + sendBuyInputFn() { + if (this.buyfilt1 == '') { + alert('請輸入交貨期限'); + return; + } + if (this.buyfilt1 < 1) { + alert('交貨日期不得低於1日'); + return; + } + if (buyArr[1].installment == 2) { + + } + }, + isBuyInputIng: true, } }; diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 349557ee..8065babd 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,8 +1,10 @@ makeBFacilityNo("T", $facility_arr, (int)$num); + // 電梯做番號 + $facilityno = $createFacilityNo->makeBFacilityNo("B", $facility_arr, (int)$num); echo json_encode($facilityno); echo '-------'; $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; @@ -307,6 +310,9 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c header('Content-Type: application/json'); $jsonData = json_encode($files); + + T8insert($_POST, $facilityno); + $conn->commit(); } catch (PDOException $e) { $conn->rollback(); @@ -314,4 +320,120 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo $e->getMessage(); die('Error!:' . $e->getMessage()); } +}; + +function T8insert($data, $facilityno) +{ + require_once("../connt8.php"); + $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 + $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 + $customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱 + $phone = !empty($data['phone']) ? $data['phone'] : null; //客戶電話 + $vat = !empty($data['vat']) ? $data['vat'] : null; //統編 + $email = !empty($data['email']) ? $data['email'] : null; + $salesman = !empty($data['salesman']) ? $data['salesman'] : null; // 銷售人員 + $partyA = !empty($data['partyA']) ? $data['partyA'] : null; //客戶名稱 / 業務聯絡人 + $partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址 + $contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : null; + $contract_end_date = !empty($data['contract_end_date']) ? $data['contract_end_date'] : null; + $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量 + $elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯 + + if ($elevators['maintainance'] == 'A') { + $elevators['maintainance'] = 'C3'; + } else if ($elevators['maintainance'] == 'B') { + $elevators['maintainance'] = 'C4'; + } else if ($elevators['maintainance'] == 'C') { + $elevators['maintainance'] = 'C5'; + } + + + $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; + $stmt = $conn->prepare($sql); + $stmt->bindParama(':BizPartnerId', $contractno); + $stmt->execute(); + $result = $stmt->fetchAll(PDO::FETCH_ASSOC); + $date = date('Y-m-sH-s-i'); + $createTime = str_replace("-", '', $date); + $beginDate = str_replace("-", '', $contract_begin_date); + $endDate = str_replace("-", '', $contract_end_date); + if (empty($result)) { + // 若 客戶資料為空,新增一筆到 comCustomer + // 新增客戶資料 + $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)"; + $stmt = $connT8->prepare($sql); + + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':InvoiceAddress', $address); + $stmt->bindParam(':CreateTime', $createTime); + + $stmt->execute(); + + + $sql = "INSERT INTO comBusinessPartner(BizPartnerId,BizPartnerName,WorkTelNo,TaxNo,EnterpriseName,ContractAddress,EMail,CreatorId,CreateTime)VALUES(:BizPartnerId,:BizPartnerName,:WorkTelNo,:TaxNo,:EnterpriseName,:ContractAddress,:EMail,:CreatorId,:CreateTime)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':BizPartnerName', $partyA); + $stmt->bindParam(':WorkTelNo', $phone); + $stmt->bindParam(':TaxNo', $vat); + $stmt->bindParam(':EnterpriseName', $customer); //企業名稱 + $stmt->bindParam(':ContractAddress', $partyAaddress); + $stmt->bindParam(':EMail', $email); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + + $stmt->execute(); + } else { + // 若客戶資料不為空,更新該客戶資訊。 + $sql = "UPDATE comCustomer SET + PersonId=:PersonId, + InvoiceAddress=:InvoiceAddress, + LastOperatorId=:LastOperatorId, + LastOperateTime=:LastOperateTime, + WHERE BizPartnerId=:BizPartnerId + "; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':InvoiceAddress', $address); + $stmt->bindParam(':LastOperatorId', $user_id); + $stmt->bindParam(':LastOperateTime', $createTime); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); + + + $sql = "UPDATE comBusinessPartner SET + BizPartnerName=:BizPartnerName, + WorkTelNo=:WorkTelNo, + TaxNo=:TaxNo, + EnterpriseName=:EnterpriseName, + ContractAddress=:ContractAddress, + EMail=:EMail, + LastOperatorId=:LastOperatorId, + LastOperateTime=:LastOperateTime + "; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerName', $partyA); + $stmt->bindParam(':WorkTelNo', $phone); + $stmt->bindParam(':TaxNo', $vat); + $stmt->bindParam(':EnterpriseName', $customer); + $stmt->bindParam(':ContractAddress', $partyAaddress); + $stmt->bindParam(':EMail', $email); + $stmt->bindParam(':LastOperatorId', $user_id); + $stmt->bindParam(':LastOperateTime', $createTime); + $stmt->execute(); + } + + //新增於 comProject + $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,ValidityToDate,:CreateTime,:CreatorId,1)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':ProjectId', $contractno); + $stmt->bindParam(':ProjectName', $customer); + $stmt->bindParam(':TypeId', $elevators['maintainance']); + $stmt->bindParam(':ValidityFromDate', $beginDate); + $stmt->bindParam(':ValidityToDate', $endDate); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->execute(); } diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php new file mode 100644 index 00000000..6207df0e --- /dev/null +++ b/wms/contract/api/testT8API.php @@ -0,0 +1,38 @@ +prepare($sql); + // $stmt->execute(); + + $sql = "UPDATE comBusinessPartner SET WorkTelNo = '' WHERE BizPartnerId='M0225202301'"; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + + echo 'Success'; +} catch (PDOException $e) { + echo ''; +} +// $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; +// $stmt = $conn->prepare($sql); +// $stmt->bindParam(':BizPartnerId', $contractno); +// $stmt->execute(); +// $result = $stmt->fetch(PDO::FETCH_NUM); +// $arr = array(); +// if (!empty($result)) { +// foreach ($result as $key => $value) { +// $arr[$key] = $value; +// } +// } +// $count = empty($result) == '' ? 0 : COUNT($result); +// echo '
';
+// print_r($result);
+// echo '
'; +// echo '
'; + +// $createTime = Date('Y-m-sH-i-s'); + +// echo str_replace('-', '', $createTime); diff --git a/wms/contract/conn.php b/wms/contract/conn.php index b92e67e5..78007657 100644 --- a/wms/contract/conn.php +++ b/wms/contract/conn.php @@ -1,43 +1,42 @@ -errorInfo()的形式獲取錯誤資訊 - //PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 - //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 - //設定主動以警告的形式報錯 - $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); - //如果連接錯誤,將抛出一個PDOException異常對象 -} -catch ( PDOException $e ){ - //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 - die("ERROR!!!: ". $e->getMessage()); -} - -//$conn = null; //關閉資料庫的連線 \ No newline at end of file +errorInfo()的形式獲取錯誤資訊 + //PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 + //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 + //設定主動以警告的形式報錯 + $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + //如果連接錯誤,將抛出一個PDOException異常對象 +} catch (PDOException $e) { + //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 + die("ERROR!!!: " . $e->getMessage()); +} + +//$conn = null; //關閉資料庫的連線 diff --git a/wms/contract/connt8.php b/wms/contract/connt8.php new file mode 100644 index 00000000..59f2b247 --- /dev/null +++ b/wms/contract/connt8.php @@ -0,0 +1,15 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } +} catch (PDOException $e) { + // echo "fail"; + // echo $e->getMessage(); + die("ERROR!!!: " . $e->getMessage()); +} diff --git a/wms/header.php b/wms/header.php index 3347bb17..83c6bfa3 100644 --- a/wms/header.php +++ b/wms/header.php @@ -34,7 +34,7 @@ if (isset($_REQUEST["function_name"])) { * 連線T8 MSSQL */ try { - $conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "ztPmPP!HRoV6SL3E"); + $conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "M0225", "IFFBU1E="); if ($conn) { $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }