From 79d4fecce6acc8d90dec812cf475969e2ab64faa Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 4 Mar 2024 20:25:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E3=80=81=E4=BF=9D=E9=A4=8A?= =?UTF-8?q?=E7=B0=BD=E5=9B=9E&=E7=8D=8E=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elevator_new_deal_bonus_v2_0.php | 73 +- ...evator_new_deal_bonus_v2_0_examination.php | 121 +-- wms/contract/api/T8api.php | 2 +- wms/contract/api/getContractData.php | 15 - wms/contract/api/postContractData.php | 1 + wms/contract/api/postNewContractData.php | 761 +++++++++++------- wms/contract/api/test copy.json | 407 ++++++++-- wms/contract/api/test.json | 2 +- wms/contract/api/testT8API.php | 127 ++- wms/contract/contract-newelevator-input.php | 14 +- wms/contract/js/alpine.js | 13 +- 11 files changed, 989 insertions(+), 547 deletions(-) diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php index 84dde3cd..15f87514 100644 --- a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php @@ -35,13 +35,14 @@ result_array[ -function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id){ +function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id) +{ $bonus_array = []; - if ($ver == "2.0"){ + if ($ver == "2.0") { $discount = round($elevator_knockdown_price / $elevator_list_price, 3); #銷售點數,取到小數點第三位。 - + #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) - switch ($contract_type){ + switch ($contract_type) { case "strategy_customer": #契約員獎金($sales_bonus) $sales_bonus = $elevator_knockdown_price * 0.007; @@ -51,7 +52,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele case "general_customer": switch ($elevator_type) { - #客梯(passenger)、貨梯(cargo) + #客梯(passenger)、貨梯(cargo) case ($elevator_type == "passenger" or $elevator_type == "cargo"): switch ($discount) { case ($discount >= 1.0): @@ -62,14 +63,14 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele break; case ($discount >= 0.75 and $discount < 0.9): $sales_bonus = $elevator_knockdown_price * 0.015; - break; + break; case ($discount < 0.75): $sales_bonus = $elevator_knockdown_price * 0.008; - break; + break; }; - break; - - #小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive) + break; + + #小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive) case ($elevator_type == "dumbwaiter" or $elevator_type == "flatbase" or $elevator_type == "positive_drive"): switch ($discount) { case ($discount >= 1.0): @@ -80,7 +81,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele break; case ($discount >= 0.72 and $discount < 0.9): $sales_bonus = $elevator_knockdown_price * 0.015; - break; + break; case ($discount < 0.72): $sales_bonus = $elevator_knockdown_price * 0.008; break; @@ -91,74 +92,72 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele $region_manager_bonus = 600; break; }; - + #營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20% - array_push($bonus_array,[ + 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,[ + 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,[ + 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,[ + 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,[ + 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,[ + "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 #獎金水庫 + "ver" => $ver, #獎金版本 + "result_status" => "error", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 ]; }; - + return $result_array; }; - -?> \ No newline at end of file diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php index 771b791b..600d4071 100644 --- a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php @@ -41,76 +41,85 @@ require_once("elevator_new_deal_bonus_v2_0.php"); #獎金測試 $examination_array = [ #錯誤版本 - ["1.0","strategy_customer","passenger",1000000,1000000,"M0001", "M0003"], + ["1.0", "strategy_customer", "passenger", 1000000, 1000000, "M0001", "M0003"], #戰略客戶(strategy_customer) - ["2.0","strategy_customer","passenger",1000000,1000000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數100% - ["2.0","strategy_customer","passenger",1000000,900000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數90% - ["2.0","strategy_customer","passenger",1000000,750000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數75% - ["2.0","strategy_customer","passenger",1000000,600000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數60% - ["2.0","strategy_customer","cargo",1000000,1000000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數100% - ["2.0","strategy_customer","cargo",1000000,900000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數90% - ["2.0","strategy_customer","cargo",1000000,750000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數75% - ["2.0","strategy_customer","cargo",1000000,600000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數60% - ["2.0","strategy_customer","dumbwaiter",1000000,1000000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數100% - ["2.0","strategy_customer","dumbwaiter",1000000,900000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數90% - ["2.0","strategy_customer","dumbwaiter",1000000,720000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數75% - ["2.0","strategy_customer","dumbwaiter",1000000,600000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數60% - ["2.0","strategy_customer","flatbase",1000000,1000000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數100% - ["2.0","strategy_customer","flatbase",1000000,900000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數90% - ["2.0","strategy_customer","flatbase",1000000,720000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數75% - ["2.0","strategy_customer","flatbase",1000000,600000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數60% - ["2.0","strategy_customer","positive_drive",1000000,1000000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數100% - ["2.0","strategy_customer","positive_drive",1000000,900000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數90% - ["2.0","strategy_customer","positive_drive",1000000,720000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數75% - ["2.0","strategy_customer","positive_drive",1000000,600000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數60% + ["2.0", "strategy_customer", "passenger", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數100% + ["2.0", "strategy_customer", "passenger", 1000000, 900000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數90% + ["2.0", "strategy_customer", "passenger", 1000000, 750000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數75% + ["2.0", "strategy_customer", "passenger", 1000000, 600000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數60% + ["2.0", "strategy_customer", "cargo", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數100% + ["2.0", "strategy_customer", "cargo", 1000000, 900000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數90% + ["2.0", "strategy_customer", "cargo", 1000000, 750000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數75% + ["2.0", "strategy_customer", "cargo", 1000000, 600000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數60% + ["2.0", "strategy_customer", "dumbwaiter", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數100% + ["2.0", "strategy_customer", "dumbwaiter", 1000000, 900000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數90% + ["2.0", "strategy_customer", "dumbwaiter", 1000000, 720000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數75% + ["2.0", "strategy_customer", "dumbwaiter", 1000000, 600000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數60% + ["2.0", "strategy_customer", "flatbase", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數100% + ["2.0", "strategy_customer", "flatbase", 1000000, 900000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數90% + ["2.0", "strategy_customer", "flatbase", 1000000, 720000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數75% + ["2.0", "strategy_customer", "flatbase", 1000000, 600000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數60% + ["2.0", "strategy_customer", "positive_drive", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數100% + ["2.0", "strategy_customer", "positive_drive", 1000000, 900000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數90% + ["2.0", "strategy_customer", "positive_drive", 1000000, 720000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數75% + ["2.0", "strategy_customer", "positive_drive", 1000000, 600000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數60% #一般客戶(general_customer) - ["2.0","general_customer","passenger",1000000,1000000,"M0001", "M0003"], #一般客戶、客梯、銷售點數100% - ["2.0","general_customer","passenger",1000000,900000,"M0001", "M0003"], #一般客戶、客梯、銷售點數90% - ["2.0","general_customer","passenger",1000000,750000,"M0001", "M0003"], #一般客戶、客梯、銷售點數75% - ["2.0","general_customer","passenger",1000000,600000,"M0001", "M0003"], #一般客戶、客梯、銷售點數60% - ["2.0","general_customer","cargo",1000000,1000000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數100% - ["2.0","general_customer","cargo",1000000,900000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數90% - ["2.0","general_customer","cargo",1000000,750000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數75% - ["2.0","general_customer","cargo",1000000,600000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數60% - ["2.0","general_customer","dumbwaiter",1000000,1000000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數100% - ["2.0","general_customer","dumbwaiter",1000000,900000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數90% - ["2.0","general_customer","dumbwaiter",1000000,720000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數75% - ["2.0","general_customer","dumbwaiter",1000000,600000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數60% - ["2.0","general_customer","flatbase",1000000,1000000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數100% - ["2.0","general_customer","flatbase",1000000,900000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數90% - ["2.0","general_customer","flatbase",1000000,720000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數75% - ["2.0","general_customer","flatbase",1000000,600000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數60% - ["2.0","general_customer","positive_drive",1000000,1000000,"M0001", "M0003"], #一般客戶、強驅、銷售點數100% - ["2.0","general_customer","positive_drive",1000000,900000,"M0001", "M0003"], #一般客戶、強驅、銷售點數90% - ["2.0","general_customer","positive_drive",1000000,720000,"M0001", "M0003"], #一般客戶、強驅、銷售點數75% - ["2.0","general_customer","positive_drive",1000000,600000,"M0001", "M0003"] #一般客戶、強驅、銷售點數60% + ["2.0", "general_customer", "passenger", 1000000, 1000000, "M0001", "M0003"], #一般客戶、客梯、銷售點數100% + ["2.0", "general_customer", "passenger", 1000000, 900000, "M0001", "M0003"], #一般客戶、客梯、銷售點數90% + ["2.0", "general_customer", "passenger", 1000000, 750000, "M0001", "M0003"], #一般客戶、客梯、銷售點數75% + ["2.0", "general_customer", "passenger", 1000000, 600000, "M0001", "M0003"], #一般客戶、客梯、銷售點數60% + ["2.0", "general_customer", "cargo", 1000000, 1000000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數100% + ["2.0", "general_customer", "cargo", 1000000, 900000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數90% + ["2.0", "general_customer", "cargo", 1000000, 750000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數75% + ["2.0", "general_customer", "cargo", 1000000, 600000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數60% + ["2.0", "general_customer", "dumbwaiter", 1000000, 1000000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數100% + ["2.0", "general_customer", "dumbwaiter", 1000000, 900000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數90% + ["2.0", "general_customer", "dumbwaiter", 1000000, 720000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數75% + ["2.0", "general_customer", "dumbwaiter", 1000000, 600000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數60% + ["2.0", "general_customer", "flatbase", 1000000, 1000000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數100% + ["2.0", "general_customer", "flatbase", 1000000, 900000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數90% + ["2.0", "general_customer", "flatbase", 1000000, 720000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數75% + ["2.0", "general_customer", "flatbase", 1000000, 600000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數60% + ["2.0", "general_customer", "positive_drive", 1000000, 1000000, "M0001", "M0003"], #一般客戶、強驅、銷售點數100% + ["2.0", "general_customer", "positive_drive", 1000000, 900000, "M0001", "M0003"], #一般客戶、強驅、銷售點數90% + ["2.0", "general_customer", "positive_drive", 1000000, 720000, "M0001", "M0003"], #一般客戶、強驅、銷售點數75% + ["2.0", "general_customer", "positive_drive", 1000000, 600000, "M0001", "M0003"] #一般客戶、強驅、銷售點數60% ]; -for($i = 0; $i '戰略客戶', + 'general_customer' => '一般客戶' + ]; + //作番機種($elevator_type):客梯(passenger)、貨梯(cargo)、小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive) + $elevator = [ + "passenger" => "客梯", + "cargo" => "貨梯", + "dumbwaiter" => "小電梯", + "flatbase" => "平台踢", + "positive_drive" => "強驅" + ]; echo "獎金版本:" . $result["ver"] . "
"; echo "計算結果:" . $result["result_status"] . "
"; + echo "參數說明: " . $customer[$examination_array[$i][1]] . " 、 " . $elevator[$examination_array[$i][2]] . "、 作番表價:" . $examination_array[$i][3] . " 、 作番賣價: " . $examination_array[$i][4] . "、 營業員員工號:" . $examination_array[$i][5] . " 、 區域經理員工號:" . $examination_array[$i][6] . "
"; echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . " " - . $examination_array[$i][5] . " " . $examination_array[$i][6] . "
"; - for($j = 0; $j"; + for ($j = 0; $j < count($result["bonus_array"]); $j++) { echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " " - . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["payment_schedul_due"] . " " - . $result["bonus_array"][$j]["payment_schedul_regulation"] . "
"; + . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["payment_schedul_due"] . " " + . $result["bonus_array"][$j]["payment_schedul_regulation"] . "
"; }; echo "-------------------------" . "
"; - }; - - -?> diff --git a/wms/contract/api/T8api.php b/wms/contract/api/T8api.php index 7bf12c6f..245a318d 100644 --- a/wms/contract/api/T8api.php +++ b/wms/contract/api/T8api.php @@ -7,7 +7,7 @@ function T8salIncomeApply($data, $api_url) // $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; $validation = get_Auth(); // echo '
';
-    // print_r(json_encode($data));
+    // print_r(json_encode($data, JSON_UNESCAPED_UNICODE));
     // echo '
'; $header = [ "CHI_Authorization :" . $validation, diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index 667c33b7..e2aedd43 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -186,28 +186,13 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont foreach ($other_option_arr as $key => $option) { if ($option['item_qty'] == $result['item_qty']) { $result['option_other_price'] += intval($option['item_unit_price']); - // echo '1..'; - // echo "
";
-                        // print_r($option['item_unit_price']);
-                        // echo "
"; } else if ($option['item_qty'] / $result['item_qty'] != 1) { $item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數 $result['option_other_price'] += intval($option['item_unit_price']) * $item_qty; - // echo '2..'; - // echo "
";
-                        // print_r(intval($option['item_unit_price']) . ' *' . $item_qty . '=' . intval($option['item_unit_price']) * $item_qty);
-                        // echo "
"; } else { $result['option_other_price'] += $option['item_unit_price'] * intval($option['item_qty']); - // echo ' } - // echo '
';
-                    // print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
-                    // echo '
'; } - - // print_r($result['option_other_price']); - // exit(); } diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 6b9b210b..243b9ad3 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -620,6 +620,7 @@ function T8insert($data, $facilityno, $depId) "SPrice" => intval($elevator['sold_price']), "SQuantity" => $SQuantity, "ProjectId" => "$contractno", + "FromBillNo" => "$contractno", "CU_MaterialId" => "$facility_no", "CU_EstPayDate" => intval($payDay) ]; diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index 2a1ebca5..6fd5756c 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -1,10 +1,16 @@ + "; + // print_r($elevators_detail_arr); + // echo ""; + // exit(); $files = !empty($_FILES['files']) ? $_FILES['files'] : null; $files_id = null; @@ -67,19 +76,131 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); echo json_encode($facilityno); - // $bonus_result = BounsCount($_POST, $conn, $facilityno); - // if (!empty($bonus_result) && $bonus_result['status'] == "2") { - // $fail_arr[] = '獎金計算錯誤,請再檢查或連繫資訊人員'; - // // header("HTTP/1.1 422 Unprocessable Entity"); - // echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); - // exit(); - // } + $bonus_result = BounsCount($_POST, $conn, $facilityno); + if (!empty($bonus_result) && $bonus_result['status'] == "2") { + $fail_arr[] = '獎金計算錯誤,請再檢查或連繫資訊人員'; + // header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); + exit(); + } T8Insert($_POST, $facilityno, $connT8); - exit(); $conn->beginTransaction(); + //create account table + $accounttype = "A"; + $accountid = $vat; + $pwd = "123"; + $name = $customer; + $tel = $lm_tel ?? ''; + $sql = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, creater, create_at) + VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address , :creater, :created_at)"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':accounttype', $accounttype); + $stmt->bindParam(':accountid', $contractno); + $stmt->bindParam(':pwd', $pwd); + $stmt->bindParam(':name', $customer); + $stmt->bindParam(':tel', $tel); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':creater', $created_by); + $stmt->bindParam(':created_at', $created_at); + $stmt->execute(); + // exit(); + + //create table Wipwholestatus (作番大日程) + foreach ($elevators_detail_arr as $key => $value) { + $facilityno = $facilityno[$key]; // 作番 + $weight = $value['item_weight']; // 載重 + $person = $value['person']; // 人乘 + $floor = $value['floor']; // 樓層 + $open = $value['item_op']; // 開門方式 + $speed = $value['speed']; //速度 + $qc = $value['qc']; + $facility_kind = $value['spec']; //型號 + $contract_arrival_date = $value['contract_arrival_date']; //到工地日期 + $site_manager = $value['manage']; + $warehouseid = $value['warehouseid']; + $sql = "INSERT INTO Wipwholestatus + (contract_type,contractno,salesid,custom,accountid,site_manager,warehouseid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,area_no,address,contract_arrival_date,real_contract_arrival_date,qc_official_type,creater,create_at) VALUES + ('A',:contractno,:salesid,:custom,:accountid,:site_manager,:warehouseid,:facilityno,:weight,:numberofpassenger,:numberoffloor,:opentype,:speed,:facility_kind,:area_no,:address,:contract_arrival_date,:real_contract_arrival_date,:qc_official_type,:creater,:create_at)"; + // $sql = "INSERT INTO Wipwholestatus + // (contract_type,contractno,salesid,custom,accountid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,address,contract_arrival_date,qc_official_type,creater,create_at) VALUES + // ('A','$contractno','$salesman','$customer','$customer','$facilityno','$weight','$person','$floor','$open','$speed','$facility_kind','$address','$contract_arrival_date','$qc','$created_by','$created_at')"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':contractno', $contractno); + $stmt->bindParam(':salesid', $salesman); + $stmt->bindParam(':custom', $customer); + $stmt->bindParam(':accountid', $customer); + $stmt->bindParam(':site_manager', $site_manager); + $stmt->bindParam(':warehouseid', $warehouseid); + $stmt->bindParam(':facilityno', $facilityno); + $stmt->bindParam(':weight', $weight); + $stmt->bindParam(':numberofpassenger', $person); + $stmt->bindParam(':numberoffloor', $floor); + $stmt->bindParam(':opentype', $open); + $stmt->bindParam(':speed', $speed); + $stmt->bindParam(':facility_kind', $facility_kind); + $stmt->bindParam(':area_no', $area_no); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':contract_arrival_date', $contract_arrival_date); + $stmt->bindParam(':real_contract_arrival_date', $contract_arrival_date); + $stmt->bindParam(':qc_official_type', $qc); + $stmt->bindParam(':creater', $created_by); + $stmt->bindParam(':create_at', $created_at); + $stmt->execute(); + $lastId = $conn->lastInsertId(); + // echo "
";
+      // print_r($lastId);
+      // echo "
"; + if (!empty($lastId)) { + echo '123'; + // 寫入待簽程狀態 A (營業) + do_wws_assign1($salesman, $lastId, 'A', $conn); + // // 寫入待簽程狀態 G (工務) + do_wws_assign1($warehouseid, $lastId, 'G', $conn); + } + + + // create table worksite (戰情室) + $latitude = $value['latitude']; + $longitude = $value['longitude']; + $sql = "INSERT INTO worksite + (latitude,longitude,facilitynum,facilityno,address,buildcompany,process,status,marchintotime,creater,create_at)VALUES + (:latitude,:longitude,'1',:facilityno,:address,:bulidcompany,'進行中','未工勘',:marchintotime,:creater,:create_at)"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':latitude', $latitude); + $stmt->bindParam(':longitude', $longitude); + $stmt->bindParam(':facilityno', $facilityno); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':bulidcompany', $customer); + $stmt->bindParam(':marchintotime', $contract_arrival_date); + $stmt->bindParam(':creater', $created_by); + $stmt->bindParam(':create_at', $created_at); + $stmt->execute(); + + // create table schedule + $contract_begin_date = ''; + $contract_end_date = ''; // 一年 + $comboNo = new CreateComboNo('em', $contract_begin_date, $contract_end_date); + $comboArr = json_decode($comboNo->getComboNo(), true); + 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', $facility_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(); + } + } + + + $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(":accountid", $salesman); @@ -125,7 +246,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':file_size', $file['size']); $stmt->bindParam(':created_at', $created_at); $stmt->bindParam(':created_by', $created_by); - // $stmt->execute(); + $stmt->execute(); } else { throw new PDOException('檔案上傳失敗:' . $msg); } @@ -158,7 +279,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(":created_at", $created_at); $stmt->bindParam(":created_by", $created_by); $stmt->bindParam(":qc", $qc); - // $stmt->execute(); + $stmt->execute(); $result = $conn->commit(); @@ -194,6 +315,15 @@ function T8Insert($data, $facilityno, $connT8) $createTime = str_replace('-', '', $createAt); $signing_date = intval(str_replace("-", '', $data['signing_date'])); //簽訂日期 // echo + // $pay_kind = [ + // '1' => '簽約', + // '2' => '二次款', + // '3' => '貨抵工地', + // '4' => '材料其他', + // '5' => '試車完工', //安裝完畢 + // '6' => '交車' //交車 + // ]; + $pay_kind = [ '1' => '簽約', '2' => '二次款', @@ -228,7 +358,6 @@ function T8Insert($data, $facilityno, $connT8) $stmt->bindParam(':TaxNo', $vat); $stmt->bindParam(':EnterpriseName', $partyA); //企業名稱 $stmt->bindParam(':ContactAddress', $partyAaddress); - // $stmt->bindParam(':EMail', $email); $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreateTime', $createTime); $stmt->execute(); @@ -236,8 +365,8 @@ function T8Insert($data, $facilityno, $connT8) $sql = "INSERT INTO comCustomer - (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) - VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; + (OrgId,BizPartnerTypeId,ConditionId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) + VALUES('1000','10','TWD','0008',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; // $sql = "INSERT INTO comCustomer // (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) // VALUES('1000','10','TWD','$contractno','$salesman','$user_id',1,'$partyAaddress','$createTime','35')"; @@ -253,6 +382,7 @@ function T8Insert($data, $facilityno, $connT8) // // 若客戶資料不為空,更新該客戶資訊。 $sql = "UPDATE comCustomer SET PersonId=:PersonId, + ConditionId='0008', InvoiceAddress=:InvoiceAddress, LastOperatorId=:LastOperatorId, LastOperateTime=:LastOperateTime @@ -306,176 +436,208 @@ function T8Insert($data, $facilityno, $connT8) $stmt->bindParam(':CreatorId', $user_id); $stmt->execute(); } - - foreach ($elevators as $index => $elevator) { - $count = 1; - // 產品集成維護 - $facility_no = $facilityno[$index]; - $MaterialName = "$partyA($facility_no)"; - $sql = "INSERT INTO comMaterial + $sql = "SELECT * FROM salSalesOrder WHERE BillNo = :BillNo"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BillNo', $contractno); + $contractT8 = $stmt->fetch(PDO::FETCH_ASSOC); + if (empty($contractT8)) { + foreach ($elevators as $index => $elevator) { + $count = 1; + // 產品集成維護 + $facility_no = $facilityno[$index]; + $MaterialName = "$partyA($facility_no)"; + $contract_arrival_a = $elevator['contract_arrival_date']; + + $sql = "INSERT INTO comMaterial (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime,IsInUsed) VALUES ('1000',:MaterialId,'10','A',:CreatorId,:CreateTime,1)"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':MaterialId', $facility_no); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); - $sql = "INSERT INTO comMaterialGroup + $sql = "INSERT INTO comMaterialGroup (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime) VALUES ('10',:MaterialId,:MaterialName,'A',1,'SET',:CreatorId,:CreateTime)"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':MaterialId', $facility_no); - $stmt->bindParam(':MaterialName', $MaterialName); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); - - $sql = "INSERT INTO comMaterialPurchases + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':MaterialName', $MaterialName); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + $sql = "INSERT INTO comMaterialPurchases (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime) VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':MaterialId', $facility_no); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); - $sql = "INSERT INTO plsMaterialPlanData + $sql = "INSERT INTO plsMaterialPlanData (PlanRangeId,MaterialId,FOrgId,MaterialTypeId,CreatorId,CreateTime,DefaultDemandOrg) VALUES (1000,:MaterialId,1000,10,:CreatorId,:CreateTime,1000) "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':MaterialId', $facility_no); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); - $sql = "INSERT INTO comMaterialSales + $sql = "INSERT INTO comMaterialSales (OrgId,MAterialTypeId,MaterialId,CurrId,SUnitId,SupplyOrgId,CreatorId,CreateTime,IsInUsed) VALUES (1000,10,:MaterialId,'TWD','SET',1000,:CreatorId,:CreateTime,1) "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':MaterialId', $facility_no); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + // 階段收款資訊 + $salOrderStagePay_row = []; + $equipment_total = 0; + $install_total = 0; + $equipment_total = $pay_arr['equipment_total']; + $install_total = $pay_arr['install_total']; + $count_a = 0; + $count_month = 1; + foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) { + if ($detail['kind'] == 3) { + $PlanPayDate = $contract_arrival_a; + } else if ($detail['kind'] > 3) { + $PlanPayDate = date("Y-m-d", strtotime($contract_arrival_a . '+' . $count_month . ' month')); + $count_month++; + } else { + $PlanPayDate = $signing_date; + $count_a++; + if ($count_a == 1) { + $PlanPayDate = date("Y-m-d", strtotime($signing_date . '+' . $count_a . ' month')); + } + } + + $contract_arrival_date = intval(str_replace("-", '', $PlanPayDate)); //貨到工地日 + + $PayStage = $pay_kind[$detail['kind']]; + $PlanPercentage = intval($detail['pay_scale']) / 100; + $rows = [ + "PayStage" => "$PayStage", //收款階段 + "PlanPercentage" => $PlanPercentage, //計劃收款比例(%) + "PlanPayAmt" => $detail['amount'], //計劃收款金額 + "PlanPayDate" => $contract_arrival_date, //計劃收款日期 1.第一筆都是簽約日 + "BillNo" => "$contractno", + "RowCode" => $key + 1, + "RowNo" => $key + 1, + "UnWriteOffOAmount" => $detail['amount'] //未核銷金額 + ]; + $salOrderStagePay_row[] = $rows; + } - // 階段收款資訊 - $salOrderStagePay_row = []; - $equipment_total = 0; - $install_total = 0; - $equipment_total = $pay_arr['equipment_total']; - $install_total = $pay_arr['install_total']; - foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) { - $PayStage = $pay_kind[$detail['kind']]; - $PlanPercentage = intval($detail['pay_scale']) / 100; - $rows = [ - "PayStage" => "$PayStage", //收款階段 - "PlanPercentage" => $PlanPercentage, //計劃收款比例(%) - "PlanPayAmt" => $detail['amount'], //計劃收款金額 - "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 - "BillNo" => "$contractno", - "RowCode" => $key + 1, - "RowNo" => $key + 1, - "UnWriteOffOAmount" => $detail['amount'] //未核銷金額 + // 設備 + $row1 = [ + "TaxId" => "ST005", + "RequirementDate" => $signing_date, //出貨日期 + "ConsignmentDate" => $signing_date, //發貨日期 + "BillNo" => "$contractno", //合約號 + "RowCode" => $count, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => $equipment_total, //交易價格 + "CU_MaterialId" => $facility_no + ]; + $count++; + // 安裝 + $row2 = [ + "TaxId" => "ST005", + "RequirementDate" => $signing_date, //出貨日期 + "ConsignmentDate" => $signing_date, //發貨日期 + "BillNo" => "$contractno", //合約號 + "RowCode" => $count, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => $install_total, //交易價格 + "CU_MaterialId" => $facility_no ]; - $salOrderStagePay_row[] = $rows; + $count++; + // 產品(作番) + $row3 = [ + "TaxId" => "ST005", + "RequirementDate" => $signing_date, //出貨日期 + "ConsignmentDate" => $signing_date, //發貨日期 + "BillNo" => "$contractno", //合約號 + "RowCode" => $count, //全部筆數排列 + "ItemType" => 0, + "MaterialId" => "$facility_no", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 0, //交易價格 + "CU_MaterialId" => $facility_no // 歸屬作番號 + ]; + $count++; + $SubOrder_row[] = $row1; + $SubOrder_row[] = $row2; + $SubOrder_row[] = $row3; + $count++; } - - // 設備 - $row1 = [ + $MainSalesOrder_row = [ + "BillNo" => "$contractno", //合約單號 + "BillDate" => $signing_date, //簽約日期 + "TypeId" => "SO", // + "FOrgId" => "1000", + "OrgId" => "1000", + "ModeId" => "M", // T汰改 M新梯 + "BizPartnerId" => "$contractno", //客戶代碼 + "CurrId" => "TWD", + "CurrOAmount" => 1, + "CurrLAmount" => 1, + "PersonId" => "$salesman", //業務人員 + "DueToId" => "$contractno", //債務方 + "TradeConditionId" => "", "TaxId" => "ST005", - "RequirementDate" => $signing_date, //出貨日期 - "ConsignmentDate" => $signing_date, //發貨日期 - "BillNo" => "$contractno", //合約號 - "RowCode" => $count, //全部筆數排列 - "ItemType" => 1, - "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) - "SUnitId" => "SET", - "SQuantity" => 1, //交易數量 - "SPrice" => $equipment_total //交易價格 + "CreditorCompId" => "1001", + "CreditorOrgId" => "1000", + "CreatorId" => "$user_id" + // "CompId" => "1001", + // "CreditorCurrOAmount" => 1, + // "CreditorCurrLAmount" => 1 ]; - $count++; - // 安裝 - $row2 = [ - "TaxId" => "ST005", - "RequirementDate" => $signing_date, //出貨日期 - "ConsignmentDate" => $signing_date, //發貨日期 - "BillNo" => "$contractno", //合約號 - "RowCode" => $count, //全部筆數排列 - "ItemType" => 1, - "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) - "SUnitId" => "SET", - "SQuantity" => 1, //交易數量 - "SPrice" => $install_total //交易價格 + $MainSalesOrder = [ + "name" => "MainSalesOrder", + 'rows' => [$MainSalesOrder_row] ]; - $count++; - // 產品(作番) - $row3 = [ - "TaxId" => "ST005", - "RequirementDate" => $signing_date, //出貨日期 - "ConsignmentDate" => $signing_date, //發貨日期 - "BillNo" => "$contractno", //合約號 - "RowCode" => $count, //全部筆數排列 - "ItemType" => 0, - "MaterialId" => "$facility_no", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) - "SUnitId" => "SET", - "SQuantity" => 1, //交易數量 - "SPrice" => 0 //交易價格 + $SubOrder = [ + "name" => "SubOrder", + "rows" => $SubOrder_row + ]; + $salOrderStagePay = [ + "name" => "salOrderStagePay", + "rows" => $salOrderStagePay_row ]; - $count++; - $SubOrder_row[] = $row1; - $SubOrder_row[] = $row2; - $SubOrder_row[] = $row3; - $count++; - } - $MainSalesOrder_row = [ - "BillNo" => "$contractno", //合約單號 - "BillDate" => $signing_date, //簽約日期 - "TypeId" => "SO", // - "FOrgId" => "1000", - "OrgId" => "1000", - "ModeId" => "M", // T汰改 M新梯 - "BizPartnerId" => "$contractno", //客戶代碼 - "CurrId" => "TWD", - "CurrOAmount" => 1, - "CurrLAmount" => 1, - "PersonId" => "$user_id", //業務人員 - "DueToId" => "$contractno", //債務方 - "TradeConditionId" => "", - "TaxId" => "ST005", - "CreditorCompId" => "1001", - "CreditorOrgId" => "1000", - // "CompId" => "1001", - // "CreditorCurrOAmount" => 1, - // "CreditorCurrLAmount" => 1 - ]; - $MainSalesOrder = [ - "name" => "MainSalesOrder", - 'rows' => [$MainSalesOrder_row] - ]; - $SubOrder = [ - "name" => "SubOrder", - "rows" => $SubOrder_row - ]; - $salOrderStagePay = [ - "name" => "salOrderStagePay", - "rows" => [$salOrderStagePay_row] - ]; - $API_body = []; - $API_body[] = $MainSalesOrder; - $API_body[] = $SubOrder; - $API_body[] = $salOrderStagePay; - echo "
";
-    print_r(json_encode($API_body, JSON_UNESCAPED_UNICODE));
-    echo "
"; - $api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; - - $result = T8salIncomeApply($API_body, $api_url); - echo "
";
-    print_r($result);
-    echo "
"; + $API_body = []; + $API_body[] = $MainSalesOrder; + $API_body[] = $SubOrder; + $API_body[] = $salOrderStagePay; + echo "
";
+      print_r(json_encode($API_body, JSON_UNESCAPED_UNICODE));
+      echo "
"; + $api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; + + $result = T8salIncomeApply($API_body, $api_url); + // echo "
";
+      // print_r($result);
+      // echo "
"; + if ($result['Status'] == 'Fails' || $result['Status'] == 'Error') { + echo $result['ErrorMsg']; + } + } else { + echo '資料已新增過,請洽資訊人員'; + } $connT8->commit(); } catch (PDOException $e) { $connT8->rollback(); @@ -487,153 +649,168 @@ function T8Insert($data, $facilityno, $connT8) function BounsCount($data, $conn, $facilityno) { - // echo '
';
-  // print_r($facilityno);
-  // echo '
'; - // exit; - require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php"); - $dailyNecessities = [ - 'MAE100' => 'passenger', //小機房 - 'MAM200' => 'passenger', //無機房 - 'MAH100' => 'dumbwaiter', //小電梯 - 'MAQ100' => 'positive_drive', //強趨梯 - 'MAF100' => 'cargo', //貨梯 - 'MAP100' => 'flatbase', // 平台踢 - ]; - $contractType = [ - '1' => 'strategy_customer', - '2' => 'general_customer' - ]; - $signing_date = $data['signing_date']; - $bonus_v1_0_date = '2024-01-02'; - $bonus_v2_0_date = '2024-01-03'; - $contract_type = $data['contract_type']; - $total = $data['price_total']; - $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶 - // $elevator_knockdown_price = $data['price_total']; //受價總額 - $elevators = json_decode($data['elevators_detail_arr'], true); - $contract_no = $data['contractno']; - $salesman = $data['salesman']; - $manager = $data['manager']; - $contract_kind = 1; - $create_id = $data['user_id']; - $create_at = date("Y-m-d H:i:s"); - $status = 1; - - - - - - $result_bonus = []; - $result_bonus_arr = []; - if ($signing_date <= $bonus_v1_0_date) { - $ver = '1.0'; - foreach ($elevators as $key => $elevator) { - - $elevator_knockdown_price = $elevator['elevator_price']; // 單台電梯售價 - $elevator_list_price = $elevator['option_other_price'] + $elevator['option_price'] + $elevator['elevator_price']; //牌價 - $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager); - $facility_no = $facilityno[$key]; - $bonus_json = [ - 'contract_type' => $type, - 'total' => $elevator_list_price, - 'fee_per_st' => $elevator_knockdown_price - ]; + try { + require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php"); + $dailyNecessities = [ + 'MAE100' => 'passenger', //小機房 + 'MAM200' => 'passenger', //無機房 + 'MAH100' => 'dumbwaiter', //小電梯 + 'MAQ100' => 'positive_drive', //強趨梯 + 'MAF100' => 'cargo', //貨梯 + 'MAP100' => 'flatbase', // 平台踢 + ]; + $contractType = [ + '1' => 'strategy_customer', + '2' => 'general_customer' + ]; + $signing_date = $data['signing_date']; + $bonus_v1_0_date = '2024-01-02'; + $bonus_v2_0_date = '2024-01-03'; + $contract_type = $data['contract_type']; + $total = $data['price_total']; + $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶 + // $elevator_knockdown_price = $data['price_total']; //受價總額 + $elevators = json_decode($data['elevators_detail_arr'], true); + $contract_no = $data['contractno']; + $salesman = $data['salesman']; + $manager = $data['manager']; + $contract_kind = 1; + $create_id = $data['user_id']; + $create_at = date("Y-m-d H:i:s"); + $status = 1; + + + + + + $result_bonus = []; + $result_bonus_arr = []; + if ($signing_date <= $bonus_v1_0_date) { + $ver = '1.0'; + foreach ($elevators as $key => $elevator) { + + $elevator_knockdown_price = $elevator['elevator_price']; // 單台電梯售價 + $elevator_list_price = $elevator['option_other_price'] + $elevator['option_price'] + $elevator['elevator_price']; //牌價 + $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager); + $facility_no = $facilityno[$key]; + $bonus_json = [ + 'contract_type' => $type, + 'total' => $elevator_list_price, + 'fee_per_st' => $elevator_knockdown_price + ]; - if (!empty($result_bonus)) { - if ($result_bonus['result_status'] != "error") { - foreach ($result_bonus['bonus_array'] as $i => $result) { - $bonus_type = explode('-', $result['bonus_type']); - $pay_man_type = $bonus_type[0]; //發放類別 - $bonus_kind = $bonus_type[1]; - $amount = $result['bonus_amount']; //獎金水庫 - $bonus_receiver = $result['bonus_receiver']; //發放人員 - $bonus_json['payment_schedul_due'] = $result['payment_schedul_due']; - $bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation']; - $bonus_json['bonus_kind'] = $bonus_kind; - $a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE); - $sql = "INSERT INTO bonus + if (!empty($result_bonus)) { + if ($result_bonus['result_status'] != "error") { + foreach ($result_bonus['bonus_array'] as $i => $result) { + $bonus_type = explode('-', $result['bonus_type']); + $pay_man_type = $bonus_type[0]; //發放類別 + $bonus_kind = $bonus_type[1]; + $amount = $result['bonus_amount']; //獎金水庫 + $bonus_receiver = $result['bonus_receiver']; //發放人員 + $bonus_json['payment_schedul_due'] = $result['payment_schedul_due']; + $bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation']; + $bonus_json['bonus_kind'] = $bonus_kind; + $a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE); + $sql = "INSERT INTO bonus (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,status,bonus_json,create_id,create_at) VALUES ($pay_man_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$bonus_receiver',$status,'$a','$create_id','$create_at') "; - $stmt = $conn->prepare($sql); - $stmt->execute(); + $stmt = $conn->prepare($sql); + $stmt->execute(); + } + $request = [ + "status" => "1", + "data" => "Success" + ]; + return $request; } $request = [ - "status" => "1", - "data" => "Success" + "status" => "2", + "data" => "create_bonus_error" ]; return $request; } - $request = [ - "status" => "2", - "data" => "create_bonus_error" - ]; - return $request; } - } - } else if ($signing_date >= $bonus_v2_0_date) { - $ver = '2.0'; - foreach ($elevators as $key => $elevator) { - $elevator_type = $dailyNecessities[$elevator['spec']]; - $elevator_list_price = $elevator['option_other_price'] + $elevator['option_price'] + $elevator['elevator_price']; - $elevator_knockdown_price = $elevator['elevator_price']; - $commission_fee = $elevator['commission_fee']; - $result_bonus = elevator_new_deal_bonus_v2_0( - $ver, - $type, - $elevator_type, - $elevator_list_price, - $elevator_knockdown_price, - $salesman, - $manager - ); - // echo '
';
-      // print_r($result_bonus);
-      // echo '
'; - $facility_no = $facilityno[$key]; - $bonus_json = [ - 'contract_type' => $type, - 'total' => $elevator_list_price, - 'fee_per_st' => $elevator_knockdown_price - ]; - if (!empty($result_bonus)) { - if ($result_bonus['result_status'] != "error") { - foreach ($result_bonus['bonus_array'] as $i => $result) { - $bonus_type = explode('-', $result['bonus_type']); - $pay_man_type = $bonus_type[0]; //發放類別 - $bonus_kind = $bonus_type[1]; - $amount = $result['bonus_amount']; //獎金水庫 - $bonus_receiver = $result['bonus_receiver']; //發放人員 - $bonus_json['payment_schedul_due'] = $result['payment_schedul_due']; - $bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation']; - $bonus_json['bonus_kind'] = $bonus_kind; - $a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE); - $sql = "INSERT INTO bonus + } else if ($signing_date >= $bonus_v2_0_date) { + $ver = '2.0'; + foreach ($elevators as $key => $elevator) { + $option_other_price = !empty($elevator['option_other_price']) ? intval($elevator['option_other_price']) : 0; + $elevator_type = $dailyNecessities[$elevator['spec']]; + $elevator_list_price = $option_other_price + $elevator['option_price'] + $elevator['elevator_price']; + $elevator_knockdown_price = $elevator['elevator_price']; + $commission_fee = $elevator['commission_fee']; + $result_bonus = elevator_new_deal_bonus_v2_0( + $ver, + $type, + $elevator_type, + $elevator_list_price, + $elevator_knockdown_price, + $salesman, + $manager + ); + // echo '
';
+        // print_r($result_bonus);
+        // echo '
'; + $facility_no = $facilityno[$key]; + $bonus_json = [ + 'contract_type' => $type, + 'total' => $elevator_list_price, + 'fee_per_st' => $elevator_knockdown_price + ]; + if (!empty($result_bonus)) { + if ($result_bonus['result_status'] != "error") { + foreach ($result_bonus['bonus_array'] as $i => $result) { + $bonus_type = explode('-', $result['bonus_type']); + $pay_man_type = $bonus_type[0]; //發放類別 + $bonus_kind = $bonus_type[1]; + $amount = $result['bonus_amount']; //獎金水庫 + $bonus_receiver = $result['bonus_receiver']; //發放人員 + $bonus_json['payment_schedul_due'] = $result['payment_schedul_due']; + $bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation']; + $bonus_json['bonus_kind'] = $bonus_kind; + $a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE); + $sql = "INSERT INTO bonus (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,status,bonus_json,create_id,create_at) VALUES ($pay_man_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$bonus_receiver',$status,'$a','$create_id','$create_at') "; - $stmt = $conn->prepare($sql); - $stmt->execute(); + $stmt = $conn->prepare($sql); + $stmt->execute(); + } } + $request = [ + "status" => "1", + "data" => "Success" + ]; + } else { + $request = [ + "status" => "2", + "data" => "create_bonus_error" + ]; } - $request = [ - "status" => "1", - "data" => "Success" - ]; - } else { - $request = [ - "status" => "2", - "data" => "create_bonus_error" - ]; } } - } - return $request; - - try { + return $request; } catch (PDOException $e) { header("HTTP/1.1 500 Internal Server Error"); die('Error!:' . $e->getMessage()); } } + +function do_wws_assign1($user_id, $form_id, $flow_code, $conn) +{ + $tds = date("Y-m-d H:i:s"); + + $sql = "select appwms.nextval('form_key') form_key"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $form_key = $result['form_key']; + + $sql = "INSERT INTO flow (system_id, flow_id, form_key, form_id,flow_code) VALUES ('wws', 'wws01', '$form_key', '$form_id','$flow_code');"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + + $sql = "INSERT INTO subflow (form_key, seq, current_assigner, create_date) VALUES ('$form_key', '1', '$user_id', '$tds');"; + $stmt = $conn->prepare($sql); + $stmt->execute(); +} diff --git a/wms/contract/api/test copy.json b/wms/contract/api/test copy.json index 5df03461..b9dd2f3f 100644 --- a/wms/contract/api/test copy.json +++ b/wms/contract/api/test copy.json @@ -3,22 +3,23 @@ "name": "MainSalesOrder", "rows": [ { - "BillNo": "M24020076", - "BillDate": 20240305, + "BillNo": "M23110121", + "BillDate": 20240313, "TypeId": "SO", "FOrgId": "1000", "OrgId": "1000", "ModeId": "M", - "BizPartnerId": "M24020076", + "BizPartnerId": "M23110121", "CurrId": "TWD", "CurrOAmount": 1, "CurrLAmount": 1, - "PersonId": "M0225", - "DueToId": "M24020076", + "PersonId": "M0042", + "DueToId": "M23110121", "TradeConditionId": "", "TaxId": "ST005", "CreditorCompId": "1001", - "CreditorOrgId": "1000" + "CreditorOrgId": "1000", + "CreatorId": "M0225" } ] }, @@ -27,87 +28,371 @@ "rows": [ { "TaxId": "ST005", - "RequirementDate": 20240305, - "ConsignmentDate": 20240305, - "BillNo": "M24020076", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", "RowCode": 1, "ItemType": 1, "MaterialId": "A40001", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 910000 + "SPrice": 3904000, + "CU_MaterialId": "4MH00836" }, { "TaxId": "ST005", - "RequirementDate": 20240305, - "ConsignmentDate": 20240305, - "BillNo": "M24020076", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", "RowCode": 2, "ItemType": 1, "MaterialId": "A40008", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 390000 + "SPrice": 976000, + "CU_MaterialId": "4MH00836" }, { "TaxId": "ST005", - "RequirementDate": 20240305, - "ConsignmentDate": 20240305, - "BillNo": "M24020076", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", "RowCode": 3, "ItemType": 0, - "MaterialId": "4MW00705", + "MaterialId": "4MH00836", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 0 + "SPrice": 0, + "CU_MaterialId": "4MH00836" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00837" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00837" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00837", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00837" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00838" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00838" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00838", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00838" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00839" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00839" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00839", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00839" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00840" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00840" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00840", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00840" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00841" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00841" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00841", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00841" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00842" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00842" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00842", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00842" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 3904000, + "CU_MaterialId": "4MH00843" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 976000, + "CU_MaterialId": "4MH00843" + }, + { + "TaxId": "ST005", + "RequirementDate": 20240313, + "ConsignmentDate": 20240313, + "BillNo": "M23110121", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MH00843", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0, + "CU_MaterialId": "4MH00843" } ] }, { "name": "salOrderStagePay", "rows": [ - [ - { - "PayStage": "簽約", - "PlanPercentage": 0.2, - "PlanPayAmt": 260000, - "PlanPayDate": 20240101, - "BillNo": "M24020076", - "RowCode": 0, - "RowNo": 0, - "UnWriteOffOAmount": 260000 - }, - { - "PayStage": "貨抵工地", - "PlanPercentage": 0.5, - "PlanPayAmt": 650000, - "PlanPayDate": 20240101, - "BillNo": "M24020076", - "RowCode": 1, - "RowNo": 1, - "UnWriteOffOAmount": 650000 - }, - { - "PayStage": "試車完工", - "PlanPercentage": 0.2, - "PlanPayAmt": 260000, - "PlanPayDate": 20240101, - "BillNo": "M24020076", - "RowCode": 2, - "RowNo": 2, - "UnWriteOffOAmount": 260000 - }, - { - "PayStage": "交車", - "PlanPercentage": 0.1, - "PlanPayAmt": 130000, - "PlanPayDate": 20240101, - "BillNo": "M24020076", - "RowCode": 3, - "RowNo": 3, - "UnWriteOffOAmount": 130000 - } - ] + { + "PayStage": "簽約", + "PlanPercentage": 0.2, + "PlanPayAmt": 976000, + "PlanPayDate": 20240413, + "BillNo": "M23110121", + "RowCode": 1, + "RowNo": 1, + "UnWriteOffOAmount": 976000 + }, + { + "PayStage": "二次款", + "PlanPercentage": 0.4, + "PlanPayAmt": 1952000, + "PlanPayDate": 20240313, + "BillNo": "M23110121", + "RowCode": 2, + "RowNo": 2, + "UnWriteOffOAmount": 1952000 + }, + { + "PayStage": "貨抵工地", + "PlanPercentage": 0.2, + "PlanPayAmt": 976000, + "PlanPayDate": 20241104, + "BillNo": "M23110121", + "RowCode": 3, + "RowNo": 3, + "UnWriteOffOAmount": 976000 + }, + { + "PayStage": "試車完工", + "PlanPercentage": 0.1, + "PlanPayAmt": 488000, + "PlanPayDate": 20241204, + "BillNo": "M23110121", + "RowCode": 4, + "RowNo": 4, + "UnWriteOffOAmount": 488000 + }, + { + "PayStage": "交車", + "PlanPercentage": 0.1, + "PlanPayAmt": 488000, + "PlanPayDate": 20250104, + "BillNo": "M23110121", + "RowCode": 5, + "RowNo": 5, + "UnWriteOffOAmount": 488000 + } ] } ] \ No newline at end of file diff --git a/wms/contract/api/test.json b/wms/contract/api/test.json index c0585164..da130a89 100644 --- a/wms/contract/api/test.json +++ b/wms/contract/api/test.json @@ -27,7 +27,7 @@ ] }, { - //salSalesOrderDetail + // salSalesOrderDetail "name": "SubOrder", "rows": [ { diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index 89077ffc..e9d2f04f 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,9 +1,5 @@ "M24020076", //合約單號 + "BillNo" => "$contract_no", //合約單號 "BillDate" => 20210420, //簽約日期 "TypeId" => "SO", // "FOrgId" => "1000", "OrgId" => "1000", "ModeId" => "M", // T汰改 M新梯 - "BizPartnerId" => "M24020076", //客戶代碼 + "BizPartnerId" => "$contract_no", //客戶代碼 "CurrId" => "TWD", "CurrOAmount" => 1, "CurrLAmount" => 1, - "PersonId" => "M0225", //業務人員 - "DueToId" => "M24020076", //債務方 + "PersonId" => "M0177", //業務人員 + "DueToId" => "$contract_no", //債務方 "TradeConditionId" => "", "TaxId" => "ST005", "CreditorCompId" => "1001", "CreditorOrgId" => "1000", - // "CompId" => "1001", - // "CreditorCurrOAmount" => 1, - // "CreditorCurrLAmount" => 1 + "CreatorId" => "M0225" + ]; // //salSalesOrderDetail // $SubOrder_row = []; @@ -104,13 +128,13 @@ for ($i = 0; $i < 3; $i++) { "ConsignmentDate" => 20210420, //發貨日期 // "DispatchCompId" => "1001", // "DispatchOrgId" => "1000", - "BillNo" => "M24020076", //合約號 + "BillNo" => "$contract_no", //合約號 "RowCode" => $i, //全部筆數排列 "ItemType" => 1, "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) "SUnitId" => "SET", "SQuantity" => 1, //交易數量 - "SPrice" => 50000 //交易價格 + "SPrice" => 100000 //交易價格 ]; } if ($i == 1) { @@ -122,25 +146,21 @@ for ($i = 0; $i < 3; $i++) { "ConsignmentDate" => 20210420, //發貨日期 // "DispatchCompId" => "1001", // "DispatchOrgId" => "1000", - "BillNo" => "M24020076", //合約號 + "BillNo" => "$contract_no", //合約號 "RowCode" => $i, //全部筆數排列 "ItemType" => 1, "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) "SUnitId" => "SET", "SQuantity" => 1, //交易數量 - "SPrice" => 700000 //交易價格 + "SPrice" => 650000 //交易價格 ]; } if ($i == 2) { $row = [ - // "SupplyCompId" => "1001", - // "SupplyOrgId" => "1000", "TaxId" => "ST005", "RequirementDate" => 20210420, //出貨日期 "ConsignmentDate" => 20210420, //發貨日期 - // "DispatchCompId" => "1001", - // "DispatchOrgId" => "1000", - "BillNo" => "M24020076", //合約號 + "BillNo" => "$contract_no", //合約號 "RowCode" => $i, //全部筆數排列 "ItemType" => 0, "MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) @@ -152,65 +172,14 @@ for ($i = 0; $i < 3; $i++) { $SubOrder_row[] = $row; } -// // $salOrderStagePay_row = []; -// // // for ($i = 0; $i < 2; $i) { -// // // if ($i == 0) { -// // // $row = [ -// // // "BillNo" => "M24010201", -// // // "RowCode" => 1, -// // // "RowNo" => 1, -// // // "PayStage" => "簽約", //收款階段 -// // // "PlanPercentage" => 0.10, //計劃收款比例(%) -// // // "PlanPayAmt" => 100000, //計劃收款金額 -// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 -// // // "UnWriteOffOAmount" => 100000 //未核銷金額 -// // // ]; -// // // } -// // // if ($i == 1) { -// // // $row = [ -// // // "BillNo" => "M24010201", -// // // "RowCode" => 1, -// // // "RowNo" => 1, -// // // "PayStage" => "貨抵工地", //收款階段 -// // // "PlanPercentage" => 0.40, //計劃收款比例(%) -// // // "PlanPayAmt" => 100000, //計劃收款金額 -// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 -// // // "UnWriteOffOAmount" => 100000 //未核銷金額 -// // // ]; -// // // } -// // // if ($i == 2) { -// // // $row = [ -// // // "BillNo" => "M24010201", -// // // "RowCode" => 1, -// // // "RowNo" => 1, -// // // "PayStage" => "試車完工", //收款階段 -// // // "PlanPercentage" => 0.30, //計劃收款比例(%) -// // // "PlanPayAmt" => 100000, //計劃收款金額 -// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 -// // // "UnWriteOffOAmount" => 100000 //未核銷金額 -// // // ]; -// // // } -// // // if ($i == 3) { -// // // $row = [ -// // // "BillNo" => "M24010201", -// // // "RowCode" => 1, -// // // "RowNo" => 1, -// // // "PayStage" => "交車", //收款階段 -// // // "PlanPercentage" => 0.20, //計劃收款比例(%) -// // // "PlanPayAmt" => 100000, //計劃收款金額 -// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 -// // // "UnWriteOffOAmount" => 100000 //未核銷金額 -// // // ]; -// // // } -// // // $salOrderStagePay_row[] = $row; -// // // } + $salOrderStagePay_row = []; $roww = [ "PayStage" => "簽約", //收款階段 "PlanPercentage" => 0.5, //計劃收款比例(%) "PlanPayAmt" => 375000, //計劃收款金額 "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 - "BillNo" => "M24020076", + "BillNo" => "$contract_no", "RowCode" => 1, "RowNo" => 1, "UnWriteOffOAmount" => 375000 //未核銷金額 @@ -220,12 +189,14 @@ $roww2 = [ "PlanPercentage" => 0.5, "PlanPayAmt" => 375000, "PlanPayDate" => 20240101, - "BillNo" => "M24020076", + "BillNo" => "$contract_no", "RowCode" => 2, "RowNo" => 2, "UnWriteOffOAmount" => 375000 ]; $salOrderStagePay_row[] = $roww; +$salOrderStagePay_row[] = $roww2; + $MainSalesOrder = [ "name" => "MainSalesOrder", @@ -250,9 +221,9 @@ $APIbody[] = $salOrderStagePay; // print_r($data); // echo ""; -// echo "
";
-// print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
-// echo "
"; +echo "
";
+print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
+echo "
"; // exit(); $header = [ diff --git a/wms/contract/contract-newelevator-input.php b/wms/contract/contract-newelevator-input.php index 75992ffc..70d83b32 100644 --- a/wms/contract/contract-newelevator-input.php +++ b/wms/contract/contract-newelevator-input.php @@ -134,7 +134,17 @@ $persons = array_map(function ($person) { - + 區域 + + + @@ -187,7 +197,7 @@ $persons = array_map(function ($person) { QC和官檢 - diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index 104ab4f7..59d63b01 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -829,6 +829,8 @@ const contractNewInput = () => { elevators_detail_arr: [], // 電梯台數 Array pay_arr: [], //電梯付款種類 nums: 0, //電梯數量 + area_no: 'T', + contract_arrival_date: '' }, step: 1, isLoading: false, @@ -868,14 +870,15 @@ const contractNewInput = () => { this.data.elevators_detail_arr[i].longitude = ''; // 緯度 this.data.elevators_detail_arr[i].manage = ''; // 工地負責人 this.data.elevators_detail_arr[i].qc = ''; // QC和官檢 - this.data.elevators_detail_arr[i].contract_arrival_date = ''; //合約交期(到工地) + this.data.elevators_detail_arr[i].contract_arrival_date = this.data.contract_arrival_date; //合約交期(到工地) + // this.data.elevators_detail_arr[i].area_no = ''; //區域 } this.step = 3; this.isLoading = false; } else if (this.step == 3) { console.log(this.data.elevators_detail_arr); - this.step = 4; - this.isLoading = false; + // this.step = 4; + // this.isLoading = false; } }, getContractDate() { @@ -889,7 +892,7 @@ const contractNewInput = () => { return } if (!this.customize) { - console.log(res.data); + console.log(res.data.customer); this.data.customer = res.data.company this.data.manager = res.data.manager this.data.vat = res.data.uscc @@ -904,6 +907,7 @@ const contractNewInput = () => { this.data.elevators_detail_arr = res.data.elevators_detail_arr; this.data.nums = res.data.nums; this.data.pay_arr = res.data.pay_arr; + this.data.contract_arrival_date = res.data.facilitok_date; } this.step = 2 this.isLoading = false @@ -919,6 +923,7 @@ const contractNewInput = () => { form.append('customer', this.data.customer); form.append('manager', this.data.manager); form.append('vat', this.data.vat); + form.append('area_no', this.data.area_no); form.append('case_name', this.data.case_name); form.append('linkman', this.data.linkman); form.append('lm_tel', this.data.lm_tel);