diff --git a/wms/contract-repair/api/deleteNewContractData.php b/wms/contract-repair/api/deleteNewContractData.php index d7feb1c1..34575f0c 100644 --- a/wms/contract-repair/api/deleteNewContractData.php +++ b/wms/contract-repair/api/deleteNewContractData.php @@ -1,6 +1,25 @@ prepare($sql); + $stmt->bindParam(":id",$id); + $stmt->bindParam(":del",$del); + $stmt->bindParam(":user_id",$user_id); + $stmt->bindParam(":date",$date); + $stmt->execute(); + header("HTTP/1.1 204 NO Content"); + }catch(PDOException $e){ + die("ERROR!!!". $e->getMessage()); + } +} if(isset($_GET['contractid']) && $_GET['contractid']!=""){ try{ $id = $_GET["contractid"]; @@ -12,4 +31,5 @@ if(isset($_GET['contractid']) && $_GET['contractid']!=""){ }catch(PDOException $e){ die("ERROR!!!: ". $e->getMessage()); } -} \ No newline at end of file +} +?> \ No newline at end of file diff --git a/wms/contract-repair/api/getContractData.php b/wms/contract-repair/api/getContractData.php index aadc45cd..1352cdb1 100644 --- a/wms/contract-repair/api/getContractData.php +++ b/wms/contract-repair/api/getContractData.php @@ -57,7 +57,6 @@ if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contrac }catch (PDOException $e ){ die("ERROR!!!: ". $e->getMessage()); } -<<<<<<< HEAD } ////////////////////////////// //// 合約簽回(修理) @@ -68,7 +67,8 @@ if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contrac if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r'){ try{ $contractno = $_GET['contractno']; - $sql = "SELECT a.*,b.name FROM pricereview_repair_main AS a + $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 "; @@ -87,6 +87,4 @@ if(isset($_GET['contractno']) && $_GET['contractno']!='' && isset($_GET['contrac }catch(PDOException $e){ die("ERROR!!:".$e->getMessage()); } -======= ->>>>>>> 1e6352f45c1f05ebbeb9736555124e07ff5fc958 } \ No newline at end of file diff --git a/wms/contract-repair/api/postContractData.php b/wms/contract-repair/api/postContractData.php index d7eee3cd..635d81f9 100644 --- a/wms/contract-repair/api/postContractData.php +++ b/wms/contract-repair/api/postContractData.php @@ -304,7 +304,7 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['co $stmt -> execute(); header('Content-Type: application/json'); - $jsonData = json_encode($files); + // $jsonData = json_encode($files); $conn->commit(); }catch(PDOException $e){ @@ -321,9 +321,87 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['co //// 製作人:梓誠 /// 時間 : ////////////////////////////// -if(isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b'){ +if(isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'r'){ try{ + $created_at = date('Y-m-d H:i:s'); + $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; + $company = !empty($_POST['company']) ? $_POST['company'] : null; + $repairid = !empty($_POST['repairid']) ? $_POST['repairid'] : null; + $facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null; + $taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; + $invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null; + $address = !empty($_POST['address']) ? $_POST['address'] : null; + $repair_no = !empty($_POST['repair_no']) ? $_POST['repair_no'] : null; + $total_price= !empty($_POST['total_price']) ? $_POST['total_price'] : null; + $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; + $type = !empty($_POST['type']) ? $_POST['type'] : null; + $sign_date = !empty($_POST['sign_date']) ? $_POST['sign_date']: null; + + $fail_arr = []; + if($contractno === '') return $fail_arr[] = '合約號為必填'; + if($repair_no === '') return $fail_arr[] = '報價單編號為必填'; + if($company === '') return $fail_arr[] = '客戶名稱為必填'; + // if($taxid === '') return $fail_arr[] = '統一編號為必填'; + if($facilityno === '') return $fail_arr[] = '電梯編號為必填'; + if($address === '') return $fail_arr[] = '工程地址為必填'; + if($type === '') return $fail_arr[] = '工程類別為必填'; + if($invoice === '') return $fail_arr[] = '發票抬頭為必填'; + if(count($fail_arr)>0){ + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + // exit(); + //create contrac_r_signed_back table + $conn -> beginTransaction(); + $sql = "INSERT INTO contract_r_signed_back( + repair_no, + contractno, + company, + taxid, + facilityno, + address, + type, + invoice, + repaireid, + total_price, + sign_date, + create_userid, + create_date) VALUES( + :repair_no, + :contractno, + :company, + :taxid, + :facilityno, + :address, + :type, + :invoice, + :repaireid, + :total_price, + :sign_date, + :create_userid, + :create_date + )"; + $stmt = $conn -> prepare($sql); + $stmt -> bindParam(":repair_no",$repair_no); + $stmt -> bindParam(":contractno",$contractno); + $stmt -> bindParam(":company",$company); + $stmt -> bindParam(":taxid",$taxid); + $stmt -> bindParam(":facilityno",$facilityno); + $stmt -> bindParam(":address",$address); + $stmt -> bindParam(":type", $type); + $stmt -> bindParam(":invoice", $invoice); + $stmt -> bindParam(":repaireid",$repaireid); + $stmt -> bindParam(":total_price",$total_price); + $stmt -> bindParam(":sign_date",$sign_date); + $stmt -> bindParam(":create_userid",$user_id); + $stmt -> bindParam("create_date",$created_at); + + $stmt -> execute(); + header('Content-Type: application/json'); + // $jsonData = json_encode($files); + $conn -> commit(); }catch(PDOException $e){ $conn -> rollback(); echo $e->getMessage(); diff --git a/wms/contract-repair/api/putContractData.php b/wms/contract-repair/api/putContractData.php index f1e78164..0698a041 100644 --- a/wms/contract-repair/api/putContractData.php +++ b/wms/contract-repair/api/putContractData.php @@ -3,6 +3,45 @@ require_once("../conn.php"); include_once("./upload_chk.php"); ini_set ( 'date.timezone' , 'Asia/Taipei' ); // echo json_encode(explode(',', $_POST['deletefiles'])); +if(isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id']!=""){ + try{ + $create_date = date('Y-m-d H:i:s'); + $repair_no = !empty($POST['repair_no']) ? $_POST['repair_no'] : null; + $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; + $company = !empty($_POST['company']) ? $_POST['conpany'] : null; + $taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; + $facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null; + $address = !empty($_POST['address']) ? $_POST['address'] : null; + $type = !empty($_POST['type']) ? $_POST['type'] : null; + $invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null; + $repaireid = !empty($_POST['repaireid']) ? $_POST['repaireid'] : null; + // $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; + $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; + + $fail_arr = []; + if(empty($repair_no)) $fail_arr[] = '號為必填'; + if(empty($contractno)) $fail_arr[] = '合約號為必填'; + if(empty($company)) $fail_arr[] = '客戶名稱為必填'; + if(empty($taxid)) $fail_arr[] = '統一編號為必填'; + if(empty($facilityno)) $fail_arr[] = '電梯號為必填'; + if(empty($address)) $fail_arr[] = '工程地址為必填'; + if(empty($type)) $fail_arr[] = '工程類行為必填'; + if(empty($invoice)) $fail_arr[] = '發票抬頭為必填'; + if(empty($repaireid)) $fail_arr[] = '維修人員為必填'; + if(count($fail_arr) > 0){ + header("HTTP/1.1 442 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + $conn -> beginTransaction(); + + + }catch(PDOException $e){ + $conn->rollback(); + header("HTTPP/1.1 500 Internal Server Error"); + die('Error!:' .$e->getMessage()); + } +} if(isset($_POST['contractno']) && $_POST['contractno']!="" && isset($_POST["id"]) && $_POST['id']!=""){ try{ $created_at = date('Y-m-d H:i:s'); diff --git a/wms/contract-repair/contract-repair-edit.php b/wms/contract-repair/contract-repair-edit.php new file mode 100644 index 00000000..ff8b124c --- /dev/null +++ b/wms/contract-repair/contract-repair-edit.php @@ -0,0 +1,201 @@ +prepare($sql_str); +$stmt->bindParam(':id', $id); +$stmt->execute(); +$contract= $stmt->fetch(PDO::FETCH_ASSOC); +// echo '
'; +// print_r($contract); +// echo ''; +// $files_id = $contract['files_id']; +// $sql_str = "SELECT * FROM contract_back_files WHERE files_id = :files_id "; +// $stmt = $conn->prepare($sql_str); +// $stmt->bindParam(':files_id', $files_id); +// $stmt->execute(); +// $files= $stmt->fetchAll(PDO::FETCH_ASSOC); +// $files = json_encode($files); +$accounttype = "M"; +$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(":accounttype", $accounttype); +$stmt -> execute(); +$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); +$persons = array_map(function($person){ + return [ + 'view'=>$person['accountid'] .'-'. $person['name'], + 'value'=>$person['accountid'], + 'name'=>$person['name'] + ]; +}, $persons); +?> + + + + + + + + + +
+ 合約管理(修理)+ |
+ |||||||
+ 檢視合約+ |
+ + + + | +||||||
立約人 | +
+
+ 未填寫 + |
+
+ 維保人員 | +
+
+ 未填寫 + |
+
+ 電梯編號 | +
+
+ 未填寫 + |
+
+ 報價單編號 | +
+
+ 未填寫 + |
+
工程類別 | +
+
+ 未填寫 + |
+ 簽訂時間 | +
+
+ 未填寫 + |
+ 發票抬頭 | +
+
+ 未填寫 + |
+ 統一編號 | +
+
+ 未填寫 + |
+
工程地址 | +
+
+ 未填寫 + |
+
+ + | + | + | + |
未填寫
+ +未填寫
未填寫
項次 | +合約號 | +客戶名稱 | +統編 | +總金額 | +建檔者 | +建立時間 | +操作 | +
---|---|---|---|---|---|---|---|
+ | + | + | + | + | + | + |
+ + + + + ,'')"> + + + + |
+