From f6b04618b5c0fe1a754f7bff02349ad84038fcb9 Mon Sep 17 00:00:00 2001 From: 10994015 Date: Mon, 6 Nov 2023 17:51:19 +0800 Subject: [PATCH] 1106 --- wms/contract/api/getComboNo.php | 29 ++++ ...createFacilityNo.php => getFacilityNo.php} | 0 wms/contract/api/postContractData.php | 139 ++++++++++-------- wms/contract/contract-input.php | 14 +- 4 files changed, 117 insertions(+), 65 deletions(-) create mode 100644 wms/contract/api/getComboNo.php rename wms/contract/api/{createFacilityNo.php => getFacilityNo.php} (100%) diff --git a/wms/contract/api/getComboNo.php b/wms/contract/api/getComboNo.php new file mode 100644 index 00000000..5c0bb380 --- /dev/null +++ b/wms/contract/api/getComboNo.php @@ -0,0 +1,29 @@ +'BW002', + 'month'=>'EM002', + 'quarter'=>'EQ002', + 'half'=>'HY002', + 'year'=>'EY002' + ]; + public $bwarr = [ + 'week','month','week','month','week','quarter', + 'week','month','week','month','week','half', + 'week','month','week','month','week','quarter', + 'week','month','week','month','week','year' + ]; + public $emarr = [ + 'month','month','quarter','month','month','half', + 'month','month','quarter','month','month','year' + ]; + public $combo; + public $startdate; + public $enddate; + public function __construct($combo, $startdate, $enddate){ + } + public function getComboNo(){ + + } +} \ No newline at end of file diff --git a/wms/contract/api/createFacilityNo.php b/wms/contract/api/getFacilityNo.php similarity index 100% rename from wms/contract/api/createFacilityNo.php rename to wms/contract/api/getFacilityNo.php diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index a499cecd..fa67c1be 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,45 +1,46 @@ prepare($sql_str); @@ -118,10 +117,9 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") { $stmt->bindParam(':accountid',$mworker); $stmt->execute(); $worker = $stmt->fetch(PDO::FETCH_ASSOC); - + + $facilityno = $createFacilityNo->makeBFacilityNo("T", $dailyNecessities[$spec], (int)$num); $define = "B"; - $facilityno = $createFacilityNo->makeTFacilityNo("T", $dailyNecessities[$spec], $num)[0]; - echo $facilityno; $customerid = $vat; $opentype = $opendoor; $repairtype = "A"; @@ -129,35 +127,52 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") { $maintainance = "E"; $repairerid = $mworker; $repairername = $worker['name']; - $creater = $user_id; - $create_at = date("Y-m-d H:i:s"); - $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) - VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; + + foreach($facilityno as $fno){ + + $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) + VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':contractno' ,$contractno); + $stmt -> bindParam(':define' ,$define); + $stmt -> bindParam(':facilityno' ,$fno); + $stmt -> bindParam(':latitude' ,$latitude); + $stmt -> bindParam(':longitude' ,$longitude); + $stmt -> bindParam(':customerid' ,$customerid); + $stmt -> bindParam(':weight' ,$weight); + $stmt -> bindParam(':numberofpassenger' ,$numberofpassenger); + $stmt -> bindParam(':numberofstop' ,$numberofstop); + $stmt -> bindParam(':numberoffloor' ,$numberoffloor); + $stmt -> bindParam(':opentype' ,$opentype); + $stmt -> bindParam(':speed' ,$speed); + $stmt -> bindParam(':repairtype' ,$repairtype); + $stmt -> bindParam(':maintainance' ,$maintainance); + $stmt -> bindParam(':facility_kind' ,$facility_kind); + $stmt -> bindParam(':address' ,$address); + $stmt -> bindParam(':repairerid' ,$repairerid); + $stmt -> bindParam(':repairername' ,$repairername); + $stmt -> bindParam(':creater' ,$creater); + $stmt -> bindParam(':create_at' ,$create_at); + $stmt -> bindParam(':area' ,$area); + $stmt -> bindParam(':takecertificatedate' ,$takecertificatedate); + $stmt -> bindParam(':licensedate' ,$licensedate); + + $result = $stmt -> execute(); + } + + //create schedule table + $comboMo = new CreateComboNo(); + + $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; $stmt = $conn -> prepare($sql_str); $stmt -> bindParam(':contractno' ,$contractno); - $stmt -> bindParam(':define' ,$define); $stmt -> bindParam(':facilityno' ,$facilityno); - $stmt -> bindParam(':latitude' ,$latitude); - $stmt -> bindParam(':longitude' ,$longitude); - $stmt -> bindParam(':customerid' ,$customerid); - $stmt -> bindParam(':weight' ,$weight); - $stmt -> bindParam(':numberofpassenger' ,$numberofpassenger); - $stmt -> bindParam(':numberofstop' ,$numberofstop); - $stmt -> bindParam(':numberoffloor' ,$numberoffloor); - $stmt -> bindParam(':opentype' ,$opentype); - $stmt -> bindParam(':speed' ,$speed); - $stmt -> bindParam(':repairtype' ,$repairtype); - $stmt -> bindParam(':maintainance' ,$maintainance); - $stmt -> bindParam(':facility_kind' ,$facility_kind); - $stmt -> bindParam(':address' ,$address); + $stmt -> bindParam(':combono' ,$combono); $stmt -> bindParam(':repairerid' ,$repairerid); $stmt -> bindParam(':repairername' ,$repairername); + $stmt -> bindParam(':duedate' ,$duedate); $stmt -> bindParam(':creater' ,$creater); $stmt -> bindParam(':create_at' ,$create_at); - $stmt -> bindParam(':area' ,$area); - $stmt -> bindParam(':takecertificatedate' ,$takecertificatedate); - $stmt -> bindParam(':licensedate' ,$licensedate); - $result = $stmt -> execute(); header('Content-Type: application/json'); diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index e098a317..40945478 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -1,6 +1,7 @@ prepare($sql_str); @@ -13,6 +14,10 @@ $stmt = $conn->prepare($sql_str); $stmt->bindParam(':accounttype',$accounttype); $stmt->execute(); $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); + +$createFacilityNo = new CreateFacilityNo(); +$facilityno = $createFacilityNo->makeTFacilityNo("T", 'X', 5); +print_r($facilityno); ?> @@ -30,7 +35,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); }, cities:[], data:{ - contractno:'', + contractno:'Q23080026', total_price:'', //合約總價 vat:'', //統一編號 mtype:'A', //維修型態 @@ -61,6 +66,8 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); takecertificatedate:'', //交車日、竣檢日 licensedate:'', //許可證有效日期 num:'', //電梯數量 + latitude:'', //緯度 + longitude:'', //經度 }, customize:false, step:1, @@ -198,6 +205,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); form.append('longitude', this.data.longitude); form.append('user_id', ''); form.append('user_name', ''); + form.append('num', this.data.num); // 如果有附件檔案,可以逐一加入 for (var i = 0; i < this.data.files.length; i++) { @@ -336,8 +344,8 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);