From d084346a37c47f66eb0691faa9a762ed210155f6 Mon Sep 17 00:00:00 2001 From: Cheng Date: Fri, 23 Feb 2024 17:43:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E5=90=88=E7=B4=84=E7=B0=BD?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elevator_new/elevator_new_deal_bonus.php | 218 +++++++++++ .../contract-renovate-input.php | 190 +++++----- wms/contract/api/getContractData.php | 43 ++- wms/contract/api/postNewContractData.php | 74 +++- wms/contract/api/testT8API.php | 43 ++- wms/contract/contract-newelevator-input.php | 337 ++++++++++++------ wms/contract/js/alpine.js | 45 ++- 7 files changed, 725 insertions(+), 225 deletions(-) create mode 100644 wms/bonus/elevator_new/elevator_new_deal_bonus.php diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus.php b/wms/bonus/elevator_new/elevator_new_deal_bonus.php new file mode 100644 index 00000000..c26e747d --- /dev/null +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus.php @@ -0,0 +1,218 @@ += 1.0): + $sales_bonus = $elevator_knockdown_price * 0.02; + break; + case ($discount >= 0.9 and $discount < 1.0): + $sales_bonus = $elevator_knockdown_price * 0.018; + break; + case ($discount >= 0.75 and $discount < 0.9): + $sales_bonus = $elevator_knockdown_price * 0.015; + break; + case ($discount < 0.75): + $sales_bonus = $elevator_knockdown_price * 0.008; + break; + }; + break; + + #小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive) + case ($elevator_type == "dumbwaiter" or $elevator_type == "flatbase" or $elevator_type == "positive_drive"): + switch ($discount) { + case ($discount >= 1.0): + $sales_bonus = $elevator_knockdown_price * 0.02; + break; + case ($discount >= 0.9 and $discount < 1.0): + $sales_bonus = $elevator_knockdown_price * 0.018; + break; + case ($discount >= 0.72 and $discount < 0.9): + $sales_bonus = $elevator_knockdown_price * 0.015; + break; + case ($discount < 0.72): + $sales_bonus = $elevator_knockdown_price * 0.008; + break; + }; + break; + }; + #區域經理提成獎金($region_manager_bonus) + $region_manager_bonus = 600; + break; + }; + + #營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20% + array_push($bonus_array, [ + "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.2), #金額 + "payment_schedul_due" => "deposit", #訂金已收款20% + "payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定 + ]); + + #營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50% + array_push($bonus_array, [ + "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.5), #金額 + "payment_schedul_due" => "shipping", #訂金已收款20% + "payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定 + ]); + + #營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30% + array_push($bonus_array, [ + "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.3), #金額 + "payment_schedul_due" => "acceptance", #訂金已收款20% + "payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定 + ]); + + #區域經理提成獎金水庫-----訂金已收款100%,發放總獎金50% + array_push($bonus_array, [ + "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱 + "bonus_receiver" => $region_manger_id, #發放人員 + "bonus_amount" => round($region_manager_bonus * 0.5), #金額 + "payment_schedul_due" => "deposit", #訂金已收款100% + "payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定 + ]); + + #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50% + array_push($bonus_array, [ + "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱 + "bonus_receiver" => $region_manger_id, #發放人員 + "bonus_amount" => round($region_manager_bonus * 0.5), #金額 + "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100% + "payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定 + ]); + + $result_array = [ + "ver" => $ver, #獎金版本 + "result_status" => "success", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + } else { + array_push($bonus_array, [ + "bonus_type" => "error", #獎金名稱 + "bonus_receiver" => "error", #發放人員 + "bonus_amount" => 0, #金額 + "payment_schedul_due" => "9999-1-1", #預計發放時間 + "payment_schedul_regulation" => "error" #發放規定 + ]); + + $result_array = [ + "ver" => $ver, #獎金版本 + "result_status" => "error", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + }; + + return $result_array; +}; + +function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_price, $sales_id, $region_manger_id) +{ + $bonus_array = []; + if ($ver == "1.0") { + + #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) + switch ($contract_type) { + case "strategy_customer": + #契約員獎金($sales_bonus) + $sales_bonus = $elevator_knockdown_price * 0.007; + #地區經理經理獎金($region_manager_bonus) + $region_manager_bonus = 400; + break; + + case "general_customer": + #契約員獎金($sales_bonus) + $sales_bonus = $elevator_knockdown_price * 0.015; + #區域經理獎金($region_manager_bonus) + $region_manager_bonus = 600; + break; + }; + + #營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20% + array_push($bonus_array, [ + "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.2), #金額 + "payment_schedul_due" => "deposit", #訂金已收款20% + "payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定 + ]); + + #營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50% + array_push($bonus_array, [ + "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.5), #金額 + "payment_schedul_due" => "shipping", #訂金已收款20% + "payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定 + ]); + + #營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30% + array_push($bonus_array, [ + "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.3), #金額 + "payment_schedul_due" => "acceptance", #訂金已收款20% + "payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定 + ]); + + #區域經理獎金水庫-----訂金已收款100%,發放總獎金50% + array_push($bonus_array, [ + "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱 + "bonus_receiver" => $region_manger_id, #發放人員 + "bonus_amount" => round($region_manager_bonus * 0.5), #金額 + "payment_schedul_due" => "deposit", #訂金已收款100% + "payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定 + ]); + + #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50% + array_push($bonus_array, [ + "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱 + "bonus_receiver" => $region_manger_id, #發放人員 + "bonus_amount" => round($region_manager_bonus * 0.5), #金額 + "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100% + "payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定 + ]); + + $result_array = [ + "ver" => $ver, #獎金版本 + "result_status" => "success", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + } else { + array_push($bonus_array, [ + "bonus_type" => "error", #獎金名稱 + "bonus_receiver" => "error", #發放人員 + "bonus_amount" => 0, #金額 + "payment_schedul_due" => "9999-1-1", #預計發放時間 + "payment_schedul_regulation" => "error" #發放規定 + ]); + + $result_array = [ + "ver" => $ver, #獎金版本 + "result_status" => "error", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + }; + + return $result_array; +}; diff --git a/wms/contract-repair/contract-renovate-input.php b/wms/contract-repair/contract-renovate-input.php index deaeb0cb..f1c9212d 100644 --- a/wms/contract-repair/contract-renovate-input.php +++ b/wms/contract-repair/contract-renovate-input.php @@ -92,7 +92,7 @@ $contractSalesman = $stmt->fetchAll(PDO::FETCH_ASSOC); - 材料 + 材料 1、訂金 @@ -143,8 +143,11 @@ $contractSalesman = $stmt->fetchAll(PDO::FETCH_ASSOC); - - - - - - --> - - - 安裝 - 5、安裝完畢款 - - - - - - - - - - - - 6、驗收款 - - - - - - - - - - - - 7、其他 - - - - - - - - - - + + + + + + + 6、驗收款 + + + + + + + + + + + + 7、其他 + + + + + + + + + + - - 合計 - - - - - - - - - - - - + + 合計 + + + + + + + + + + + + - - + + - + - + - + + - \ No newline at end of file diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index f1c1a3fc..253e8d54 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -46,15 +46,52 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') { try { $contractno = $_GET['contractno']; - $sql_str = "SELECT a.*,b.lm_tel,b.uscc,b.manager FROM pricereview_main AS a + $sql_str = "SELECT a.*,b.lm_tel,b.uscc,b.manager,b.linkman FROM pricereview_main AS a LEFT JOIN hope_elevator_customer AS b ON a.contractno = b.vol_no - WHERE a.contractno = :contractno AND a.status = 'YS' "; + WHERE a.contractno = :contractno AND a.status != 'YN' "; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':contractno', $contractno); $stmt->execute(); $contract = $stmt->fetch(PDO::FETCH_ASSOC); - $contractResponse = json_encode($contract); + $salesman = $contract['person']; + $sql = "SELECT * FROM account WHERE accountid = :accountid "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':accountid', $salesman); + $stmt->execute(); + $account_detail = $stmt->fetch(PDO::FETCH_ASSOC); + $contract['manager'] = $account_detail['manager']; + $contract['salesman_departno'] = $account_detail['department_id']; + + + $mid = $contract['id']; + $sql = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A' "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->execute(); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $elevators_detail_arr = []; + foreach ($results as $keys => $result) { + $note = explode(',', $result['note']); + $result['spec'] = $note[0]; //型號 + $result['person'] = $note[1]; // 人承 + $result['floor'] = $note[2]; // 樓層 + $result['speed'] = $note[3]; // 速度 + for ($i = 0; $i < $result['item_qty']; $i++) { + $result['item_no'] = $i + 1; + array_push($elevators_detail_arr, $result); + } + } + $count = COUNT($elevators_detail_arr); + + $contract['elevators'] = $results; + $contract['elevators_detail_arr'] = $elevators_detail_arr; + $contract['nums'] = $count; + // echo '
';
+        // print_r($contract);
+        // echo '
'; + // exit; + $contractResponse = json_encode($contract); // 設定回應標頭為 JSON header('Content-Type: application/json'); diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index 0ee6964e..08735fdc 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -24,6 +24,14 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $salesman = $_POST["salesman"]; $qc = $_POST["qc"]; $contracttype = $_POST["contracttype"]; + $elevators_nums = $_POST['nums']; + $elevators = json_decode($_POST['elevators'], true); + $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], true); + BounsCount($_POST, $conn); + // echo '
';
+    // print_r($elevators);
+    // echo '
'; + // exit; $files = !empty($_FILES['files']) ? $_FILES['files'] : null; $files_id = null; @@ -43,8 +51,27 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - - + //create facility table + $createFacilityNo = new CreateFacilityNo(); + $dailyNecessities = [ + 'MAE100' => 'X', + 'MAM200' => 'W', + 'MAH100' => 'H', + 'MAQ100' => 'Z', + 'MAF100' => 'F', + 'MAZ100' => 'B', + ]; + $arr = []; + // 建立作番號 + foreach ($elevators_detail_arr as $elevator) { + // $spec = explode('-', $elevator['item_spec']); + $arr[] = $dailyNecessities[$elevator['spec']]; + } + $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); + echo '
';
+    print_r($facilityno);
+    echo '
'; + exit(); $conn->beginTransaction(); $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; @@ -151,6 +178,7 @@ function T8Insert($data) $user_id = $data['user_id']; $salesman = $data['salesman']; $createAt = date("Y-m-dH-i-s"); + $elevators[] = $data['elevators']; $createTime = str_replace('-', '', $createAt); @@ -252,3 +280,45 @@ function T8Insert($data) $stmt->execute(); } } + + +function BounsCount($data, $conn) +{ + // echo '
';
+  // print_r($data);
+  // echo '
'; + // exit; + require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php"); + $signing_date = $data['signing_date']; + $bonus_v1_0_date = '2024-01-02'; + $bonus_v2_0_date = '2024-01-03'; + $contractType = [ + '1' => 'strategy_customer', + '2' => 'general_customer' + ]; + $contract_type = $data['contract_type']; + + $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶 + $elevator_knockdown_price = $data['price_total']; //受價總額 + + $salesman = $data['salesman']; + $manager = $data['manager']; + + $result_bonus = []; + if ($signing_date <= $bonus_v1_0_date) { + $ver = '1.0'; + $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager); + } else if ($signing_date >= $bonus_v2_0_date) { + $ver = '2.0'; + } + + echo '
';
+  print_r($result_bonus);
+  echo '
'; + exit(); + try { + } catch (PDOException $e) { + header("HTTP/1.1 500 Internal Server Error"); + die('Error!:' . $e->getMessage()); + } +} diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index 41870a4c..9512cbc8 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,13 +1,36 @@ -$ADdate = implode('-', $click); -echo '
';
-print_r($date);
-echo '
'; + + 地址轉經緯度 + + -echo '
';
-print_r($ADdate);
-echo '
'; + +

輸入地址以獲取經緯度

+
+ + +
+
+ + + \ No newline at end of file diff --git a/wms/contract/contract-newelevator-input.php b/wms/contract/contract-newelevator-input.php index 219ced48..75992ffc 100644 --- a/wms/contract/contract-newelevator-input.php +++ b/wms/contract/contract-newelevator-input.php @@ -1,17 +1,17 @@ -prepare($sql_str); $stmt->bindParam(":accounttype", $accounttype); -$stmt -> execute(); +$stmt->execute(); $persons = $stmt->fetchAll(PDO::FETCH_ASSOC); -$persons = array_map(function($person){ +$persons = array_map(function ($person) { return [ - 'view'=>$person['accountid'] .'-'. $person['name'], - 'value'=>$person['accountid'], - 'name'=>$person['name'] + 'view' => $person['name'] . '-' . $person['accountid'], + 'value' => $person['accountid'], + 'name' => $person['name'] ]; }, $persons); ?> @@ -21,7 +21,7 @@ $persons = array_map(function($person){
-
+
@@ -31,106 +31,233 @@ $persons = array_map(function($person){

合約入力(新梯)

- + + + + +
- -