From fec7c90fc916ad31f5af14827a631654be088f82 Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 4 Dec 2023 17:26:49 +0800 Subject: [PATCH] 231204.cheng --- .../api/deleteNewContractData.php | 15 + wms/contract-repair/api/getComboNo.php | 59 + wms/contract-repair/api/getContractData.php | 60 + wms/contract-repair/api/getFacilityNo.php | 518 +++++++ wms/contract-repair/api/getPriceview.php | 16 + wms/contract-repair/api/postContractData.php | 319 +++++ .../api/postContractNewApplyData.php | 68 + .../api/postNewContractData.php | 139 ++ wms/contract-repair/api/putContractData.php | 135 ++ wms/contract-repair/api/store_contract.php | 0 wms/contract-repair/api/upload_chk.php | 61 + wms/contract-repair/conn.php | 43 + wms/contract-repair/contract-repair-input.php | 351 +++++ wms/contract-repair/js/alpine.js | 1260 +++++++++++++++++ wms/contract-repair/js/alpinejs/cdn.min.js | 5 + wms/contract-repair/js/axios.js | 25 + wms/contract-repair/js/axios/axios.min.js | 2 + wms/contract-repair/js/el.js | 48 + .../js/jquery/jquery-3.1.1.min.js | 4 + wms/contract-repair/styles/BiauKai.ttf | Bin 0 -> 13946204 bytes .../styles/font-awesome/all.min.css | 9 + wms/contract-repair/styles/style.css | 692 +++++++++ wms/contract-repair/styles/style.css.map | 1 + wms/contract-repair/styles/style.scss | 722 ++++++++++ wms/mkt/pricereview_repair-create.php | 1 + wms/mkt/pricereview_repair.php | 4 + 26 files changed, 4557 insertions(+) create mode 100644 wms/contract-repair/api/deleteNewContractData.php create mode 100644 wms/contract-repair/api/getComboNo.php create mode 100644 wms/contract-repair/api/getContractData.php create mode 100644 wms/contract-repair/api/getFacilityNo.php create mode 100644 wms/contract-repair/api/getPriceview.php create mode 100644 wms/contract-repair/api/postContractData.php create mode 100644 wms/contract-repair/api/postContractNewApplyData.php create mode 100644 wms/contract-repair/api/postNewContractData.php create mode 100644 wms/contract-repair/api/putContractData.php create mode 100644 wms/contract-repair/api/store_contract.php create mode 100644 wms/contract-repair/api/upload_chk.php create mode 100644 wms/contract-repair/conn.php create mode 100644 wms/contract-repair/contract-repair-input.php create mode 100644 wms/contract-repair/js/alpine.js create mode 100644 wms/contract-repair/js/alpinejs/cdn.min.js create mode 100644 wms/contract-repair/js/axios.js create mode 100644 wms/contract-repair/js/axios/axios.min.js create mode 100644 wms/contract-repair/js/el.js create mode 100644 wms/contract-repair/js/jquery/jquery-3.1.1.min.js create mode 100644 wms/contract-repair/styles/BiauKai.ttf create mode 100644 wms/contract-repair/styles/font-awesome/all.min.css create mode 100644 wms/contract-repair/styles/style.css create mode 100644 wms/contract-repair/styles/style.css.map create mode 100644 wms/contract-repair/styles/style.scss create mode 100644 wms/mkt/pricereview_repair.php diff --git a/wms/contract-repair/api/deleteNewContractData.php b/wms/contract-repair/api/deleteNewContractData.php new file mode 100644 index 00000000..d7feb1c1 --- /dev/null +++ b/wms/contract-repair/api/deleteNewContractData.php @@ -0,0 +1,15 @@ +prepare($sql_str); + $stmt->bindParam(":contractid", $id); + $stmt->execute(); + header("HTTP/1.1 204 No Content"); + }catch(PDOException $e){ + die("ERROR!!!: ". $e->getMessage()); + } +} \ No newline at end of file diff --git a/wms/contract-repair/api/getComboNo.php b/wms/contract-repair/api/getComboNo.php new file mode 100644 index 00000000..c258be15 --- /dev/null +++ b/wms/contract-repair/api/getComboNo.php @@ -0,0 +1,59 @@ +'BW002', + 'month'=>'EM002', + 'quarter'=>'EQ002', + 'half'=>'HY002', + 'year'=>'EY002' + ]; + private $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' + ]; + private $emarr = [ + 'month','month','quarter','month','month','half', + 'month','month','quarter','month','month','year' + ]; + private $combo; + private $startdate; + private $enddate; + public function __construct($combo, $startdate, $enddate){ + $this->combo = $combo; + $this->startdate = $startdate; + $this->enddate = $enddate; + } + public function getComboNo(){ + $comboarr = (array) $this->combo === 'bw' ? $this->bwarr : $this->emarr; + + $startdate = new DateTime($this->startdate); + $enddate = new DateTime($this->enddate); + + $interval = date_diff($startdate, $enddate); + + $months = $interval->y * 12 + $interval->m; + $months = $this->combo === 'bw' ? $months*2 : $months; + + $newarr = []; + $idx = 0; + $ori_first_month = date('m', strtotime($this->startdate)); + $first_day = date('Y-m-d', strtotime($this->startdate. ' + 3 days')); + $new_first_month = date('m', strtotime($first_day)); + if($ori_first_month != $new_first_month){ + $first_day = date('Y-m-t', strtotime($this->startdate)); + } + $scheduleDate = new DateTime($first_day); + for ($i = 0; $i < $months; $i++){ + $newarr[] = [$this->comboarr[$comboarr[$idx]], $scheduleDate->format("Y-m-d")]; + $idx ++; + $scheduleDate = $startdate->modify("+1 month"); + if($idx >= count($comboarr)){ + $idx = 0; + } + } + return json_encode($newarr); + } +} \ No newline at end of file diff --git a/wms/contract-repair/api/getContractData.php b/wms/contract-repair/api/getContractData.php new file mode 100644 index 00000000..df52d1dd --- /dev/null +++ b/wms/contract-repair/api/getContractData.php @@ -0,0 +1,60 @@ +prepare($sql_str); + $stmt->bindParam(':vol_no', $contractno); + $stmt->execute(); + $contract= $stmt->fetch(PDO::FETCH_ASSOC); + + if(empty($contract)){ + echo false; + exit; + } + $apply_key = $contract['apply_key']; + $sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':apply_key', $apply_key); + $stmt->execute(); + $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()); + } +} + +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); + $contractResponse = json_encode($contract); + + // 設定回應標頭為 JSON + header('Content-Type: application/json'); + + // 將 JSON 回應返回給客戶端 + echo $contractResponse; + }catch (PDOException $e ){ + die("ERROR!!!: ". $e->getMessage()); + } +} \ No newline at end of file diff --git a/wms/contract-repair/api/getFacilityNo.php b/wms/contract-repair/api/getFacilityNo.php new file mode 100644 index 00000000..fcf0b76f --- /dev/null +++ b/wms/contract-repair/api/getFacilityNo.php @@ -0,0 +1,518 @@ + false, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_EMULATE_PREPARES => false, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + ]; + $pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options); + $pdo->exec('SET CHARACTER SET utf8mb4'); + return $pdo; + } catch (PDOException $e) { + die("Something wrong: {$e->getMessage()}"); + } + } + + /** + * 結束資料庫連線 + */ + function endConnectionDB($pdo) + { + unset($pdo); + } + + /** + * 取得下一個新的作番 + * @param string $facility_type : M:新梯 T:汰改 B:保養 + * @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 + * @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 + * @param int $num : 號機 + * @return array $new_facility_arr + */ + function getNextFacilityNo($facility_type, $sale_type, $make_type, $num = 1) + { + $this->checkYearAndResetAllSeq(); + $Y = substr(date("Y"), 3, 1); + + switch ($facility_type) { + case "M": + $next_seq = $this->getNextFacilitySeq("mf_vol_no") + 1; + $new_facility_arr = []; + for ($start_num = 1; $start_num <= $num; $start_num++) { + $facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1] + . str_pad($next_seq, 5, "0", STR_PAD_LEFT); + array_push($new_facility_arr, $facility_no_tmp); + $next_seq++; + } + return $new_facility_arr; + case "T": + $next_seq = $this->getNextFacilitySeq("tf_vol_no"); + $new_facility_arr = []; + for ($start_num = 1; $start_num <= $num; $start_num++) { + $facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1] + . str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) + . str_pad($start_num, 2, "0", STR_PAD_LEFT); + array_push($new_facility_arr, $facility_no_tmp); + } + return $new_facility_arr; + case "B": + $next_seq = $this->getNextFacilitySeq("bf_vol_no"); + $new_facility_arr = []; + for ($start_num = 1; $start_num <= $num; $start_num++) { + $facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1] + . str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) + . str_pad($start_num, 2, "0", STR_PAD_LEFT); + array_push($new_facility_arr, $facility_no_tmp); + } + return $new_facility_arr; + default: + return "不存在的作番類型"; + } + } + + /** + * 建立新的作番 + * @param string $facility_type : M:新梯 T:汰改 B:保養 + * @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 + * @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 + * @param string $num : 號機 (非必填) + * @return string $new_facility_no + */ + function makeFacilityNo($facility_type, $sale_type, $make_type, $num = null) + { + + $this->checkYearAndResetAllSeq(); + + $faclikity_details = array( + 'facility_type' => $facility_type, + 'sale_type' => $sale_type, + 'make_type' => $make_type, + 'num' => $num + ); + + switch ($facility_type) { + case "M": + return $this->makeNewMFacilityNo($faclikity_details); + break; + case "T": + return $this->makeNewTFacilityNo($faclikity_details); + break; + case "B": + return $this->makeNewBFacilityNo($faclikity_details); + break; + default: + return "不存在的作番類型"; + } + } + + /** + * 建立作番 -- 新梯 + */ + function makeNewMFacilityNo($faclikity_details) + { + $Y = substr(date("Y"), 3, 1); + $sale_type = $faclikity_details['sale_type']; + $make_type = $faclikity_details['make_type']; + $num = $faclikity_details['num']; + $next_seq = $this->getNextFacilitySeq("mf_vol_no") + 1; + $new_facility_no_arr = []; + + for ($i = 1; $i <= $num; $i++) { + $new_facility_no = $Y . $sale_type . $make_type[$i - 1] + . str_pad($next_seq, 5, "0", STR_PAD_LEFT); + array_push($new_facility_no_arr, $new_facility_no); + $next_seq++; + } + + foreach ($new_facility_no_arr as $new_facility_no) { + if ($this->getMakeNewMFacilityNoStatus($faclikity_details) !== "1") { + return $new_facility_no . ":" . $this->getMakeNewTFacilityNoStatus($faclikity_details); + } + // seq +1 + $this->facilitySeqAddOne("M"); + } + return $new_facility_no_arr; + } + + /** + * 建立作番 -- 汰改 + */ + function makeNewTFacilityNo($faclikity_details) + { + + $Y = substr(date("Y"), 3, 1); + $sale_type = $faclikity_details['sale_type']; + $make_type = $faclikity_details['make_type']; + $num = $faclikity_details['num']; + $next_seq = $this->getNextFacilitySeq("tf_vol_no"); + $new_facility_no_arr = []; + + for ($i = 1; $i <= $num; $i++) { + $new_facility_no = $Y . $sale_type . $make_type[$i - 1] + . str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) + . str_pad($i, 2, "0", STR_PAD_LEFT); + array_push($new_facility_no_arr, $new_facility_no); + } + + foreach ($new_facility_no_arr as $new_facility_no) { + if ($this->getMakeNewTFacilityNoStatus($faclikity_details) !== "1") { + return $new_facility_no . ":" . $this->getMakeNewTFacilityNoStatus($faclikity_details); + } + // seq +1 + $this->facilitySeqAddOne("T"); + return $new_facility_no_arr; + } + } + + /** + * 建立作番 -- 保養 + */ + function makeNewBFacilityNo($faclikity_details) + { + + $Y = substr(date("Y"), 3, 1); + $sale_type = $faclikity_details['sale_type']; + $make_type = $faclikity_details['make_type']; + $num = $faclikity_details['num']; + $next_seq = $this->getNextFacilitySeq("bf_vol_no"); + $new_facility_no_arr = []; + + for ($i = 1; $i <= $num; $i++) { + $new_facility_no = $Y . $sale_type . $make_type[$i - 1] + . str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) + . str_pad($i, 2, "0", STR_PAD_LEFT); + array_push($new_facility_no_arr, $new_facility_no); + } + + foreach ($new_facility_no_arr as $new_facility_no) { + if ($this->getMakeNewBFacilityNoStatus($faclikity_details) !== "1") { + return $new_facility_no . ":" . $this->getMakeNewBFacilityNoStatus($faclikity_details); + } + // seq +1 + $this->facilitySeqAddOne("B"); + return $new_facility_no_arr; + } + } + + /** + * 檢查作番編列狀態 - 新梯 + * @param array $faclikity_details + * @return string $status : 1:正確 else:error message + */ + function getMakeNewMFacilityNoStatus($faclikity_details) + { + $sale_type = $faclikity_details['sale_type']; + $make_type = $faclikity_details['make_type']; + + if ($this->checkSaleTypeStatus($sale_type) == false) + return "銷售代號錯誤"; + if ($this->checkMakeTypeStatus($make_type) == false) + return "製造編號類型錯誤"; + return "1"; + } + + /** + * 檢查作番編列狀態 - 汰改 + * @param array $faclikity_details + * @return string $status : 1:正確 else:error message + */ + function getMakeNewTFacilityNoStatus($faclikity_details) + { + $sale_type = $faclikity_details['sale_type']; + $make_type = $faclikity_details['make_type']; + + if ($this->checkSaleTypeStatus($sale_type) == false) + return "銷售代號錯誤"; + if ($this->checkMakeTypeStatus($make_type) == false) + return "製造編號類型錯誤"; + return "1"; + } + + /** + * 檢查作番編列狀態 - 保養 + * @param array $faclikity_details + * @return string $status : 1:正確 else:error message + */ + function getMakeNewBFacilityNoStatus($faclikity_details) + { + $sale_type = $faclikity_details['sale_type']; + $make_type = $faclikity_details['make_type']; + + if ($this->checkSaleTypeStatus($sale_type) == false) + return "銷售代號錯誤"; + if ($this->checkMakeTypeStatus($make_type) == false) + return "製造編號類型錯誤"; + return "1"; + } + + /** + * seq 取號 + * @param string $type M:新梯 T:汰改 B:保養 + */ + function facilitySeqAddOne($type) + { + $type_arr = array( + "M" => "mf_vol_no", + "T" => "tf_vol_no", + "B" => "bf_vol_no", + ); + if (!empty($type_arr[$type])) { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare('UPDATE sequence SET current_val = current_val + 1 WHERE `seq_name` = ?'); + $sth->bindValue(1, $type_arr[$type]); + $sth->execute(); + } + } + + /** + * 修正 seq 取號 + * @param string $type M:新梯 T:汰改 B:保養 + */ + function facilityFixSeq($type) + { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $type_arr = array( + "M" => "mf_vol_no", + "T" => "tf_vol_no", + "B" => "bf_vol_no", + ); + $after_fix_seq = $this->getMaxSeq($type); + $sql = " + UPDATE sequence + SET current_val = ? + WHERE seq_name = ? + "; + $sth = $pdo->prepare($sql); + $sth->bindValue(1, $after_fix_seq); + $sth->bindValue(2, $type_arr[$type]); + $sth->execute(); + } + + function getMaxSeq($type) + { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $Y = substr(date("Y"), 3, 1); + $seq_num = $type == 'M' ? 5 : 3; + $sql = " + SELECT MAX(SUBSTR(f.facilityno,4,?))+1 AS seq + FROM facility AS f + WHERE 1=1 + AND SUBSTR(f.facilityno,1,1) = ? + AND f.define = ? + ORDER BY SUBSTR(f.facilityno,4,3) ASC + "; + $sth = $pdo->prepare($sql); + $sth->bindValue(1, $seq_num); + $sth->bindValue(2, $Y); + $sth->bindValue(3, $type); + $sth->execute(); + $result = $sth->fetch(); + return $result['seq']; + } + + /** + * 檢查年月後 新梯及汰改seq歸零 + */ + function checkYearAndResetAllSeq() + { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare('SELECT * FROM `sequence` WHERE `seq_name` = ?'); + $sth->bindValue(1, 'mf_vol_no'); + $sth->execute(); + $result = $sth->fetch(); + $yyyymm = $result['yyyymm']; + $dataY = substr($yyyymm, 0, 4); + $today_Y = date("Y"); + $today_Ym = date("Ym"); + if ($dataY != $today_Y) { + $sth = $pdo->prepare('UPDATE `sequence` SET `current_val` = ? , `yyyymm` = ? WHERE `seq_name` = ?'); + $sth->bindValue(1, '0'); + $sth->bindValue(2, $today_Ym); + $sth->bindValue(3, 'mf_vol_no'); + $sth->execute(); + } + } + + /** + * 檢查作番在 facility table 中是否重複 + * @param string|array $facility_no + * @return boolean $status : true:沒重複 false:重複 + */ + function checkFacilityRepeatStatus($facility_no) + { + if (gettype($facility_no) == "string") { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); + $sth->bindValue(1, $facility_no); + $sth->execute(); + if ($sth->rowCount() == 0) + return true; + return false; + } + if (gettype($facility_no) == "array") { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $status = true; + foreach ($facility_no as $row) { + $sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); + $sth->bindValue(1, $row); + $sth->execute(); + if ($sth->rowCount() !== 0) + $status = false; + } + return $status; + } + } + + /** + * 檢查 $sale_type 是否有存在規則之中 + * @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 + * @return boolean $status : true:合法代碼 false:非法代碼 + */ + function checkSaleTypeStatus($sale_type) + { + + if (!in_array($sale_type, ['M', 'E', 'T', 'J', 'X'])) + return false; + return true; + } + + /** + * 檢查 $sale_type 是否有存在規則之中 + * @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 + * @return boolean $status : true:合法代碼 false:非法代碼 + */ + function checkMakeTypeStatus($make_type) + { + foreach ($make_type as $row) + if (!in_array($row, ['X', 'W', 'H', 'Z', 'F', 'B', 'Q', 'T', 'N', 'W', 'J', 'Y'])) + return false; + return true; + } + + /** + * 檢查 取得下個作番的 seq + * @param string $seq_name : 新梯:mf_vol_no 汰改:tf_vol_no 保養:bf_vol_no + * @return int $seq : 作番流水號 + */ + function getNextFacilitySeq($seq_name) + { + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare('SELECT * FROM `sequence` WHERE `seq_name` = ?'); + $sth->bindValue(1, $seq_name); + $sth->execute(); + $result = $sth->fetch(); + return $result['current_val']; + } + + /** + * 建立新的新梯作番 + * @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 + * @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 + * @param int $seq_name : 幾個案場 0-99 + * @return array $new_facilityno : 作番號 + */ + function makeMFacilityNo($sale_type, $make_type, $num) + { + if (count($make_type) !== $num) + return "陣列數量不一致!"; + $new_facility_no = $this->getNextFacilityNo("M", $sale_type, $make_type, $num); + if ($this->checkFacilityRepeatStatus($new_facility_no) == false) { + // 如果作番號重複 使用此函數修正 + $this->facilityFixSeq("M"); + } + return $this->makeFacilityNo("M", $sale_type, $make_type, $num); + } + + /** + * 建立新的汰改作番 + * @param array $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 + * @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 + * @param int $seq_name : 幾個案場 0-99 + * @return array $new_facilityno : 作番號 + */ + function makeTFacilityNo($sale_type, $make_type, $num) + { + if (count($make_type) !== $num) + return "陣列數量不一致!"; + $new_facility_no = $this->getNextFacilityNo("T", $sale_type, $make_type, $num); + if ($this->checkFacilityRepeatStatus($new_facility_no) == false) { + // 如果作番號重複 使用此函數修正 + $this->facilityFixSeq("T"); + } + return $this->makeFacilityNo("T", $sale_type, $make_type, $num); + } + + /** + * 建立新的保養作番 + * @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 + * @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 + * @param int $seq_name : 幾個案場 0-99 + * @return array $new_facilityno : 作番號 + */ + function makeBFacilityNo($sale_type, $make_type, $num = 1) + { + if (count($make_type) !== $num) + return "陣列數量不一致!"; + $new_facility_no = $this->getNextFacilityNo("B", $sale_type, $make_type, $num); + if ($this->checkFacilityRepeatStatus($new_facility_no) == false) { + // 如果作番號重複 使用此函數修正 + $this->facilityFixSeq("B"); + } + return $this->makeFacilityNo("B", $sale_type, $make_type, $num); + } +} + + +// $cfn = new CreateFacilityNo; +// // 建立作番號 - 新梯 +// print_r($cfn->makeMFacilityNo("M", ["X", "W"], 2)); +// echo "

"; +// // 建立作番號 - 汰改 +// print_r($cfn->makeTFacilityNo("M", ["X", "W"], 2)); +// echo "

"; +// // 建立作番號 - 保養 +// print_r($cfn->makeBFacilityNo("M", ["X", "W"], 2)); +// echo "

"; diff --git a/wms/contract-repair/api/getPriceview.php b/wms/contract-repair/api/getPriceview.php new file mode 100644 index 00000000..0d52f0a8 --- /dev/null +++ b/wms/contract-repair/api/getPriceview.php @@ -0,0 +1,16 @@ +prepare($sql_str); + $stmt->bindParam(':id',$id); + $stmt->execute(); + $prices = $stmt->fetch(PDO::FETCH_ASSOC); + header("Content-Type: application/json"); + + echo json_encode(['prices'=> $prices]); + +}catch (PDOException $e ){ + die("ERROR!!!: ". $e->getMessage()); +} \ No newline at end of file diff --git a/wms/contract-repair/api/postContractData.php b/wms/contract-repair/api/postContractData.php new file mode 100644 index 00000000..69e7d859 --- /dev/null +++ b/wms/contract-repair/api/postContractData.php @@ -0,0 +1,319 @@ + 0) { + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + + //create account table + $accounttype = "A"; + $accountid = $vat; + $pwd = "123"; + $name = $partyA; + $tel = $phone ?? ''; + $repairerid = $mworker; + $creater = $user_id; + $create_at = date('Y-m-d H:i:s'); + + $conn->beginTransaction(); + + $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':accounttype' ,$accounttype); + $stmt -> bindParam(':accountid' ,$accountid); + $stmt -> bindParam(':pwd' ,$pwd); + $stmt -> bindParam(':name' ,$name); + $stmt -> bindParam(':tel' ,$tel); + $stmt -> bindParam(':address' ,$address); + $stmt -> bindParam(':email' ,$email); + $stmt -> bindParam(':repairerid' ,$repairerid); + $stmt -> bindParam(':creater' ,$creater); + $stmt -> bindParam(':create_at' ,$create_at); + $stmt -> execute(); + + //create contract table + + $contracttype = $mtype; + $company = $partyA; + $taxid = $vat; + $tel = $phone; + $promiser = $partyA; + $contractperson = $partyA; + + $contractaddress = $address; + $contracttel = $phone; + $contractemail = $email; + $contract_employee = $salesman; + $start_date = $contract_begin_date; + $end_date = $contract_end_date; + + $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':contracttype' ,$contracttype); + $stmt -> bindParam(':contractno' ,$contractno); + $stmt -> bindParam(':company' ,$company); + $stmt -> bindParam(':taxid' ,$taxid); + $stmt -> bindParam(':address' ,$address); + $stmt -> bindParam(':tel' ,$tel); + $stmt -> bindParam(':promiser' ,$promiser); + $stmt -> bindParam(':contractperson' ,$contractperson); + $stmt -> bindParam(':contractaddress' ,$contractaddress); + $stmt -> bindParam(':contracttel' ,$contracttel); + $stmt -> bindParam(':contractemail' ,$contractemail); + $stmt -> bindParam(':contract_employee' ,$contract_employee); + $stmt -> bindParam(':start_date' ,$start_date); + $stmt -> bindParam(':end_date' ,$end_date); + $stmt -> bindParam(':creater' ,$creater); + $stmt -> bindParam(':create_at' ,$create_at); + $stmt -> execute(); + + //create facility table + $createFacilityNo = new CreateFacilityNo(); + $dailyNecessities = [ + 'MAE100'=>'X', + 'MAM200'=>'W', + 'MAH100'=>'H', + 'MAQ100'=>'Z', + 'MAF100'=>'F', + 'MAZ100'=>'B', + ]; + $facility_arr = []; + foreach($elevators as $elevator){ + $facility_arr[] = $dailyNecessities[$elevator['spec']]; + } + echo json_encode($facility_arr); + $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); + echo json_encode($facilityno); + echo '-------'; + $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':accountid',$mworker); + $stmt->execute(); + $worker = $stmt->fetch(PDO::FETCH_ASSOC); + $customerid = $vat; + $define = "B"; + $repairtype = $mtype; + $repairerid = $mworker; + $repairername = $worker['name']; + foreach($elevators as $idx=>$elevator){ + $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' ,$facilityno[$idx]); + $stmt -> bindParam(':latitude' ,$elevator['latitude']); + $stmt -> bindParam(':longitude' ,$elevator['longitude']); + $stmt -> bindParam(':customerid' ,$customerid); + $stmt -> bindParam(':weight' ,$elevator['weight']); + $stmt -> bindParam(':numberofpassenger' ,$elevator['persons']); + $stmt -> bindParam(':numberofstop' ,$elevator['stop']); + $stmt -> bindParam(':numberoffloor' ,$elevator['floors']); + $stmt -> bindParam(':opentype' ,$elevator['opendoor']); + $stmt -> bindParam(':speed' ,$elevator['speed']); + $stmt -> bindParam(':repairtype' ,$repairtype); + $stmt -> bindParam(':maintainance' ,$elevator['maintainance']); + $stmt -> bindParam(':facility_kind' ,$elevator['spec']); + $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' ,$elevator['takecertificatedate']); + $stmt -> bindParam(':licensedate' ,$elevator['useful_date']); + $result = $stmt -> execute(); + } + + //create schedule table + + $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); + $comboArr = json_decode($comboNo->getComboNo(), true); + foreach($facilityno as $no){ + foreach($comboArr as $combo){ + $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(':facilityno' ,$no); + $stmt -> bindParam(':combono' ,$combo[0]); + $stmt -> bindParam(':repairerid' ,$repairerid); + $stmt -> bindParam(':repairername' ,$repairername); + $stmt -> bindParam(':duedate' ,$combo[1]); + $stmt -> bindParam(':creater' ,$creater); + $stmt -> bindParam(':create_at' ,$create_at); + $result = $stmt -> execute(); + } + } + // create contract_b_signed_back table + $contract_type = $mtype; + $company = $customer; + $customer_no = $vat; + $salesperson = $salesman; + $customer_phone = $phone; + $customer_email = $email; + $repairman = $mworker; + $cycle = $mcycle; + $contact_person = $partyA; + $contact_address = $partyAaddress; + $contact_phone = $partyAphone; + $contract_email = $partyAemail; + $elevators_number = $num; + $bonus = 1000; + $max_bonus = 2000; + + if(!empty($files)){ + $englisharr = range('a', 'z'); + $file = $_FILES['files']; + $file_name = $file['name']; + $file_type = $file['type']; + $tmp_name = $file['tmp_name']; + $file_size = $file['size']; + $error = $file['error']; + $newfiles = []; + foreach( $files as $file ){ + $i = 0; //新陣列的索引編號 + foreach( $file as $key => $val ){ + $newfiles[$i]['name'] = $files['name'][$key]; + $newfiles[$i]['type'] = $files['type'][$key]; + $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; + $newfiles[$i]['error'] = $files['error'][$key]; + $newfiles[$i]['size'] = $files['size'][$key]; + $i++; + } //foreach 第2層 end + } + $max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) + $allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 + $path = '../images/contracts/'; + if (!file_exists($path)) { mkdir($path); } + $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 + $datetime = (string)date('YmdHis'); + $files_id = 'b' . $datetime; // 保養=>b + 日期時間 + foreach( $newfiles as $key => $file ){ + $randNum = rand(1000,9999); + $randEnglish = $englisharr[rand(0,25)]; + $file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; + $msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); + if($msg==1){ + $msg = '檔案傳送成功!'; + $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':files_id' ,$files_id); + $stmt -> bindParam(':file_name' ,$file_name); + $stmt -> bindParam(':file_mime' ,$file['type']); + $stmt -> bindParam(':file_size' ,$file['size']); + $stmt -> bindParam(':created_at' ,$created_at); + $stmt -> bindParam(':created_by' ,$user_id); + $stmt ->execute(); + } + $msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '
'; + $src_name = $path.$file['name']; + if( file_exists($src_name) ){ + //副檔名 + $extname = pathinfo($src_name, PATHINFO_EXTENSION); + //主檔名 + $basename = basename($src_name, '.'.$extname); + } + + } + }else{ + $files = null; + } + $sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) + VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(":contract_no",$contractno); + $stmt -> bindParam(":contract_type",$contract_type); + $stmt -> bindParam(":company",$company); + $stmt -> bindParam(":customer_no",$customer_no); + $stmt -> bindParam(":salesperson",$salesperson); + $stmt -> bindParam(":contract_start_date",$contract_begin_date); + $stmt -> bindParam(":contract_end_date",$contract_end_date); + $stmt -> bindParam(":total_price",$total_price); + $stmt -> bindParam(":customer_phone",$customer_phone); + $stmt -> bindParam(":customer_email",$customer_email); + $stmt -> bindParam(":repairman",$repairman); + $stmt -> bindParam(":cycle",$cycle); + $stmt -> bindParam(":contact_person",$contact_person); + $stmt -> bindParam(":contact_address",$contact_address); + $stmt -> bindParam(":contact_phone",$contact_phone); + $stmt -> bindParam(":contact_email",$contact_email); + $stmt -> bindParam(":elevators_number",$elevators_number); + $stmt -> bindParam(":area",$area); + $stmt -> bindParam(":address",$address); + $stmt -> bindParam(":files_id",$files_id); + $stmt -> bindParam(":bonus",$bonus); + $stmt -> bindParam(":max_bonus",$max_bonus); + $stmt -> bindParam(":created_at", $created_at); + $stmt -> bindParam(":created_by",$user_id); + + $stmt -> execute(); + + header('Content-Type: application/json'); + $jsonData = json_encode($files); + + $conn->commit(); + }catch(PDOException $e){ + $conn->rollback(); + echo $e->getMessage(); + die('Error!:'.$e->getMessage()); + } +} + + + + diff --git a/wms/contract-repair/api/postContractNewApplyData.php b/wms/contract-repair/api/postContractNewApplyData.php new file mode 100644 index 00000000..f0032a78 --- /dev/null +++ b/wms/contract-repair/api/postContractNewApplyData.php @@ -0,0 +1,68 @@ +beginTransaction(); + try{ + if($isFirst == 1){ + $sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, progress, status, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :progress, :status, :created_at, :created_by)"; + $stmt = $conn -> prepare($sql_str); + $stmt ->bindParam(':mid', $mid); + $stmt ->bindParam(':contractno', $vol_no); + $stmt ->bindParam(':sales_man', $salesman); + $stmt ->bindParam(':apply_date', $apply_date); + $stmt ->bindParam(':apply_type', $apply_type); + $stmt ->bindParam(':case_name', $case_name); + $stmt ->bindParam(':customer', $customer); + $stmt ->bindParam(':manager', $manager); + $stmt ->bindParam(':vat', $vat); + $stmt ->bindParam(':total_price', $total_price); + $stmt ->bindParam(':buy_fee', $buy_fee); + $stmt ->bindParam(':install_fee', $install_fee); + $stmt ->bindParam(':contact_address', $contact_address); + $stmt ->bindParam(':workdeadline_a', $workdeadline_a); + $stmt ->bindParam(':workdeadline_b', $workdeadline_b); + $stmt ->bindParam(':test_time', $test_time); + $stmt ->bindParam(':freedeadline', $freedeadline); + $stmt ->bindParam(':trade_address', $trade_address); + $stmt ->bindParam(':tradedeadline', $tradedeadline); + $stmt ->bindParam(':progress', $progress); + $stmt ->bindParam(':status', $status); + $stmt ->bindParam(':created_at', $created_at); + $stmt ->bindParam(':created_by', $created_by); + $stmt ->execute(); + header("HTTP/1.1 201 success!"); + $conn->commit(); + } + }catch(PDOException $e){ + $conn->rollback(); + echo $e->getMessage(); + die('Error!:'.$e->getMessage()); + } + + +} \ No newline at end of file diff --git a/wms/contract-repair/api/postNewContractData.php b/wms/contract-repair/api/postNewContractData.php new file mode 100644 index 00000000..001fe1f5 --- /dev/null +++ b/wms/contract-repair/api/postNewContractData.php @@ -0,0 +1,139 @@ + 0) { + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + + + $conn->beginTransaction(); + + $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(":accountid",$salesman); + $stmt -> execute(); + $saleman = $stmt->fetch(PDO::FETCH_ASSOC); + $salesman_name = $saleman['name']; + if(!empty($files)){ + $englisharr = range('a', 'z'); + $files = $_FILES['files']; + $newfiles = []; + foreach( $files as $file ){ + $i = 0; //新陣列的索引編號 + foreach( $file as $key => $val ){ + $newfiles[$i]['name'] = $files['name'][$key]; + $newfiles[$i]['type'] = $files['type'][$key]; + $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; + $newfiles[$i]['error'] = $files['error'][$key]; + $newfiles[$i]['size'] = $files['size'][$key]; + $i++; + } //foreach 第2層 end + } + $max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) + $allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 + $path = '../images/contracts/'; + if (!file_exists($path)) { mkdir($path); } + $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 + $datetime = (string)date('YmdHis'); + $files_id = 'm' . $datetime; // 保養=>b + 日期時間 + foreach( $newfiles as $key => $file ){ + $randNum = rand(1000,9999); + $randEnglish = $englisharr[rand(0,25)]; + $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; + $msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); + if($msg==1){ + $msg = '檔案傳送成功!'; + $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':files_id' ,$files_id); + $stmt -> bindParam(':file_name' ,$file_name); + $stmt -> bindParam(':file_mime' ,$file['type']); + $stmt -> bindParam(':file_size' ,$file['size']); + $stmt -> bindParam(':created_at' ,$created_at); + $stmt -> bindParam(':created_by' ,$created_by); + $stmt ->execute(); + }else{ + throw new PDOException('檔案上傳失敗:' . $msg); + } + $msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '
'; + $src_name = $path.$file['name']; + if( file_exists($src_name) ){ + //副檔名 + $extname = pathinfo($src_name, PATHINFO_EXTENSION); + //主檔名 + $basename = basename($src_name, '.'.$extname); + } + } + }else{ + $files = null; + } + + $sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(":contract_no",$contractno); + $stmt -> bindParam(":customer",$customer); + $stmt -> bindParam(":manager",$manager); + $stmt -> bindParam(":vat",$vat); + $stmt -> bindParam(":case_name",$case_name); + $stmt -> bindParam(":linkman",$linkman); + $stmt -> bindParam(":lm_tel",$lm_tel); + $stmt -> bindParam(":address",$address); + $stmt -> bindParam(":salesman",$salesman); + $stmt -> bindParam(":salesman_name",$salesman_name); + $stmt -> bindParam(":files_id",$files_id); + $stmt -> bindParam(":created_at",$created_at); + $stmt -> bindParam(":created_by",$created_by); + $stmt -> bindParam(":qc",$qc); + $stmt -> execute(); + + + $result = $conn->commit(); + if($result){ + header("HTTP/1.1 201 Created"); + } + + }catch(PDOException $e){ + $conn->rollback(); + header("HTTP/1.1 500 Internal Server Error"); + die('Error!:'.$e->getMessage()); + } + } \ No newline at end of file diff --git a/wms/contract-repair/api/putContractData.php b/wms/contract-repair/api/putContractData.php new file mode 100644 index 00000000..f1e78164 --- /dev/null +++ b/wms/contract-repair/api/putContractData.php @@ -0,0 +1,135 @@ + 0) { + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + + $conn->beginTransaction(); + + $sql_str = "UPDATE contract_m_signed_back SET contract_no=:contract_no, customer=:customer, manager=:manager, vat=:vat, case_name=:case_name, linkman=:linkman, lm_tel=:lm_tel, address=:address, salesman=:salesman, qc_official_type=:qc WHERE id = :id"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':contract_no' ,$contract_no); + $stmt -> bindParam(':customer' ,$customer); + $stmt -> bindParam(':manager' ,$manager); + $stmt -> bindParam(':vat' ,$vat); + $stmt -> bindParam(':case_name' ,$case_name); + $stmt -> bindParam(':linkman' ,$linkman); + $stmt -> bindParam(':lm_tel' ,$lm_tel); + $stmt -> bindParam(':address' ,$address); + $stmt -> bindParam(':salesman' ,$salesman); + $stmt -> bindParam(':qc' ,$qc); + $stmt -> bindParam(':id' ,$id); + $stmt -> execute(); + if(!empty($deletefiles)){ + $sql_str = "DELETE FROM contract_back_files WHERE id IN ($deletefiles)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> execute(); + } + + if(!empty($files)){ + $englisharr = range('a', 'z'); + $files = $_FILES['files']; + $newfiles = []; + foreach( $files as $file ){ + $i = 0; //新陣列的索引編號 + foreach( $file as $key => $val ){ + $newfiles[$i]['name'] = $files['name'][$key]; + $newfiles[$i]['type'] = $files['type'][$key]; + $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; + $newfiles[$i]['error'] = $files['error'][$key]; + $newfiles[$i]['size'] = $files['size'][$key]; + $i++; + } //foreach 第2層 end + } + $max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) + $allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 + $path = '../images/contracts/'; + if (!file_exists($path)) { mkdir($path); } + $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 + $datetime = (string)date('YmdHis'); + $files_id = ($files_id !== null ) ? $files_id : 'm' . $datetime; // 新梯=>m + 日期時間 + foreach( $newfiles as $key => $file ){ + $randNum = rand(1000,9999); + $randEnglish = $englisharr[rand(0,25)]; + $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; + $msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); + if($msg==1){ + $msg = '檔案傳送成功!'; + $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; + $stmt = $conn -> prepare($sql_str); + $stmt -> bindParam(':files_id' ,$files_id); + $stmt -> bindParam(':file_name' ,$file_name); + $stmt -> bindParam(':file_mime' ,$file['type']); + $stmt -> bindParam(':file_size' ,$file['size']); + $stmt -> bindParam(':created_at' ,$created_at); + $stmt -> bindParam(':created_by' ,$created_by); + $stmt ->execute(); + }else{ + throw new PDOException('檔案上傳失敗:' . $msg); + } + $msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '
'; + $src_name = $path.$file['name']; + if( file_exists($src_name) ){ + //副檔名 + $extname = pathinfo($src_name, PATHINFO_EXTENSION); + //主檔名 + $basename = basename($src_name, '.'.$extname); + } + } + }else{ + $files = null; + } + + $conn->commit(); + }catch(PDOException $e) { + $conn->rollback(); + header("HTTP/1.1 500 Internal Server Error"); + die('Error!:'.$e->getMessage()); + } + + + + + + + + + +} \ No newline at end of file diff --git a/wms/contract-repair/api/store_contract.php b/wms/contract-repair/api/store_contract.php new file mode 100644 index 00000000..e69de29b diff --git a/wms/contract-repair/api/upload_chk.php b/wms/contract-repair/api/upload_chk.php new file mode 100644 index 00000000..958cb6d5 --- /dev/null +++ b/wms/contract-repair/api/upload_chk.php @@ -0,0 +1,61 @@ + $max_size ){ + //當目前檔案容量超過容量限制時, 以下準備顯示的資訊 + if( $max_size >= 4096*4096 ){ + $max_size /= (4096*4096); + $max_size .= 'M'; + }elseif( $max_size >= 4096 ){ + $max_size /= 4096; + $max_size .= 'K'; + } + $msg ='上傳檔案過大,請選擇容量小於 '.$max_size.' 的檔案'; + + //3.判斷檔案類型 =========================================== + //in_array($ext, $allow_ext) 判斷 $ext變數的值 是否在 $allow_ext 這個陣列變數中 + }elseif( !in_array( $ext, $allow_ext ) ){ + $allow_str = ''; //準備將允許檔案類型的陣列內容, 組合成字串 + foreach( $allow_ext as $key=>$value ){ + //if的縮寫語法:條件?成立執行的工作:不成立執行的工作; + $key==0? $allow_str.= $value : $allow_str.=', '.$value; + } + $msg = '檔案類型不符合,請選擇 '.$allow_str.' 檔案'; + + //4.以上條件都沒問題的話, 則進行最後else中的工作=============== + }else{ + //搬移檔案 move_uploaded_file(要搬移的檔案, 目的地位置及目的檔案名稱), 成功傳回true(1) + $msg = @move_uploaded_file($tmp_name, $path.$file_name); + } + }else{ + //這裡表示上傳有錯誤, 匹配錯誤編號顯示對應的訊息 ====================================== + switch ($error) { + case 1: $msg = '上傳檔案超過 upload_max_filesize 容量最大值'; break; + case 2: $msg = '上傳檔案超過 post_max_size 總容量最大值'; break; + case 3: $msg = '檔案只有部份被上傳'; break; + case 4: $msg = '沒有檔案被上傳'; break; + case 6: $msg = '找不到主機端暫存檔案的目錄位置'; break; + case 7: $msg = '檔案寫入失敗'; break; + case 8: $msg = '上傳檔案被PHP程式中斷,表示主機端系統錯誤'; break; + } + } //if( $error == 0 ){ ..... end + + return $msg; //回傳$msg的結果 + } \ No newline at end of file diff --git a/wms/contract-repair/conn.php b/wms/contract-repair/conn.php new file mode 100644 index 00000000..b92e67e5 --- /dev/null +++ b/wms/contract-repair/conn.php @@ -0,0 +1,43 @@ +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 diff --git a/wms/contract-repair/contract-repair-input.php b/wms/contract-repair/contract-repair-input.php new file mode 100644 index 00000000..09351a13 --- /dev/null +++ b/wms/contract-repair/contract-repair-input.php @@ -0,0 +1,351 @@ +prepare($sql_str); +$stmt->bindParam(':accounttype',$accounttype); +$stmt->execute(); +$workers = $stmt->fetchAll(PDO::FETCH_ASSOC); +$accounttype = "M"; +$sql_str = "SELECT id,accountid, name FROM account WHERE accounttype = :accounttype"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':accounttype',$accounttype); +$stmt->execute(); +$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); +?> + + + + + + +
+
+ +
+ + + + + + + + + +
+

合約入力(修理)

+
+ + + + + +
+
+ +
+ + + + \ No newline at end of file diff --git a/wms/contract-repair/js/alpine.js b/wms/contract-repair/js/alpine.js new file mode 100644 index 00000000..930867c1 --- /dev/null +++ b/wms/contract-repair/js/alpine.js @@ -0,0 +1,1260 @@ +const contractDownload = ()=> { + return{ + init(){ + this.standardData = this.deepClone(this.data); + this.onstandardViewData = this.deepClone(this.data); + this.buystandardData = this.deepClone(this.buydata); + this.buyonstandardViewData = this.deepClone(this.buydata); + // CKEDITOR.replace('editor',{ + // extraplugins:'filebrowser', + // height:80, + // width:'100%', + // filebrowserUploadMethod:'form', + // filebrowserUploadUrl:'./ckeditor_upload.php' + // }); + }, + installfill1:'', + installfill2:'', + installAffix:1, + buyfill1:'', + buyfill2:'', + buyAffix:1, + 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:{ + editshow: false, + plaintext: '茲因甲方向乙方訂購電梯,並委由乙方安裝系爭電梯,經雙方同意共同訂立本合約書,其條款如下:' + }, + partyA:{ + editshow:false, + plaintext:partyAcompany , + }, + partyAcontractno:{ + editshow:false, + plaintext:partyAcontractno, + }, + list:{ + plaintext: [ + { + editshow:false, + origin:true, + text:`安裝產品名稱、數量及單價:
1、 ${people} 人座  ${floor} 停站速度每分鐘 ${speed} 公尺 交流變頻變壓電腦智能控制升降機 ${num} 部。單價:新台幣 ${numberToChinese(totalInstallPrice)} 元整( ${numberWithCommas(totalInstallPrice)} )(含5%加值型營業稅)。`, + type:'title', + deleted: false, + id:0, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'安裝產品規格:如附表一。', + type:'title', + deleted: false, + id:1, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'安裝地點:'+ partyAaddress + '。' , + type:'title', + deleted: false, + id:2, + input_id:null, + }, + { + editshow:false, + origin:true, + text:`安裝報酬:安裝勞務報酬為新台幣(以下皆同) ${numberToChinese(totalPrice)} 元整(${numberWithCommas(totalPrice)} )(含5%加值型營業稅)。`, + type:'title', + deleted: false, + id:3, + input_id:null, + }, + { + editshow:false, + origin:true, + text: install_pay_text, + type:'title', + deleted: false, + id:4, + input_id:'fill1', + }, + { + editshow:false, + origin:true, + text:'安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台__日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於__日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。', + type:'title', + deleted: false, + id:5, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'交車事項:
一、乙方完成產品安裝後,甲方應儘速理交車事宜,不得無故或藉故拖延。如經乙方通知,甲方遲未辦理交車事宜,則於乙方催告後,即視同交車完成。
二、乙方試車完成後,甲方應配合提供建物使用執照及其他竣工檢查所需文件,以利乙方代甲方辦理昇降設備竣工檢查。
三、甲方於昇降設備竣工檢查合格及取得使用許可證後,交車事項即為完成。', + type:'title', + deleted: false, + id:6, + input_id:null, + }, + + { + editshow:false, + origin:true, + text:'因故延期:
如因天災、地變及其他不可抗力之因素,或甲方未將電梯昇降路及機械室之建築工程等配合事項未於貨抵工地前七日整理完善,或甲方未將符合規格之電源於安裝前送電至機械室,或房屋建築及其他應配合相關事項未完成,致影響乙方如期安裝產品時,乙方安裝日期應依受影響日數向後延展,如因可歸責於甲方事由者亦同。', + type:'title', + deleted: false, + id:7, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'工程變更:
甲方對本工程之規格有變更設計及增減工程數量時,應於合約訂立日後壹個月內預先以書面通知乙方且需經雙方同意,如因工程變更而致乙方成本增加時,則甲方應吸收所有增加之成本並追認給付給乙方,否則乙方依原合約之貨品規格、數量交貨,甲方亦應依原合約之貨品規格、數量給付款項。', + type:'title', + deleted: false, + id:8, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'工地清理及除外事項:
一、本工程於貨到現場前,其工地廢料雜物及臨時設備,應由甲方清除整理,同時提供乙方放置貨品之處所。
二、有關建築工事回填澆灌後之清潔,應由甲方負責清理。
三、升降設備除外工程表所列之各項工程不包括於乙方本合約施作範圍,應由甲方負責處理。', + type:'title', + deleted: false, + id:9, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'電梯保養:
一、乙方完工交車後,期後__個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。', + type:'title', + deleted: false, + id:10, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'特約條款:
一、本設備器材在款項未付清前,其所有權仍歸屬乙方所有,價款付清後所有權始轉移給甲方。
二、如因甲方因素或建物設計上之疏忽,致影響驗收時,甲方不得以此做為逾期或拒付款之藉口。
三、本合約所有日數約定,均以工作天計算。', + type:'title', + deleted: false, + id:11, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'終止合約權:
一、甲乙雙方之任一方若有違反合約之事實或發生清算或破產等信用貶落情形,致工程無法進行時,經催告而未改善者,他方得終止本合約,違約方必須賠償對方之損失。
二、乙方逾期交貨或甲方逾期未交付工地受領產品逾壹個月以上經他方催告仍不改善,他方得終止本合約,並請求損害賠償。', + type:'title', + deleted: false, + id:12, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'合意管轄:
因本合約而涉訟,甲、乙方雙方同意以桃園地方法院為第一審管轄法院。催告仍不改善,他方得終止本合約,並請求損害賠償。', + type:'title', + deleted: false, + id:13, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'附則:
本合約經甲、乙雙方簽章後立即生效,甲、乙雙方各存執正副本各壹份為憑,印花雙方各自貼付。', + type:'title', + deleted: false, + id:14, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'合約附件:
本合約附件為本合約之一部份,與本合約具同等效力,甲乙雙方均應遵守之。', + type:'title', + deleted: false, + id:15, + input_id:null, + }, + ] + } + }, + buydata:{ + illustrate:{ + editshow: false, + plaintext: '茲因甲方向乙方訂購電梯,經雙方同意共同訂立本合約書,其條款如下:' + }, + partyA:{ + editshow:false, + plaintext:partyAcompany , + }, + partyAcontractno:{ + editshow:false, + plaintext:partyAcontractno, + }, + list:{ + plaintext: [ + { + editshow:false, + origin:true, + text:`產品名稱、數量及單價:
1、 ${people} 人座 ${floor} 停站速度每分鐘 ${speed} 公尺 交流變頻變壓電腦智能控制升降機 ${bigChineseArr[num]} 部。單價:新台幣 ${numberToChinese(totalBuyPrice)} 元整( ${numberWithCommas(totalBuyPrice)} )(含5%加值型營業稅)。`, + type:'title', + deleted: false, + id:0, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'產品規格:如附表一。', + type:'title', + deleted: false, + id:1, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'交貨及安裝地點:'+ partyAaddress + '。' , + type:'title', + deleted: false, + id:2, + input_id:null, + }, + { + editshow:false, + origin:true, + text:`產品總價:產品價金為新台幣 ${numberToChinese(totalBuyPrice)} 元整( ${numberWithCommas(totalBuyPrice)} )(含5%加值型營業稅)。`, + type:'title', + deleted: false, + id:3, + input_id:null, + }, + { + editshow:false, + origin:true, + text: buy_pay_text, + type:'title', + deleted: false, + id:4, + input_id:'buyfill1', + }, + { + editshow:false, + origin:true, + text:'交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第180日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。', + type:'title', + deleted: false, + id:5, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'施工規範依據:
甲方或其指定工程師,於本契約簽訂後二星期內,提供組立電梯之大樓建築有關圖面,以供乙方製作電梯配置圖,乙方製妥電梯配置圖後請甲方簽認,甲方於接獲乙方提請審核之電梯配置圖後,一星期內簽認並送還乙方,乙方應於接獲甲方簽認之電梯配置圖後,安排電梯組件之生產並按預定時間內製造完成。', + type:'title', + deleted: false, + id:6, + input_id:null, + }, + + { + editshow:false, + origin:true, + text:'因故延期:
一、如因天災、地變及其他不可抗力之因素,致影響乙方如期交付產品時,本合約第六條之交貨日期應依受影響日數向後延展,如因可歸責於甲方事由者亦同。
二、如因可歸責甲方事由致工期展延逾第六條日期時,如因物價波動致成本增加,乙方得請求物價調漲之補償,或終止合約。', + type:'title', + deleted: false, + id:7, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'工程變更:
甲方對本工程之規格有變更設計及增減工程數量時,應於合約訂立日後壹個月內預先以書面通知乙方且需經雙方同意,如因工程變更而致乙方成本增加時,則甲方應吸收所有增加之成本並追認給付給乙方,否則乙方依原合約之貨品規格、數量交貨,甲方亦應依原合約之貨品規格、數量給付款項。', + type:'title', + deleted: false, + id:8, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'工地清理及除外事項:
一、本工程於貨到現場前,其工地廢料雜物及臨時設備,應由甲方清除整理,同時提供乙方放置貨品之處所。
二、有關建築工事回填澆灌後之清潔,應由甲方負責清理。', + type:'title', + deleted: false, + id:9, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'合約時效:
本合約及其附件自簽訂之日起,至保固期滿之日止為有效期間。', + type:'title', + deleted: false, + id:10, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'特約條款:
一、本設備器材在款項未付清前,其所有權仍歸屬乙方所有,價款付清後所有權始轉移給甲方。
二、如因甲方因素或建物設計上之疏忽,致影響驗收時,甲方不得以此做為逾期或拒付款之藉口。
三、本合約所有日數約定,均以工作天計算。', + type:'title', + deleted: false, + id:11, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'終止合約權:
一、甲乙雙方之任一方若有違反合約之事實或發生清算或破產等信用貶落情形,致工程無法進行時,經催告而未改善者,他方得終止本合約,違約方必須賠償對方之損失。
二、乙方逾期交貨或甲方逾期未交付工地受領產品逾壹個月以上經他方催告仍不改善,他方得終止本合約,並請求損害賠償。', + type:'title', + deleted: false, + id:12, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'合意管轄:
因本合約而涉訟,甲、乙方雙方同意以桃園地方法院為第一審管轄法院。', + type:'title', + deleted: false, + id:13, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'附則:
本合約經甲、乙雙方簽章後立即生效,甲、乙雙方各存執正本各壹份為憑。', + type:'title', + deleted: false, + id:14, + input_id:null, + }, + { + editshow:false, + origin:true, + text:'合約附件:
本合約附件為本合約之一部份,與本合約具同等效力,甲乙雙方均應遵守之,本合約附件計有:', + type:'title', + deleted: false, + id:15, + input_id:null, + }, + ] + } + }, + fill:[], + standardData:{}, + onstandardViewData:{}, + 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){ + // clone[key].text = clone[key].text.replace(//, '___') + } + } else { + clone[key] = obj[key] + } + } + } + return clone; + }, + modelshow: false, + modelText: '', + modelContent: '', + objName: '', + isList: false, + actionType: 'i', //i=> insert , u=> update + index:0, + isInstall:true, + chineseNumbers(number){ + const units = ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']; + if (number <= 10) { + return units[number]; + } else if (number < 20) { + return '十' + units[number - 10]; + } else if (number < 30) { + return '二十' + units[number - 20]; + } else if (number < 40) { + return '三十' + units[number - 30]; + } else if (number < 50) { + return '四十' + units[number - 40]; + } else { + return '五十'; + } + }, + mouseover(obj, isInstall=true){ + if(isInstall){ + if(!this.onstandardViewData[obj].editshow){ + this.onstandardViewData[obj].editshow = true + } + }else{ + if(!this.buyonstandardViewData[obj].editshow){ + this.buyonstandardViewData[obj].editshow = true + } + } + + }, + mouseoverlist(idx, inInstall=true){ + if(inInstall){ + if(!this.onstandardViewData.list.plaintext[idx].editshow){ + this.onstandardViewData.list.plaintext[idx].editshow = true + } + }else{ + if(!this.buyonstandardViewData.list.plaintext[idx].editshow){ + this.buyonstandardViewData.list.plaintext[idx].editshow = true + } + } + + }, + mouseoutlist(idx){ + if(this.onstandardViewData.list.plaintext[idx].editshow){ + this.onstandardViewData.list.plaintext[idx].editshow = false + } + if(this.buyonstandardViewData.list.plaintext[idx].editshow){ + this.buyonstandardViewData.list.plaintext[idx].editshow = false + } + }, + mouseout(obj){ + if(this.onstandardViewData[obj].editshow){ + this.onstandardViewData[obj].editshow = false + } + if(this.buyonstandardViewData[obj].editshow){ + this.buyonstandardViewData[obj].editshow = false + } + }, + modelshowEditFn(text, obj, isList=false, isInstall=true){ + if(this.modelshow){ + return; + } + this.isInstall = isInstall + this.actionType = 'u' + this.modelshow = true + this.modelText = text + this.objName = obj + this.isList =isList + this.actionType = 'u' + if(isInstall){ + if(isList){ + this.$refs.editor.value = this.onstandardViewData.list.plaintext[obj].text + // CKEDITOR.instances.editor.setData(this.onstandardViewData.list.plaintext[obj].text); + return + } + if(!isList){ + this.$refs.editor.value = this.onstandardViewData[obj].plaintext + // CKEDITOR.instances.editor.setData(this.onstandardViewData[obj].plaintext); + return + } + }else{ + if(isList){ + this.$refs.editor.value = this.buyonstandardViewData.list.plaintext[obj].text + // CKEDITOR.instances.editor.setData(this.buyonstandardViewData.list.plaintext[obj].text); + return + } + if(!isList){ + this.$refs.editor.value = this.buyonstandardViewData[obj].plaintext + // CKEDITOR.instances.editor.setData(this.buyonstandardViewData[obj].plaintext); + return + } + } + + }, + modelcloseFn(){ + if(this.modelshow){ + this.modelshow = false + this.modelText = '' + this.modelContent = '' + this.isList = false + this.$refs.editor.value ='' + // CKEDITOR.instances.editor.setData('') + } + }, + modelshowAddUpFn(idx, isInstall=true){ + this.isInstall = isInstall + this.index = idx + this.actionType = 'i' + this.modelshow = true + this.modelText = '新增一條例' + }, + modelshowAddDownFn(idx, isInstall=true){ + this.isInstall = isInstall + this.index = idx + 1 + this.actionType = 'i' + this.modelshow = true + this.modelText = '新增一條例' + }, + updateEditor(){ + let max = 0; + if(this.isInstall){ + this.onstandardViewData.list.plaintext.forEach(item=>{ + if(item.id > max) { + max = item.id + }; + }) + }else{ + this.buyonstandardViewData.list.plaintext.forEach(item=>{ + if(item.id > max) { + max = item.id + }; + }) + } + + max = max + 1 + if(this.actionType == 'i'){ + let newObj = { + editshow:false, + origin:false, + text:this.removeTrailingNewline(this.$refs.editor.value), + // text:this.removeTrailingNewline(this.convertHtmlToPlainText(this.$refs.editor.value)), + // text:this.removeTrailingNewline(this.convertHtmlToPlainText(CKEDITOR.instances.editor.getData())), + type:'title', + deleted: false, + id:max, + } + if(this.isInstall){ + this.data.list.plaintext.splice(this.index, 0, newObj) + this.onstandardViewData.list.plaintext.splice(this.index, 0, newObj) + }else{ + this.buydata.list.plaintext.splice(this.index, 0, newObj) + this.buyonstandardViewData.list.plaintext.splice(this.index, 0, newObj) + } + this.modelcloseFn() + return + } + if(this.actionType == 'u'){ + if(this.isInstall){ + if(this.isList){ + // this.data.list.plaintext[this.objName].text = this.convertHtmlToPlainText(CKEDITOR.instances.editor.getData()) + this.data.list.plaintext[this.objName].text = this.convertHtmlToPlainText(this.$refs.editor.value) + // this.onstandardViewData.list.plaintext[this.objName].text = this.convertHtmlToPlainText(CKEDITOR.instances.editor.getData()) + // this.onstandardViewData.list.plaintext[this.objName].text = this.convertHtmlToPlainText(this.$refs.editor.value) + this.onstandardViewData.list.plaintext[this.objName].text = this.$refs.editor.value + }else{ + // this.data[this.objName].plaintext = this.convertHtmlToPlainText(CKEDITOR.instances.editor.getData()) + this.data[this.objName].plaintext = this.convertHtmlToPlainText(this.$refs.editor.value) + // this.onstandardViewData[this.objName].plaintext = this.convertHtmlToPlainText(CKEDITOR.instances.editor.getData()) + // this.onstandardViewData[this.objName].plaintext = this.convertHtmlToPlainText(this.$refs.editor.value) + this.onstandardViewData[this.objName].plaintext = this.$refs.editor.value + } + }else{ + if(this.isList){ + this.buydata.list.plaintext[this.objName].text = this.convertHtmlToPlainText(this.$refs.editor.value) + this.buyonstandardViewData.list.plaintext[this.objName].text = this.$refs.editor.value + }else{ + this.buydata[this.objName].plaintext = this.convertHtmlToPlainText(this.$refs.editor.value) + this.buyonstandardViewData[this.objName].plaintext = this.$refs.editor.value + } + } + } + this.modelcloseFn() + return + }, + deleteEditor(idx, isInstall=true){ + if(isInstall){ + if(confirm('確定要刪除嗎?')){ + let id = this.onstandardViewData.list.plaintext[idx].id + this.data.list.plaintext.forEach(item=>{ + if(item.id == id){ + item.deleted = 1; + } + }) + this.onstandardViewData.list.plaintext.splice(idx, 1) + } + }else{ + if(confirm('確定要刪除嗎?')){ + let id = this.buyonstandardViewData.list.plaintext[idx].id + // this.buydata.list.plaintext[idx].deleted = 1 + this.buydata.list.plaintext.forEach(item=>{ + if(item.id == id){ + if(!item.deleted){ + item.deleted = 1; + } + } + }) + this.buyonstandardViewData.list.plaintext.splice(idx, 1) + } + } + }, + removeTrailingNewline(str) { + return str.replace(/\n+$/, ''); + }, + convertHtmlToPlainText(htmlString) { + // 創建一個新的DOMParser對象 + var parser = new DOMParser(); + + // 使用parseFromString方法解析傳入的HTML字符串 + var doc = parser.parseFromString(htmlString, 'text/html'); + + // 返回解析後的純文本內容 + return doc.body.textContent || ''; + }, + exportFn(type){ + const form = this.$refs.form + const prviewType = this.$refs.form.querySelector('#prview-type'); + const list = this.$refs.form.querySelector('#prview-list'); + const standardList = this.$refs.form.querySelector('#standard-prview-list'); + const illustrate = this.$refs.form.querySelector('#illustrate'); + const standardIllustrate = this.$refs.form.querySelector('#standard-illustrate'); + const partyA = this.$refs.form.querySelector('#partyA'); + const partyAcontractno = this.$refs.form.querySelector('#partyAcontractno'); + const total_price = this.$refs.form.querySelector('#total_price'); + prviewType.value = type + if(type === 1){ + const standardJsonText = this.buystandardData.list.plaintext.map((item, idx)=>{ + let text = '' + text = item.text.replace(/\s+/g, "") + this.buydata.list.plaintext[idx].text = this.buydata.list.plaintext[idx].text.replace(/\s+/g, "") + + return { + text: text, + id: item.id + } + }); + const jsonText = this.buydata.list.plaintext.map(item=>{ + let text = '' + text = item.text + return { + text: text, + origin: item.origin ? 1 : 0, + deleted: item.deleted ? 1 : 0, + id: item.id, + updated: item.updated ? 1 : 0, + } + }); + list.value = JSON.stringify(jsonText) + standardList.value = JSON.stringify(standardJsonText) + illustrate.value = this.buydata.illustrate.plaintext + standardIllustrate.value = this.buystandardData.illustrate.plaintext + partyA.value = this.buydata.partyA.plaintext + partyAcontractno.value = this.buydata.partyAcontractno.plaintext + total_price.value = totalBuyPrice + form.submit(); + return; + } + if(type === 2){ + // list.value = JSON.stringify(this.data.list.plaintext) + const standardJsonText = this.standardData.list.plaintext.map((item, idx)=>{ + let text = '' + text = item.text.replace(/\s+/g, "") + if(this.data.list.plaintext[idx] !== undefined){ + this.data.list.plaintext[idx].text = this.data.list.plaintext[idx].text.replace(/\s+/g, "") + } + return { + text: text, + id: item.id + } + }) + const jsonText = this.data.list.plaintext.map(item=>{ + let text = '' + item.text + text = item.text + return { + text: text, + origin: item.origin ? 1 : 0, + deleted: item.deleted ? 1 : 0, + id: item.id, + updated: item.updated ? 1 : 0, + } + }) + list.value = JSON.stringify(jsonText) + standardList.value = JSON.stringify(standardJsonText) + illustrate.value = this.data.illustrate.plaintext + standardIllustrate.value = this.standardData.illustrate.plaintext + partyA.value = this.data.partyA.plaintext + partyAcontractno.value = this.data.partyAcontractno.plaintext + total_price.value = totalInstallPrice + form.submit(); + + return; + } + }, + toggleBuyStandard:true, + toggleInstallStandard:true, + isbuyShow:true, + sendInstallInputFn(){ + if(this.installfill1 == ''){ + alert('請輸入安裝試車期限'); + return; + } + if(this.installfill2 == ''){ + alert('請輸入免費保養月數'); + return; + } + if(this.installfill1 < 45){ + alert('安裝試車期限不得低於45日'); + return; + } + if(this.installfill1 < 1){ + alert('免費保養月數不得低於1個月'); + return; + } + this.isInstallInputIng = false + this.data.list.plaintext[1].text = '安裝產品規格:如附表'+ this.affixArr[Number(this.installAffix)] +'。' + this.standardData.list.plaintext[1].text = '安裝產品規格:如附表'+ this.affixArr[Number(this.installAffix)] +'。' + this.onstandardViewData.list.plaintext[1].text = '安裝產品規格:如附表'+ this.affixArr[Number(this.installAffix)] +'。' + this.data.list.plaintext[5].text = '安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台 '+this.installfill1+' 日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於四十五日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。' + this.standardData.list.plaintext[5].text = '安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台 '+this.installfill1+' 日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於四十五日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。' + this.onstandardViewData.list.plaintext[5].text = '安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台 '+this.installfill1+' 日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於四十五日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。' + this.data.list.plaintext[10].text = '電梯保養:
一、乙方完工交車後,期後 '+this.installfill2+' 個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。' + this.standardData.list.plaintext[10].text = '電梯保養:
一、乙方完工交車後,期後 '+this.installfill2+' 個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。' + this.onstandardViewData.list.plaintext[10].text = '電梯保養:
一、乙方完工交車後,期後 '+this.installfill2+' 個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。' + }, + sendInstallInputKeyupFn(e){ + if(e.keyCode !== 13) return + if(this.installfill1 == ''){ + alert('請輸入安裝試車期限'); + return; + } + if(this.installfill2 == ''){ + alert('請輸入免費保養月數'); + return; + } + if(this.installfill1 < 45){ + alert('安裝試車期限不得低於45日'); + return; + } + if(this.installfill1 < 1){ + alert('免費保養月數不得低於1個月'); + return; + } + this.isInstallInputIng = false + this.data.list.plaintext[1].text = '安裝產品規格:如附表'+ this.affixArr[Number(this.installAffix)] +'。' + this.standardData.list.plaintext[1].text = '安裝產品規格:如附表'+ this.affixArr[Number(this.installAffix)] +'。' + this.onstandardViewData.list.plaintext[1].text = '安裝產品規格:如附表'+ this.affixArr[Number(this.installAffix)] +'。' + this.data.list.plaintext[5].text = '安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台 '+this.installfill1+' 日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於四十五日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。' + this.standardData.list.plaintext[5].text = '安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台 '+this.installfill1+' 日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於四十五日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。' + this.onstandardViewData.list.plaintext[5].text = '安裝試車事項:
一、甲方應於實際出貨日期前七日,清理升降設備之建築物升降道,及完成底坑防水之處理,上述事項完成後,甲方即以書面或電話通知乙方進場安裝,乙方應於貨抵工地後每台 '+this.installfill1+' 日內安裝完成。
二、甲方接到乙方電梯安裝完成通知之日起,倘因甲方因素致無法於四十五日內交車時,甲方應付清總價款全部餘額。
三、如因非關乙方因素致乙方無法進場施作時,於該因素或障礙排除前,甲方應對已進場之材料或設備負保管責任及整修費用。' + this.data.list.plaintext[10].text = '電梯保養:
一、乙方完工交車後,期後 '+this.installfill2+' 個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。' + this.standardData.list.plaintext[10].text = '電梯保養:
一、乙方完工交車後,期後 '+this.installfill2+' 個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。' + this.onstandardViewData.list.plaintext[10].text = '電梯保養:
一、乙方完工交車後,期後 '+this.installfill2+' 個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。
二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。
三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。' + }, + sendBuyInputFn(){ + if(this.buyfill1 == ''){ + alert('請輸入交貨期限'); + return; + } + if(this.buyfill1 < 1){ + alert('交貨期限不得低於1日'); + return; + } + if(buyArr[1].installment == 2){ + this.buydata.list.plaintext[4].text = this.buydata.list.plaintext[4].text.replace('____', this.buyfill2); + this.buystandardData.list.plaintext[4].text = this.buydata.list.plaintext[4].text.replace('____', this.buyfill2); + this.buyonstandardViewData.list.plaintext[4].text = this.buydata.list.plaintext[4].text.replace('____', this.buyfill2); + } + this.isBuyInputIng = false + this.buydata.list.plaintext[1].text = '產品規格:如附表'+ this.affixArr[Number(this.buyAffix)] +'。' + this.buystandardData.list.plaintext[1].text = '產品規格:如附表'+ this.affixArr[Number(this.buyAffix)] +'。' + this.buyonstandardViewData.list.plaintext[1].text = '產品規格:如附表'+ this.affixArr[Number(this.buyAffix)] +'。' + this.buydata.list.plaintext[5].text = '交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第 '+this.buyfill1+' 日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。' + this.buystandardData.list.plaintext[5].text = '交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第 '+this.buyfill1+' 日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。' + this.buyonstandardViewData.list.plaintext[5].text = '交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第 '+this.buyfill1+' 日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。' + let buyAffixHtml = '' + for(let i=0;i${numberToSmallChinese(i+1)}、附表${numberToSmallChinese(i+1)}                                                       共 1 張` + } + this.buydata.list.plaintext[15].text = this.buydata.list.plaintext[15].text + buyAffixHtml + this.buystandardData.list.plaintext[15].text = this.buystandardData.list.plaintext[15].text + buyAffixHtml + this.buyonstandardViewData.list.plaintext[15].text = this.buyonstandardViewData.list.plaintext[15].text + buyAffixHtml + }, + sendBuyInputKeyupFn(e){ + if(e.keyCode !== 13) return + if(this.buyfill1 == ''){ + alert('請輸入交貨期限'); + return; + } + if(this.buyfill1 < 1){ + alert('交貨期限不得低於1日'); + return; + } + if(buyArr[1].installment == 2){ + this.buydata.list.plaintext[4].text = this.buydata.list.plaintext[4].text.replace('____', this.buyfill2); + this.buystandardData.list.plaintext[4].text = this.buydata.list.plaintext[4].text.replace('____', this.buyfill2); + this.buyonstandardViewData.list.plaintext[4].text = this.buydata.list.plaintext[4].text.replace('____', this.buyfill2); + } + this.isBuyInputIng = false + this.buydata.list.plaintext[1].text = '產品規格:如附表'+ this.affixArr[Number(this.buyAffix)] +'。' + this.buystandardData.list.plaintext[1].text = '產品規格:如附表'+ this.affixArr[Number(this.buyAffix)] +'。' + this.buyonstandardViewData.list.plaintext[1].text = '產品規格:如附表'+ this.affixArr[Number(this.buyAffix)] +'。' + this.buydata.list.plaintext[5].text = '交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第 '+this.buyfill1+' 日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。' + this.buystandardData.list.plaintext[5].text = '交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第 '+this.buyfill1+' 日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。' + this.buyonstandardViewData.list.plaintext[5].text = '交貨期限及甲方配合事項:
乙方應於接獲甲方圖色確認第 '+this.buyfill1+' 日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。' + let buyAffixHtml = '' + for(let i=0;i${numberToSmallChinese(i+1)}、附表${numberToSmallChinese(i+1)}                                                       共 1 張` + } + this.buydata.list.plaintext[15].text = this.buydata.list.plaintext[15].text + buyAffixHtml + this.buystandardData.list.plaintext[15].text = this.buystandardData.list.plaintext[15].text + buyAffixHtml + this.buyonstandardViewData.list.plaintext[15].text = this.buyonstandardViewData.list.plaintext[15].text + buyAffixHtml + }, + affixArr:['', '一', '一、二','一、二、三', '一、二、三、四', '一、二、三、四、五'], + isBuyInputIng:true, + isInstallInputIng:true, + } +}; + +const contractNewInput =()=> { + return { + init(){}, + data:{ + contractno:'', + customer:'', + manager:'', + vat:'', + case_name:'', + linkman:'', + lm_tel:'', + address:'', + salesman:'', + qc:'', + qc:'', + // files:[], + }, + step:1, + isLoading:false, + customize:false, + nextStepFn(){ + if(this.data.contractno == '') return alert('合約號為必填') + this.isLoading = true + if(this.step == 1){ + this.getContractDate(); + } + }, + nextStepKeyupFn(e){ + if(e.keyCode != 13) return + if(this.step == 1){ + this.getContractDate(); + console.log(this.step); + } + }, + preStepFn(){ + if(this.step == 2){ + this.step = 1 + } + }, + getContractDate(){ + axios.get('./api/getContractData.php?contracttype=m&contractno=' + this.data.contractno).then(res=>{ + if(!res.data){ + this.step = 2 + this.isLoading = false + return + } + if(!this.customize){ + console.log(res.data); + this.data.customer = res.data.customer + this.data.manager = res.data.manager + this.data.vat = res.data.uscc + this.data.case_name = res.data.case_name + this.data.linkman = res.data.linkman + this.data.lm_tel = res.data.lm_tel + this.data.address = res.data.address + this.data.salesman = res.data.salesman + this.data.qc = res.data.qc + } + this.step = 2 + this.isLoading = false + }).catch(err=>{ + console.error(err) + this.isLoading = false + }) + }, + save(){ + this.isLoading = true + const form = new FormData(); + form.append('contractno', this.data.contractno); + form.append('customer', this.data.customer); + form.append('manager', this.data.manager); + form.append('vat', this.data.vat); + form.append('case_name', this.data.case_name); + form.append('linkman', this.data.linkman); + form.append('lm_tel', this.data.lm_tel); + form.append('address', this.data.address); + form.append('salesman', this.data.salesman); + form.append('qc', this.data.qc); + form.append('contracttype', 'm'); + form.append('user_id', user_id); + for (var i = 0; i < this.data.files.length; i++) { + form.append('files[]', this.data.files[i]); + } + axios.post('./api/postNewContractData.php', form).then(res=>{ + console.log(res); + if(res.status === 201){ + alert('儲存成功'); + this.step = 1 + this.data.contractno='' + this.data.customer='' + this.data.manager='' + this.data.vat='' + this.data.case_name='' + this.data.linkman='' + this.data.lm_tel='' + this.data.address='' + this.data.salesman='' + this.data.qc='' + this.data.files=[] + this.customize = false + + }else{ + alert('儲存失敗!可能為以下錯誤:\n' + res.data) + } + this.isLoading = false + }).catch(error=>{ + let code = error.response.status; + if(code == 422){ + this.fail_arr = error.response.data + this.errorFn(); + } + if(code == 500){ + alert('儲存失敗!可能為以下錯誤:\n' + error.response.data) + } + + this.isLoading = false + }) + }, + errorFn(){ + let msg = '' + for(let i = 0; i < this.fail_arr.length; i++){ + msg += this.fail_arr[i] + '、' + } + alert(msg) + }, + uploadFiles(e){ + this.data.files = e.target.files + }, + } +}; + +const contractInput =()=> { + return{ + init(){ + $('.contract-input-component .form .dropdown').dropdown(); + + axios.get('./twzip.json').then(res=>{ + this.cities = res.data.cities + }) + }, + cities:[], + data:{ + contractno:'B23100060', + total_price:'', //合約總價 + vat:'', //統一編號 + mtype:'A', //維修型態 + phone:'', //客戶電話 + email:'', //Email + mworker:'', //保養員 + mcycle:'', //保養頻率 + salesman:'', //營業員 + contract_begin_date:'', //合約開始時間 + contract_end_date:'', //合約終止時間 + area:'', //區域 + zip:'', //郵遞區號 + address:'', //地址 + customer:'', //立約人 + partyA:'', //業務聯繫人 + partyAaddress:'', //業務聯繫人地址 + partyAphone:'', //業務聯繫人電話 + partyAemail:'', //業務聯繫人email + files:[], //附件檔案 + num:'', //電梯數量 + disabled:false, //資料庫是否有電梯數量資料 + elevators:[], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 + }, + customize:false, + step:1, + isLoading:false, + fail_arr:[], + nextStepFn(){ + if(this.step==1){ + if(this.data.contractno == '') return alert('請輸入合約號'); + this.isLoading = true + this.getContractDate(); + }else if(this.step == 2){ + if(this.data.num <= 0) return alert('請填寫電梯數量!') + if(!this.data.disabled){ + this.createElevator(); + } + this.step = 3 + } + }, + nextStepKeyupFn(e){ + if(e.keyCode !== 13) return + if(this.step==1){ + if(this.data.contractno == '') return alert('請輸入合約號'); + this.isLoading = true + this.getContractDate(); + + }else if(this.step == 2){ + this.step = 3 + } + }, + createElevator(){ + for(let i=0;i{ + if(!res.data){ + this.step = 2 + this.isLoading = false + return + } + if(!this.customize){ + console.log(res.data); + this.data.total_price = res.data.sold_price + this.data.salesman = res.data.salesman + this.data.contract_begin_date = res.data.contract_begin_date + this.data.contract_end_date = res.data.contract_end_date + this.data.address = res.data.address + this.data.customer = res.data.customer + this.data.partyA = res.data.customer + this.data.partyAaddress = res.data.address + this.data.num = res.data.num + this.data.disabled = (res.data.num > 0) ? true : false; + this.data.elevators = res.data.elevators + let cityIndex = this.data.address.indexOf('市'); + console.log(cityIndex); + if(cityIndex == -1) { + cityIndex = this.data.address.indexOf('縣'); + } + if (cityIndex > 1) { + // 獲取''市''前面的兩個字 + let city = this.data.address.substring(cityIndex - 2, cityIndex + 1); + this.data.area = city; + } else { + this.data.area = '' + } + } + this.step = 2 + this.isLoading = false + }).catch(err=>{ + console.error(err) + this.isLoading = false + }) + }, + preStepFn(){ + if(this.step==2){ + if(confirm('回到上一頁會將會初始化資料,確定返回嗎?')){ + this.step = 1 + this.data.total_price = '' + this.data.salesman = '' + this.data.contract_begin_date = '' + this.data.contract_end_date = '' + this.data.address = '' + this.data.customer = '' + this.data.partyA = '' + this.data.partyAaddress = '' + this.step = 1 + this.data.num = '' + this.data.disabled = false + this.data.elevators = [] + this.data.files = [] + this.data.vat = '' + this.data.mtype = '' + this.data.phone = '' + this.data.email = '' + this.data.mworker = '' + this.data.mcycle = '' + this.data.area = '' + this.data.zip = '' + this.data.partyAphone = '' + this.data.partyAemail = '' + return; + } + }else if(this.step == 3){ + this.step = 2 + } + }, + save(){ + this.isLoading = true + const form = new FormData(); + form.append('contractno', this.data.contractno); + form.append('total_price', this.data.total_price); + form.append('vat', this.data.vat); + form.append('mtype', this.data.mtype); + form.append('phone', this.data.phone); + form.append('email', this.data.email); + form.append('mworker', this.data.mworker); + form.append('mcycle', this.data.mcycle); + form.append('salesman', this.data.salesman); + form.append('contract_begin_date', this.data.contract_begin_date); + form.append('contract_end_date', this.data.contract_end_date); + form.append('address', this.data.address); + form.append('area', this.data.area); + form.append('customer', this.data.customer); + form.append('partyA', this.data.partyA); + form.append('partyAaddress', this.data.partyAaddress); + form.append('partyAphone', this.data.partyAphone); + form.append('partyAemail', this.data.partyAemail); + form.append('user_id', user_id); + form.append('user_name', user_name); + form.append('num', this.data.num); + form.append('elevators', JSON.stringify(this.data.elevators)); + form.append('contracttype', 'b'); + + // 如果有附件檔案,可以逐一加入 + for (var i = 0; i < this.data.files.length; i++) { + form.append('files[]', this.data.files[i]); + } + axios.post('./api/postContractData.php', form).then(res=>{ + console.log(res.status); + if(res.status === 200){ + alert('儲存成功'); + this.step = 1 + this.data.total_price = '' + this.data.salesman = '' + this.data.contract_begin_date = '' + this.data.contract_end_date = '' + this.data.address = '' + this.data.customer = '' + this.data.partyA = '' + this.data.partyAaddress = '' + this.step = 1 + this.data.num = '' + this.data.disabled = false + this.data.elevators = [] + this.data.files = [] + this.data.vat = '' + this.data.mtype = '' + this.data.phone = '' + this.data.email = '' + this.data.mworker = '' + this.data.mcycle = '' + this.data.area = '' + this.data.zip = '' + this.data.partyAphone = '' + this.data.partyAemail = '' + } + this.isLoading = false + }).catch(error=>{ + let code = error.response.status; + if(code == 422){ + this.fail_arr = error.response.data + this.errorFn(); + } + if(code == 500){ + alert('儲存失敗!可能為以下錯誤:\n' + error.response.data) + } + + this.isLoading = false + }) + }, + errorFn(){ + let msg = '' + for(let i = 0; i < this.fail_arr.length; i++){ + msg += this.fail_arr[i] + '、' + } + alert(msg) + }, + uploadFiles(e){ + this.data.files = e.target.files + }, + } +}; + +const contractNewApply = ()=>{ + return { + step:1, + isLoading:false, + data:{ + mid: mid, + vol_no: contractno, + salesman: salesman, + salesmanname:salesmanname, + apply_date: apply_date, + apply_type:'A', + case_name: case_name, + company: company, + manager: manager, + vat: vat, + total_price: price_total, + price_a: price_a, + price_b: price_b, + address: address, + workdeadline_a:30, //完工期限: 幾天內安裝完成,預設30 + workdeadline_b:7, //完工期限: 幾天內整理完善,預設7 + regulations:10, //附則 + freedeadline:18, //免保期限(月) + tradeaddress:'', //交貨地點 + tradedeadline: 90, //交貨期限 + items: items, + }, + pays:{ + 1:0, + 2:0, + 3:0, + 4:0, + 5:0, + 6:0, + 7:0, + }, + tickets:{ + 1:0, + 2:0, + 3:0, + 4:0, + 5:0, + 6:0, + 7:0, + }, + localnumber(num){ + return num.toLocaleString(); + }, + storageFn(){ + this.isLoading = true + const isFirst = 1; + const form = new FormData(); + form.append('mid', this.data.mid); + form.append('vol_no', this.data.vol_no); + form.append('salesman', this.data.salesman); + form.append('apply_date', this.data.apply_date); + form.append('apply_type', this.data.apply_type); + form.append('case_name', this.data.case_name); + form.append('company', this.data.company); + form.append('manager', this.data.manager); + form.append('vat', this.data.vat); + form.append('total_price', this.data.total_price); + form.append('price_a', this.data.price_a); + form.append('price_b', this.data.price_b); + form.append('address', this.data.address); + form.append('workdeadline_a', this.data.workdeadline_a); + form.append('workdeadline_b', this.data.workdeadline_b); + form.append('regulations', this.data.regulations); + form.append('freedeadline', this.data.freedeadline); + form.append('tradeaddress', this.data.tradeaddress); + form.append('tradedeadline', this.data.tradedeadline); + form.append('isFirst', isFirst); + form.append('user_id', user_id); + axios.post('./api/postContractNewApplyData.php', form).then(res=>{ + if(res.status === 200){ + alert('暫存成功'); + console.log(res.data); + } + this.isLoading = false + }).catch(error=>{ + alert('儲存失敗!可能為以下錯誤:\n' + error.response.data) + this.isLoading = false + }) + } + } +} \ No newline at end of file diff --git a/wms/contract-repair/js/alpinejs/cdn.min.js b/wms/contract-repair/js/alpinejs/cdn.min.js new file mode 100644 index 00000000..922cc02e --- /dev/null +++ b/wms/contract-repair/js/alpinejs/cdn.min.js @@ -0,0 +1,5 @@ +(()=>{var Ze=!1,Qe=!1,H=[],et=-1;function zt(e){En(e)}function En(e){H.includes(e)||H.push(e),vn()}function we(e){let t=H.indexOf(e);t!==-1&&t>et&&H.splice(t,1)}function vn(){!Qe&&!Ze&&(Ze=!0,queueMicrotask(Sn))}function Sn(){Ze=!1,Qe=!0;for(let e=0;ee.effect(t,{scheduler:r=>{tt?zt(r):r()}}),rt=e.raw}function nt(e){I=e}function qt(e){let t=()=>{};return[n=>{let i=I(n);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),L(i))},i},()=>{t()}]}function q(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}function O(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>O(i,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)O(n,t,!1),n=n.nextElementSibling}function v(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var Ut=!1;function Wt(){Ut&&v("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),Ut=!0,document.body||v("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's `