diff --git a/wms/contract/api/getFacilityNo.php b/wms/contract/api/getFacilityNo.php index fcf0b76f..55df3c57 100644 --- a/wms/contract/api/getFacilityNo.php +++ b/wms/contract/api/getFacilityNo.php @@ -1,518 +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 "

"; + 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/api/postContractData.php b/wms/contract/api/postContractData.php index 8065babd..a2ae94d2 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -140,7 +140,13 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c } echo json_encode($facility_arr); // 電梯做番號 - $facilityno = $createFacilityNo->makeBFacilityNo("B", $facility_arr, (int)$num); + $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); + // if ($user_id == 'M0225') { + // echo '
';
+        //     print_r($facilityno);
+        //     echo '
'; + // exit(); + // } echo json_encode($facilityno); echo '-------'; $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; @@ -307,12 +313,22 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->execute(); - header('Content-Type: application/json'); - $jsonData = json_encode($files); - + // $date = date('Y-m-sH-s-i'); + // $createTime = str_replace("-", '', $date); + // $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)"; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':BizPartnerId', $contractno); + // $stmt->bindParam(':PersonId', $salesman); + // $stmt->bindParam(':CreatorId', $user_id); + // $stmt->bindParam(':InvoiceAddress', $address); + // $stmt->bindParam(':CreateTime', $createTime); + // $stmt->execute(); T8insert($_POST, $facilityno); + header('Content-Type: application/json'); + $jsonData = json_encode($files); + $conn->commit(); } catch (PDOException $e) { $conn->rollback(); @@ -338,102 +354,139 @@ function T8insert($data, $facilityno) $contract_end_date = !empty($data['contract_end_date']) ? $data['contract_end_date'] : null; $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量 $elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯 + $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; - if ($elevators['maintainance'] == 'A') { - $elevators['maintainance'] = 'C3'; - } else if ($elevators['maintainance'] == 'B') { - $elevators['maintainance'] = 'C4'; - } else if ($elevators['maintainance'] == 'C') { - $elevators['maintainance'] = 'C5'; - } + $connT8->beginTransaction(); $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; $stmt = $conn->prepare($sql); - $stmt->bindParama(':BizPartnerId', $contractno); + $stmt->bindParam(':BizPartnerId', $contractno); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $date = date('Y-m-sH-s-i'); $createTime = str_replace("-", '', $date); $beginDate = str_replace("-", '', $contract_begin_date); $endDate = str_replace("-", '', $contract_end_date); - if (empty($result)) { - // 若 客戶資料為空,新增一筆到 comCustomer - // 新增客戶資料 - $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)"; - $stmt = $connT8->prepare($sql); - - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->bindParam(':PersonId', $salesman); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':InvoiceAddress', $address); - $stmt->bindParam(':CreateTime', $createTime); + // if (empty($result)) { + // 若 客戶資料為空,新增一筆到 comCustomer + // 新增客戶資料 + $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)"; + $stmt = $connT8->prepare($sql); - $stmt->execute(); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':InvoiceAddress', $address); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); - $sql = "INSERT INTO comBusinessPartner(BizPartnerId,BizPartnerName,WorkTelNo,TaxNo,EnterpriseName,ContractAddress,EMail,CreatorId,CreateTime)VALUES(:BizPartnerId,:BizPartnerName,:WorkTelNo,:TaxNo,:EnterpriseName,:ContractAddress,:EMail,:CreatorId,:CreateTime)"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->bindParam(':BizPartnerName', $partyA); - $stmt->bindParam(':WorkTelNo', $phone); - $stmt->bindParam(':TaxNo', $vat); - $stmt->bindParam(':EnterpriseName', $customer); //企業名稱 - $stmt->bindParam(':ContractAddress', $partyAaddress); - $stmt->bindParam(':EMail', $email); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); - } else { - // 若客戶資料不為空,更新該客戶資訊。 - $sql = "UPDATE comCustomer SET - PersonId=:PersonId, - InvoiceAddress=:InvoiceAddress, - LastOperatorId=:LastOperatorId, - LastOperateTime=:LastOperateTime, - WHERE BizPartnerId=:BizPartnerId - "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':PersonId', $salesman); - $stmt->bindParam(':InvoiceAddress', $address); - $stmt->bindParam(':LastOperatorId', $user_id); - $stmt->bindParam(':LastOperateTime', $createTime); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); + // $sql = "INSERT INTO comBusinessPartner(BizPartnerId,BizPartnerName,WorkTelNo,TaxNo,EnterpriseName,ContractAddress,EMail,CreatorId,CreateTime)VALUES(:BizPartnerId,:BizPartnerName,:WorkTelNo,:TaxNo,:EnterpriseName,:ContractAddress,:EMail,:CreatorId,:CreateTime)"; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':BizPartnerId', $contractno); + // $stmt->bindParam(':BizPartnerName', $partyA); + // $stmt->bindParam(':WorkTelNo', $phone); + // $stmt->bindParam(':TaxNo', $vat); + // $stmt->bindParam(':EnterpriseName', $customer); //企業名稱 + // $stmt->bindParam(':ContractAddress', $partyAaddress); + // $stmt->bindParam(':EMail', $email); + // $stmt->bindParam(':CreatorId', $user_id); + // $stmt->bindParam(':CreateTime', $createTime); + // $stmt->execute(); + // } else { + // // 若客戶資料不為空,更新該客戶資訊。 + // $sql = "UPDATE comCustomer SET + // PersonId=:PersonId, + // InvoiceAddress=:InvoiceAddress, + // LastOperatorId=:LastOperatorId, + // LastOperateTime=:LastOperateTime, + // WHERE BizPartnerId=:BizPartnerId + // "; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':PersonId', $salesman); + // $stmt->bindParam(':InvoiceAddress', $address); + // $stmt->bindParam(':LastOperatorId', $user_id); + // $stmt->bindParam(':LastOperateTime', $createTime); + // $stmt->bindParam(':BizPartnerId', $contractno); + // $stmt->execute(); - $sql = "UPDATE comBusinessPartner SET - BizPartnerName=:BizPartnerName, - WorkTelNo=:WorkTelNo, - TaxNo=:TaxNo, - EnterpriseName=:EnterpriseName, - ContractAddress=:ContractAddress, - EMail=:EMail, - LastOperatorId=:LastOperatorId, - LastOperateTime=:LastOperateTime - "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerName', $partyA); - $stmt->bindParam(':WorkTelNo', $phone); - $stmt->bindParam(':TaxNo', $vat); - $stmt->bindParam(':EnterpriseName', $customer); - $stmt->bindParam(':ContractAddress', $partyAaddress); - $stmt->bindParam(':EMail', $email); - $stmt->bindParam(':LastOperatorId', $user_id); - $stmt->bindParam(':LastOperateTime', $createTime); - $stmt->execute(); - } - //新增於 comProject - $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,ValidityToDate,:CreateTime,:CreatorId,1)"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':ProjectId', $contractno); - $stmt->bindParam(':ProjectName', $customer); - $stmt->bindParam(':TypeId', $elevators['maintainance']); - $stmt->bindParam(':ValidityFromDate', $beginDate); - $stmt->bindParam(':ValidityToDate', $endDate); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->execute(); + // $sql = "UPDATE comBusinessPartner SET + // BizPartnerName=:BizPartnerName, + // WorkTelNo=:WorkTelNo, + // TaxNo=:TaxNo, + // EnterpriseName=:EnterpriseName, + // ContractAddress=:ContractAddress, + // EMail=:EMail, + // LastOperatorId=:LastOperatorId, + // LastOperateTime=:LastOperateTime + // WHERE BizPartnerId = :BizPartnerId + // "; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':BizPartnerName', $partyA); + // $stmt->bindParam(':WorkTelNo', $phone); + // $stmt->bindParam(':TaxNo', $vat); + // $stmt->bindParam(':EnterpriseName', $customer); + // $stmt->bindParam(':ContractAddress', $partyAaddress); + // $stmt->bindParam(':EMail', $email); + // $stmt->bindParam(':LastOperatorId', $user_id); + // $stmt->bindParam(':LastOperateTime', $createTime); + // $stmt->bindParam(':BizPartnerId', $contractno); + // $stmt->execute(); + // } + + // //新增於 comProject。合約 table + // $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,ValidityToDate,:CreateTime,:CreatorId,1)"; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':ProjectId', $contractno); + // $stmt->bindParam(':ProjectName', $customer); + // $stmt->bindParam(':TypeId', $elevators['maintainance']); + // $stmt->bindParam(':ValidityFromDate', $beginDate); + // $stmt->bindParam(':ValidityToDate', $endDate); + // $stmt->bindParam(':CreateTime', $createTime); + // $stmt->bindParam(':CreatorId', $user_id); + // $stmt->execute(); + + + // // 新增電梯數 + // foreach ($elevators as $index => $elevator) { + // echo '
';
+    // print_r($elevator);
+    // echo '
'; + // if ($elevator['maintainance'] == 'A') { + // $elevator['maintainance'] = 'C3'; + // } else if ($elevator['maintainance'] == 'B') { + // $elevator['maintainance'] = 'C4'; + // } else if ($elevator['maintainance'] == 'C') { + // $elevator['maintainance'] = 'C5'; + // } + // $sql = "INSERT INTO comMaterial(MaterialId,MaterialCategoryId,CreatorId,CreateTime) VALUES (:MaterialId,'E',:CreatorId,:CreateTime)"; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':MaterialId', $facilityno[$index]); + // $stmt->bindParam(':CreatorId', $user_id); + // $stmt->bindParam(':CreateTime', $createTime); + // $stmt->execute(); + // /// 還沒修完 + + // $sql = "INSERT INTO comMaterialGroup(MaterialId,MaterialName,MaterialCategoryId,UnitId,CreatorId,CreateTime) VALUES (:MaterialId,:MaterialName,'E','SET',:CreatorId,:CreateTime)"; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':MaterialId', $facilityno[$index]); + // $stmt->bindParam(':MaterialName', $customer); + // $stmt->bindParam(':CreatorId', $user_id); + // $stmt->bindParam(':CreateTime', $createTime); + // $stmt->execute(); + // /// 還沒修完 + + // $sql = "INSERT INTO comMaterialPurchases(MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime) VALUES (:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)"; + // $stmt = $connT8->prepare($sql); + // $stmt->bindParam(':MaterialId', $facilityno[$index]); + // $stmt->bindParam(':CreatorId', $user_id); + // $stmt->bindParam(':CreateTime', $createTime); + // $stmt->execute(); + + $connT8->commit(); + // } } diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index 6207df0e..e5a32c6c 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -8,7 +8,7 @@ try { // $stmt = $connT8->prepare($sql); // $stmt->execute(); - $sql = "UPDATE comBusinessPartner SET WorkTelNo = '' WHERE BizPartnerId='M0225202301'"; + $sql = "UPDATE comBusinessPartner SET WorkTelNo = '' WHERE BizPartnerId= 'M0225202301'"; $stmt = $connT8->prepare($sql); $stmt->execute();