From fd89ea5305b6eca86eb2eb97ac3adbf70b7ff5cd Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 11 Dec 2023 09:18:19 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/contract-repair/api/getContractData.php | 66 +- wms/contract-repair/contract-repair-edit.php | 115 +- wms/contract-repair/js/alpine.js | 1379 +++++++++--------- 3 files changed, 786 insertions(+), 774 deletions(-) diff --git a/wms/contract-repair/api/getContractData.php b/wms/contract-repair/api/getContractData.php index 1352cdb1..51085b0a 100644 --- a/wms/contract-repair/api/getContractData.php +++ b/wms/contract-repair/api/getContractData.php @@ -1,7 +1,7 @@ -prepare($sql_str); $stmt->bindParam(':vol_no', $contractno); $stmt->execute(); - $contract= $stmt->fetch(PDO::FETCH_ASSOC); + $contract = $stmt->fetch(PDO::FETCH_ASSOC); - if(empty($contract)){ + if (empty($contract)) { echo false; exit; } @@ -21,41 +21,41 @@ if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contrac $stmt = $conn->prepare($sql_str); $stmt->bindParam(':apply_key', $apply_key); $stmt->execute(); - $elevators= $stmt->fetchAll(PDO::FETCH_ASSOC); + $elevators = $stmt->fetchAll(PDO::FETCH_ASSOC); $count = COUNT($elevators); $contract['elevators'] = $elevators; $contract['num'] = $count; $contractResponse = json_encode($contract); - + // 設定回應標頭為 JSON header('Content-Type: application/json'); - + // 將 JSON 回應返回給客戶端 echo $contractResponse; // echo json_encode($contractResponse); - }catch (PDOException $e ){ - die("ERROR!!!: ". $e->getMessage()); + } catch (PDOException $e) { + die("ERROR!!!: " . $e->getMessage()); } } -if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contracttype']) && $_GET['contracttype']=='m'){ - try{ +if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') { + try { $contractno = $_GET['contractno']; $sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':vol_no', $contractno); $stmt->execute(); - $contract= $stmt->fetch(PDO::FETCH_ASSOC); + $contract = $stmt->fetch(PDO::FETCH_ASSOC); $contractResponse = json_encode($contract); - + // 設定回應標頭為 JSON header('Content-Type: application/json'); - + // 將 JSON 回應返回給客戶端 echo $contractResponse; - }catch (PDOException $e ){ - die("ERROR!!!: ". $e->getMessage()); + } catch (PDOException $e) { + die("ERROR!!!: " . $e->getMessage()); } } ////////////////////////////// @@ -64,19 +64,35 @@ if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contrac //// 製作人:梓誠 /// 時間 : ////////////////////////////// -if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r'){ - try{ +if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') { + try { $contractno = $_GET['contractno']; + $fail_arr = []; + + $sql = "SELECT COUNT(*) AS num FROM pricereview_repair_main WHERE contractno = :contractno"; + $stmt = $conn->prepare($sql); + + $stmt->bindParam(":contractno", $contractno); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $count = $result['num']; + if ($count > 1) { + $fail_arr[] = '合約單號重複,請至契約管理(修理)查看。'; + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + // $contractno = $_GET['contractno']; $sql = "SELECT a.*,b.name,b.accountid FROM pricereview_repair_main AS a LEFT JOIN account AS b ON a.repairerid = b.accountid WHERE a.contractno = :contractno "; $stmt = $conn->prepare($sql); - - $stmt -> bindParam(':contractno',$contractno); + + $stmt->bindParam(':contractno', $contractno); $stmt->execute(); - $contract = $stmt -> fetch(PDO::FETCH_ASSOC); + $contract = $stmt->fetch(PDO::FETCH_ASSOC); $contractResponse = json_encode($contract); // 設定回應標頭為 JSON @@ -84,7 +100,7 @@ if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contrac // 將 JSON 回應給客戶端 echo $contractResponse; - }catch(PDOException $e){ - die("ERROR!!:".$e->getMessage()); + } catch (PDOException $e) { + die("ERROR!!:" . $e->getMessage()); } -} \ No newline at end of file +} diff --git a/wms/contract-repair/contract-repair-edit.php b/wms/contract-repair/contract-repair-edit.php index ff8b124c..29f23282 100644 --- a/wms/contract-repair/contract-repair-edit.php +++ b/wms/contract-repair/contract-repair-edit.php @@ -1,4 +1,4 @@ -prepare($sql_str); $stmt->bindParam(':id', $id); $stmt->execute(); -$contract= $stmt->fetch(PDO::FETCH_ASSOC); +$contract = $stmt->fetch(PDO::FETCH_ASSOC); // echo '
';
 // print_r($contract);
 // echo '
'; @@ -21,13 +21,13 @@ $accounttype = "M"; $sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(":accounttype", $accounttype); -$stmt -> execute(); +$stmt->execute(); $persons = $stmt->fetchAll(PDO::FETCH_ASSOC); -$persons = array_map(function($person){ +$persons = array_map(function ($person) { return [ - 'view'=>$person['accountid'] .'-'. $person['name'], - 'value'=>$person['accountid'], - 'name'=>$person['name'] + 'view' => $person['accountid'] . '-' . $person['name'], + 'value' => $person['accountid'], + 'name' => $person['name'] ]; }, $persons); ?> @@ -39,12 +39,9 @@ $persons = array_map(function($person){ - -
-
+ +
+
@@ -55,8 +52,8 @@ $persons = array_map(function($person){ - - + + - + - +

檢視合約

@@ -69,60 +66,60 @@ $persons = array_map(function($person){
立約人 - -

未填寫

+ +

未填寫

維保人員

未填寫

電梯編號 - +

未填寫

報價單編號 - -

未填寫

+ +

未填寫

工程類別 - -

未填寫

+ +

未填寫

簽訂時間 - -

未填寫

-
+ +

未填寫

+
發票抬頭 - +

未填寫

統一編號 - +

未填寫

工程地址 - -

未填寫

+ +

未填寫

-