From 11abc3ceef9e61a3d023d5a2550143470ebf9e8e Mon Sep 17 00:00:00 2001 From: "gary_chen\\gary_chen" Date: Mon, 13 Nov 2023 16:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=A4=A7=E6=97=A5=E7=A8=8B?= =?UTF-8?q?=E7=94=B3=E8=AB=8B=E8=A8=88=E7=95=AB=E5=9C=96=E4=B8=8A=E5=82=B3?= =?UTF-8?q?=E7=B0=BD=E6=A0=B8=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...change-planning-customer-name-function.php | 13 +- ...e-change-planning-customer-name-submit.php | 239 +++++++----------- ...wipwhole-change-planning-customer-name.php | 42 +-- wms/wipwhole-rec-invoice-edit.php | 92 ++++--- 4 files changed, 166 insertions(+), 220 deletions(-) diff --git a/wms/wipwhole-change-planning-customer-name-function.php b/wms/wipwhole-change-planning-customer-name-function.php index 14f6fae6..a5ae80ad 100644 --- a/wms/wipwhole-change-planning-customer-name-function.php +++ b/wms/wipwhole-change-planning-customer-name-function.php @@ -33,6 +33,8 @@ function isLeader($link, $user_id) return true; if (getDepartmentId($link, $user_id) == '315' && getRoleId($link, $user_id) == '1') return true; + if (getDepartmentId($link, $user_id) == '220' && getRoleId($link, $user_id) == '1') + return true; return false; } @@ -426,10 +428,8 @@ function getChangeStatus($link, $cid) function getChangeStatusName($link, $cid) { $dataArr = array( - 'A' => '申請中', 'B' => '申請中', 'C' => '已取消', - 'D' => '工務已通過', 'Z' => '已通過', ); $sql = " @@ -628,19 +628,14 @@ function getAssignStatusSelect($link, $user_id, $nowFormStatus) $options_str = ""; diff --git a/wms/wipwhole-change-planning-customer-name-submit.php b/wms/wipwhole-change-planning-customer-name-submit.php index 689aadb5..8dbffb67 100644 --- a/wms/wipwhole-change-planning-customer-name-submit.php +++ b/wms/wipwhole-change-planning-customer-name-submit.php @@ -13,7 +13,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $tds = date("Y-m-d H:i:s"); // 單次申請 - if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && empty($all_contractno_change)) { + if (($_POST['assign_status'] == 'B') && empty($all_contractno_change)) { $data_arr = array( 'id' => $id, 'all_contractno_change' => $all_contractno_change, @@ -40,7 +40,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } // 批次申請 - if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && !empty($all_contractno_change)) { + if (($_POST['assign_status'] == 'B') && !empty($all_contractno_change)) { $wipwholestatus_id_arr = getWipwholestatusIdByConstractNo($link, $contractno); $customer_planning_verify_file = fileIUpload("customer_planning_verify_file"); @@ -74,71 +74,45 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } } - // 單次申請 營業 - if ($_POST['assign_status'] == 'D') { - $tds = date("Y-m-d H:i:s"); - $next_users = $_POST['next_users']; - $seq = $_POST['seq']; - $sql = " - UPDATE wipwhole_change_planning_customer_details - SET change_status = 'D' - WHERE id = '$cid' - "; - mysqli_query($link, $sql); - $sql = " - UPDATE flow - SET flow_code = 'D' - WHERE form_key = '$form_key' - "; - mysqli_query($link, $sql); - $sql = " - INSERT into subflow ( - form_key, - seq, - current_assigner, - create_date - ) VALUES ( - '$form_key', - '2', - '$next_users', - '$tds' - ) - "; - mysqli_query($link, $sql); - } + // // 單次申請 營業 + // if ($_POST['assign_status'] == 'B') { + // $tds = date("Y-m-d H:i:s"); + // $next_users = $_POST['next_users']; + // $seq = $_POST['seq']; + // $sql = " + // UPDATE wipwhole_change_planning_customer_details + // SET change_status = 'D' + // WHERE id = '$cid' + // "; + // mysqli_query($link, $sql); + // $sql = " + // UPDATE flow + // SET flow_code = 'D' + // WHERE form_key = '$form_key' + // "; + // mysqli_query($link, $sql); + // $sql = " + // INSERT into subflow ( + // form_key, + // seq, + // current_assigner, + // create_date + // ) VALUES ( + // '$form_key', + // '2', + // '$next_users', + // '$tds' + // ) + // "; + // mysqli_query($link, $sql); + // } + // 取消 if ($_POST['assign_status'] == 'C') { $tds = date("Y-m-d H:i:s"); $next_users = "00000"; - if ($user_id == 'M0060') { - if (getChangeStatus($link, $cid) == 'D' || getChangeStatus($link, $cid) == 'A') { - $seq = $_POST['seq']; - } - $sql = " - INSERT into subflow ( - form_key, - seq, - current_assigner, - create_date - ) VALUES ( - '$form_key', - '$seq', - '$next_users', - '$tds' - ) - "; - mysqli_query($link, $sql); - } else if (isLeader($link, $user_id)) { - if (getChangeStatus($link, $cid) == 'D') { - $sql = " - UPDATE subflow - SET current_assigner = '$next_users', - create_date = '$tds' - WHERE form_key = '$form_key' - AND seq = '$seq' - "; - mysqli_query($link, $sql); - } else if (getChangeStatus($link, $cid) == 'A') { + if (isLeader($link, $user_id)) { + if (getChangeStatus($link, $cid) == 'B') { $seq = $_POST['seq']; $sql = " UPDATE subflow @@ -192,89 +166,66 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // 通過 if ($_POST['assign_status'] == 'Z') { - if ($user_id == 'M0060') { - $tds = date("Y-m-d H:i:s"); - $next_users = $_POST['next_users']; - $seq = $_POST['seq'] + 1; - $sql = " - UPDATE wipwhole_change_planning_customer_details - SET change_status = 'Z' - WHERE id = '$cid' - "; - mysqli_query($link, $sql); - $sql = " - UPDATE flow - SET flow_code = 'Z' - WHERE form_key = '$form_key' - "; - mysqli_query($link, $sql); - $sql = " - INSERT into subflow ( - form_key, - seq, - current_assigner, - create_date - ) VALUES ( - '$form_key', - '$seq', - '$next_users', - '$tds' - ) - "; - mysqli_query($link, $sql); - - // // 發送系統通知 - // $contractno = $_POST['contractno']; - // $facilityno = $_POST['facilityno']; - // $real_contract_arrival_date = $_POST['real_contract_arrival_date']; - // $salesid = $_POST['salesid']; - // $gongWuokid = $_POST['gongWuokid']; - // $old_real_address = $_POST['old_real_address']; - // $real_address = $_POST['real_address']; - // $content = "合約號 : $contractno - // 作番號 : $facilityno - // 出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . " - // 工地地址微調: " . $old_real_address . " => " . $real_address_tmp; - - // // 大日程出貨日調整 通知營業人員 - // $noticeData = array( - // 'related_id' => $cid, - // 'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno, - // 'content' => $content, - // 'permission' => $salesid, - // ); - // addNotice($link, $noticeData); - // // 大日程出貨日調整 通知工務人員 - // $noticeData = array( - // 'related_id' => $cid, - // 'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno, - // 'content' => $content, - // 'permission' => $gongWuokid, - // ); - // addNotice($link, $noticeData); - // $shengguano_arr = getShengguanokOptions($link); - // foreach ($shengguano_arr as $row) : - // $contractno = $_POST['contractno']; - // $facilityno = $_POST['facilityno']; - // $real_contract_arrival_date = $_POST['real_contract_arrival_date']; - // $gongWuokid = $_POST['gongWuokid']; - // $old_real_address = $_POST['old_real_address']; - // $real_address = $_POST['real_address']; - // $content = "合約號 : $contractno - // 作番號 : $facilityno - // 出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . " - // 工地地址微調: " . $old_real_address . " => " . $real_address_tmp; + $tds = date("Y-m-d H:i:s"); + $next_users = $_POST['next_users']; + $seq = $_POST['seq'] + 1; + $customer_planning_verify_file = fileIUpload("customer_planning_verify_file"); + $all_contractno_change = empty($_POST['all_contractno_change']) ? null : $_POST['all_contractno_change']; + $custom_name = $_POST['custom_name']; + $contractno = $_POST['contractno']; - // // 大日程出貨日調整 通知營業人員 - // $noticeData = array( - // 'related_id' => $cid, - // 'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno, - // 'content' => $content, - // 'permission' => $row['val'], - // ); - // addNotice($link, $noticeData); - // endforeach; + if (isLeader($link, $user_id)){ + $data_arr = array( + 'id' => $id, + 'all_contractno_change' => $all_contractno_change, + 'custom_name' => $custom_name, + 'contractno' => $contractno, + 'tds' => $tds, + 'form_key' => getFomkeySeq($link), + 'user_id' => $user_id, + 'customer_planning_verify_file' => $customer_planning_verify_file, + 'change_status' => $_POST['assign_status'] + ); + addWipwholeChangeContractdateDetails($link, $data_arr); + // 取得寫入後表單seq + $data_arr['last_id'] = $link->insert_id; + // 寫入待簽 + addFlow($link, $data_arr); + $data_arr['seq'] = '0'; + $data_arr['current_assigner'] = $user_id; + addSubflow($link, $data_arr); + $data_arr['seq'] = '1'; + $data_arr['current_assigner'] = $next_users; + addSubflow($link, $data_arr); } + + $form_key = getFomkeySeq($link); + $sql = " + UPDATE wipwhole_change_planning_customer_details + SET change_status = 'Z' + WHERE id = '$cid' + "; + mysqli_query($link, $sql); + $sql = " + UPDATE flow + SET flow_code = 'Z' + WHERE form_key = '$form_key' + "; + mysqli_query($link, $sql); + $sql = " + INSERT into subflow ( + form_key, + seq, + current_assigner, + create_date + ) VALUES ( + '$form_key', + '$seq', + '$next_users', + '$tds' + ) + "; + mysqli_query($link, $sql); } } diff --git a/wms/wipwhole-change-planning-customer-name.php b/wms/wipwhole-change-planning-customer-name.php index c2bc904e..24a9e5cc 100644 --- a/wms/wipwhole-change-planning-customer-name.php +++ b/wms/wipwhole-change-planning-customer-name.php @@ -269,7 +269,7 @@ if (!empty(checkNowFormStatus($link))) 填寫客戶姓名 - + "; @@ -281,8 +281,8 @@ if (!empty(checkNowFormStatus($link))) 上傳計劃圖 - - + 下載附件" : ""; ?> @@ -326,7 +326,11 @@ if (!empty(checkNowFormStatus($link))) if (empty(checkNowFormStatus($link))) { if (isLeader($link, $user_id)) { - echoMaxSelect($max_options); + echo " + + "; } else if (in_array(getDepartmentId($link, $user_id), [ '311', '312', '313', '314', '315', '501', '511', '512', '513', '514', @@ -340,16 +344,8 @@ if (!empty(checkNowFormStatus($link))) endforeach; echo ""; } - } else if (checkNowFormStatus($link) == 'A' || checkNowFormStatus($link) == 'D') { - echo " - - "; } else if (checkNowFormStatus($link) == 'B') { if (isLeader($link, $user_id)) { - echoMaxSelect($max_options); - } else { echo " "; echo ""; - } else if (checkNowFormStatus($link) == 'A') { - if ($user_id == 'M0060') { - echo ""; - } else if (isLeader($link, $user_id)) { - echo ""; - } else { - echo ""; - } - echo ""; } else if (checkNowFormStatus($link) == 'B') { if (isLeader($link, $user_id)) { echo ""; - } else if ($user_id == 'M0060') { - echo ""; - } else { - echo ""; - } - echo ""; - } else if (checkNowFormStatus($link) == 'D') { - if (isLeader($link, $user_id)) { - echo ""; - } else if ($user_id == 'M0060') { - echo ""; } else { echo ""; } echo ""; - } + } ?> diff --git a/wms/wipwhole-rec-invoice-edit.php b/wms/wipwhole-rec-invoice-edit.php index 075ad168..945ef6ec 100644 --- a/wms/wipwhole-rec-invoice-edit.php +++ b/wms/wipwhole-rec-invoice-edit.php @@ -1334,7 +1334,7 @@ include "wipwhole-rec-invoice-edit-submit.php"; (工務助理項目) - + 安裝發包廠商 @@ -1913,7 +1913,6 @@ include "wipwhole-rec-invoice-edit-submit.php"; // 發包類型 let outsourcer_type = $("input[name^='outsourcer_type']:checked").val(); - // 預計出貨日(到工地) let real_contract_arrival_date = $("#real_contract_arrival_date").val(); // 樓停 @@ -1921,38 +1920,63 @@ include "wipwhole-rec-invoice-edit-submit.php"; // 目前操作者 let user_id = ''; - if (outsourcer_type === 'I') { - resetTOutSourcerDate(); - $("#estimate_install_start_date").val(dateAddDays(real_contract_arrival_date, 5)); - $("#estimate_install_start_date_owner").val(user_id); - $("#estimate_install_end_date").val( - dateAddDays($("#estimate_install_start_date").val(), specificationDayFormula(numberofstop)) - ); - $("#estimate_install_end_date_owner").val(user_id); - } - if (outsourcer_type === 'T') { - resetIOutSourcerDate(); - $("#estimate_tryrun_start_date").val(dateAddDays(real_contract_arrival_date, 5)); - $("#estimate_tryrun_start_date_owner").val(user_id); - $("#estimate_tryrun_end_date").val( - dateAddDays($("#estimate_tryrun_start_date").val(), specificationDayFormula(numberofstop)) - ); - $("#estimate_tryrun_end_date_owner").val(user_id); - } - if (outsourcer_type === 'IT') { - $("#estimate_install_start_date").val(dateAddDays(real_contract_arrival_date, 5)); - $("#estimate_install_start_date_owner").val(user_id); - $("#estimate_install_end_date").val( - dateAddDays($("#estimate_install_start_date").val(), specificationDayFormula(numberofstop)) - ); - $("#estimate_install_end_date_owner").val(user_id); - $("#estimate_tryrun_start_date").val(dateAddDays($("#estimate_install_end_date").val(), 1)); - $("#estimate_tryrun_start_date_owner").val(user_id); - $("#estimate_tryrun_end_date").val( - dateAddDays($("#estimate_tryrun_start_date").val(), specificationDayFormula(numberofstop)) - ); - $("#estimate_tryrun_end_date_owner").val(user_id); + if (getSetOutSourcerDateStatus() == '1') { + if (outsourcer_type === 'I') { + resetTOutSourcerDate(); + $("#estimate_install_start_date").val(dateAddDays(real_contract_arrival_date, 5)); + $("#estimate_install_start_date_owner").val(user_id); + $("#estimate_install_end_date").val( + dateAddDays($("#estimate_install_start_date").val(), specificationDayFormula(numberofstop)) + ); + $("#estimate_install_end_date_owner").val(user_id); + } + if (outsourcer_type === 'T') { + resetIOutSourcerDate(); + $("#estimate_tryrun_start_date").val(dateAddDays(real_contract_arrival_date, 5)); + $("#estimate_tryrun_start_date_owner").val(user_id); + $("#estimate_tryrun_end_date").val( + dateAddDays($("#estimate_tryrun_start_date").val(), specificationDayFormula(numberofstop)) + ); + $("#estimate_tryrun_end_date_owner").val(user_id); + } + if (outsourcer_type === 'IT') { + $("#estimate_install_start_date").val(dateAddDays(real_contract_arrival_date, 5)); + $("#estimate_install_start_date_owner").val(user_id); + $("#estimate_install_end_date").val( + dateAddDays($("#estimate_install_start_date").val(), specificationDayFormula(numberofstop)) + ); + $("#estimate_install_end_date_owner").val(user_id); + $("#estimate_tryrun_start_date").val(dateAddDays($("#estimate_install_end_date").val(), 1)); + $("#estimate_tryrun_start_date_owner").val(user_id); + $("#estimate_tryrun_end_date").val( + dateAddDays($("#estimate_tryrun_start_date").val(), specificationDayFormula(numberofstop)) + ); + $("#estimate_tryrun_end_date_owner").val(user_id); + } + } else { + const errrMessage = { + '2': '請選擇發包種類' + } + if ((errrMessage[getSetOutSourcerDateStatus()] !== 'undefined')) { + alert(errrMessage[getSetOutSourcerDateStatus()]); + } else { + alert("不明錯誤"); + } + } + + } + + function getSetOutSourcerDateStatus() { + let outsourcer_type = $("input[name^='outsourcer_type']:checked").val(); + let real_contract_arrival_date = $("#real_contract_arrival_date").val(); + let numberofstop = $("#numberofstop").val(); + let user_id = ''; + + if (typeof outsourcer_type == 'undefined') + return 2; + return 0; + } function resetIOutSourcerDate() {