From 1d3989ba9c9f6f1576d2c07c196127944df768c9 Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 26 Feb 2024 18:02:29 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E5=A5=91=E7=B4=84?= =?UTF-8?q?=E7=8D=8E=E9=87=91=E5=92=8C=E7=B0=BD=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/bonus/bonus.php | 18 ++- .../other/maintenance_contract_bonus_v2_1.php | 52 ++++--- ...erm_contract_m1_free_charge_bonus_v2_1.php | 127 +++++++++--------- wms/contract/api/getContractData.php | 59 ++++++-- wms/contract/api/postContractData.php | 25 ++-- wms/contract/api/postNewContractData.php | 63 ++++++--- wms/contract/contract-input.php | 20 +-- wms/contract/js/alpine.js | 3 +- 8 files changed, 222 insertions(+), 145 deletions(-) diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php index 4e0b84fd..63bec621 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/bonus.php @@ -32,15 +32,17 @@ if (!empty($_GET['check'])) { if ($_GET['check'] == 4) { $oneMonthAgo = date("Y-m-d", strtotime("$now +1 months")); // $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' AND status IN (1,2,5)"; - $clause .= "AND status IN (1,2,5)"; + $clause .= "AND a.status IN (1,2,5)"; } else if ($_GET['check'] == 2) { - $clause .= "AND status = 1"; + $clause .= "AND a.status = 1"; } else if ($_GET['check'] == 3) { - $clause .= "AND status IN (2,5)"; + $clause .= "AND a.status IN (2,5)"; } } -$sql = "SELECT * FROM bonus WHERE 1=1 $clause"; +$sql = "SELECT a.*,b.customer FROM bonus AS a +LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no +WHERE 1=1 $clause"; $stmt = $conn->prepare($sql); $stmt->execute(); $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -130,17 +132,21 @@ function isPay($contract_no, $connT8) btn-sm categoryBtn"> 未發獎金 btn-sm categoryBtn"> 已發獎金 btn-sm categoryBtn"> 人事發放作業 + btn-sm categoryBtn"> 獎金總計(人) + + + - + @@ -178,8 +184,8 @@ function isPay($contract_no, $connT8) ?> - + diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php index 610da6d7..598202d4 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1.php @@ -55,48 +55,48 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case ($discount >= 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.6; + $sales_bonus = ($fee_per_st) * 0.6; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.7; + $sales_bonus = ($fee_per_st) * 0.7; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.8; + $sales_bonus = ($fee_per_st) * 0.8; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.9; + $sales_bonus = ($fee_per_st) * 0.9; break; }; break; case ($discount >= 0.6 and $discount < 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.48; + $sales_bonus = ($fee_per_st) * 0.48; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.56; + $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.64; + $sales_bonus = ($fee_per_st) * 0.64; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.72; + $sales_bonus = ($fee_per_st) * 0.72; break; }; break; case ($discount < 0.6): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.42; + $sales_bonus = ($fee_per_st) * 0.42; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.49; + $sales_bonus = ($fee_per_st) * 0.49; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.56; + $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.63; + $sales_bonus = ($fee_per_st) * 0.63; break; }; break; @@ -111,16 +111,16 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "free_to_charge": switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.3; + $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.35; + $sales_bonus = ($fee_per_st) * 0.35; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.4; + $sales_bonus = ($fee_per_st) * 0.4; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.45; + $sales_bonus = ($fee_per_st) * 0.45; break; }; #地區處長獎金($region_director_bonus) @@ -132,16 +132,16 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "renew_priceissue": switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.25; + $sales_bonus = ($fee_per_st) * 0.25; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.3; + $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.35; + $sales_bonus = ($fee_per_st) * 0.35; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.4; + $sales_bonus = ($fee_per_st) * 0.4; break; }; #地區處長獎金($region_director_bonus) @@ -226,7 +226,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, #2月1次 case "bimonthly": - $payment_ratio_due_array = array(0.166, 0.166, 0.166, 0.166, 0.166, 0.166); + $payment_ratio_due_array = array(); + for ($i = 0; $i < 6; $i++) { + array_push($payment_ratio_due_array, 1 / 6); + } $payday_due_array = array(1, 3, 5, 7, 9, 11); for ($i = 0; $i < count($payment_ratio_due_array); $i++) { if ($i < count($payment_ratio_due_array) - 1) { @@ -246,7 +249,12 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, #月付 case "monthly": - $payment_ratio_due_array = array(0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083); + $payment_ratio_due_array = array(); + // $payment_ratio_due_array = array(); + for ($i = 0; $i < 12; $i++) { + array_push($payment_ratio_due_array, 1 / 12); + } + $payday_due_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); for ($i = 0; $i < count($payment_ratio_due_array); $i++) { if ($i < count($payment_ratio_due_array) - 1) { diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php index 7122fbd3..d29650b2 100644 --- a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php @@ -41,12 +41,13 @@ result_array[ -function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id){ +function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id) +{ $bonus_array = []; - if ($ver == "2.1"){ + if ($ver == "2.1") { $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); #契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge) - switch ($contract_type){ + switch ($contract_type) { case "longcontract_m1_free_charge": #契約員獎金($sales_bonus) #合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) @@ -54,57 +55,57 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract case ($discount >= 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.6; + $sales_bonus = ($fee_per_st) * 0.6; break; case ($fee_per_st > 300 and $fee_per_st <= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.7; - break; + $sales_bonus = ($fee_per_st) * 0.7; + break; case ($fee_per_st > 4000 and $fee_per_st <= 5000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.8; + $sales_bonus = ($fee_per_st) * 0.8; break; case ($fee_per_st > 5000 and $fee_per_st <= 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.9; - break; + $sales_bonus = ($fee_per_st) * 0.9; + break; case ($fee_per_st > 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 1.0; + $sales_bonus = ($fee_per_st) * 1.0; break; }; break; case ($discount >= 0.6 and $discount < 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.42; + $sales_bonus = ($fee_per_st) * 0.42; break; case ($fee_per_st > 300 and $fee_per_st <= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.49; - break; + $sales_bonus = ($fee_per_st) * 0.49; + break; case ($fee_per_st > 4000 and $fee_per_st <= 5000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.56; + $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st > 5000 and $fee_per_st <= 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.63; - break; + $sales_bonus = ($fee_per_st) * 0.63; + break; case ($fee_per_st > 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.7; + $sales_bonus = ($fee_per_st) * 0.7; break; }; break; case ($discount < 0.6): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.3; + $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st > 300 and $fee_per_st <= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.35; - break; + $sales_bonus = ($fee_per_st) * 0.35; + break; case ($fee_per_st > 4000 and $fee_per_st <= 5000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.4; + $sales_bonus = ($fee_per_st) * 0.4; break; case ($fee_per_st > 5000 and $fee_per_st <= 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.45; - break; + $sales_bonus = ($fee_per_st) * 0.45; + break; case ($fee_per_st > 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.5; + $sales_bonus = ($fee_per_st) * 0.5; break; }; break; @@ -116,81 +117,77 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $regular_contract_manger_bonus = 300; break; }; - + #地區處長獎金、專任契約經理、契約員獎金 - switch ($payment_period_amount){ - #簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 - #總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, + switch ($payment_period_amount) { + #簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 + #總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, case $payment_period_amount >= 60: #地區處長獎金 - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "地區處長獎金", #獎金名稱 "bonus_receiver" => $region_director_id, #發放人員 "bonus_amount" => round($region_director_bonus), #金額 - "pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "bonus_regulation" => "訂金收回後次月發放" #發放規定 - ]); + ]); #專任契約經理獎金 - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "專任契約經理獎金", #獎金名稱 "bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_amount" => round($regular_contract_manger_bonus), #金額 - "pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "bonus_regulation" => "訂金收回後次月發放" #發放規定 - ]); - + ]); + #產生契約員每個月的獎金應發比例 $payment_ratio_due_array = array(); for ($i = 0; $i < $payment_period_amount; $i++) { - array_push($payment_ratio_due_array, 1/$payment_period_amount); - } - + array_push($payment_ratio_due_array, 1 / $payment_period_amount); + } + $payday_due_array = array(); for ($i = 0; $i < $payment_period_amount; $i++) { - array_push($payday_due_array, $i+1 ); - } - - for($i = 0; $i < count($payment_ratio_due_array); $i++) { - if($i < count($payment_ratio_due_array) - 1){ + array_push($payday_due_array, $i + 1); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 - }else{ + } else { $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 - }; - array_push($bonus_array,[ + }; + array_push($bonus_array, [ "bonus_type" => "契約員獎金", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 - "pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 - ]); - } + ]); + } break; } - + $result_array = [ - "ver"=>$ver, #獎金版本 - "result_status"=>"success", #計算結果 - "bonus_array"=>$bonus_array #獎金水庫 + "ver" => $ver, #獎金版本 + "result_status" => "success", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 ]; - - }else{ - array_push($bonus_array,[ + } else { + array_push($bonus_array, [ "bonus_type" => "error", #獎金名稱 "bonus_receiver" => "error", #發放人員 "bonus_amount" => 0, #金額 "pay_day_due" => "9999-1-1", #預計發放時間 "bonus_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; }; - - -?> diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index 253e8d54..5534b8eb 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -1,5 +1,6 @@ prepare($sql); $stmt->bindParam(':mid', $mid); $stmt->execute(); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $elevators_results = $stmt->fetchAll(PDO::FETCH_ASSOC); $elevators_detail_arr = []; - foreach ($results as $keys => $result) { + + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->execute(); + $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $option_arr = []; + + foreach ($elevators_results as $keys => $result) { + $item_no = $result['item_no']; //電梯項次 + // 電梯 OPTION + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' AND option_relate_spec = :item_no"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->execute(); + $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $option_arr[] = $option_results; + if (!empty($option_results)) { + $result['option_price'] = 0; + // 電梯 OPTION 價格分別加到各台電梯 + foreach ($option_arr[$keys] as $key => $option) { + if ($option['item_qty'] == $result['item_qty']) { + $result['option_price'] += intval($option['item_unit_price']); + echo '1..'; + } else if ($option['item_qty'] > $result['item_qty'] != 1) { + $item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數 + $result['option_price'] += intval($option['item_unit_price']) * $item_qty; + echo '2..'; + } else { + $result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']); + echo '3..'; + } + echo '
';
+                    print_r($option['item_no'] . '--->' . $option['item_unit_price']);
+                    echo '
'; + } + + print_r($result['option_price']); + exit(); + } $note = explode(',', $result['note']); - $result['spec'] = $note[0]; //型號 + $result['spec'] = $note[0]; //型號 $result['person'] = $note[1]; // 人承 $result['floor'] = $note[2]; // 樓層 $result['speed'] = $note[3]; // 速度 @@ -82,21 +124,20 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont array_push($elevators_detail_arr, $result); } } + // print_r(COUNT($option_results)); + $count = COUNT($elevators_detail_arr); - $contract['elevators'] = $results; + $contract['elevators'] = $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'); // 將 JSON 回應返回給客戶端 - echo $contractResponse; + // echo $contractResponse; } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 29038b9f..d3ecf356 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -88,10 +88,10 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c if ($address == '') $fail_arr[] = '地址為必填'; if ($area == '') $fail_arr[] = '區域為必填'; if ($customer == '') $fail_arr[] = '客戶為必填'; - if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; - if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; - if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; - if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; + // if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; + // if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; + // if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; + // if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; if ($num == '') $fail_arr[] = '電梯數量為必填'; if ($payType == '') $fail_arr[] = '付款方式為必填'; if (count($fail_arr) > 0) { @@ -99,7 +99,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - T8insert($_POST, $facilityno, $depId); + // T8insert($_POST, $facilityno, $depId); bonusCreate($_POST, $facilityno, $conn); //create account table $accounttype = "A"; @@ -127,7 +127,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':repairerid', $repairerid); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - $stmt->execute(); + // $stmt->execute(); //create contract table @@ -163,7 +163,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':end_date', $end_date); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - $stmt->execute(); + // $stmt->execute(); //create facility table // $createFacilityNo = new CreateFacilityNo(); @@ -238,7 +238,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':area', $area); $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); $stmt->bindParam(':licensedate', $ADuseful_date); - $result = $stmt->execute(); + // $result = $stmt->execute(); } //create schedule table @@ -259,7 +259,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':duedate', $combo[1]); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - $result = $stmt->execute(); + // $result = $stmt->execute(); } } // create contract_b_signed_back table @@ -366,7 +366,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(":created_by", $user_id); $stmt->bindParam(':payType', $payType); - $stmt->execute(); + // $stmt->execute(); // T8insert($_POST, $facilityno); @@ -665,7 +665,7 @@ function bonusCreate($data, $facilityno, $conn) $status = 1; $bonus_json = []; $create_id = $data['user_id']; - $create_at = date('Y-m-d'); + $create_at = date('Y-m-d H:i:s'); $contract_no = !empty($data['contractno']) ? $data['contractno'] : ''; $contract_kind = 3; @@ -689,7 +689,7 @@ function bonusCreate($data, $facilityno, $conn) $contract_type = $elevator['contract_type']; //合約類別 $payment_period = $payment[$payType]; //付款方式 $elevator_list_price = intval($elevator['stand_price']); //牌價 - $fee_per_st = $elevator['contract_price']; //作翻契約金額 + $fee_per_st = $elevator['sold_price']; //作翻契約金額 $commission_fee = $elevator['service_expense']; //服務費(月) $receivable_date_due = $payDay; //第一筆保養款項收回日 $sales_id = $salesman; //營業人員 @@ -722,6 +722,7 @@ function bonusCreate($data, $facilityno, $conn) $stmt->execute(); } } + // exit(); } // exit(); } catch (PDOException $e) { diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index d94dac12..6180e4d4 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -27,7 +27,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $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 '
'; @@ -54,12 +54,12 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c //create facility table $createFacilityNo = new CreateFacilityNo(); $dailyNecessities = [ - 'MAE100' => 'X', - 'MAM200' => 'W', - 'MAH100' => 'H', - 'MAQ100' => 'Z', - 'MAF100' => 'F', - 'MAZ100' => 'B', + 'MAE100' => 'X', //小機房客梯 + 'MAM200' => 'W', //無機房客梯 + 'MAH100' => 'H', //小電梯 + 'MAQ100' => 'Z', //強趨梯 + 'MAF100' => 'F', //貨梯 + 'MAP100' => 'B', //平台梯 ]; $arr = []; // 建立作番號 @@ -68,9 +68,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $arr[] = $dailyNecessities[$elevator['spec']]; } $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); - echo '
';
-    print_r($facilityno);
-    echo '
'; + + BounsCount($_POST, $conn, $facilityno); exit(); $conn->beginTransaction(); @@ -282,39 +281,63 @@ function T8Insert($data) } -function BounsCount($data, $conn) +function BounsCount($data, $conn, $facilityno) { // echo '
';
-  // print_r($data);
+  // print_r($facilityno);
   // 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'; + $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']; $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶 - $elevator_knockdown_price = $data['price_total']; //受價總額 + // $elevator_knockdown_price = $data['price_total']; //受價總額 + $elevators = json_decode($data['elevators_detail_arr'], true); $salesman = $data['salesman']; $manager = $data['manager']; + + $result_bonus = []; + $result_bonus_arr = []; 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); + foreach ($elevators as $i => $elevator) { + + $elevator_knockdown_price = $elevator['item_price_ct']; + $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager); + $result_bonus['facility'] = $facilityno[$i]; + $result_bonus_arr[] = $result_bonus; + } } else if ($signing_date >= $bonus_v2_0_date) { $ver = '2.0'; - // $result_bonus = elevator_new_deal_bonus_v2_0($ver,$contract_type,); + foreach ($elevators as $i => $elevator) { + $elevator_type = $dailyNecessities[$elevator['spec']]; + $elevator_list_price = $elevator['']; + $result_bonus = elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id); + } } - + // foreach ($elevators as $elevator) { + // $elevator_knockdown_price = $elevator['item_price_ct']; + // } echo '
';
-  print_r($result_bonus);
+  print_r($result_bonus_arr);
   echo '
'; exit(); try { diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 114cea2f..58acb4a8 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -111,7 +111,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -158,7 +158,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- + - + - - + + - + diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index b2ad1eb9..db386702 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -1090,7 +1090,8 @@ const contractInput = () => { contract_type: '', manager: '', regular_contract_manger_id: '', - bonus_verson: '' + bonus_verson: '', + sold_price: '' }) } }, From 8408a410e63329e3e46c5b0cdc004b7a05849729 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 27 Feb 2024 17:37:18 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E4=BF=9D=E9=A4=8A=E7=8D=8E=E9=87=91?= =?UTF-8?q?=E8=A8=88=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/maintenance_contract_bonus_v2_1.php | 24 +- ...enance_contract_bonus_v2_1_examination.php | 8 +- ...m_contract_m1_free_charge_bonus_v2_1_1.php | 312 ++++++++++++++++++ ..._m1_free_charge_bonus_v2_1_examination.php | 174 +++++++--- wms/contract/api/postContractData.php | 140 +++++++- wms/contract/contract-input.php | 54 +-- wms/contract/js/alpine.js | 55 +-- 7 files changed, 649 insertions(+), 118 deletions(-) create mode 100644 wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php index 598202d4..27959883 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1.php @@ -45,7 +45,9 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, { $bonus_array = []; if ($ver == "2.1") { - $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); + // $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); + $discount = ($fee_per_st - $commission_fee) / $elevator_list_price; + #契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue) switch ($contract_type) { case "new": @@ -54,10 +56,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, switch ($discount) { case ($discount >= 0.8): switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.6; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.7; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -70,10 +72,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, break; case ($discount >= 0.6 and $discount < 0.8): switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.48; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -86,10 +88,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, break; case ($discount < 0.6): switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.42; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.49; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -110,10 +112,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "free_to_charge": switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.3; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.35; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -131,10 +133,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "renew_priceissue": switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.25; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php b/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php index d68bdb7d..5b26e9c8 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php @@ -270,9 +270,9 @@ $examination_array = [ // echo '10、專任契約經理員工號($regular_contract_manger_id)
'; for ($i = 0; $i < count($examination_array); $i++) { - $fee_per_st = $examination_array[$i][3]; - $commission_fee = $examination_array[$i][5]; - $elevator_list_price = $examination_array[$i][4]; + $fee_per_st = $examination_array[$i][4]; //作番金額 + $commission_fee = $examination_array[$i][5]; // 服務費 + $elevator_list_price = $examination_array[$i][3]; // 牌價 $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); // echo "$fee_per_st - $commission_fee / $elevator_list_price "; @@ -314,7 +314,7 @@ for ($i = 0; $i < count($examination_array); $i++) { ]; echo "獎金版本:" . $result["ver"] . "
"; echo "計算結果:" . $result["result_status"] . "
"; - echo "傳入參數說明:" . $contract_type[$examination_array[$i][1]] . "、" . $pay_kind[$examination_array[$i][2]] . "、牌價" . $examination_array[$i][3] . "元、簽約價" . $examination_array[$i][4] . "元、服務費600元(折扣率" . $discount . ")、契約人員 : " . $examination_array[$i][7] . "、區經理 : " . $examination_array[$i][8] . " 、契約經理 : " . $examination_array[$i][9] . "
"; + echo "傳入參數說明:" . $contract_type[$examination_array[$i][1]] . "、" . $pay_kind[$examination_array[$i][2]] . "、牌價" . $examination_array[$i][3] . "元、簽約價" . $examination_array[$i][4] . "元、服務費" . $commission_fee . "元(折扣率" . $discount . ")、契約人員 : " . $examination_array[$i][7] . "、區經理 : " . $examination_array[$i][8] . " 、契約經理 : " . $examination_array[$i][9] . "
"; 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] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . " " . $examination_array[$i][9] . "
"; diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php new file mode 100644 index 00000000..70a19f40 --- /dev/null +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php @@ -0,0 +1,312 @@ +$ver, #獎金版本 + "result_status"=>"success", #計算結果 + "$bonus_array"=>$bonus_array #所有獎金水庫 + ]; + +*/ + + + +function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '') +{ + $bonus_array = []; + if ($ver == "2.1") { + $discount = ($fee_per_st - $commission_fee) / $elevator_list_price; + #契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge) + switch ($contract_type) { + case "longcontract_m1_free_charge": + #契約員獎金($sales_bonus) + #合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) + switch ($discount) { + case ($discount >= 0.8): + switch ($fee_per_st) { + case ($fee_per_st < 3000): + $sales_bonus = ($fee_per_st) * 0.6; + break; + case ($fee_per_st >= 3000 and $fee_per_st < 4000): + $sales_bonus = ($fee_per_st) * 0.7; + break; + case ($fee_per_st >= 4000 and $fee_per_st < 5000): + $sales_bonus = ($fee_per_st) * 0.8; + break; + case ($fee_per_st >= 5000 and $fee_per_st < 6000): + $sales_bonus = ($fee_per_st) * 0.9; + break; + case ($fee_per_st >= 6000): + $sales_bonus = ($fee_per_st) * 1.0; + break; + }; + break; + case ($discount >= 0.6 and $discount < 0.8): + switch ($fee_per_st) { + case ($fee_per_st < 3000): + $sales_bonus = ($fee_per_st) * 0.42; + break; + case ($fee_per_st >= 3000 and $fee_per_st <= 4000): + $sales_bonus = ($fee_per_st) * 0.49; + break; + case ($fee_per_st >= 4000 and $fee_per_st < 5000): + $sales_bonus = ($fee_per_st) * 0.56; + break; + case ($fee_per_st >= 5000 and $fee_per_st < 6000): + $sales_bonus = ($fee_per_st) * 0.63; + break; + case ($fee_per_st >= 6000): + $sales_bonus = ($fee_per_st) * 0.7; + break; + }; + break; + case ($discount < 0.6): + switch ($fee_per_st) { + case ($fee_per_st < 3000): + $sales_bonus = ($fee_per_st) * 0.3; + break; + case ($fee_per_st >= 3000 and $fee_per_st < 4000): + $sales_bonus = ($fee_per_st) * 0.35; + break; + case ($fee_per_st >= 4000 and $fee_per_st < 5000): + $sales_bonus = ($fee_per_st) * 0.4; + break; + case ($fee_per_st >= 5000 and $fee_per_st < 6000): + $sales_bonus = ($fee_per_st) * 0.45; + break; + case ($fee_per_st >= 6000): + $sales_bonus = ($fee_per_st) * 0.5; + break; + }; + break; + }; + + #地區處長獎金($region_director_bonus) + $region_director_bonus = 170; + #專任契約經理獎金($regular_contract_manger_bonus) + $regular_contract_manger_bonus = 300; + break; + }; + #付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) + array_push($bonus_array, [ + "bonus_type" => "地區處長獎金", #獎金名稱 + "bonus_receiver" => $region_director_id, #發放人員 + "bonus_amount" => round($region_director_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 + "bonus_regulation" => "訂金收回後次月發放" #發放規定 + ]); + + #專任契約經理獎金 + if ($regular_contract_manger_id != '') { + array_push($bonus_array, [ + "bonus_type" => "專任契約經理獎金", #獎金名稱 + "bonus_receiver" => $regular_contract_manger_id, #發放人員 + "bonus_amount" => round($regular_contract_manger_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 + "bonus_regulation" => "訂金收回後次月發放" #發放規定 + ]); + } + + #地區處長獎金、專任契約經理、契約員獎金 + switch ($payment_period) { + #簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 + #總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, + #年繳 + case 'annually': + $payment_ratio_due_array = array(); + $a = $payment_period_amount / 12; + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, $i + 1); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + + break; + #半年繳 + case 'semiannually': + $payment_ratio_due_array = array(); + $a = $payment_period_amount / 6; + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, ($i + 1) * 6); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + #季繳 + case 'quarterly': + $a = $payment_period_amount / 3; + $payment_ratio_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, ($i + 1) * 4); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + break; + #雙月繳 + case 'bimonthly': + $a = $payment_period_amount / 2; + $payment_ratio_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, ($i + 1) * 2); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + break; + #月繳 + case 'monthly': + + #產生契約員每個月的獎金應發比例 + $payment_ratio_due_array = array(); + for ($i = 0; $i < $payment_period_amount; $i++) { + array_push($payment_ratio_due_array, 1 / $payment_period_amount); + } + + $payday_due_array = array(); + for ($i = 0; $i < $payment_period_amount; $i++) { + array_push($payday_due_array, $i + 1); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + } + + $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, #金額 + "pay_day_due" => "9999-1-1", #預計發放時間 + "bonus_regulation" => "error" #發放規定 + ]); + $result_array = [ + "ver" => $ver, #獎金版本 + "result_status" => "error", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + } + + return $result_array; +}; diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php index 0c42a890..3e0c3af0 100644 --- a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php @@ -40,62 +40,150 @@ result_array[ */ -require_once("maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php"); - -#$ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id - - +require_once("maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php"); #獎金測試 $examination_array = [ #錯誤版本 - ["1.0","longcontract_m1_free_charge",60,0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"], + // ["1.0", 'annually', "longcontract_m1_free_charge", 60, 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #60期 - ["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59) - + //付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 2999, 600, "2014-07-01", "M0001", "M0002"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'semiannually', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'quarterly', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'bimonthly', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'monthly', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 2999, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'semiannually', 60, 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'quarterly', 60, 3000, 5000, 3200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'bimonthly', 60, 3000, 6000, 4200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'monthly', 60, 3000, 7000, 5200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 2999, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'semiannually', 60, 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'quarterly', 60, 3000, 5000, 3230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'bimonthly', 60, 3000, 6000, 4230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'monthly', 60, 3000, 7000, 5230, "2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59) + + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59) ]; -for($i = 0; $i "契約員獎金", #獎金名稱 + // "bonus_receiver" => $sales_id, #發放人員 + // "bonus_amount" => round($current_bonus), #金額 + // "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間 + // "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + // ]); + // } + // echo '
';
+	// print_r($bonus_array);
+	// echo '
'; + // exit(); $result = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( - $examination_array[$i][0], - $examination_array[$i][1], - $examination_array[$i][2], - $examination_array[$i][3], - $examination_array[$i][4], - $examination_array[$i][5], - $examination_array[$i][6], - $examination_array[$i][7], - $examination_array[$i][8], - $examination_array[$i][9] + $ver, + $contract_type, + $payment_period, + $payment_period_amount, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id ); + + $discount = (($fee_per_st - $commission_fee) / $elevator_list_price); + #新簽約、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8) + $contract_type = [ + 'new' => '新簽約', + 'free_to_charge' => '免保轉有費', + 'renew_priceissue' => '續簽約(原價或僅契約金額異動)', + 'longcontract_m1_free_charge' => '五年長約' + + ]; + // 付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) + $pay_kind = [ + 'monthly' => '月繳', + 'bimonthly' => '雙月繳', + 'quarterly' => '季繳', + 'semiannually' => '半年繳', + 'annually' => '年繳' + ]; + + // + $bonus_type = [ + '1' => '契約員獎金', + '2' => '區經理獎金', + '3' => '契約經理獎金' + ]; echo "獎金版本:" . $result["ver"] . "
"; echo "計算結果:" . $result["result_status"] . "
"; - 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] . " " . $examination_array[$i][7]. " " . $examination_array[$i][8] . " " - . $examination_array[$i][9] . "
"; - for($j = 0; $j"; + echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][4] . " " + . $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . " " + . $examination_array[$i][9] . "
"; + $n = 0; + for ($j = 0; $j < count($result["bonus_array"]); $j++) { + if ($result["bonus_array"][$j]["bonus_receiver"] == "M0001") { + + $n++; + echo '[' . $n . ']'; + } echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " " - . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " " - . $result["bonus_array"][$j]["bonus_regulation"] . "
"; + . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " " + . $result["bonus_array"][$j]["bonus_regulation"] . "
"; }; echo "-------------------------" . "
"; - }; - - -?> diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index d3ecf356..e8dca10f 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -88,10 +88,10 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c if ($address == '') $fail_arr[] = '地址為必填'; if ($area == '') $fail_arr[] = '區域為必填'; if ($customer == '') $fail_arr[] = '客戶為必填'; - // if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; - // if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; - // if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; - // if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; + if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; + if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; + if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; + if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; if ($num == '') $fail_arr[] = '電梯數量為必填'; if ($payType == '') $fail_arr[] = '付款方式為必填'; if (count($fail_arr) > 0) { @@ -100,7 +100,11 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c exit(); } // T8insert($_POST, $facilityno, $depId); - bonusCreate($_POST, $facilityno, $conn); + $aaa = bonusCreate($_POST, $facilityno, $conn); + echo '
';
+        print_r($aaa);
+        echo '
'; + exit; //create account table $accounttype = "A"; $accountid = $vat; @@ -658,10 +662,13 @@ function bonusCreate($data, $facilityno, $conn) { try { require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php"); + require_once("../../bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php"); + $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; $contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : ''; $salesman = !empty($data['salesman']) ? $data['salesman'] : ''; $payType = !empty($data['payType']) ? $data['payType'] : ''; + $contract_type = $data['contract_type']; //合約類別 $status = 1; $bonus_json = []; $create_id = $data['user_id']; @@ -676,28 +683,114 @@ function bonusCreate($data, $facilityno, $conn) 'A40005' => 'semiannually', // 半年繳 'A40003' => 'monthly' //月繳 ]; - + $fail_arr = []; $payDay = getNext25thDate($contract_begin_date); foreach ($elevators as $key => $elevator) { - // print_r($payDay); - // echo '
';
-            // print_r($elevator);
-            // echo '
'; - // exit; $facility_no = $facilityno[$key]; $ver = $elevator['bonus_verson']; //獎金版本 - $contract_type = $elevator['contract_type']; //合約類別 $payment_period = $payment[$payType]; //付款方式 - $elevator_list_price = intval($elevator['stand_price']); //牌價 - $fee_per_st = $elevator['sold_price']; //作翻契約金額 - $commission_fee = $elevator['service_expense']; //服務費(月) + $elevator_list_price = !empty(intval($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價 + $fee_per_st = !empty(round($elevator['sold_price'] / 1.05, 2)) ? round($elevator['sold_price'] / 1.05, 2) : ''; //作翻契約金額 (不含稅) + $commission_fee = !empty($elevator['service_expense']) ? $elevator['service_expense'] : ''; //服務費(月/台) $receivable_date_due = $payDay; //第一筆保養款項收回日 $sales_id = $salesman; //營業人員 $discount = $elevator['discount']; $region_director_id = $elevator['manager']; $regular_contract_manger_id = !empty($elevator['regular_contract_manger_id']) ? $elevator['regular_contract_manger_id'] : ''; - $results = maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id); + $maintain_months = intval($elevator['maintain_months']); + $years = $maintain_months / 12; + + if ($maintain_months == '') $fail_arr[] = "保養月費為必填"; + if ($fee_per_st == '') $fail_arr[] = "契約金額為必填"; + if ($elevator_list_price == '') $fail_arr[] = "牌價為必填"; + if ($region_director_id == '') $fail_arr[] = '區處長為必填'; + if ($sales_id == '') $fail_arr[] = "契約人為必填"; + + if (COUNT($fail_arr) > 0) { + return $fail_arr; + break; + } + // $years = ($maintain_months % 12) == 0 ? $maintain_months / 12 : ''; + // 如果保養合約 大於一年 + if (!empty($maintain_months)) { + if ($maintain_months > 12 && $contract_type == 'new') { + // 第一年為新簽約 + $results = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + for ($i = 0; $i < $maintain_months - 1; $i++) { + $contract_type = 'renew_priceissue'; + // 第二年以上改續約 + $result2 = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } + } else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') { + // 超過一年的續約 + for ($i = 0; $i < $years; $i++) { + $contract_type = 'renew_priceissue'; + $result2 = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } + } else if ($maintain_months >= 60) { + $contract_type = 'longcontract_m1_free_charge'; + $result = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $maintain_months, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } else { + $results = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } + } $bonus_json = [ 'contract_type' => $contract_type, 'total' => $elevator_list_price, @@ -721,6 +814,21 @@ function bonusCreate($data, $facilityno, $conn) $stmt = $conn->prepare($sql); $stmt->execute(); } + if (!empty($result2)) { + foreach ($results2['bonus_array'] as $i => $result) { + + $bonus_type = $result['bonus_type']; + $pay_day = $result['pay_day_due']; + $amount = $result['bonus_amount']; + $receiver = $result['bonus_receiver']; + $a = json_encode($bonus_json); + $sql = "INSERT INTO bonus + (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day_due,status,bonus_json,create_id,create_at) VALUES + ($bonus_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')"; + $stmt = $conn->prepare($sql); + // $stmt->execute(); + } + } } // exit(); } diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 58acb4a8..cbec41c1 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -57,8 +57,8 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

業務確認項

@@ -158,7 +158,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- + - + + + + + - - - + + + + - - - - - - + + diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index db386702..ad56eb3b 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -1016,6 +1016,7 @@ const contractInput = () => { disabled: false, //資料庫是否有電梯數量資料 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 payType: '', //付款方式 + contract_type: '' // bonus_verson: 2.1, // manager: '', // regular_contract_manger_id: '', @@ -1048,6 +1049,7 @@ const contractInput = () => { data.bonus_verson = 2.1; }, getManager() { + for (let i = 0; i < this.data.elevators.length; i++) { this.getBonusVerson(this.data.elevators[i]); axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => { @@ -1070,29 +1072,31 @@ const contractInput = () => { } }, createElevator() { - for (let i = 0; i < this.data.num; i++) { - this.data.elevators.push({ - spec: '', //規格 - weight: '', //載重 - speed: '', //速度 - persons: '', //人乘 - stop: '', //樓停 - floors: '', //樓層 - latitude: '', //緯度 - longitude: '', //經度 - elevator_brand: '', //廠牌 - opendoor: '', //開門方式 - maintainance: '', //保養別 - takecertificatedate: '', //竣檢日 - useful_date: '', //許可證有效日期 - maintain_times: '', //保養頻率 - discount: '', //折價率 - contract_type: '', - manager: '', - regular_contract_manger_id: '', - bonus_verson: '', - sold_price: '' - }) + if (this.data.num != this.data.elevators.length) { + for (let i = 0; i < this.data.num; i++) { + this.data.elevators.push({ + spec: '', //規格 + weight: '', //載重 + speed: '', //速度 + persons: '', //人乘 + stop: '', //樓停 + floors: '', //樓層 + latitude: '', //緯度 + longitude: '', //經度 + elevator_brand: '', //廠牌 + opendoor: '', //開門方式 + maintainance: '', //保養別 + takecertificatedate: '', //竣檢日 + useful_date: '', //許可證有效日期 + maintain_times: '', //保養頻率 + discount: '', //折價率 + // contract_type: '', + manager: '', + regular_contract_manger_id: '', + bonus_verson: '', + sold_price: '' + }) + } } }, getContractDate() { @@ -1109,7 +1113,7 @@ const contractInput = () => { this.data.total_price = Number(res.data.elevators[i].sold_price) + Number(this.data.total_price); // 服務費 (以單筆合約記,但計算獎金須傳入單月服務費) - this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / 12); + this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / res.data.elevators[i]); // 折扣率 this.data.elevators[i].discount = Math.round(((res.data.elevators[i].sold_price / res.data.elevators[i].stand_price) + this.data.elevators[i].service_expense) * 100); } @@ -1206,7 +1210,8 @@ const contractInput = () => { form.append('num', this.data.num); form.append('elevators', JSON.stringify(this.data.elevators)); form.append('contracttype', 'b'); - form.append('payType', this.data.payType) + form.append('payType', this.data.payType); + form.append('contract_type', this.data.contract_type); // 如果有附件檔案,可以逐一加入 for (var i = 0; i < this.data.files.length; i++) { From 2978a669f28606d6fdfaabb28b291e46bec6cee4 Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 26 Feb 2024 18:02:29 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E5=A5=91=E7=B4=84?= =?UTF-8?q?=E7=8D=8E=E9=87=91=E5=92=8C=E7=B0=BD=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/bonus/bonus.php | 18 ++- .../other/maintenance_contract_bonus_v2_1.php | 52 ++++--- ...erm_contract_m1_free_charge_bonus_v2_1.php | 127 +++++++++--------- wms/contract/api/getContractData.php | 59 ++++++-- wms/contract/api/postContractData.php | 25 ++-- wms/contract/api/postNewContractData.php | 63 ++++++--- wms/contract/contract-input.php | 20 +-- wms/contract/js/alpine.js | 3 +- 8 files changed, 222 insertions(+), 145 deletions(-) diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php index 4e0b84fd..63bec621 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/bonus.php @@ -32,15 +32,17 @@ if (!empty($_GET['check'])) { if ($_GET['check'] == 4) { $oneMonthAgo = date("Y-m-d", strtotime("$now +1 months")); // $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' AND status IN (1,2,5)"; - $clause .= "AND status IN (1,2,5)"; + $clause .= "AND a.status IN (1,2,5)"; } else if ($_GET['check'] == 2) { - $clause .= "AND status = 1"; + $clause .= "AND a.status = 1"; } else if ($_GET['check'] == 3) { - $clause .= "AND status IN (2,5)"; + $clause .= "AND a.status IN (2,5)"; } } -$sql = "SELECT * FROM bonus WHERE 1=1 $clause"; +$sql = "SELECT a.*,b.customer FROM bonus AS a +LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no +WHERE 1=1 $clause"; $stmt = $conn->prepare($sql); $stmt->execute(); $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -130,17 +132,21 @@ function isPay($contract_no, $connT8) btn-sm categoryBtn"> 未發獎金 btn-sm categoryBtn"> 已發獎金 btn-sm categoryBtn"> 人事發放作業 + btn-sm categoryBtn"> 獎金總計(人)
項次合約類別 合約號合約名稱 作番號 獎金類別 獎金版本
契約成交價 - +

未填寫

區域 @@ -374,28 +374,28 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); 獎金適用版本 - +
作番契約金額(月) 牌價(標準價) - +

標準價+Option價格+與其他電梯共同分擔的費用貨價格

服務費 - + 折扣率(%)折扣率(%)
(作番契約金額+服務費/台數) / 牌價 * 100
地區處長員工號 專任契約經理員工號
- - +
區域 @@ -201,7 +201,17 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
合約類別 + +
獎金適用版本
作番契約金額(月)
服務費 + + 牌價(標準價)

標準價+Option價格+與其他電梯共同分擔的費用貨價格

服務費 - - 折扣率(%)
(作番契約金額+服務費/台數) / 牌價 * 100
地區處長員工號 專任契約經理員工號
+ + + - + @@ -178,8 +184,8 @@ function isPay($contract_no, $connT8) ?> - + diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php index 610da6d7..598202d4 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1.php @@ -55,48 +55,48 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case ($discount >= 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.6; + $sales_bonus = ($fee_per_st) * 0.6; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.7; + $sales_bonus = ($fee_per_st) * 0.7; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.8; + $sales_bonus = ($fee_per_st) * 0.8; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.9; + $sales_bonus = ($fee_per_st) * 0.9; break; }; break; case ($discount >= 0.6 and $discount < 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.48; + $sales_bonus = ($fee_per_st) * 0.48; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.56; + $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.64; + $sales_bonus = ($fee_per_st) * 0.64; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.72; + $sales_bonus = ($fee_per_st) * 0.72; break; }; break; case ($discount < 0.6): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.42; + $sales_bonus = ($fee_per_st) * 0.42; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.49; + $sales_bonus = ($fee_per_st) * 0.49; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.56; + $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.63; + $sales_bonus = ($fee_per_st) * 0.63; break; }; break; @@ -111,16 +111,16 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "free_to_charge": switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.3; + $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.35; + $sales_bonus = ($fee_per_st) * 0.35; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.4; + $sales_bonus = ($fee_per_st) * 0.4; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.45; + $sales_bonus = ($fee_per_st) * 0.45; break; }; #地區處長獎金($region_director_bonus) @@ -132,16 +132,16 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "renew_priceissue": switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.25; + $sales_bonus = ($fee_per_st) * 0.25; break; case ($fee_per_st >= 3001 and $fee_per_st <= 3499): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.3; + $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.35; + $sales_bonus = ($fee_per_st) * 0.35; break; case ($fee_per_st >= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.4; + $sales_bonus = ($fee_per_st) * 0.4; break; }; #地區處長獎金($region_director_bonus) @@ -226,7 +226,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, #2月1次 case "bimonthly": - $payment_ratio_due_array = array(0.166, 0.166, 0.166, 0.166, 0.166, 0.166); + $payment_ratio_due_array = array(); + for ($i = 0; $i < 6; $i++) { + array_push($payment_ratio_due_array, 1 / 6); + } $payday_due_array = array(1, 3, 5, 7, 9, 11); for ($i = 0; $i < count($payment_ratio_due_array); $i++) { if ($i < count($payment_ratio_due_array) - 1) { @@ -246,7 +249,12 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, #月付 case "monthly": - $payment_ratio_due_array = array(0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083); + $payment_ratio_due_array = array(); + // $payment_ratio_due_array = array(); + for ($i = 0; $i < 12; $i++) { + array_push($payment_ratio_due_array, 1 / 12); + } + $payday_due_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); for ($i = 0; $i < count($payment_ratio_due_array); $i++) { if ($i < count($payment_ratio_due_array) - 1) { diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php index 7122fbd3..d29650b2 100644 --- a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php @@ -41,12 +41,13 @@ result_array[ -function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id){ +function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id) +{ $bonus_array = []; - if ($ver == "2.1"){ + if ($ver == "2.1") { $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); #契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge) - switch ($contract_type){ + switch ($contract_type) { case "longcontract_m1_free_charge": #契約員獎金($sales_bonus) #合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) @@ -54,57 +55,57 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract case ($discount >= 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.6; + $sales_bonus = ($fee_per_st) * 0.6; break; case ($fee_per_st > 300 and $fee_per_st <= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.7; - break; + $sales_bonus = ($fee_per_st) * 0.7; + break; case ($fee_per_st > 4000 and $fee_per_st <= 5000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.8; + $sales_bonus = ($fee_per_st) * 0.8; break; case ($fee_per_st > 5000 and $fee_per_st <= 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.9; - break; + $sales_bonus = ($fee_per_st) * 0.9; + break; case ($fee_per_st > 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 1.0; + $sales_bonus = ($fee_per_st) * 1.0; break; }; break; case ($discount >= 0.6 and $discount < 0.8): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.42; + $sales_bonus = ($fee_per_st) * 0.42; break; case ($fee_per_st > 300 and $fee_per_st <= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.49; - break; + $sales_bonus = ($fee_per_st) * 0.49; + break; case ($fee_per_st > 4000 and $fee_per_st <= 5000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.56; + $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st > 5000 and $fee_per_st <= 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.63; - break; + $sales_bonus = ($fee_per_st) * 0.63; + break; case ($fee_per_st > 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.7; + $sales_bonus = ($fee_per_st) * 0.7; break; }; break; case ($discount < 0.6): switch ($fee_per_st) { case ($fee_per_st <= 3000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.3; + $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st > 300 and $fee_per_st <= 4000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.35; - break; + $sales_bonus = ($fee_per_st) * 0.35; + break; case ($fee_per_st > 4000 and $fee_per_st <= 5000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.4; + $sales_bonus = ($fee_per_st) * 0.4; break; case ($fee_per_st > 5000 and $fee_per_st <= 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.45; - break; + $sales_bonus = ($fee_per_st) * 0.45; + break; case ($fee_per_st > 6000): - $sales_bonus = ($fee_per_st - $commission_fee) * 0.5; + $sales_bonus = ($fee_per_st) * 0.5; break; }; break; @@ -116,81 +117,77 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $regular_contract_manger_bonus = 300; break; }; - + #地區處長獎金、專任契約經理、契約員獎金 - switch ($payment_period_amount){ - #簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 - #總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, + switch ($payment_period_amount) { + #簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 + #總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, case $payment_period_amount >= 60: #地區處長獎金 - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "地區處長獎金", #獎金名稱 "bonus_receiver" => $region_director_id, #發放人員 "bonus_amount" => round($region_director_bonus), #金額 - "pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "bonus_regulation" => "訂金收回後次月發放" #發放規定 - ]); + ]); #專任契約經理獎金 - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "專任契約經理獎金", #獎金名稱 "bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_amount" => round($regular_contract_manger_bonus), #金額 - "pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "bonus_regulation" => "訂金收回後次月發放" #發放規定 - ]); - + ]); + #產生契約員每個月的獎金應發比例 $payment_ratio_due_array = array(); for ($i = 0; $i < $payment_period_amount; $i++) { - array_push($payment_ratio_due_array, 1/$payment_period_amount); - } - + array_push($payment_ratio_due_array, 1 / $payment_period_amount); + } + $payday_due_array = array(); for ($i = 0; $i < $payment_period_amount; $i++) { - array_push($payday_due_array, $i+1 ); - } - - for($i = 0; $i < count($payment_ratio_due_array); $i++) { - if($i < count($payment_ratio_due_array) - 1){ + array_push($payday_due_array, $i + 1); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 - }else{ + } else { $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 - }; - array_push($bonus_array,[ + }; + array_push($bonus_array, [ "bonus_type" => "契約員獎金", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 - "pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 - ]); - } + ]); + } break; } - + $result_array = [ - "ver"=>$ver, #獎金版本 - "result_status"=>"success", #計算結果 - "bonus_array"=>$bonus_array #獎金水庫 + "ver" => $ver, #獎金版本 + "result_status" => "success", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 ]; - - }else{ - array_push($bonus_array,[ + } else { + array_push($bonus_array, [ "bonus_type" => "error", #獎金名稱 "bonus_receiver" => "error", #發放人員 "bonus_amount" => 0, #金額 "pay_day_due" => "9999-1-1", #預計發放時間 "bonus_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; }; - - -?> diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index 253e8d54..5534b8eb 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -1,5 +1,6 @@ prepare($sql); $stmt->bindParam(':mid', $mid); $stmt->execute(); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $elevators_results = $stmt->fetchAll(PDO::FETCH_ASSOC); $elevators_detail_arr = []; - foreach ($results as $keys => $result) { + + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->execute(); + $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $option_arr = []; + + foreach ($elevators_results as $keys => $result) { + $item_no = $result['item_no']; //電梯項次 + // 電梯 OPTION + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' AND option_relate_spec = :item_no"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->execute(); + $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $option_arr[] = $option_results; + if (!empty($option_results)) { + $result['option_price'] = 0; + // 電梯 OPTION 價格分別加到各台電梯 + foreach ($option_arr[$keys] as $key => $option) { + if ($option['item_qty'] == $result['item_qty']) { + $result['option_price'] += intval($option['item_unit_price']); + echo '1..'; + } else if ($option['item_qty'] > $result['item_qty'] != 1) { + $item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數 + $result['option_price'] += intval($option['item_unit_price']) * $item_qty; + echo '2..'; + } else { + $result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']); + echo '3..'; + } + echo '
';
+                    print_r($option['item_no'] . '--->' . $option['item_unit_price']);
+                    echo '
'; + } + + print_r($result['option_price']); + exit(); + } $note = explode(',', $result['note']); - $result['spec'] = $note[0]; //型號 + $result['spec'] = $note[0]; //型號 $result['person'] = $note[1]; // 人承 $result['floor'] = $note[2]; // 樓層 $result['speed'] = $note[3]; // 速度 @@ -82,21 +124,20 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont array_push($elevators_detail_arr, $result); } } + // print_r(COUNT($option_results)); + $count = COUNT($elevators_detail_arr); - $contract['elevators'] = $results; + $contract['elevators'] = $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'); // 將 JSON 回應返回給客戶端 - echo $contractResponse; + // echo $contractResponse; } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 29038b9f..d3ecf356 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -88,10 +88,10 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c if ($address == '') $fail_arr[] = '地址為必填'; if ($area == '') $fail_arr[] = '區域為必填'; if ($customer == '') $fail_arr[] = '客戶為必填'; - if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; - if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; - if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; - if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; + // if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; + // if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; + // if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; + // if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; if ($num == '') $fail_arr[] = '電梯數量為必填'; if ($payType == '') $fail_arr[] = '付款方式為必填'; if (count($fail_arr) > 0) { @@ -99,7 +99,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - T8insert($_POST, $facilityno, $depId); + // T8insert($_POST, $facilityno, $depId); bonusCreate($_POST, $facilityno, $conn); //create account table $accounttype = "A"; @@ -127,7 +127,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':repairerid', $repairerid); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - $stmt->execute(); + // $stmt->execute(); //create contract table @@ -163,7 +163,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':end_date', $end_date); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - $stmt->execute(); + // $stmt->execute(); //create facility table // $createFacilityNo = new CreateFacilityNo(); @@ -238,7 +238,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':area', $area); $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); $stmt->bindParam(':licensedate', $ADuseful_date); - $result = $stmt->execute(); + // $result = $stmt->execute(); } //create schedule table @@ -259,7 +259,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':duedate', $combo[1]); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - $result = $stmt->execute(); + // $result = $stmt->execute(); } } // create contract_b_signed_back table @@ -366,7 +366,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(":created_by", $user_id); $stmt->bindParam(':payType', $payType); - $stmt->execute(); + // $stmt->execute(); // T8insert($_POST, $facilityno); @@ -665,7 +665,7 @@ function bonusCreate($data, $facilityno, $conn) $status = 1; $bonus_json = []; $create_id = $data['user_id']; - $create_at = date('Y-m-d'); + $create_at = date('Y-m-d H:i:s'); $contract_no = !empty($data['contractno']) ? $data['contractno'] : ''; $contract_kind = 3; @@ -689,7 +689,7 @@ function bonusCreate($data, $facilityno, $conn) $contract_type = $elevator['contract_type']; //合約類別 $payment_period = $payment[$payType]; //付款方式 $elevator_list_price = intval($elevator['stand_price']); //牌價 - $fee_per_st = $elevator['contract_price']; //作翻契約金額 + $fee_per_st = $elevator['sold_price']; //作翻契約金額 $commission_fee = $elevator['service_expense']; //服務費(月) $receivable_date_due = $payDay; //第一筆保養款項收回日 $sales_id = $salesman; //營業人員 @@ -722,6 +722,7 @@ function bonusCreate($data, $facilityno, $conn) $stmt->execute(); } } + // exit(); } // exit(); } catch (PDOException $e) { diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index d94dac12..6180e4d4 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -27,7 +27,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $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 '
'; @@ -54,12 +54,12 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c //create facility table $createFacilityNo = new CreateFacilityNo(); $dailyNecessities = [ - 'MAE100' => 'X', - 'MAM200' => 'W', - 'MAH100' => 'H', - 'MAQ100' => 'Z', - 'MAF100' => 'F', - 'MAZ100' => 'B', + 'MAE100' => 'X', //小機房客梯 + 'MAM200' => 'W', //無機房客梯 + 'MAH100' => 'H', //小電梯 + 'MAQ100' => 'Z', //強趨梯 + 'MAF100' => 'F', //貨梯 + 'MAP100' => 'B', //平台梯 ]; $arr = []; // 建立作番號 @@ -68,9 +68,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $arr[] = $dailyNecessities[$elevator['spec']]; } $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); - echo '
';
-    print_r($facilityno);
-    echo '
'; + + BounsCount($_POST, $conn, $facilityno); exit(); $conn->beginTransaction(); @@ -282,39 +281,63 @@ function T8Insert($data) } -function BounsCount($data, $conn) +function BounsCount($data, $conn, $facilityno) { // echo '
';
-  // print_r($data);
+  // print_r($facilityno);
   // 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'; + $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']; $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶 - $elevator_knockdown_price = $data['price_total']; //受價總額 + // $elevator_knockdown_price = $data['price_total']; //受價總額 + $elevators = json_decode($data['elevators_detail_arr'], true); $salesman = $data['salesman']; $manager = $data['manager']; + + $result_bonus = []; + $result_bonus_arr = []; 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); + foreach ($elevators as $i => $elevator) { + + $elevator_knockdown_price = $elevator['item_price_ct']; + $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager); + $result_bonus['facility'] = $facilityno[$i]; + $result_bonus_arr[] = $result_bonus; + } } else if ($signing_date >= $bonus_v2_0_date) { $ver = '2.0'; - // $result_bonus = elevator_new_deal_bonus_v2_0($ver,$contract_type,); + foreach ($elevators as $i => $elevator) { + $elevator_type = $dailyNecessities[$elevator['spec']]; + $elevator_list_price = $elevator['']; + $result_bonus = elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id); + } } - + // foreach ($elevators as $elevator) { + // $elevator_knockdown_price = $elevator['item_price_ct']; + // } echo '
';
-  print_r($result_bonus);
+  print_r($result_bonus_arr);
   echo '
'; exit(); try { diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 114cea2f..58acb4a8 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -111,7 +111,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -158,7 +158,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- + - + - - + + - + diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index b2ad1eb9..db386702 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -1090,7 +1090,8 @@ const contractInput = () => { contract_type: '', manager: '', regular_contract_manger_id: '', - bonus_verson: '' + bonus_verson: '', + sold_price: '' }) } }, From f1aca066250b6c8ca403801102a6fe36307d19d5 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 27 Feb 2024 17:37:18 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BF=9D=E9=A4=8A=E7=8D=8E=E9=87=91?= =?UTF-8?q?=E8=A8=88=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/maintenance_contract_bonus_v2_1.php | 24 +- ...enance_contract_bonus_v2_1_examination.php | 8 +- ...m_contract_m1_free_charge_bonus_v2_1_1.php | 312 ++++++++++++++++++ ..._m1_free_charge_bonus_v2_1_examination.php | 174 +++++++--- wms/contract/api/postContractData.php | 140 +++++++- wms/contract/contract-input.php | 54 +-- wms/contract/js/alpine.js | 55 +-- 7 files changed, 649 insertions(+), 118 deletions(-) create mode 100644 wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php index 598202d4..27959883 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1.php @@ -45,7 +45,9 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, { $bonus_array = []; if ($ver == "2.1") { - $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); + // $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); + $discount = ($fee_per_st - $commission_fee) / $elevator_list_price; + #契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue) switch ($contract_type) { case "new": @@ -54,10 +56,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, switch ($discount) { case ($discount >= 0.8): switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.6; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.7; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -70,10 +72,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, break; case ($discount >= 0.6 and $discount < 0.8): switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.48; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.56; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -86,10 +88,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, break; case ($discount < 0.6): switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.42; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.49; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -110,10 +112,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "free_to_charge": switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.3; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.35; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): @@ -131,10 +133,10 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, case "renew_priceissue": switch ($fee_per_st) { - case ($fee_per_st <= 3000): + case ($fee_per_st < 3000): $sales_bonus = ($fee_per_st) * 0.25; break; - case ($fee_per_st >= 3001 and $fee_per_st <= 3499): + case ($fee_per_st >= 3000 and $fee_per_st <= 3499): $sales_bonus = ($fee_per_st) * 0.3; break; case ($fee_per_st >= 3500 and $fee_per_st <= 3999): diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php b/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php index d68bdb7d..5b26e9c8 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php @@ -270,9 +270,9 @@ $examination_array = [ // echo '10、專任契約經理員工號($regular_contract_manger_id)
'; for ($i = 0; $i < count($examination_array); $i++) { - $fee_per_st = $examination_array[$i][3]; - $commission_fee = $examination_array[$i][5]; - $elevator_list_price = $examination_array[$i][4]; + $fee_per_st = $examination_array[$i][4]; //作番金額 + $commission_fee = $examination_array[$i][5]; // 服務費 + $elevator_list_price = $examination_array[$i][3]; // 牌價 $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); // echo "$fee_per_st - $commission_fee / $elevator_list_price "; @@ -314,7 +314,7 @@ for ($i = 0; $i < count($examination_array); $i++) { ]; echo "獎金版本:" . $result["ver"] . "
"; echo "計算結果:" . $result["result_status"] . "
"; - echo "傳入參數說明:" . $contract_type[$examination_array[$i][1]] . "、" . $pay_kind[$examination_array[$i][2]] . "、牌價" . $examination_array[$i][3] . "元、簽約價" . $examination_array[$i][4] . "元、服務費600元(折扣率" . $discount . ")、契約人員 : " . $examination_array[$i][7] . "、區經理 : " . $examination_array[$i][8] . " 、契約經理 : " . $examination_array[$i][9] . "
"; + echo "傳入參數說明:" . $contract_type[$examination_array[$i][1]] . "、" . $pay_kind[$examination_array[$i][2]] . "、牌價" . $examination_array[$i][3] . "元、簽約價" . $examination_array[$i][4] . "元、服務費" . $commission_fee . "元(折扣率" . $discount . ")、契約人員 : " . $examination_array[$i][7] . "、區經理 : " . $examination_array[$i][8] . " 、契約經理 : " . $examination_array[$i][9] . "
"; 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] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . " " . $examination_array[$i][9] . "
"; diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php new file mode 100644 index 00000000..70a19f40 --- /dev/null +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php @@ -0,0 +1,312 @@ +$ver, #獎金版本 + "result_status"=>"success", #計算結果 + "$bonus_array"=>$bonus_array #所有獎金水庫 + ]; + +*/ + + + +function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '') +{ + $bonus_array = []; + if ($ver == "2.1") { + $discount = ($fee_per_st - $commission_fee) / $elevator_list_price; + #契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge) + switch ($contract_type) { + case "longcontract_m1_free_charge": + #契約員獎金($sales_bonus) + #合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) + switch ($discount) { + case ($discount >= 0.8): + switch ($fee_per_st) { + case ($fee_per_st < 3000): + $sales_bonus = ($fee_per_st) * 0.6; + break; + case ($fee_per_st >= 3000 and $fee_per_st < 4000): + $sales_bonus = ($fee_per_st) * 0.7; + break; + case ($fee_per_st >= 4000 and $fee_per_st < 5000): + $sales_bonus = ($fee_per_st) * 0.8; + break; + case ($fee_per_st >= 5000 and $fee_per_st < 6000): + $sales_bonus = ($fee_per_st) * 0.9; + break; + case ($fee_per_st >= 6000): + $sales_bonus = ($fee_per_st) * 1.0; + break; + }; + break; + case ($discount >= 0.6 and $discount < 0.8): + switch ($fee_per_st) { + case ($fee_per_st < 3000): + $sales_bonus = ($fee_per_st) * 0.42; + break; + case ($fee_per_st >= 3000 and $fee_per_st <= 4000): + $sales_bonus = ($fee_per_st) * 0.49; + break; + case ($fee_per_st >= 4000 and $fee_per_st < 5000): + $sales_bonus = ($fee_per_st) * 0.56; + break; + case ($fee_per_st >= 5000 and $fee_per_st < 6000): + $sales_bonus = ($fee_per_st) * 0.63; + break; + case ($fee_per_st >= 6000): + $sales_bonus = ($fee_per_st) * 0.7; + break; + }; + break; + case ($discount < 0.6): + switch ($fee_per_st) { + case ($fee_per_st < 3000): + $sales_bonus = ($fee_per_st) * 0.3; + break; + case ($fee_per_st >= 3000 and $fee_per_st < 4000): + $sales_bonus = ($fee_per_st) * 0.35; + break; + case ($fee_per_st >= 4000 and $fee_per_st < 5000): + $sales_bonus = ($fee_per_st) * 0.4; + break; + case ($fee_per_st >= 5000 and $fee_per_st < 6000): + $sales_bonus = ($fee_per_st) * 0.45; + break; + case ($fee_per_st >= 6000): + $sales_bonus = ($fee_per_st) * 0.5; + break; + }; + break; + }; + + #地區處長獎金($region_director_bonus) + $region_director_bonus = 170; + #專任契約經理獎金($regular_contract_manger_bonus) + $regular_contract_manger_bonus = 300; + break; + }; + #付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) + array_push($bonus_array, [ + "bonus_type" => "地區處長獎金", #獎金名稱 + "bonus_receiver" => $region_director_id, #發放人員 + "bonus_amount" => round($region_director_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 + "bonus_regulation" => "訂金收回後次月發放" #發放規定 + ]); + + #專任契約經理獎金 + if ($regular_contract_manger_id != '') { + array_push($bonus_array, [ + "bonus_type" => "專任契約經理獎金", #獎金名稱 + "bonus_receiver" => $regular_contract_manger_id, #發放人員 + "bonus_amount" => round($regular_contract_manger_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 + "bonus_regulation" => "訂金收回後次月發放" #發放規定 + ]); + } + + #地區處長獎金、專任契約經理、契約員獎金 + switch ($payment_period) { + #簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 + #總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, + #年繳 + case 'annually': + $payment_ratio_due_array = array(); + $a = $payment_period_amount / 12; + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, $i + 1); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + + break; + #半年繳 + case 'semiannually': + $payment_ratio_due_array = array(); + $a = $payment_period_amount / 6; + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, ($i + 1) * 6); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + #季繳 + case 'quarterly': + $a = $payment_period_amount / 3; + $payment_ratio_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, ($i + 1) * 4); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + break; + #雙月繳 + case 'bimonthly': + $a = $payment_period_amount / 2; + $payment_ratio_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payment_ratio_due_array, 1 / $a); + } + + $payday_due_array = array(); + for ($i = 0; $i < $a; $i++) { + array_push($payday_due_array, ($i + 1) * 2); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + break; + #月繳 + case 'monthly': + + #產生契約員每個月的獎金應發比例 + $payment_ratio_due_array = array(); + for ($i = 0; $i < $payment_period_amount; $i++) { + array_push($payment_ratio_due_array, 1 / $payment_period_amount); + } + + $payday_due_array = array(); + for ($i = 0; $i < $payment_period_amount; $i++) { + array_push($payday_due_array, $i + 1); + } + + for ($i = 0; $i < count($payment_ratio_due_array); $i++) { + if ($i < count($payment_ratio_due_array) - 1) { + $current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 + } else { + $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 + }; + array_push($bonus_array, [ + "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($current_bonus), #金額 + "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 + "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + ]); + } + break; + } + + $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, #金額 + "pay_day_due" => "9999-1-1", #預計發放時間 + "bonus_regulation" => "error" #發放規定 + ]); + $result_array = [ + "ver" => $ver, #獎金版本 + "result_status" => "error", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + } + + return $result_array; +}; diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php index 0c42a890..3e0c3af0 100644 --- a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php @@ -40,62 +40,150 @@ result_array[ */ -require_once("maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php"); - -#$ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id - - +require_once("maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php"); #獎金測試 $examination_array = [ #錯誤版本 - ["1.0","longcontract_m1_free_charge",60,0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"], + // ["1.0", 'annually', "longcontract_m1_free_charge", 60, 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #60期 - ["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8) - ["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6) - ["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59) - ["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59) - + //付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 2999, 600, "2014-07-01", "M0001", "M0002"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'semiannually', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'quarterly', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'bimonthly', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'monthly', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 2999, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'semiannually', 60, 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'quarterly', 60, 3000, 5000, 3200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'bimonthly', 60, 3000, 6000, 4200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'monthly', 60, 3000, 7000, 5200, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 2999, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'annually', 60, 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'semiannually', 60, 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'quarterly', 60, 3000, 5000, 3230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'bimonthly', 60, 3000, 6000, 4230, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59) + ["2.1", "longcontract_m1_free_charge", 'monthly', 60, 3000, 7000, 5230, "2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59) + + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 5000, 2600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 6000, 3600, "2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59) + // ["2.1", "longcontract_m1_free_charge", '', 60, 3000, 7000, 4600, "2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59) ]; -for($i = 0; $i "契約員獎金", #獎金名稱 + // "bonus_receiver" => $sales_id, #發放人員 + // "bonus_amount" => round($current_bonus), #金額 + // "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間 + // "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + // ]); + // } + // echo '
';
+	// print_r($bonus_array);
+	// echo '
'; + // exit(); $result = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( - $examination_array[$i][0], - $examination_array[$i][1], - $examination_array[$i][2], - $examination_array[$i][3], - $examination_array[$i][4], - $examination_array[$i][5], - $examination_array[$i][6], - $examination_array[$i][7], - $examination_array[$i][8], - $examination_array[$i][9] + $ver, + $contract_type, + $payment_period, + $payment_period_amount, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id ); + + $discount = (($fee_per_st - $commission_fee) / $elevator_list_price); + #新簽約、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8) + $contract_type = [ + 'new' => '新簽約', + 'free_to_charge' => '免保轉有費', + 'renew_priceissue' => '續簽約(原價或僅契約金額異動)', + 'longcontract_m1_free_charge' => '五年長約' + + ]; + // 付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) + $pay_kind = [ + 'monthly' => '月繳', + 'bimonthly' => '雙月繳', + 'quarterly' => '季繳', + 'semiannually' => '半年繳', + 'annually' => '年繳' + ]; + + // + $bonus_type = [ + '1' => '契約員獎金', + '2' => '區經理獎金', + '3' => '契約經理獎金' + ]; echo "獎金版本:" . $result["ver"] . "
"; echo "計算結果:" . $result["result_status"] . "
"; - 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] . " " . $examination_array[$i][7]. " " . $examination_array[$i][8] . " " - . $examination_array[$i][9] . "
"; - for($j = 0; $j"; + echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][4] . " " + . $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . " " + . $examination_array[$i][9] . "
"; + $n = 0; + for ($j = 0; $j < count($result["bonus_array"]); $j++) { + if ($result["bonus_array"][$j]["bonus_receiver"] == "M0001") { + + $n++; + echo '[' . $n . ']'; + } echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " " - . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " " - . $result["bonus_array"][$j]["bonus_regulation"] . "
"; + . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " " + . $result["bonus_array"][$j]["bonus_regulation"] . "
"; }; echo "-------------------------" . "
"; - }; - - -?> diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index d3ecf356..e8dca10f 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -88,10 +88,10 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c if ($address == '') $fail_arr[] = '地址為必填'; if ($area == '') $fail_arr[] = '區域為必填'; if ($customer == '') $fail_arr[] = '客戶為必填'; - // if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; - // if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; - // if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; - // if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; + if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; + if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; + if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; + if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; if ($num == '') $fail_arr[] = '電梯數量為必填'; if ($payType == '') $fail_arr[] = '付款方式為必填'; if (count($fail_arr) > 0) { @@ -100,7 +100,11 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c exit(); } // T8insert($_POST, $facilityno, $depId); - bonusCreate($_POST, $facilityno, $conn); + $aaa = bonusCreate($_POST, $facilityno, $conn); + echo '
';
+        print_r($aaa);
+        echo '
'; + exit; //create account table $accounttype = "A"; $accountid = $vat; @@ -658,10 +662,13 @@ function bonusCreate($data, $facilityno, $conn) { try { require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php"); + require_once("../../bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php"); + $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; $contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : ''; $salesman = !empty($data['salesman']) ? $data['salesman'] : ''; $payType = !empty($data['payType']) ? $data['payType'] : ''; + $contract_type = $data['contract_type']; //合約類別 $status = 1; $bonus_json = []; $create_id = $data['user_id']; @@ -676,28 +683,114 @@ function bonusCreate($data, $facilityno, $conn) 'A40005' => 'semiannually', // 半年繳 'A40003' => 'monthly' //月繳 ]; - + $fail_arr = []; $payDay = getNext25thDate($contract_begin_date); foreach ($elevators as $key => $elevator) { - // print_r($payDay); - // echo '
';
-            // print_r($elevator);
-            // echo '
'; - // exit; $facility_no = $facilityno[$key]; $ver = $elevator['bonus_verson']; //獎金版本 - $contract_type = $elevator['contract_type']; //合約類別 $payment_period = $payment[$payType]; //付款方式 - $elevator_list_price = intval($elevator['stand_price']); //牌價 - $fee_per_st = $elevator['sold_price']; //作翻契約金額 - $commission_fee = $elevator['service_expense']; //服務費(月) + $elevator_list_price = !empty(intval($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價 + $fee_per_st = !empty(round($elevator['sold_price'] / 1.05, 2)) ? round($elevator['sold_price'] / 1.05, 2) : ''; //作翻契約金額 (不含稅) + $commission_fee = !empty($elevator['service_expense']) ? $elevator['service_expense'] : ''; //服務費(月/台) $receivable_date_due = $payDay; //第一筆保養款項收回日 $sales_id = $salesman; //營業人員 $discount = $elevator['discount']; $region_director_id = $elevator['manager']; $regular_contract_manger_id = !empty($elevator['regular_contract_manger_id']) ? $elevator['regular_contract_manger_id'] : ''; - $results = maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id); + $maintain_months = intval($elevator['maintain_months']); + $years = $maintain_months / 12; + + if ($maintain_months == '') $fail_arr[] = "保養月費為必填"; + if ($fee_per_st == '') $fail_arr[] = "契約金額為必填"; + if ($elevator_list_price == '') $fail_arr[] = "牌價為必填"; + if ($region_director_id == '') $fail_arr[] = '區處長為必填'; + if ($sales_id == '') $fail_arr[] = "契約人為必填"; + + if (COUNT($fail_arr) > 0) { + return $fail_arr; + break; + } + // $years = ($maintain_months % 12) == 0 ? $maintain_months / 12 : ''; + // 如果保養合約 大於一年 + if (!empty($maintain_months)) { + if ($maintain_months > 12 && $contract_type == 'new') { + // 第一年為新簽約 + $results = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + for ($i = 0; $i < $maintain_months - 1; $i++) { + $contract_type = 'renew_priceissue'; + // 第二年以上改續約 + $result2 = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } + } else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') { + // 超過一年的續約 + for ($i = 0; $i < $years; $i++) { + $contract_type = 'renew_priceissue'; + $result2 = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } + } else if ($maintain_months >= 60) { + $contract_type = 'longcontract_m1_free_charge'; + $result = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $maintain_months, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } else { + $results = maintenance_contract_bonus_v2_1( + $ver, + $contract_type, + $payment_period, + $elevator_list_price, + $fee_per_st, + $commission_fee, + $receivable_date_due, + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); + } + } $bonus_json = [ 'contract_type' => $contract_type, 'total' => $elevator_list_price, @@ -721,6 +814,21 @@ function bonusCreate($data, $facilityno, $conn) $stmt = $conn->prepare($sql); $stmt->execute(); } + if (!empty($result2)) { + foreach ($results2['bonus_array'] as $i => $result) { + + $bonus_type = $result['bonus_type']; + $pay_day = $result['pay_day_due']; + $amount = $result['bonus_amount']; + $receiver = $result['bonus_receiver']; + $a = json_encode($bonus_json); + $sql = "INSERT INTO bonus + (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day_due,status,bonus_json,create_id,create_at) VALUES + ($bonus_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')"; + $stmt = $conn->prepare($sql); + // $stmt->execute(); + } + } } // exit(); } diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 58acb4a8..cbec41c1 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -57,8 +57,8 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

業務確認項

@@ -158,7 +158,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- + - + + + + + - - - + + + + - - - - - - + + diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index db386702..ad56eb3b 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -1016,6 +1016,7 @@ const contractInput = () => { disabled: false, //資料庫是否有電梯數量資料 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 payType: '', //付款方式 + contract_type: '' // bonus_verson: 2.1, // manager: '', // regular_contract_manger_id: '', @@ -1048,6 +1049,7 @@ const contractInput = () => { data.bonus_verson = 2.1; }, getManager() { + for (let i = 0; i < this.data.elevators.length; i++) { this.getBonusVerson(this.data.elevators[i]); axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => { @@ -1070,29 +1072,31 @@ const contractInput = () => { } }, createElevator() { - for (let i = 0; i < this.data.num; i++) { - this.data.elevators.push({ - spec: '', //規格 - weight: '', //載重 - speed: '', //速度 - persons: '', //人乘 - stop: '', //樓停 - floors: '', //樓層 - latitude: '', //緯度 - longitude: '', //經度 - elevator_brand: '', //廠牌 - opendoor: '', //開門方式 - maintainance: '', //保養別 - takecertificatedate: '', //竣檢日 - useful_date: '', //許可證有效日期 - maintain_times: '', //保養頻率 - discount: '', //折價率 - contract_type: '', - manager: '', - regular_contract_manger_id: '', - bonus_verson: '', - sold_price: '' - }) + if (this.data.num != this.data.elevators.length) { + for (let i = 0; i < this.data.num; i++) { + this.data.elevators.push({ + spec: '', //規格 + weight: '', //載重 + speed: '', //速度 + persons: '', //人乘 + stop: '', //樓停 + floors: '', //樓層 + latitude: '', //緯度 + longitude: '', //經度 + elevator_brand: '', //廠牌 + opendoor: '', //開門方式 + maintainance: '', //保養別 + takecertificatedate: '', //竣檢日 + useful_date: '', //許可證有效日期 + maintain_times: '', //保養頻率 + discount: '', //折價率 + // contract_type: '', + manager: '', + regular_contract_manger_id: '', + bonus_verson: '', + sold_price: '' + }) + } } }, getContractDate() { @@ -1109,7 +1113,7 @@ const contractInput = () => { this.data.total_price = Number(res.data.elevators[i].sold_price) + Number(this.data.total_price); // 服務費 (以單筆合約記,但計算獎金須傳入單月服務費) - this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / 12); + this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / res.data.elevators[i]); // 折扣率 this.data.elevators[i].discount = Math.round(((res.data.elevators[i].sold_price / res.data.elevators[i].stand_price) + this.data.elevators[i].service_expense) * 100); } @@ -1206,7 +1210,8 @@ const contractInput = () => { form.append('num', this.data.num); form.append('elevators', JSON.stringify(this.data.elevators)); form.append('contracttype', 'b'); - form.append('payType', this.data.payType) + form.append('payType', this.data.payType); + form.append('contract_type', this.data.contract_type); // 如果有附件檔案,可以逐一加入 for (var i = 0; i < this.data.files.length; i++) { From 2f1afae09efd6727eb526049573a39fb72ae6b8c Mon Sep 17 00:00:00 2001 From: Cheng Date: Thu, 29 Feb 2024 20:14:00 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E3=80=81=E4=BF=9D?= =?UTF-8?q?=E9=A4=8A=E7=8D=8E=E9=87=91=E8=A8=88=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/bonus/api/postStatus.php | 125 +++++- wms/bonus/bonus_person.php | 146 +++++++ .../elevator_new/elevator_new_deal_bonus.php | 20 +- wms/bonus/maintainance_bonus.php | 366 ++++++++++++++++++ ...tail.php => maintainance_bonus_detail.php} | 0 wms/bonus/{bonus.php => new_bonus.php} | 37 +- .../other/maintenance_contract_bonus_v2_1.php | 3 +- ...m_contract_m1_free_charge_bonus_v2_1_1.php | 19 +- wms/contract/api/getContractData.php | 94 ++++- wms/contract/api/postContractData.php | 95 +++-- wms/contract/api/postNewContractData.php | 133 ++++++- wms/contract/contract-input.php | 5 +- wms/contract/js/alpine.js | 16 +- 13 files changed, 922 insertions(+), 137 deletions(-) create mode 100644 wms/bonus/bonus_person.php create mode 100644 wms/bonus/maintainance_bonus.php rename wms/bonus/{bonus_detail.php => maintainance_bonus_detail.php} (100%) rename wms/bonus/{bonus.php => new_bonus.php} (83%) diff --git a/wms/bonus/api/postStatus.php b/wms/bonus/api/postStatus.php index 86f9f88d..0ebcd723 100644 --- a/wms/bonus/api/postStatus.php +++ b/wms/bonus/api/postStatus.php @@ -2,22 +2,36 @@ require_once("../../contract/conn.php"); if (!empty($_POST['id']) && !empty($_POST['postType']) && $_POST['postType'] == 'a') { - try { - $id = empty($_POST['id']) ? '' : $_POST['id']; - $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; - $amount = empty($_POST['amount']) ? '' : $_POST['amount']; - $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; - $review_at = date("Y-m-d H:i:s"); - $sql = "UPDATE bonus SET status = 2 ,bonus_actual='$amount',review_hr = '$user_id' ,review_at = '$review_at',pay_day ='$pay_day',update_id='$user_id',update_at='$review_at' WHERE id = $id"; - $stmt = $conn->prepare($sql); - $stmt->execute(); + if ($_POST['contract_type'] == 'maintainance') { + try { + $id = empty($_POST['id']) ? '' : $_POST['id']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $amount = empty($_POST['amount']) ? '' : $_POST['amount']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $review_at = date("Y-m-d H:i:s"); + $sql = "UPDATE bonus SET status = 2 ,bonus_actual='$amount',review_hr = '$user_id' ,review_at = '$review_at',pay_day ='$pay_day',update_id='$user_id',update_at='$review_at' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); - header("HTTP/1.1 200 success!"); - echo 'Success'; - } catch (PDOException $e) { - header("HTTP/1.1 404 failed!"); - echo $e->getMessage(); - die('Error!:' . $e->getMessage()); + header("HTTP/1.1 200 success!"); + echo 'Success'; + } catch (PDOException $e) { + header("HTTP/1.1 404 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } + } else if ($_POST['contract_type'] == 'new') { + try { + $id = empty($_POST['id']) ? '' : $_POST['id']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $amount = empty($_POST['amount']) ? '' : $_POST['amount']; + + header("HTTP/1.1 200 success!"); + echo 'Success'; + } catch (PDOException $e) { + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } } } // 獎金確認發放,並更新獎金 OR 實際發放時間 @@ -109,3 +123,84 @@ if (!empty($_POST['postType']) && $_POST['postType'] == 'd') { } // echo 'ddddd'; } +// 查看T8 是否收款 +if (!empty($_POST['postType']) && $_POST['postType'] == 'e') { + $sql = "SELECT contract_no FROM bonus WHERE contract_type = 3 AND T8api_status = 1 "; + $stmt = $conn->prepare($sql); + $stmt->execute(); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + // echo "
";
+    // print_r($results);
+    // echo "
"; + foreach ($results as $result) { + $contract_no = $result['contract_no']; + $a = isPay($contract_no, $connT8); + + if ($a == '1') { + try { + $sql = "UPDATE bonus SET T8api_status = 2 WHERE contract_no = :contract_no"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(":contract_no", $contract_no); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + echo 'Success'; + } catch (PDOException $e) { + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } + } + } +} + +function isPay($contract_no, $connT8) +{ + // echo $contract_no; + $sql = "SELECT + a.BillNo, + b.OTaxAmt as amount, + a.CU_EstPayDate as createDate, + b.PersonId as personId, + c.BillNo as CBno, + c.CU_MaterialId as facility +FROM salIncomeApplyDetail as a +LEFT JOIN salIncomeApplyMaster as b ON a.BillNo = b.BillNo +LEFT JOIN ( + SELECT aMaster.BillNo,aMaster.BizPartnerId,aDetail.CU_MaterialId FROM arCheckBill as aMaster + LEFT JOIN arCheckBillDetail as aDetail ON aMaster.BizPartnerId = aDetail.FromBillNo + WHERE aMaster.BizPartnerId = '$contract_no' AND aMaster.TypeId = 'RVS' + ) AS c ON a.BillNo = c.BizPartnerId +WHERE a.BillNo = '$contract_no' +AND a.RowNo = '1' +"; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + // $data['amount'] = intval($data['amount']); + if (!empty($data['CBno']) && $data['CBno'] != '') { + $checkBillNo = $data['CBno']; + + $sql = "SELECT +c.BillDate AS CheckBillDate +FROM arWriteOffBill AS a +LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo +LEFT JOIN +(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail +LEFT JOIN + (SELECT + arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo + FROM arCheckBill + LEFT JOIN arCheckBillInvInfo + ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 +ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c +ON a.BillNo=c.BillNo +WHERE c.checkBillNo = '$checkBillNo' +"; + + $stmt = $connT8->prepare($sql); + $stmt->execute(); + + return '1'; + } else { + return '2'; + } +} diff --git a/wms/bonus/bonus_person.php b/wms/bonus/bonus_person.php new file mode 100644 index 00000000..1b01b289 --- /dev/null +++ b/wms/bonus/bonus_person.php @@ -0,0 +1,146 @@ +='$select_date' AND pay_day_due <= '$select_date1' "; + } else { + $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' "; + } + + // $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' "; + $sql = "SELECT a.receiver,a.amount,b.name FROM bonus AS a +LEFT JOIN account AS b ON a.receiver = b.accountid +WHERE 1=1 AND contract_type = 3 $clause ORDER BY a.receiver ASC"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $person_arr = []; + $bonus_arr = []; + $count = 0; + + $a = 0; + $j = 0; +} + +for ($i = 0; $i < COUNT($results); $i++) { + $a++; + if ($i + 1 < COUNT($results)) { + if ($results[$i]['receiver'] != $results[$i + 1]['receiver']) { + $amount = 0; + if ($i != $j) { + for ($j; $j <= $i; $j++) { + $amount += $results[$j]['amount']; + } + $person_arr['person_id'] = $results[$i]['receiver']; + $person_arr['person'] = $results[$i]['name']; + $person_arr['bonus'] = $amount; + array_push($bonus_arr, $person_arr); + } else { + $amount += $results[$j]['amount']; + $person_arr['person_id'] = $results[$i]['receiver']; + $person_arr['person'] = $results[$i]['name']; + $person_arr['bonus'] = $amount; + array_push($bonus_arr, $person_arr); + } + + $j = $i + 1; + } + } else { + $amount = 0; + for ($j; $j <= $i; $j++) { + $amount += $results[$j]['amount']; + } + $amount += $results[$i]['amount']; + $person_arr['person_id'] = $results[$i]['receiver']; + $person_arr['bonus'] = $amount; + $person_arr['person'] = $results[$i]['name']; + array_push($bonus_arr, $person_arr); + } +} + +?> +
+ +
項次合約類別 合約號合約名稱 作番號 獎金類別 獎金版本
契約成交價 - +

未填寫

區域 @@ -374,28 +374,28 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); 獎金適用版本 - +
作番契約金額(月) 牌價(標準價) - +

標準價+Option價格+與其他電梯共同分擔的費用貨價格

服務費 - + 折扣率(%)折扣率(%)
(作番契約金額+服務費/台數) / 牌價 * 100
地區處長員工號 專任契約經理員工號
- - +
區域 @@ -201,7 +201,17 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
合約類別 + +
獎金適用版本
作番契約金額(月)
服務費 + + 牌價(標準價)

標準價+Option價格+與其他電梯共同分擔的費用貨價格

服務費 - - 折扣率(%)
(作番契約金額+服務費/台數) / 牌價 * 100
地區處長員工號 專任契約經理員工號
+ + + + + + +
+

月份、個人獎金計算

+
+
+ + + + + + + + + + + + +
年份 + + 月份 + +
+ + +
+ + + + + + + + + + + + + $bonus) { + ?> + + + + + + + + +
工號姓名總獎金水庫(實發總價)
+ \ No newline at end of file diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus.php b/wms/bonus/elevator_new/elevator_new_deal_bonus.php index c26e747d..7138e787 100644 --- a/wms/bonus/elevator_new/elevator_new_deal_bonus.php +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus.php @@ -59,7 +59,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele #營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20% array_push($bonus_array, [ - "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱 + "bonus_type" => "1-訂金段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.2), #金額 "payment_schedul_due" => "deposit", #訂金已收款20% @@ -68,7 +68,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele #營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50% array_push($bonus_array, [ - "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱 + "bonus_type" => "1-出貨款段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.5), #金額 "payment_schedul_due" => "shipping", #訂金已收款20% @@ -77,7 +77,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele #營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30% array_push($bonus_array, [ - "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱 + "bonus_type" => "1-驗收款段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.3), #金額 "payment_schedul_due" => "acceptance", #訂金已收款20% @@ -86,7 +86,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele #區域經理提成獎金水庫-----訂金已收款100%,發放總獎金50% array_push($bonus_array, [ - "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱 + "bonus_type" => "2-訂金段", #獎金名稱 "bonus_receiver" => $region_manger_id, #發放人員 "bonus_amount" => round($region_manager_bonus * 0.5), #金額 "payment_schedul_due" => "deposit", #訂金已收款100% @@ -95,7 +95,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50% array_push($bonus_array, [ - "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱 + "bonus_type" => "2-貨到工地款段", #獎金名稱 "bonus_receiver" => $region_manger_id, #發放人員 "bonus_amount" => round($region_manager_bonus * 0.5), #金額 "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100% @@ -150,7 +150,7 @@ function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_ #營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20% array_push($bonus_array, [ - "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱 + "bonus_type" => "1-訂金段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.2), #金額 "payment_schedul_due" => "deposit", #訂金已收款20% @@ -159,7 +159,7 @@ function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_ #營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50% array_push($bonus_array, [ - "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱 + "bonus_type" => "1-出貨款段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.5), #金額 "payment_schedul_due" => "shipping", #訂金已收款20% @@ -168,7 +168,7 @@ function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_ #營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30% array_push($bonus_array, [ - "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱 + "bonus_type" => "1-驗收款段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.3), #金額 "payment_schedul_due" => "acceptance", #訂金已收款20% @@ -177,7 +177,7 @@ function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_ #區域經理獎金水庫-----訂金已收款100%,發放總獎金50% array_push($bonus_array, [ - "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱 + "bonus_type" => "2-訂金段", #獎金名稱 "bonus_receiver" => $region_manger_id, #發放人員 "bonus_amount" => round($region_manager_bonus * 0.5), #金額 "payment_schedul_due" => "deposit", #訂金已收款100% @@ -186,7 +186,7 @@ function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_ #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50% array_push($bonus_array, [ - "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱 + "bonus_type" => "2-貨到工地款段", #獎金名稱 "bonus_receiver" => $region_manger_id, #發放人員 "bonus_amount" => round($region_manager_bonus * 0.5), #金額 "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100% diff --git a/wms/bonus/maintainance_bonus.php b/wms/bonus/maintainance_bonus.php new file mode 100644 index 00000000..ee2ab36b --- /dev/null +++ b/wms/bonus/maintainance_bonus.php @@ -0,0 +1,366 @@ + '新梯', + '2' => '汰改', + '3' => '保養' +]; + +$bonus_type = [ + '1' => '契約人獎金', + '2' => '區經理獎金', + '3' => '專任契約經理獎金' +]; + +$bonus_status = [ + '1' => '未確認', + '2' => '應發已確認', + '3' => '應發未確認', + '4' => '暫不發放', + '5' => '人事審核確認' +]; +$clause = ''; +if ($user_id != 'M0225') { + $clause .= "AND receiver == '$user_id'"; +} +if (!empty($_GET['check'])) { + // 人事發放作業,應為一個月內 + if ($_GET['check'] == 4) { + $oneMonthAgo = date("Y-m-d", strtotime("$now +1 months")); + // $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' AND status IN (1,2,5)"; + $clause .= "AND a.status IN (1,2,5)"; + } else if ($_GET['check'] == 2) { + $clause .= "AND a.status = 1"; + } else if ($_GET['check'] == 3) { + $clause .= "AND a.status IN (2,5)"; + } +} + +$sql = "SELECT a.*,b.customer FROM bonus AS a +LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no +WHERE 1=1 $clause AND a.contract_type = 3"; + +$stmt = $conn->prepare($sql); +$stmt->execute(); +$datas = $stmt->fetchAll(PDO::FETCH_ASSOC); + + +$now = new DateTime(); +$oneMonthAgo = $now->modify('+1 month'); + +$id = []; +foreach ($datas as $data) { + $id[] = $data['id']; +} +$id_str = implode(',', $id); + +// 查看 T8 是否有收款明細 +// require("./api/get.php"); +?> + + + + + + + + +
+
+
+ + + + + + + +
+

(契約)獎金計算

+
+ + btn-sm categoryBtn"> 所有獎金 + + btn-sm categoryBtn"> 未發獎金 + btn-sm categoryBtn"> 已發獎金 + btn-sm categoryBtn"> 人事發放作業 + btn-sm categoryBtn"> 獎金總計(人) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $data) : + + $contract_no = $data['contract_no']; + $json = json_decode($data['bonus_json']); + $total = empty($json->total) ? 0 : $json->total; + $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; + $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; + // $isPay = isPay($data['contract_no'], $connT8); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項次合約號合約名稱作番號獎金類別獎金版本作番金額(月)牌價服務費應發人員預計發放時間應發獎金水庫實發金額狀態實際發放時間發放 / 詳情詳情
+ + + -- + + + + 查看詳情 + + 查看詳情查看詳情
+
+
+ + + + + \ No newline at end of file diff --git a/wms/bonus/bonus_detail.php b/wms/bonus/maintainance_bonus_detail.php similarity index 100% rename from wms/bonus/bonus_detail.php rename to wms/bonus/maintainance_bonus_detail.php diff --git a/wms/bonus/bonus.php b/wms/bonus/new_bonus.php similarity index 83% rename from wms/bonus/bonus.php rename to wms/bonus/new_bonus.php index 63bec621..c595e442 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/new_bonus.php @@ -42,7 +42,7 @@ if (!empty($_GET['check'])) { $sql = "SELECT a.*,b.customer FROM bonus AS a LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no -WHERE 1=1 $clause"; +WHERE 1=1 $clause AND a.contract_type = 1 ORDER BY a.id DESC"; $stmt = $conn->prepare($sql); $stmt->execute(); $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -124,23 +124,30 @@ function isPay($contract_no, $connT8)
+ + + + + + + +
+

(契約)獎金計算

+
- btn-sm categoryBtn"> 所有獎金 + btn-sm categoryBtn"> 所有獎金 - btn-sm categoryBtn"> 未發獎金 - btn-sm categoryBtn"> 已發獎金 - btn-sm categoryBtn"> 人事發放作業 - btn-sm categoryBtn"> 獎金總計(人) + btn-sm categoryBtn"> 未發獎金 + btn-sm categoryBtn"> 已發獎金 + btn-sm categoryBtn"> 人事發放作業 + btn-sm categoryBtn"> 獎金總計(人) - - - @@ -154,7 +161,6 @@ function isPay($contract_no, $connT8) - @@ -165,7 +171,7 @@ function isPay($contract_no, $connT8) - + @@ -173,7 +179,8 @@ function isPay($contract_no, $connT8) $data) : - + $bonus_json = json_decode($data['bonus_json']); + $bonus_kind = !empty($bonus_json->bonus_kind) ? $bonus_json->bonus_kind : ''; $contract_no = $data['contract_no']; $json = json_decode($data['bonus_json']); $total = empty($json->total) ? 0 : $json->total; @@ -187,13 +194,12 @@ function isPay($contract_no, $connT8) - + - + @@ -336,6 +342,7 @@ function isPay($contract_no, $connT8) form.append('pay_day', pay_day) form.append('amount', amount); form.append('postType', 'a'); + form.append('contract_type', 'new'); axios.post('./api/postStatus.php', form).then((res) => { if (res.data == 'Success') { alert('更新成功'); diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php index 27959883..086dbbf1 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php +++ b/wms/bonus/other/maintenance_contract_bonus_v2_1.php @@ -43,10 +43,11 @@ result_array[ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '') { + // $fee_per_st = round($fee_per_st); $bonus_array = []; if ($ver == "2.1") { // $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); - $discount = ($fee_per_st - $commission_fee) / $elevator_list_price; + $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 10); #契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue) switch ($contract_type) { diff --git a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php index 70a19f40..db37fd30 100644 --- a/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php +++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php @@ -120,7 +120,7 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract }; #付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) array_push($bonus_array, [ - "bonus_type" => "地區處長獎金", #獎金名稱 + "bonus_type" => "2", #獎金名稱 "bonus_receiver" => $region_director_id, #發放人員 "bonus_amount" => round($region_director_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 @@ -130,7 +130,7 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract #專任契約經理獎金 if ($regular_contract_manger_id != '') { array_push($bonus_array, [ - "bonus_type" => "專任契約經理獎金", #獎金名稱 + "bonus_type" => "3", #獎金名稱 "bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_amount" => round($regular_contract_manger_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 @@ -162,11 +162,11 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 }; array_push($bonus_array, [ - "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_type" => "1", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間 - "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + "bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定 ]); } @@ -191,11 +191,11 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 }; array_push($bonus_array, [ - "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_type" => "1", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 - "bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 + "bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定 ]); } break; @@ -219,7 +219,7 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 }; array_push($bonus_array, [ - "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_type" => "1", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 @@ -227,7 +227,6 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract ]); } break; - break; #雙月繳 case 'bimonthly': $a = $payment_period_amount / 2; @@ -248,7 +247,7 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 }; array_push($bonus_array, [ - "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_type" => "1", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 @@ -278,7 +277,7 @@ function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 }; array_push($bonus_array, [ - "bonus_type" => "契約員獎金", #獎金名稱 + "bonus_type" => "1", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($current_bonus), #金額 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index 5534b8eb..7d31dcbb 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -73,14 +73,17 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont $stmt->execute(); $elevators_results = $stmt->fetchAll(PDO::FETCH_ASSOC); $elevators_detail_arr = []; - - $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' "; - $stmt = $conn->prepare($sql); - $stmt->bindParam(':mid', $mid); - $stmt->execute(); - $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); - $option_arr = []; - + $contract_elevator_qty = 0; + // $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' "; + // $stmt = $conn->prepare($sql); + // $stmt->bindParam(':mid', $mid); + // $stmt->execute(); + // $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + // $option_arr = []; + + foreach ($elevators_results as $keys) { + $contract_elevator_qty += $keys['item_qty']; + } foreach ($elevators_results as $keys => $result) { $item_no = $result['item_no']; //電梯項次 // 電梯 OPTION @@ -91,36 +94,87 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont $stmt->execute(); $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); $option_arr[] = $option_results; + // echo "
";
+            // print_r($option_arr);
+            // echo "
"; if (!empty($option_results)) { $result['option_price'] = 0; // 電梯 OPTION 價格分別加到各台電梯 - foreach ($option_arr[$keys] as $key => $option) { + foreach ($option_results as $key => $option) { if ($option['item_qty'] == $result['item_qty']) { $result['option_price'] += intval($option['item_unit_price']); - echo '1..'; - } else if ($option['item_qty'] > $result['item_qty'] != 1) { + // 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_price'] += intval($option['item_unit_price']) * $item_qty; - echo '2..'; + // echo '2..'; + // echo "
";
+                        // print_r(intval($option['item_unit_price']) . ' *' . $item_qty . '=' . intval($option['item_unit_price']) * $item_qty);
+                        // echo "
"; } else { $result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']); - echo '3..'; + // echo '3..'; } - echo '
';
-                    print_r($option['item_no'] . '--->' . $option['item_unit_price']);
-                    echo '
'; + // echo '
';
+                    // print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
+                    // echo '
'; } - print_r($result['option_price']); - exit(); + // print_r($result['option_price']); + // exit(); } + // 查詢保固延長 + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='E' AND option_relate_spec = :item_no"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->execute(); + $other_option_arr = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!empty($other_option_arr)) { + $result['option_other_price'] = 0; + // 電梯 OPTION 價格分別加到各台電梯 + 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 '3..'; + } + // echo '
';
+                    // print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
+                    // echo '
'; + } + + // print_r($result['option_other_price']); + // exit(); + } + + $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++) { + $count_qty = $result['item_qty']; + for ($i = 0; $i < $count_qty; $i++) { + $result['elevator_price'] = round($result['item_price_ct'] / $result['item_qty']); //合約單台電提價格 + $result['commission_fee'] = round($contract['special_fee']) / $contract_elevator_qty; $result['item_no'] = $i + 1; + $result['item_qty'] = 1; array_push($elevators_detail_arr, $result); } } @@ -137,7 +191,7 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont header('Content-Type: application/json'); // 將 JSON 回應返回給客戶端 - // echo $contractResponse; + echo $contractResponse; } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index e8dca10f..445d0b5b 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -35,6 +35,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $files = !empty($_FILES['files']) ? $_FILES['files'] : null; $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; $payType = !empty($_POST['payType']) ? $_POST['payType'] : null; + $contract_type = !empty($_POST['contract_type']) ? $_POST['contract_type'] : null; $sql = "SELECT * FROM account WHERE accountid = '$salesman'"; $stmt = $conn->prepare($sql); @@ -72,7 +73,6 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c // exit(); // } echo json_encode($facilityno); - /// 獎金計算 $fail_arr = []; if ($contractno === '') return $fail_arr[] = '合約號為必填'; if ($total_price == '') $fail_arr[] = '合約總價為必填'; @@ -93,17 +93,21 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; if ($num == '') $fail_arr[] = '電梯數量為必填'; - if ($payType == '') $fail_arr[] = '付款方式為必填'; + if ($payType == '') $fail_arr[] = '分期方式為必填'; + if ($contract_type == '') $fail_arr[] = '合約類別為必填'; if (count($fail_arr) > 0) { header("HTTP/1.1 422 Unprocessable Entity"); echo json_encode($fail_arr); exit(); } // T8insert($_POST, $facilityno, $depId); + /// 獎金計算 $aaa = bonusCreate($_POST, $facilityno, $conn); - echo '
';
-        print_r($aaa);
-        echo '
'; + if ($aaa['status'] == 2) { + header("HTTP/1.1 422 Unprocessable Entity"); + echo $aaa['data']; + exit(); + } exit; //create account table $accounttype = "A"; @@ -683,6 +687,7 @@ function bonusCreate($data, $facilityno, $conn) 'A40005' => 'semiannually', // 半年繳 'A40003' => 'monthly' //月繳 ]; + $fail_arr = []; $payDay = getNext25thDate($contract_begin_date); foreach ($elevators as $key => $elevator) { @@ -690,7 +695,7 @@ function bonusCreate($data, $facilityno, $conn) $ver = $elevator['bonus_verson']; //獎金版本 $payment_period = $payment[$payType]; //付款方式 $elevator_list_price = !empty(intval($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價 - $fee_per_st = !empty(round($elevator['sold_price'] / 1.05, 2)) ? round($elevator['sold_price'] / 1.05, 2) : ''; //作翻契約金額 (不含稅) + $fee_per_st = !empty($elevator['sold_price']) ? intval(round($elevator['sold_price'] / 1.05, 2)) : ''; //作翻契約金額 (不含稅) $commission_fee = !empty($elevator['service_expense']) ? $elevator['service_expense'] : ''; //服務費(月/台) $receivable_date_due = $payDay; //第一筆保養款項收回日 $sales_id = $salesman; //營業人員 @@ -699,7 +704,7 @@ function bonusCreate($data, $facilityno, $conn) $regular_contract_manger_id = !empty($elevator['regular_contract_manger_id']) ? $elevator['regular_contract_manger_id'] : ''; $maintain_months = intval($elevator['maintain_months']); $years = $maintain_months / 12; - + echo $years; if ($maintain_months == '') $fail_arr[] = "保養月費為必填"; if ($fee_per_st == '') $fail_arr[] = "契約金額為必填"; if ($elevator_list_price == '') $fail_arr[] = "牌價為必填"; @@ -710,12 +715,12 @@ function bonusCreate($data, $facilityno, $conn) return $fail_arr; break; } - + $renew_priceissue_bonus = []; // $years = ($maintain_months % 12) == 0 ? $maintain_months / 12 : ''; // 如果保養合約 大於一年 if (!empty($maintain_months)) { if ($maintain_months > 12 && $contract_type == 'new') { - // 第一年為新簽約 + // 第一年為 "新簽約" $results = maintenance_contract_bonus_v2_1( $ver, $contract_type, @@ -728,27 +733,28 @@ function bonusCreate($data, $facilityno, $conn) $region_director_id, $regular_contract_manger_id ); - for ($i = 0; $i < $maintain_months - 1; $i++) { + for ($i = 1; $i <= $years - 1; $i++) { $contract_type = 'renew_priceissue'; - // 第二年以上改續約 - $result2 = maintenance_contract_bonus_v2_1( + $receivable_date_due_renew = date("Y-m-d", strtotime("$receivable_date_due + $i year")); + // 第二年以上改 "續約" + $renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1( $ver, $contract_type, $payment_period, $elevator_list_price, $fee_per_st, $commission_fee, - $receivable_date_due, + $receivable_date_due_renew, $sales_id, $region_director_id, $regular_contract_manger_id ); } } else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') { - // 超過一年的續約 + // 超過一年的 "續約" for ($i = 0; $i < $years; $i++) { $contract_type = 'renew_priceissue'; - $result2 = maintenance_contract_bonus_v2_1( + $renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1( $ver, $contract_type, $payment_period, @@ -761,9 +767,9 @@ function bonusCreate($data, $facilityno, $conn) $regular_contract_manger_id ); } - } else if ($maintain_months >= 60) { - $contract_type = 'longcontract_m1_free_charge'; - $result = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( + } else if ($maintain_months >= 60 && $contract_type = 'longcontract_m1_free_charge') { + // 五年以上長約 + $results = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( $ver, $contract_type, $payment_period, @@ -791,6 +797,7 @@ function bonusCreate($data, $facilityno, $conn) ); } } + $bonus_json = [ 'contract_type' => $contract_type, 'total' => $elevator_list_price, @@ -800,22 +807,10 @@ function bonusCreate($data, $facilityno, $conn) 'receivable_date_due' => $receivable_date_due, 'discount' => $discount ]; - if ($results['result_status'] != 'error') { - foreach ($results['bonus_array'] as $i => $result) { - - $bonus_type = $result['bonus_type']; - $pay_day = $result['pay_day_due']; - $amount = $result['bonus_amount']; - $receiver = $result['bonus_receiver']; - $a = json_encode($bonus_json); - $sql = "INSERT INTO bonus - (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day_due,status,bonus_json,create_id,create_at) VALUES - ($bonus_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')"; - $stmt = $conn->prepare($sql); - $stmt->execute(); - } - if (!empty($result2)) { - foreach ($results2['bonus_array'] as $i => $result) { + if (!empty($results)) { + + if ($results['result_status'] != 'error') { + foreach ($results['bonus_array'] as $i => $result) { $bonus_type = $result['bonus_type']; $pay_day = $result['pay_day_due']; @@ -823,15 +818,43 @@ function bonusCreate($data, $facilityno, $conn) $receiver = $result['bonus_receiver']; $a = json_encode($bonus_json); $sql = "INSERT INTO bonus + (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day_due,status,bonus_json,create_id,create_at) VALUES + ($bonus_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + } + } + if (!empty($renew_priceissue_bonus)) { + // echo '1'; + foreach ($renew_priceissue_bonus as $renew_priceissue_bonus) { + foreach ($renew_priceissue_bonus['bonus_array'] as $i => $result) { + + $bonus_type = $result['bonus_type']; + $pay_day = $result['pay_day_due']; + $amount = $result['bonus_amount']; + $receiver = $result['bonus_receiver']; + $a = json_encode($bonus_json); + $sql = "INSERT INTO bonus (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day_due,status,bonus_json,create_id,create_at) VALUES ($bonus_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$receiver','$pay_day',$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" + ]; } // exit(); } + return $request; // exit(); } catch (PDOException $e) { http_response_code(404); diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index 6180e4d4..a62d6e95 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -48,7 +48,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c if (empty($qc)) $fail_arr[] = '請選擇QC或官檢'; if (count($fail_arr) > 0) { header("HTTP/1.1 422 Unprocessable Entity"); - echo json_encode($fail_arr); + echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); exit(); } //create facility table @@ -69,8 +69,14 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c } $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); - BounsCount($_POST, $conn, $facilityno); - 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(); + } + // exit(); $conn->beginTransaction(); $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; @@ -118,7 +124,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); } @@ -151,7 +157,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(); @@ -304,13 +310,17 @@ function BounsCount($data, $conn, $facilityno) $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; @@ -318,28 +328,109 @@ function BounsCount($data, $conn, $facilityno) $result_bonus_arr = []; if ($signing_date <= $bonus_v1_0_date) { $ver = '1.0'; - foreach ($elevators as $i => $elevator) { + foreach ($elevators as $key => $elevator) { - $elevator_knockdown_price = $elevator['item_price_ct']; + $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); - $result_bonus['facility'] = $facilityno[$i]; - $result_bonus_arr[] = $result_bonus; + $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(); + } + $request = [ + "status" => "1", + "data" => "Success" + ]; + 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 $i => $elevator) { + foreach ($elevators as $key => $elevator) { $elevator_type = $dailyNecessities[$elevator['spec']]; - $elevator_list_price = $elevator['']; - $result_bonus = elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id); + $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 + (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(); + } + } + $request = [ + "status" => "1", + "data" => "Success" + ]; + } else { + $request = [ + "status" => "2", + "data" => "create_bonus_error" + ]; + } } } - // foreach ($elevators as $elevator) { - // $elevator_knockdown_price = $elevator['item_price_ct']; - // } - echo '
';
-  print_r($result_bonus_arr);
-  echo '
'; - exit(); + return $request; + try { } catch (PDOException $e) { header("HTTP/1.1 500 Internal Server Error"); diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index cbec41c1..56af787c 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -209,6 +209,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); + @@ -449,9 +450,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); - - - + - - - -

輸入地址以獲取經緯度

- - - - -
- - - \ No newline at end of file +// [ +// { +// //salSalesOrder +// "name": "MainSalesOrder", +// "rows": [ +// { +// "BillNo": "Z001", //合約單號 +// "BillDate": 20210420, //簽約日期 +// "TypeId": "SO", // +// "FOrgId": "1000", +// "OrgId": "1000", +// "ModeId": "T", // T汰改 M新梯 +// "BizPartnerId": "M0225", //創建人ID +// "CurrId": "TWD", +// "CurrOAmount": 1, +// "CurrLAmount": 1, +// "PersonId": "M0225", //業務人員 +// "DueToId": "512", //業務部門 +// "TradeConditionId": "", +// "TaxId": "ST005", +// "CreditorCompId": "1000", +// "CreditorOrgId": "1000", +// "CreditorCurrOAmount": 1, +// "CreditorCurrLAmount": 1, +// "CompId": "1000" +// } +// ] +// }, +// { +// //salSalesOrderDetail +// "name": "SubOrder", +// "rows": [ +// { +// "SupplyCompId": "1001", +// "SupplyOrgId": "1000", +// "TaxId": "ST005", +// "RequirementDate": 20210420, //出貨日期 +// "ConsignmentDate": 20210420, //發貨日期 +// "DispatchCompId": "1001", +// "DispatchOrgId": "1000", +// "BillNo": "Z001", //合約號 +// "RowCode": 1, //全部筆數排列 +// "ItemType": 0, +// "MaterialId": "Z001", //作番號 +// "SUnitId": "SET", +// "SQuantity": 1, //交易數量 +// "SPrice": 1 //交易價格 +// } +// ] +// }, +// { +// "name": "salOrderStagePay", +// "rows": [ +// { +// "BillNo": "", +// "RowCode": "", +// "RowNo": "", +// "PayStage": "ST003", //收款階段 +// "PlanPercentage": "Z001", //計劃收款比例(%) +// "PlanPayAmt": 1, //計劃收款金額 +// "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日 +// "UnWriteOffOAmount": 1 //未核銷金額 +// } +// ] +// } +// ] +require_once("../../T8_Authorization_from_bpm.php"); + +$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; + +$validation = get_Auth(); + +$MainSalesOrder_row = [ + "BillNo" => "M24020076", //合約單號 + "BillDate" => 20210420, //簽約日期 + "TypeId" => "SO", // + "FOrgId" => "1000", + "OrgId" => "1000", + "ModeId" => "M", // T汰改 M新梯 + "BizPartnerId" => "M24020076", //客戶代碼 + "CurrId" => "TWD", + "CurrOAmount" => 1, + "CurrLAmount" => 1, + "PersonId" => "M0225", //業務人員 + "DueToId" => "M24020076", //債務方 + "TradeConditionId" => "", + "TaxId" => "ST005", + "CreditorCompId" => "1001", + "CreditorOrgId" => "1000", + // "CompId" => "1001", + // "CreditorCurrOAmount" => 1, + // "CreditorCurrLAmount" => 1 +]; +// //salSalesOrderDetail +// $SubOrder_row = []; +for ($i = 0; $i < 3; $i++) { + if ($i == 0) { + $row = [ + // "SupplyCompId" => "1001", + // "SupplyOrgId" => "1000", + "TaxId" => "ST005", + "RequirementDate" => 20210420, //出貨日期 + "ConsignmentDate" => 20210420, //發貨日期 + // "DispatchCompId" => "1001", + // "DispatchOrgId" => "1000", + "BillNo" => "M24020076", //合約號 + "RowCode" => $i, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 50000 //交易價格 + ]; + } + if ($i == 1) { + $row = [ + // "SupplyCompId" => "1001", + // "SupplyOrgId" => "1000", + "TaxId" => "ST005", + "RequirementDate" => 20210420, //出貨日期 + "ConsignmentDate" => 20210420, //發貨日期 + // "DispatchCompId" => "1001", + // "DispatchOrgId" => "1000", + "BillNo" => "M24020076", //合約號 + "RowCode" => $i, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 700000 //交易價格 + ]; + } + if ($i == 2) { + $row = [ + // "SupplyCompId" => "1001", + // "SupplyOrgId" => "1000", + "TaxId" => "ST005", + "RequirementDate" => 20210420, //出貨日期 + "ConsignmentDate" => 20210420, //發貨日期 + // "DispatchCompId" => "1001", + // "DispatchOrgId" => "1000", + "BillNo" => "M24020076", //合約號 + "RowCode" => $i, //全部筆數排列 + "ItemType" => 0, + "MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 0 //交易價格 + ]; + } + $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", + "RowCode" => 1, + "RowNo" => 1, + "UnWriteOffOAmount" => 375000 //未核銷金額 +]; +$roww2 = [ + "PayStage" => "貨抵工地", + "PlanPercentage" => 0.5, + "PlanPayAmt" => 375000, + "PlanPayDate" => 20240101, + "BillNo" => "M24020076", + "RowCode" => 2, + "RowNo" => 2, + "UnWriteOffOAmount" => 375000 +]; +$salOrderStagePay_row[] = $roww; + +$MainSalesOrder = [ + "name" => "MainSalesOrder", + 'rows' => [$MainSalesOrder_row] +]; +$SubOrder = [ + "name" => "SubOrder", + "rows" => $SubOrder_row +]; +$salOrderStagePay = [ + "name" => "salOrderStagePay", + "rows" => $salOrderStagePay_row +]; + +$APIbody = []; +$APIbody[] = $MainSalesOrder; +$APIbody[] = $SubOrder; +$APIbody[] = $salOrderStagePay; +// $data = file_get_contents('test copy.json'); +// $arr = json_decode($data, true); +// echo "
";
+// print_r($data);
+// echo "
"; + +// echo "
";
+// print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
+// echo "
"; +// exit(); + +$header = [ + "CHI_Authorization :" . $validation, + "GroupId:TEST" +]; +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); +curl_setopt($ch, CURLOPT_HTTPHEADER, $header); +curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($APIbody, JSON_UNESCAPED_UNICODE)); +$response = curl_exec($ch); + +if ($response === false) { + echo 'Curl error: ' . curl_error($ch); +} else { + $result = json_decode($response, true); + // 若 API 傳入失敗。 + if ($result['Status'] == 'Erroe') { + echo 'API傳入失敗,' . $result['ErrorMsg']; + print_r($result); + } else { + // print_r($result); + print_r($result); + } + print_r($result); +} + +curl_close($ch); diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 10ef98d8..92aaf7d0 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -452,8 +452,11 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); - + + + \ No newline at end of file diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index 4c4d6d36..104ab4f7 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -810,7 +810,7 @@ const contractNewInput = () => { return { init() { }, data: { - contractno: 'M24020029', + contractno: 'M24020076', customer: '', manager: '', vat: '', @@ -827,6 +827,7 @@ const contractNewInput = () => { signing_date: '', //合約簽訂日期 elevators: [], // 電梯種類 Array elevators_detail_arr: [], // 電梯台數 Array + pay_arr: [], //電梯付款種類 nums: 0, //電梯數量 }, step: 1, @@ -902,6 +903,7 @@ const contractNewInput = () => { this.data.elevators = res.data.elevators; 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.step = 2 this.isLoading = false @@ -929,6 +931,7 @@ const contractNewInput = () => { form.append('contract_type', this.data.contract_type); form.append('elevators_detail_arr', JSON.stringify(this.data.elevators_detail_arr)); form.append('elevators', JSON.stringify(this.data.elevators)); + form.append('pay_arr', JSON.stringify(this.data.pay_arr)); form.append('contracttype', 'm'); form.append('user_id', user_id); for (var i = 0; i < this.data.files.length; i++) { From 79d4fecce6acc8d90dec812cf475969e2ab64faa Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 4 Mar 2024 20:25:19 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E3=80=81=E4=BF=9D?= =?UTF-8?q?=E9=A4=8A=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) { @@ -513,8 +551,8 @@ $para = "function_name=pricereview&" . $token_link; - - + + - + - - + + + + + + + + + + + + + +
牌價 服務費 應發人員預計發放時間 應發獎金水庫 實發金額 狀態發放 / 詳情 詳情
@@ -225,7 +231,7 @@ function isPay($contract_no, $connT8) - 查看詳情
區域 + +
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); From af80c76a1cd0300f3c4fd4be3f8f656866168e0b Mon Sep 17 00:00:00 2001 From: 10994015 Date: Tue, 5 Mar 2024 11:23:38 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E5=90=88=E7=B4=84?= =?UTF-8?q?=E6=9B=B8=E7=94=B3=E8=AB=8B:=E6=96=B0=E5=A2=9E=E5=BE=85?= =?UTF-8?q?=E7=B0=BD=E9=80=9A=E7=9F=A5=E3=80=81=E5=AF=A9=E6=A0=B8=E4=BA=BA?= =?UTF-8?q?=E6=94=B9=E7=82=BA=E6=A5=AD=E5=8B=99=E9=83=A8(M0175)=E4=B8=80?= =?UTF-8?q?=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/cont/css/pricereview.css | 325 +++++++++++++++++ wms/cont/css/pricereview.css.map | 1 + wms/cont/css/pricereview.scss | 343 ++++++++++++++++++ wms/cont/js/alpinejs/cdn.min.js | 5 + wms/cont/js/pricereviewAlpine.js | 7 + wms/cont/pricereviewCheck.php | 4 + wms/cont/pricereviewCreate.php | 143 ++++++++ wms/contract/api/postContractData.php | 2 +- wms/contract/api/postContractNewApplyData.php | 39 +- wms/contract/api/postFlow.php | 58 +++ wms/contract/contract-new-apply.php | 67 +++- wms/contract/js/alpine.js | 13 +- wms/crm/crmm02-index.php | 2 +- wms/crm/crmm06_submit.php | 2 +- wms/fun_global.php | 7 +- wms/login.php | 3 +- 16 files changed, 995 insertions(+), 26 deletions(-) create mode 100644 wms/cont/css/pricereview.css create mode 100644 wms/cont/css/pricereview.css.map create mode 100644 wms/cont/css/pricereview.scss create mode 100644 wms/cont/js/alpinejs/cdn.min.js create mode 100644 wms/cont/js/pricereviewAlpine.js create mode 100644 wms/cont/pricereviewCheck.php create mode 100644 wms/cont/pricereviewCreate.php create mode 100644 wms/contract/api/postFlow.php diff --git a/wms/cont/css/pricereview.css b/wms/cont/css/pricereview.css new file mode 100644 index 00000000..afeeb875 --- /dev/null +++ b/wms/cont/css/pricereview.css @@ -0,0 +1,325 @@ +@charset "UTF-8"; +#pricereviewCreate input[type=text], #pricereviewCreate input[type=number], #pricereviewCreate select { + margin: 1px; +} +#pricereviewCreate textarea { + resize: vertical; +} +#pricereviewCreate select { + -webkit-appearance: none; /* 針對 Chrome, Safari, Opera */ + -moz-appearance: none; /* 針對 Firefox */ + appearance: none; /* 標準語法 */ +} +#pricereviewCreate > .modal { + padding: 20px; +} +#pricereviewCreate > .modal table, #pricereviewCreate > .modal th, #pricereviewCreate > .modal td { + border: 1px #ccc solid; +} +#pricereviewCreate > .modal table > thead tr th { + color: #A52A2A; +} +#pricereviewCreate > .modal table > tbody .selected { + background-color: #E7FEFB; +} +#pricereviewCreate .container table, #pricereviewCreate .container th, #pricereviewCreate .container td { + border: 1px #ccc solid; + padding: 9px; +} +#pricereviewCreate .container table.noborder, #pricereviewCreate .container table .noborder th, #pricereviewCreate .container table .noborder td, #pricereviewCreate .container th.noborder, #pricereviewCreate .container th .noborder th, #pricereviewCreate .container th .noborder td, #pricereviewCreate .container td.noborder, #pricereviewCreate .container td .noborder th, #pricereviewCreate .container td .noborder td { + border: none; +} +#pricereviewCreate .container table thead th { + background-color: #6D9EEB; +} +#pricereviewCreate .container table tbody td input { + font-size: 14px; +} +#pricereviewCreate .container table tbody th { + background-color: #CCE4F8; + font-size: 14px; + padding: 15px 2px; + min-width: 100px; + text-align: center; +} +#pricereviewCreate .container table input { + font-size: 13px; +} +#pricereviewCreate .container .pricreviewmain { + background-color: #F2F2F2; + padding: 20px; + border-radius: 6px; + margin: 30px 0; +} +#pricereviewCreate .container .pricreviewmain button { + color: #fff; + width: 55px; + height: 30px; + padding: 0; + margin-left: 6px; + margin-bottom: 2px; + font-size: 13px; +} +#pricereviewCreate .container .pricreviewmain button.addbtn { + background-color: #337AB7; + width: 30px; +} +#pricereviewCreate .container .pricreviewmain button.deleteBtn { + background-color: #D9534F; + color: #fff; + font-size: 12px; + width: 30px; +} +#pricereviewCreate .container .pricreviewmain button.selectElevator { + background-color: #D9534F; + color: #fff; +} +#pricereviewCreate .container .pricreviewmain > .divitem { + border: 1px #ccc solid; + padding: 10px; + border-radius: 4px; +} +#pricereviewCreate .container .pricreviewmain > .divitem .title { + display: flex; + align-items: center; + border-bottom: 1px #ccc solid; + padding: 10px 0; + margin-bottom: 10px; +} +#pricereviewCreate .container .pricreviewmain > .divitem .title h6 { + font-weight: 600; +} +#pricereviewCreate .container .pricreviewmain > .divitem table, #pricereviewCreate .container .pricreviewmain > .divitem th, #pricereviewCreate .container .pricreviewmain > .divitem td { + font-size: 14px; + background-color: transparent; +} +#pricereviewCreate .container .pricreviewmain > .divitem table input, #pricereviewCreate .container .pricreviewmain > .divitem table select, #pricereviewCreate .container .pricreviewmain > .divitem th input, #pricereviewCreate .container .pricreviewmain > .divitem th select, #pricereviewCreate .container .pricreviewmain > .divitem td input, #pricereviewCreate .container .pricreviewmain > .divitem td select { + font-size: 13px; + padding: 0 13px; +} +#pricereviewCreate .container .pricreviewmain > .divitem table textarea, #pricereviewCreate .container .pricreviewmain > .divitem th textarea, #pricereviewCreate .container .pricreviewmain > .divitem td textarea { + font-size: 13px; +} +#pricereviewCreate .container .pricreviewmain > .divitem table input[type=number]::-webkit-outer-spin-button, +#pricereviewCreate .container .pricreviewmain > .divitem table input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .container .pricreviewmain > .divitem th input[type=number]::-webkit-outer-spin-button, +#pricereviewCreate .container .pricreviewmain > .divitem th input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .container .pricreviewmain > .divitem td input[type=number]::-webkit-outer-spin-button, +#pricereviewCreate .container .pricreviewmain > .divitem td input[type=number]::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; +} +#pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .deleteBtn, #pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .copyBtn { + opacity: 1; +} +#pricereviewCreate .container .pricreviewmain > .divitem table .copyBtn { + width: 30px; + height: 30px; +} +#pricereviewCreate .container .pricreviewmain > .divitem table .saletd { + position: relative; +} +#pricereviewCreate .container .pricreviewmain > .divitem table .saletd > .deleteBtn { + position: absolute; + top: 50%; + transform: translateY(-50%); + right: 2px; + opacity: 0; + transition: 0.3s; +} +#pricereviewCreate .container .pricreviewmain > .divitem table .saletd > .copyBtn { + position: absolute; + top: 50%; + transform: translateY(-50%); + right: 38px; + opacity: 0; + transition: 0.3s; + width: 30px; + height: 30px; +} +#pricereviewCreate .container .pricreviewmain > .divitem table textarea { + height: auto; + min-height: 50px; +} +#pricereviewCreate .container .pricreviewmain > .filediv { + display: flex; + flex-direction: column; + margin-top: 20px; +} +#pricereviewCreate .container .pricreviewmain > .filediv label { + display: flex; + align-items: center; + margin: 10px 0; +} +#pricereviewCreate .container .pricreviewmain > .filediv label p { + width: 100px; + font-size: 15px; + font-weight: 600; +} +#pricereviewCreate .container .pricreviewmain > .filediv label input[type=file] { + width: 400px; +} +#pricereviewCreate .container .pricreviewmain > .filediv label a, #pricereviewCreate .container .pricreviewmain > .filediv label button { + width: 100px; + height: 35px; + margin: 0; + margin-right: 15px; + margin-top: 20px; +} + +.container-fluid, .container { + max-width: 1400px !important; + width: 100%; +} +.container-fluid h4, .container h4 { + font-weight: 600; +} +.container-fluid .btn-secondary, .container .btn-secondary { + background-color: #6C757D; +} + +[x-cloak][data-type=window-modal], +[x-cloak][data-type=errortext] { + display: none !important; +} + +.errortext { + font-size: 12px !important; + color: red !important; + font-weight: 600 !important; +} + +.window-modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100vh; + background-color: rgba(0, 0, 0, 0.5); + z-index: 9; + padding: 20px; +} +@keyframes fade-in { + 0% { + transform: translate(-50%, -60%); + opacity: 0; + } + 100% { + transform: translate(-50%, -55%); + opacity: 1; + } +} +.window-modal table, .window-modal th, .window-modal td { + border: 1px #ccc solid; +} +.window-modal table > thead tr th { + color: #A52A2A; +} +.window-modal table > tbody .selected { + background-color: #E7FEFB; +} +.window-modal#optionModal .window-modal-content { + max-height: 80vh; +} +.window-modal#optionModal .window-modal-content .window-modal-body { + height: 400px; + overflow-y: scroll; +} +.window-modal#toElevatorModal .window-modal-content { + min-height: 270px; + height: auto; +} +.window-modal#toElevatorModal .window-modal-content .window-modal-body { + height: auto; +} +.window-modal .window-modal-content { + z-index: 9; + background-color: #fff; + border-radius: 10px; + position: absolute; + width: 90%; + padding: 30px; + top: 50%; + left: 50%; + transform: translate(-50%, -55%); + box-shadow: 0 5px 5px #222; + animation: fade-in 0.2s linear; +} +.window-modal .window-modal-content.modal-xl { + max-width: 1200px; +} +.window-modal .window-modal-content.modal-lg { + max-width: 800px; +} +.window-modal .window-modal-content.modal-m { + max-width: 450px; +} +.window-modal .window-modal-content .window-modal-header { + display: flex; + flex-direction: column; +} +.window-modal .window-modal-content .window-modal-header button.btn-close { + position: absolute; + top: 10px; + right: 10px; + background-color: transparent; + border: none; + outline: none; + border-radius: 50%; +} +.window-modal .window-modal-content .window-modal-header > div > input { + width: 250px; +} +.window-modal .window-back { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: transparent; +} + +#pricereviewCheck > .container { + background-color: #F2F2F2; + border-radius: 15px; + padding: 20px; +} +#pricereviewCheck > .container .historytable { + max-height: 0; + overflow: hidden; +} +#pricereviewCheck > .container textarea { + resize: vertical; +} +#pricereviewCheck > .container table, #pricereviewCheck > .container th, #pricereviewCheck > .container td { + border: 1px #ccc solid; +} +#pricereviewCheck > .container table.noborder { + border: none !important; +} +#pricereviewCheck > .container table.noborder th, #pricereviewCheck > .container table.noborder td { + border: none !important; +} +#pricereviewCheck > .container .customerinfo-table input { + background-color: #EEE5E5; +} +#pricereviewCheck > .container .mi-table th { + font-weight: 600; +} +#pricereviewCheck > .container .mi-table input[type=text] { + background-color: #EEEEEE; + cursor: not-allowed; + padding: 6px 12px; + font-size: 14px; +} +#pricereviewCheck > .container .mi-table .mi-info { + font-size: 14px; +} +#pricereviewCheck > .container .mi-table .mi-info span { + font-size: 15px; + font-weight: 600; +} +#pricereviewCheck > .container .mi-table .mi-info .line { + width: 100%; + height: 0.5px; + margin: 30px 0; + background-color: #ccc; +}/*# sourceMappingURL=pricereview.css.map */ \ No newline at end of file diff --git a/wms/cont/css/pricereview.css.map b/wms/cont/css/pricereview.css.map new file mode 100644 index 00000000..4acaa24e --- /dev/null +++ b/wms/cont/css/pricereview.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["pricereview.css","pricereview.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACCZ;EACI,WAAA;ADCR;ACCI;EACI,gBAAA;ADCR;ACCI;EACI,wBAAA,EAAA,6BAAA;EACA,qBAAA,EAAA,eAAA;EACA,gBAAA,EAAA,SAAA;ADCR;ACCI;EACI,aAAA;ADCR;ACAQ;EACI,sBAAA;ADEZ;ACAQ;EACI,cAAA;ADEZ;ACAQ;EACI,yBAAA;ADEZ;ACIQ;EACI,sBAAA;EACA,YAAA;ADFZ;ACGY;EACI,YAAA;ADDhB;ACMY;EACI,yBAAA;ADJhB;ACOgB;EACI,eAAA;ADLpB;ACOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ADLpB;ACQY;EACI,eAAA;ADNhB;ACSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ADPZ;ACQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;ADNhB;ACOgB;EACI,yBAAA;EACA,WAAA;ADLpB;ACOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ADLpB;ACOgB;EACI,yBAAA;EACA,WAAA;ADLpB;ACSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ADPhB;ACQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ADNpB;ACOoB;EACI,gBAAA;ADLxB;ACSgB;EACI,eAAA;EACA,6BAAA;ADPpB;ACQoB;EACI,eAAA;EACA,eAAA;ADNxB;ACQoB;EACI,eAAA;ADNxB;ACQoB;;;;EAEA,wBAAA;EACA,SAAA;ADJpB;ACQoB;EACI,UAAA;ADNxB;ACQoB;EACI,WAAA;EACA,YAAA;ADNxB;ACQoB;EACI,kBAAA;ADNxB;ACOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ADL5B;ACOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ADL5B;ACQoB;EACI,YAAA;EACA,gBAAA;ADNxB;ACUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ADRhB;ACSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ADPpB;ACQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ADNxB;ACQoB;EACI,YAAA;ADNxB;ACQoB;EACI,YAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ADNxB;;ACcA;EACI,4BAAA;EACA,WAAA;ADXJ;ACYI;EACI,gBAAA;ADVR;ACYI;EACI,yBAAA;ADVR;;ACaA;;EAGI,wBAAA;ADXJ;;ACaA;EACI,0BAAA;EACA,qBAAA;EACA,2BAAA;ADVJ;;ACYA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;ADTJ;ACWI;EACI;IACI,gCAAA;IACA,UAAA;EDTV;ECWM;IACI,gCAAA;IACA,UAAA;EDTV;AACF;ACWI;EACI,sBAAA;ADTR;ACWI;EACI,cAAA;ADTR;ACWI;EACI,yBAAA;ADTR;ACWI;EACI,gBAAA;ADTR;ACUQ;EACI,aAAA;EACA,kBAAA;ADRZ;ACWI;EACI,iBAAA;EACA,YAAA;ADTR;ACUQ;EACI,YAAA;ADRZ;ACWI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ADTR;ACUQ;EACI,iBAAA;ADRZ;ACUQ;EACI,gBAAA;ADRZ;ACUQ;EACI,gBAAA;ADRZ;ACUQ;EACI,aAAA;EACA,sBAAA;ADRZ;ACSY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ADPhB;ACSY;EACI,YAAA;ADPhB;ACWI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ADTR;;ACcI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ADXR;ACYQ;EACI,aAAA;EACA,gBAAA;ADVZ;ACYQ;EACI,gBAAA;ADVZ;ACYQ;EACI,sBAAA;ADVZ;ACYQ;EACI,uBAAA;ADVZ;ACWY;EACI,uBAAA;ADThB;ACaY;EACI,yBAAA;ADXhB;ACeY;EACI,gBAAA;ADbhB;ACeY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ADbhB;ACeY;EACI,eAAA;ADbhB;ACcgB;EACI,eAAA;EACA,gBAAA;ADZpB;ACcgB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ADZpB","file":"pricereview.css"} \ No newline at end of file diff --git a/wms/cont/css/pricereview.scss b/wms/cont/css/pricereview.scss new file mode 100644 index 00000000..07a63973 --- /dev/null +++ b/wms/cont/css/pricereview.scss @@ -0,0 +1,343 @@ +#pricereviewCreate{ + input[type='text'], input[type='number'], select{ + margin: 1px; + } + textarea{ + resize: vertical; + } + select{ + -webkit-appearance: none; /* 針對 Chrome, Safari, Opera */ + -moz-appearance: none; /* 針對 Firefox */ + appearance: none; /* 標準語法 */ + } + >.modal{ + padding: 20px; + table, th, td{ + border:1px #ccc solid; + } + table > thead tr th{ + color:#A52A2A; + } + table > tbody .selected{ + background-color: #E7FEFB; + } + table > tbody .selected td{ + } + } + .container{ + table, th, td{ + border:1px #ccc solid; + padding: 9px; + &.noborder, .noborder th, .noborder td{ + border:none; + } + } + table{ + + thead th{ + background-color: #6D9EEB; + } + tbody { + td input{ + font-size: 14px; + } + th{ + background-color: #CCE4F8; + font-size: 14px; + padding: 15px 2px; + min-width: 100px; + text-align: center; + } + } + input{ + font-size: 13px; + } + } + .pricreviewmain{ + background-color: #F2F2F2; + padding: 20px; + border-radius: 6px ; + margin:30px 0; + button{ + color:#fff; + width: 55px; + height: 30px; + padding: 0; + margin-left: 6px; + margin-bottom: 2px; + font-size: 13px; + &.addbtn{ + background-color: #337AB7; + width: 30px; + } + &.deleteBtn{ + background-color: #D9534F; + color:#fff; + font-size: 12px; + width: 30px; + } + &.selectElevator{ + background-color: #D9534F; + color:#fff; + } + } + + >.divitem{ + border:1px #ccc solid; + padding: 10px; + border-radius: 4px ; + .title{ + display: flex; + align-items: center; + border-bottom: 1px #ccc solid; + padding: 10px 0; + margin-bottom: 10px; + h6{ + font-weight: 600; + } + + } + table, th, td{ + font-size: 14px; + background-color: transparent; + input, select{ + font-size: 13px; + padding: 0 13px; + } + textarea{ + font-size: 13px; + } + input[type=number]::-webkit-outer-spin-button, + input[type=number]::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + } + table { + tr:hover .deleteBtn ,tr:hover .copyBtn{ + opacity: 1; + } + .copyBtn{ + width: 30px; + height: 30px; + } + .saletd{ + position: relative; + >.deleteBtn{ + position: absolute; + top: 50%; + transform: translateY(-50%); + right:2px; + opacity: 0; + transition: .3s; + } + >.copyBtn{ + position: absolute; + top: 50%; + transform: translateY(-50%); + right:38px; + opacity: 0; + transition: .3s; + width: 30px; + height: 30px; + } + } + textarea{ + height: auto; + min-height: 50px; + } + } + } + >.filediv{ + display: flex; + flex-direction: column; + margin-top: 20px; + label{ + display: flex; + align-items: center; + margin:10px 0; + p{ + width:100px; + font-size: 15px; + font-weight: 600; + } + input[type="file"]{ + width:400px + } + a, button{ + width:100px; + height: 35px; + margin:0; + margin-right: 15px; + margin-top: 20px; + } + } + } + } + } +} + +.container-fluid, .container{ + max-width:1400px !important; + width: 100%; + h4{ + font-weight: 600; + } + .btn-secondary{ + background-color: #6C757D; + } +} +[x-cloak][data-type="window-modal"], +[x-cloak][data-type="errortext"] +{ + display: none !important; +} +.errortext{ + font-size:12px !important; + color:red !important; + font-weight:600 !important; +} +.window-modal{ + position: fixed; + top: 0; + left:0; + width: 100%; + height: 100vh; + background-color: rgba(0, 0, 0, 0.5); + z-index: 9; + padding: 20px; + // display: none; + @keyframes fade-in { + 0%{ + transform: translate(-50%, -60%); + opacity: 0; + } + 100%{ + transform: translate(-50%, -55%); + opacity: 1; + } + } + table, th, td{ + border:1px #ccc solid; + } + table > thead tr th{ + color:#A52A2A; + } + table > tbody .selected{ + background-color: #E7FEFB; + } + &#optionModal .window-modal-content{ + max-height: 80vh; + .window-modal-body{ + height: 400px; + overflow-y: scroll; + } + } + &#toElevatorModal .window-modal-content{ + min-height: 270px; + height: auto; + .window-modal-body{ + height: auto; + } + } + .window-modal-content{ + z-index: 9; + background-color: #fff; + border-radius: 10px; + position: absolute; + width:90%; + padding: 30px; + top: 50%; + left:50%; + transform: translate(-50%, -55%); + box-shadow: 0 5px 5px #222; + animation: fade-in .2s linear; + &.modal-xl{ + max-width:1200px; + } + &.modal-lg{ + max-width:800px; + } + &.modal-m{ + max-width:450px; + } + .window-modal-header{ + display: flex; + flex-direction: column; + button.btn-close{ + position: absolute; + top: 10px; + right:10px; + background-color: transparent; + border:none; + outline: none; + border-radius: 50%; + } + >div > input{ + width: 250px; + } + } + } + .window-back{ + position: absolute; + top: 0; + left:0; + width: 100%; + height: 100%; + background-color: transparent; + } +} + +#pricereviewCheck{ + >.container{ + background-color: #F2F2F2; + border-radius: 15px; + padding: 20px; + .historytable{ + max-height: 0; + overflow: hidden; + } + textarea{ + resize: vertical; + } + table, th, td{ + border:1px #ccc solid; + } + table.noborder{ + border:none !important; + th ,td{ + border:none !important; + } + } + .customerinfo-table{ + input{ + background-color: #EEE5E5; + } + } + .mi-table{ + th{ + font-weight: 600; + } + input[type=text]{ + background-color: #EEEEEE; + cursor: not-allowed; + padding: 6px 12px; + font-size: 14px; + } + .mi-info{ + font-size: 14px; + span{ + font-size: 15px; + font-weight: 600; + } + .line{ + width: 100%; + height: .5px; + margin:30px 0; + background-color: #ccc; + } + } + } + } + +} \ No newline at end of file diff --git a/wms/cont/js/alpinejs/cdn.min.js b/wms/cont/js/alpinejs/cdn.min.js new file mode 100644 index 00000000..922cc02e --- /dev/null +++ b/wms/cont/js/alpinejs/cdn.min.js @@ -0,0 +1,5 @@ +(()=>{var Ze=!1,Qe=!1,H=[],et=-1;function zt(e){En(e)}function En(e){H.includes(e)||H.push(e),vn()}function we(e){let t=H.indexOf(e);t!==-1&&t>et&&H.splice(t,1)}function vn(){!Qe&&!Ze&&(Ze=!0,queueMicrotask(Sn))}function Sn(){Ze=!1,Qe=!0;for(let e=0;ee.effect(t,{scheduler:r=>{tt?zt(r):r()}}),rt=e.raw}function nt(e){I=e}function qt(e){let t=()=>{};return[n=>{let i=I(n);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),L(i))},i},()=>{t()}]}function q(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}function O(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>O(i,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)O(n,t,!1),n=n.nextElementSibling}function v(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var Ut=!1;function Wt(){Ut&&v("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),Ut=!0,document.body||v("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's ` + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
有望客戶(契約)基本資料
評審單號卷號現場地址現場名稱
電梯品牌數量營業員保養方式 + +
契約期限開始契約期限結束契約性質 + + 介紹人
付款方式 + +
+ + + + + + + + + + + +
洽商進度
+ +
+ + + + + + + + + + + +
電梯詳細資料
+ +
+
+
+
+

整機單價

+ +
+ + + + + + + + + + + + + + + + + + + +
項次電梯人乘載重(KG)停數速度(m/min)開門方式規格公司發布價(台)數量公司發布價(總價)售價(台)售價(總價)
+
+
+
+
\ No newline at end of file diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 29038b9f..6eb6dcaa 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -213,7 +213,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $ADuseful_date = implode("-", $click); $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) - VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; + VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':contractno', $contractno); $stmt->bindParam(':define', $define); diff --git a/wms/contract/api/postContractNewApplyData.php b/wms/contract/api/postContractNewApplyData.php index e3ec18e5..7f2e2525 100644 --- a/wms/contract/api/postContractNewApplyData.php +++ b/wms/contract/api/postContractNewApplyData.php @@ -4,6 +4,7 @@ use function Symfony\Component\String\s; require_once("../conn.php"); include_once("./upload_chk.php"); +include_once "./postFlow.php"; ini_set('date.timezone', 'Asia/Taipei'); if ($_SERVER['REQUEST_METHOD'] != 'POST') { exit(); @@ -42,6 +43,8 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == $status = $_POST['status']; // 0:暫存 1:送審 2:退回 3:完成 $pays = json_decode($pays, true); + $form_key = $_POST['form_key']; + $files = !empty($_FILES['files']) ? $_FILES['files'] : null; @@ -160,6 +163,14 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == } } // -----處理檔案上傳 END----- + + if($status == 1){ + $current_assigner = "M0175"; + $flow_code = "A"; + $ekind = "新梯"; + createFlow($mid, $current_assigner, $flow_code, $ekind, $form_key); + } + header("HTTP/1.1 201 success!"); $conn->commit(); } else { @@ -211,7 +222,6 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == } $deleted_at = date("Y-m-d H:i:s"); $removefiles = isset($_POST['removefiles']) ? json_decode($_POST['removefiles'], true) : []; - print_r($removefiles); if(count($removefiles) > 0){ foreach($removefiles as $file){ $sql_str = "UPDATE contract_apply_files SET deleted_at = :deleted_at WHERE id = :fileid"; @@ -221,9 +231,18 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == $stmt ->execute(); } } + + if($status == 1){ + $current_assigner = "M0175"; + $flow_code = "A"; + $ekind = "新梯"; + createFlow($mid, $current_assigner, $flow_code, $ekind, $form_key); + } + header("HTTP/1.1 201 success!"); $conn->commit(); } + } catch (PDOException $e) { $conn->rollback(); header("HTTP/1.1 500 failed!"); @@ -268,6 +287,8 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == $progress = $_POST['progress']; $review_comment = $_POST['review_comment']; $user_id = $_POST['review_person_id']; + $form_key = $_POST['form_key']; + $mid = $contract_new_apply_id; $review_date = date('Y-m-d H:i:s'); $conn->beginTransaction(); try { @@ -280,6 +301,13 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == $stmt->bindParam(':review_person_id', $user_id); $stmt->bindParam(':review_date', $review_date); $stmt->execute(); + + + //發送待簽通知 + $current_assigner = "00000"; + $flow_code = "Z"; + $ekind = "新梯"; + createFlow($mid, $current_assigner, $flow_code, $ekind, $form_key); header("HTTP/1.1 200 success!"); $conn->commit(); } catch (PDOException $e) { @@ -297,6 +325,8 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == $progress = $_POST['progress']; $review_comment = $_POST['review_comment']; $user_id = $_POST['review_person_id']; + $form_key = $_POST['form_key']; + $mid = $contract_new_apply_id; echo $user_id; $review_date = date('Y-m-d H:i:s'); $conn->beginTransaction(); @@ -310,6 +340,13 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == $stmt->bindParam(':review_person_id', $user_id); $stmt->bindParam(':review_date', $review_date); $stmt->execute(); + + + //發送待簽通知 + $current_assigner = "00000"; + $flow_code = "A"; + $ekind = "新梯"; + createFlow($mid, $current_assigner, $flow_code, $ekind, $form_key); header("HTTP/1.1 200 success!"); $conn->commit(); } catch (PDOException $e) { diff --git a/wms/contract/api/postFlow.php b/wms/contract/api/postFlow.php new file mode 100644 index 00000000..90368b1c --- /dev/null +++ b/wms/contract/api/postFlow.php @@ -0,0 +1,58 @@ +prepare($sql_str); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $form_key = $result['form_key']; + $seq = 0; + + $sql_str = "INSERT INTO flow (system_id, flow_id, form_id, form_key, flow_code) + VALUES (:system_id, :flow_id, :form_id, :form_key, :flow_code)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':system_id', $system_id); + $stmt->bindParam(':flow_id', $flow_id); + $stmt->bindParam(':form_id', $form_id); + $stmt->bindParam(':form_key', $form_key); + $stmt->bindParam(':flow_code', $flow_code); + $stmt->execute(); + }else{ + $sql_str = "UPDATE flow SET flow_code = :flow_code WHERE form_key = :form_key"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':form_key', $form_key); + $stmt->bindParam(':flow_code', $flow_code); + $stmt->execute(); + + $sql_str = "SELECT MAX(seq) AS max_seq FROM subflow WHERE form_key = :form_key"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':form_key', $form_key); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $seq = $result['max_seq']; + $seq ++; + } + + $created_at = date("Y-m-d H:i:s"); + $sql_str = "INSERT INTO subflow (form_key, seq, current_assigner, update_date,create_date) + VALUES (:form_key, :seq, :current_assigner, :update_date,:create_date)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':form_key', $form_key); + $stmt->bindParam(':seq', $seq); + $stmt->bindParam(':current_assigner', $current_assigner); + $stmt->bindParam(':update_date', $created_at); + $stmt->bindParam(':create_date', $created_at); + $stmt->execute(); + + + return $form_key; +} \ No newline at end of file diff --git a/wms/contract/contract-new-apply.php b/wms/contract/contract-new-apply.php index 74153c28..e315c28c 100644 --- a/wms/contract/contract-new-apply.php +++ b/wms/contract/contract-new-apply.php @@ -1,13 +1,45 @@ alert('非法訪問!!!');"; echo ""; exit; } -$id = $_GET["id"]; +$id = null; +if(isset($_GET['id'])){ + $id = $_GET["id"]; +} +$form_key = null; +if(isset($_GET['form_key'])){ + $form_key = $_GET['form_key']; +} + +if($form_key != null){ + $sql_str = "SELECT form_id FROM flow WHERE system_id = 'cta' AND flow_id = 'cta01' AND form_key = :form_key"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':form_key', $form_key); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $id = $result['form_id']; +} + +if(!$id){ + $para = "function_name=pricereview&" . $token_link; + echo ""; + echo ""; + exit; +} + +$sql_str = "SELECT form_key FROM flow WHERE system_id = 'cta' AND flow_id = 'cta01' AND form_id = :id"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':id', $id); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_ASSOC); +if($result){ + $form_key = $result['form_key']; +} $sql_str = "SELECT contract_new_apply.*, person_account.name AS review_person_name, person_final_account.name AS review_final_person_name FROM contract_new_apply @@ -439,7 +471,13 @@ $para = "function_name=pricereview&" . $token_link;
第二期款交貨期限(日) - +

未填寫

業務承辦人
業務部審核 = 2) : ?>已同意 @@ -525,15 +563,15 @@ $para = "function_name=pricereview&" . $token_link;
業務部協理業務部審核 結案同意 結案不同意 ---
催收次數 + + ≤ 催收次數 ≤ + + +
催收金額 + + ≤ 催收金額 ≤ + + +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + $row) { ?> + + + + + + + + + + + + + + + + + + + +
合約號序號作番號部門主管契約員客戶名稱應收日期是否應收應收金額已收金額催收金額催收次數
" . $row['DeptName']; ?>" . $row['LeaderName']; ?>" . $row['PersonName']; ?>" . $row['BizPartnerName']; ?>1))? $row['collecttime']:0; ?>
+
+ + \ No newline at end of file From 2ac5424596ae8d667c6b52ffbb384c9ca31a87b1 Mon Sep 17 00:00:00 2001 From: 10994015 Date: Tue, 5 Mar 2024 18:08:50 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E4=BF=9D=E9=A4=8A=E5=83=B9=E5=AF=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/cont/css/pricereview.css | 4 + wms/cont/css/pricereview.css.map | 2 +- wms/cont/css/pricereview.scss | 5 + wms/cont/js/pricereviewAlpine.js | 111 ++++++ wms/cont/pricereviewCreate.php | 412 ++++++++++++++++++++- wms/mkt/api/postNewElevatorPricereview.php | 5 +- wms/mkt/api/postPricereviewSign.php | 20 +- wms/mkt/pricereview-index.php | 9 +- wms/mkt/pricereviewCreate.php | 3 +- 9 files changed, 541 insertions(+), 30 deletions(-) diff --git a/wms/cont/css/pricereview.css b/wms/cont/css/pricereview.css index afeeb875..3cd7f902 100644 --- a/wms/cont/css/pricereview.css +++ b/wms/cont/css/pricereview.css @@ -164,6 +164,10 @@ margin-right: 15px; margin-top: 20px; } +#pricereviewCreate .dark { + background-color: rgb(225, 225, 225) !important; + font-weight: 600; +} .container-fluid, .container { max-width: 1400px !important; diff --git a/wms/cont/css/pricereview.css.map b/wms/cont/css/pricereview.css.map index 4acaa24e..a5d7bedf 100644 --- a/wms/cont/css/pricereview.css.map +++ b/wms/cont/css/pricereview.css.map @@ -1 +1 @@ -{"version":3,"sources":["pricereview.css","pricereview.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACCZ;EACI,WAAA;ADCR;ACCI;EACI,gBAAA;ADCR;ACCI;EACI,wBAAA,EAAA,6BAAA;EACA,qBAAA,EAAA,eAAA;EACA,gBAAA,EAAA,SAAA;ADCR;ACCI;EACI,aAAA;ADCR;ACAQ;EACI,sBAAA;ADEZ;ACAQ;EACI,cAAA;ADEZ;ACAQ;EACI,yBAAA;ADEZ;ACIQ;EACI,sBAAA;EACA,YAAA;ADFZ;ACGY;EACI,YAAA;ADDhB;ACMY;EACI,yBAAA;ADJhB;ACOgB;EACI,eAAA;ADLpB;ACOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ADLpB;ACQY;EACI,eAAA;ADNhB;ACSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ADPZ;ACQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;ADNhB;ACOgB;EACI,yBAAA;EACA,WAAA;ADLpB;ACOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ADLpB;ACOgB;EACI,yBAAA;EACA,WAAA;ADLpB;ACSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ADPhB;ACQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ADNpB;ACOoB;EACI,gBAAA;ADLxB;ACSgB;EACI,eAAA;EACA,6BAAA;ADPpB;ACQoB;EACI,eAAA;EACA,eAAA;ADNxB;ACQoB;EACI,eAAA;ADNxB;ACQoB;;;;EAEA,wBAAA;EACA,SAAA;ADJpB;ACQoB;EACI,UAAA;ADNxB;ACQoB;EACI,WAAA;EACA,YAAA;ADNxB;ACQoB;EACI,kBAAA;ADNxB;ACOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ADL5B;ACOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ADL5B;ACQoB;EACI,YAAA;EACA,gBAAA;ADNxB;ACUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ADRhB;ACSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ADPpB;ACQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ADNxB;ACQoB;EACI,YAAA;ADNxB;ACQoB;EACI,YAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ADNxB;;ACcA;EACI,4BAAA;EACA,WAAA;ADXJ;ACYI;EACI,gBAAA;ADVR;ACYI;EACI,yBAAA;ADVR;;ACaA;;EAGI,wBAAA;ADXJ;;ACaA;EACI,0BAAA;EACA,qBAAA;EACA,2BAAA;ADVJ;;ACYA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;ADTJ;ACWI;EACI;IACI,gCAAA;IACA,UAAA;EDTV;ECWM;IACI,gCAAA;IACA,UAAA;EDTV;AACF;ACWI;EACI,sBAAA;ADTR;ACWI;EACI,cAAA;ADTR;ACWI;EACI,yBAAA;ADTR;ACWI;EACI,gBAAA;ADTR;ACUQ;EACI,aAAA;EACA,kBAAA;ADRZ;ACWI;EACI,iBAAA;EACA,YAAA;ADTR;ACUQ;EACI,YAAA;ADRZ;ACWI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ADTR;ACUQ;EACI,iBAAA;ADRZ;ACUQ;EACI,gBAAA;ADRZ;ACUQ;EACI,gBAAA;ADRZ;ACUQ;EACI,aAAA;EACA,sBAAA;ADRZ;ACSY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ADPhB;ACSY;EACI,YAAA;ADPhB;ACWI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ADTR;;ACcI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ADXR;ACYQ;EACI,aAAA;EACA,gBAAA;ADVZ;ACYQ;EACI,gBAAA;ADVZ;ACYQ;EACI,sBAAA;ADVZ;ACYQ;EACI,uBAAA;ADVZ;ACWY;EACI,uBAAA;ADThB;ACaY;EACI,yBAAA;ADXhB;ACeY;EACI,gBAAA;ADbhB;ACeY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ADbhB;ACeY;EACI,eAAA;ADbhB;ACcgB;EACI,eAAA;EACA,gBAAA;ADZpB;ACcgB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ADZpB","file":"pricereview.css"} \ No newline at end of file +{"version":3,"sources":["pricereview.css","pricereview.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACEZ;EACI,WAAA;ADAR;ACEI;EACI,gBAAA;ADAR;ACEI;EACI,wBAAA,EAAA,6BAAA;EACA,qBAAA,EAAA,eAAA;EACA,gBAAA,EAAA,SAAA;ADAR;ACEI;EACI,aAAA;ADAR;ACCQ;EACI,sBAAA;ADCZ;ACCQ;EACI,cAAA;ADCZ;ACCQ;EACI,yBAAA;ADCZ;ACKQ;EACI,sBAAA;EACA,YAAA;ADHZ;ACIY;EACI,YAAA;ADFhB;ACOY;EACI,yBAAA;ADLhB;ACQgB;EACI,eAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ADNpB;ACSY;EACI,eAAA;ADPhB;ACUQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ADRZ;ACSY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;ADPhB;ACQgB;EACI,yBAAA;EACA,WAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,WAAA;ADNpB;ACUY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ADRhB;ACSgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ADPpB;ACQoB;EACI,gBAAA;ADNxB;ACUgB;EACI,eAAA;EACA,6BAAA;ADRpB;ACSoB;EACI,eAAA;EACA,eAAA;ADPxB;ACSoB;EACI,eAAA;ADPxB;ACSoB;;;;EAEA,wBAAA;EACA,SAAA;ADLpB;ACSoB;EACI,UAAA;ADPxB;ACSoB;EACI,WAAA;EACA,YAAA;ADPxB;ACSoB;EACI,kBAAA;ADPxB;ACQwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ADN5B;ACQwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ADN5B;ACSoB;EACI,YAAA;EACA,gBAAA;ADPxB;ACWY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ADThB;ACUgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ADRpB;ACSoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ADPxB;ACSoB;EACI,YAAA;ADPxB;ACSoB;EACI,YAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ADPxB;ACaI;EACI,+CAAA;EACA,gBAAA;ADXR;;ACeA;EACI,4BAAA;EACA,WAAA;ADZJ;ACaI;EACI,gBAAA;ADXR;ACaI;EACI,yBAAA;ADXR;;ACcA;;EAGI,wBAAA;ADZJ;;ACcA;EACI,0BAAA;EACA,qBAAA;EACA,2BAAA;ADXJ;;ACaA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;ADVJ;ACYI;EACI;IACI,gCAAA;IACA,UAAA;EDVV;ECYM;IACI,gCAAA;IACA,UAAA;EDVV;AACF;ACYI;EACI,sBAAA;ADVR;ACYI;EACI,cAAA;ADVR;ACYI;EACI,yBAAA;ADVR;ACYI;EACI,gBAAA;ADVR;ACWQ;EACI,aAAA;EACA,kBAAA;ADTZ;ACYI;EACI,iBAAA;EACA,YAAA;ADVR;ACWQ;EACI,YAAA;ADTZ;ACYI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ADVR;ACWQ;EACI,iBAAA;ADTZ;ACWQ;EACI,gBAAA;ADTZ;ACWQ;EACI,gBAAA;ADTZ;ACWQ;EACI,aAAA;EACA,sBAAA;ADTZ;ACUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ADRhB;ACUY;EACI,YAAA;ADRhB;ACYI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ADVR;;ACeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ADZR;ACaQ;EACI,aAAA;EACA,gBAAA;ADXZ;ACaQ;EACI,gBAAA;ADXZ;ACaQ;EACI,sBAAA;ADXZ;ACaQ;EACI,uBAAA;ADXZ;ACYY;EACI,uBAAA;ADVhB;ACcY;EACI,yBAAA;ADZhB;ACgBY;EACI,gBAAA;ADdhB;ACgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ADdhB;ACgBY;EACI,eAAA;ADdhB;ACegB;EACI,eAAA;EACA,gBAAA;ADbpB;ACegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ADbpB","file":"pricereview.css"} \ No newline at end of file diff --git a/wms/cont/css/pricereview.scss b/wms/cont/css/pricereview.scss index 07a63973..7812e8e5 100644 --- a/wms/cont/css/pricereview.scss +++ b/wms/cont/css/pricereview.scss @@ -1,4 +1,5 @@ #pricereviewCreate{ + input[type='text'], input[type='number'], select{ margin: 1px; } @@ -175,6 +176,10 @@ } } } + .dark{ + background-color: rgba(225,225,225,1) !important; + font-weight: 600; + } } .container-fluid, .container{ diff --git a/wms/cont/js/pricereviewAlpine.js b/wms/cont/js/pricereviewAlpine.js index 6c21d29d..fe3df137 100644 --- a/wms/cont/js/pricereviewAlpine.js +++ b/wms/cont/js/pricereviewAlpine.js @@ -3,5 +3,116 @@ const pricereviewCreate = ()=>{ init(){ console.log(123); }, + modalShow:{ + elevator: false, + }, + total_spec:0, + elevators:[], + modalElevatorInfo:{ + spec:'', + person:'', + weight:'', + stop:'', + speed:'', + permitNumber:'', //許可證號碼 + brand:'', //品牌 + m1:0, //贈送M1 + months:12, //保養月數(月) + cycle:'EM', // 保養週期 + checkYear:'', //竣工檢查年度 + lastDate:'', // 上次年檢日期 + yearCheckFee:'', //年檢費用 + price:'', //公司發布價(月) + qty:'', //電梯數量 + sale_price:'', //契約報價 + }, + openCreateElevatorModal(){ + this.modalShow.elevator = true; + body.style.overflow = 'hidden'; + }, + hideCreateElevatorModal(){ + this.modalShow.elevator = false; + body.style.overflow = 'auto'; + this.modalElevatorInfo = { + spec:'', + person:'', + weight:'', + stop:'', + speed:'', + permitNumber:'', + brand:'', + m1:0, + months:'', + cycle:'', + checkYear:'', + lastDate:'', + yearCheckFee:'', + price:'', + qty:'', + sale_price:'', + }; + }, + createElevatorFn(){ + this.total_spec ++; + this.elevators.push({ + id: this.total_spec, + spec: this.modalElevatorInfo.spec, + person: this.modalElevatorInfo.person, + weight: this.modalElevatorInfo.weight, + stop: this.modalElevatorInfo.stop, + speed: this.modalElevatorInfo.speed, + permitNumber: this.modalElevatorInfo.permitNumber, + brand: this.modalElevatorInfo.brand, + m1: this.modalElevatorInfo.m1, + months: this.modalElevatorInfo.months, + cycle: this.modalElevatorInfo.cycle, + checkYear: this.modalElevatorInfo.checkYear, + lastDate: this.modalElevatorInfo.lastDate, + yearCheckFee: this.modalElevatorInfo.yearCheckFee, + price: this.modalElevatorInfo.price, + qty: this.modalElevatorInfo.qty, + sale_price: this.modalElevatorInfo.sale_price + }) + this.hideCreateElevatorModal(); + }, + copyElevator(idx){ + const spec = this.elevators[idx].spec; + const person = this.elevators[idx].person; + const stop = this.elevators[idx].stop; + const weight = this.elevators[idx].weight + const speed = this.elevators[idx].speed; + const permitNumber = this.elevators[idx].permitNumber; + const brand = this.elevators[idx].brand; + const m1 = this.elevators[idx].m1; + const months = this.elevators[idx].months; + const cycle = this.elevators[idx].cycle; + const checkYear = this.elevators[idx].checkYear; + const lastDate = this.elevators[idx].lastDate; + const yearCheckFee = this.elevators[idx].yearCheckFee; + const price = this.elevators[idx].price; + const qty = this.elevators[idx].qty; + const sale_price = this.elevators[idx].sale_price; + + this.total_spec ++; + this.elevators.push({ + id: this.total_spec, + spec: spec, + person: person, + stop: stop, + weight:weight, + speed: speed, + permitNumber: permitNumber, + brand: brand, + m1: m1, + months: months, + cycle: cycle, + checkYear: checkYear, + lastDate: lastDate, + yearCheckFee: yearCheckFee, + price: price, + qty: qty, + sale_price: sale_price + }) + }, } } \ No newline at end of file diff --git a/wms/cont/pricereviewCreate.php b/wms/cont/pricereviewCreate.php index 1ac0efbe..cd65c763 100644 --- a/wms/cont/pricereviewCreate.php +++ b/wms/cont/pricereviewCreate.php @@ -9,6 +9,172 @@ require_once "../mkt/conn.php";
+
+ +
+
@@ -101,7 +267,7 @@ require_once "../mkt/conn.php"; + +
- +
+
+
+ + + + +
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/wms/mkt/api/postNewElevatorPricereview.php b/wms/mkt/api/postNewElevatorPricereview.php index 841f53d6..911647f8 100644 --- a/wms/mkt/api/postNewElevatorPricereview.php +++ b/wms/mkt/api/postNewElevatorPricereview.php @@ -30,6 +30,8 @@ $attatch2_src = null; $token = $_POST['token']; $form_key = $_POST['form_key']; +$updated_at = date("Y-m-d H:i:s"); +$updated_by = $_POST['user_id']; $elevators = json_decode($_POST['elevators'], true); $options = json_decode($_POST['options'], true); $otherOptions = json_decode($_POST['otherOptions'], true); @@ -63,8 +65,6 @@ if(!empty($attatch1)){ $path = './pricereview-uploads/'; $attatch1_src = $path.$imgsrc; if (!file_exists($path)) { mkdir($path); } - - if ($error == 0) { $ext = pathinfo($file_name, PATHINFO_EXTENSION); if (!in_array($ext, $allow_ext)) { @@ -155,7 +155,6 @@ try{ $stmt->bindParam(':status', $status); $stmt->bindParam(':attatch1', $attatch1_src); $stmt->bindParam(':attatch2', $attatch2_src); - $stmt->execute(); //整機單價 diff --git a/wms/mkt/api/postPricereviewSign.php b/wms/mkt/api/postPricereviewSign.php index dfe15b01..a6981dcf 100644 --- a/wms/mkt/api/postPricereviewSign.php +++ b/wms/mkt/api/postPricereviewSign.php @@ -31,11 +31,21 @@ try{ $stmt->bindParam(':sign_id', $sign_id); $stmt->execute(); - $sql_str = "UPDATE pricereview_main SET status=:status WHERE id = :id "; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(':status', $result); - $stmt->bindParam(':id', $mid); - $stmt->execute(); + if($sign == 3){ + $sql_str = "UPDATE pricereview_main SET status=:status, updated_at=:updated_at WHERE id = :id "; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':status', $result); + $stmt->bindParam(':id', $mid); + $stmt->bindParam(':updated_at', $updated_at); + $stmt->execute(); + }else{ + $sql_str = "UPDATE pricereview_main SET status=:status WHERE id = :id "; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':status', $result); + $stmt->bindParam(':id', $mid); + $stmt->execute(); + } + include_once "./postSystemNotice.php"; $sql_str = "SELECT * FROM pricereview_main WHERE id = :id ORDER BY id DESC LIMIT 1"; diff --git a/wms/mkt/pricereview-index.php b/wms/mkt/pricereview-index.php index 2e046d1e..1026efe8 100644 --- a/wms/mkt/pricereview-index.php +++ b/wms/mkt/pricereview-index.php @@ -392,13 +392,15 @@ if ($data) : 總經理 狀態 合約書申請 + + 送審時間 + ">下載 + + + + + diff --git a/wms/mkt/pricereviewCreate.php b/wms/mkt/pricereviewCreate.php index 921de714..f9c6ba6f 100644 --- a/wms/mkt/pricereviewCreate.php +++ b/wms/mkt/pricereviewCreate.php @@ -49,12 +49,11 @@ $hope_status = [ $sql_str = "SELECT hope_elevator_customer.*, code.content AS source_content, account.name AS salesman_name FROM hope_elevator_customer LEFT JOIN code ON code.code_name = hope_elevator_customer.source LEFT JOIN account ON account.accountid = hope_elevator_customer.salesman - WHERE hope_elevator_customer.vol_no = :vol_no AND code.field_name = 'customer_source'"; + WHERE hope_elevator_customer.vol_no = :vol_no "; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':vol_no', $vol_no); $stmt->execute(); $hope_customer = $stmt->fetch(PDO::FETCH_ASSOC); - if($user_id !== $hope_customer['salesman'] && $user_id !== "M0174"){ echo ""; exit; From c9db9f89f12ab4766cfa40bacad553a97b7be2f2 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 5 Mar 2024 19:28:00 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E6=96=B0=E6=A2=AF=E3=80=81=E4=BF=9D?= =?UTF-8?q?=E9=A4=8A=E5=90=88=E7=B4=84=E7=B0=BD=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/T8_Authorization_from_bpm.php | 20 +- .../elevator_new_deal_bonus_v1_0.php | 59 +- .../elevator_new_deal_bonus_v2_0.php | 3 +- wms/contract/api/T8api.php | 9 +- wms/contract/api/getFacilityNo.php | 31 +- wms/contract/api/getT8NewContractData.php | 62 ++ wms/contract/api/postContractData.php | 43 +- wms/contract/api/postNewContractData.php | 874 +++++++++--------- wms/contract/api/test copy.json | 363 +------- wms/contract/api/testT8API.php | 53 +- wms/contract/conn.php | 6 +- wms/contract/contract-newelevator-input.php | 2 +- wms/contract/js/alpine.js | 11 +- 13 files changed, 667 insertions(+), 869 deletions(-) create mode 100644 wms/contract/api/getT8NewContractData.php diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php index 7d2ca5a8..42c4f3bd 100644 --- a/wms/T8_Authorization_from_bpm.php +++ b/wms/T8_Authorization_from_bpm.php @@ -1,12 +1,7 @@ "營銷人員銷售獎金-訂金段", #獎金名稱 "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.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php index 15f87514..82ea4798 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 @@ -10,7 +10,7 @@ 區域經理員工號($region_manger_id) 【2.函數中的變數說明】 -銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price) +// 銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price) 營業員獎金($sales_bonus) 區域經理提成獎金($region_manager_bonus) 獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款) @@ -39,6 +39,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele { $bonus_array = []; if ($ver == "2.0") { + $elevator_knockdown_price = round($elevator_knockdown_price / 1.05); //不含稅 $discount = round($elevator_knockdown_price / $elevator_list_price, 3); #銷售點數,取到小數點第三位。 #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) diff --git a/wms/contract/api/T8api.php b/wms/contract/api/T8api.php index 245a318d..88d8dffa 100644 --- a/wms/contract/api/T8api.php +++ b/wms/contract/api/T8api.php @@ -6,12 +6,13 @@ 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, JSON_UNESCAPED_UNICODE));
-    // echo '
'; + echo '
';
+    print_r($validation);
+    echo '
'; + // exit; $header = [ "CHI_Authorization :" . $validation, - "GroupId:TEST" + "GroupId:MASADA" ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL diff --git a/wms/contract/api/getFacilityNo.php b/wms/contract/api/getFacilityNo.php index 55df3c57..b4d0928f 100644 --- a/wms/contract/api/getFacilityNo.php +++ b/wms/contract/api/getFacilityNo.php @@ -378,16 +378,31 @@ class CreateFacilityNo * @param string|array $facility_no * @return boolean $status : true:沒重複 false:重複 */ + function checkFacilityRepeatStatus($facility_no) { + // worksite wipwholestatus + // 檢查 substring 後五碼 if (gettype($facility_no) == "string") { $pdo = $this->connectionDB(); $pdo->exec('SET CHARACTER SET utf8mb4'); - $sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); + $sth = $pdo->prepare('SELECT * FROM `worksite` WHERE `facilityno` = ?'); $sth->bindValue(1, $facility_no); $sth->execute(); - if ($sth->rowCount() == 0) + if ($sth->rowCount() == 0) { + return true; + } + $facility_no = substr($facility_no, -5); + echo $facility_no; + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare("SELECT * FROM `wipwholestatus` WHERE `facilityno` LIKE '%?'"); + $sth->bindValue(1, '%' . $facility_no . '%'); + $sth->execute(); + if ($sth->rowCount() == 0) { return true; + } + return false; } if (gettype($facility_no) == "array") { @@ -395,11 +410,21 @@ class CreateFacilityNo $pdo->exec('SET CHARACTER SET utf8mb4'); $status = true; foreach ($facility_no as $row) { - $sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); + $sth = $pdo->prepare('SELECT * FROM `worksite` WHERE `facilityno` = ?'); $sth->bindValue(1, $row); $sth->execute(); if ($sth->rowCount() !== 0) $status = false; + + $row = substr($row, -5); + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare("SELECT * FROM `wipwholestatus` WHERE `facilityno` LIKE ?"); + $sth->bindValue(1, '%' . $row . '%'); + $sth->execute(); + if ($sth->rowCount() != 0) { + $status = false; + } } return $status; } diff --git a/wms/contract/api/getT8NewContractData.php b/wms/contract/api/getT8NewContractData.php new file mode 100644 index 00000000..2d348558 --- /dev/null +++ b/wms/contract/api/getT8NewContractData.php @@ -0,0 +1,62 @@ +prepare($sql); +$stmt->execute(); +$result = $stmt->fetchAll(PDO::FETCH_ASSOC); +// echo "
";
+// print_r($result);
+// echo "
"; +// exit(); +$result_detail = []; +$result_master = []; +$result_arr = []; +foreach ($result as $key => $result) { + $no = $result['BillNo']; + $result_master['BillNo'] = $no; + $firstChar = substr($no, 0, 1); + if ($firstChar == 'M' && $key <= 100) { + $sql = "SELECT BizPartnerName FROM comBusinessPartner WHERE BizPartnerId = '$no' "; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $customer_name = $stmt->fetch(PDO::FETCH_ASSOC); + // $result_master[] = $result; + $sql = "SELECT + BillNo, -- 合約號 + PayStage, -- 收款階段 + PlanPercentage, -- 收款比例 + PlanPayAmt -- 收款金額 + FROM salOrderStagePay WHERE BillNo = '$no'"; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $Detail = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!empty($Detail)) { + foreach ($Detail as $key => $detail) { + $detail['PlanPercentage'] = (float)$detail['PlanPercentage']; + $Detail[$key]['PlanPercentage'] = $detail['PlanPercentage']; // 比例轉小數第二位 + $Detail[$key]['PlanPayAmt'] = intval($detail['PlanPayAmt']); // 比例金額轉整數 + + } + + if (mb_substr($Detail[0]['PayStage'], 0, 2) == '寶佳') { + $result_master['customer_status'] = 'strategy_customer'; + } else if (!empty($customer_name) && mb_substr($customer_name['BizPartnerName'], 0, 1) == '【') { + $result_master['customer_status'] = 'strategy_customer'; + } else { + $result_master['customer_status'] = 'general_customer'; + } + + $result_master['total_price'] = intval($result['OAmount']); + $result_master['detail'] = $Detail; + $result_arr[] = $result_master; + } + } +} + +echo "
";
+print_r($result_arr);
+echo "
"; diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 243b9ad3..26b97cb7 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,3 +1,5 @@ + + makeBFacilityNo("T", $facility_arr, (int)$num); + echo json_encode($facilityno); + T8insert($_POST, $facilityno, $depId, $connT8); // if ($user_id == 'M0225') { // echo '
';
         //     print_r($facilityno);
         //     echo '
'; // exit(); // } - echo json_encode($facilityno); $fail_arr = []; if ($contractno === '') return $fail_arr[] = '合約號為必填'; if ($total_price == '') $fail_arr[] = '合約總價為必填'; @@ -100,10 +103,9 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - T8insert($_POST, $facilityno, $depId); /// 獎金計算 $aaa = bonusCreate($_POST, $facilityno, $conn); - if ($aaa['status'] == 2) { + if (!empty($aaa) && $aaa['status'] == 2) { header("HTTP/1.1 422 Unprocessable Entity"); echo $aaa['data']; exit(); @@ -387,12 +389,13 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c } }; -function T8insert($data, $facilityno, $depId) +function T8insert($data, $facilityno, $depId, $connT8) { - require_once("../connt8.php"); + // require_once("../conn.php"); // 引入 T8 API 連線 require_once("./T8api.php"); + $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 $customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱 @@ -414,7 +417,7 @@ function T8insert($data, $facilityno, $depId) $connT8->beginTransaction(); $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; - $stmt = $conn->prepare($sql); + $stmt = $connT8->prepare($sql); $stmt->bindParam(':BizPartnerId', $contractno); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); @@ -428,6 +431,7 @@ function T8insert($data, $facilityno, $depId) echo 'Error'; exit; } + if (empty($result)) { // 若 客戶資料為空,新增一筆到 comCustomer // 新增客戶資料 @@ -589,25 +593,6 @@ function T8insert($data, $facilityno, $depId) $row++; // 計算分期款的收款月份 $paymonth = $i * $IncomeId[$payType]; - // switch($IncomeId[$payType]): - // case (1): - // $paymonth = $i * $IncomeId[$payType]; - // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth years")); - // break; - // case (2): - // $paymonth = $i * $IncomeId[$payType]; - // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); - // break; - // case (12): - // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); - // break; - // case (6): - // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); - // break; - // case (2): - // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); - // break; - $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); $payDay = str_replace('-', '', $countDay); $rows_data = [ @@ -666,10 +651,10 @@ function T8insert($data, $facilityno, $depId) $API_body[] = $salIncomeApplyMaster; $API_body[] = $salIncomeApplyDetail; // 呼叫 API - // echo '
';
-    // print_r($API_body);
-    // echo '
'; - $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; + echo '
';
+    print_r($API_body);
+    echo '
'; + $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; $result = T8salIncomeApply($API_body, $api_url); if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index 6fd5756c..359cbbb0 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -16,76 +16,77 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST') { } //新梯簽回 if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'm') { - try { - $created_at = date('Y-m-d H:i:s'); - $created_by = $_POST["user_id"]; - $contractno = $_POST["contractno"]; - $customer = $_POST["customer"]; - $manager = $_POST["manager"]; - $vat = $_POST["vat"]; - $case_name = $_POST["case_name"]; - $linkman = $_POST["linkman"]; - $lm_tel = $_POST["lm_tel"]; - $address = $_POST["address"]; - $salesman = $_POST["salesman"]; - $qc = $_POST["qc"]; - $contracttype = $_POST["contracttype"]; - $elevators_nums = $_POST['nums']; - $area_no = $_POST['area_no']; - $elevators = json_decode($_POST['elevators'], JSON_UNESCAPED_UNICODE); - $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], JSON_UNESCAPED_UNICODE); - // echo "
";
-    // print_r($elevators_detail_arr);
-    // echo "
"; - // exit(); - $files = !empty($_FILES['files']) ? $_FILES['files'] : null; - $files_id = null; - - $fail_arr = []; - // if (empty($contractno)) $fail_arr[] = '合約號為必填'; - // if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; - // if (empty($manager)) $fail_arr[] = '負責人為必填'; - // if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; - // if (empty($case_name)) $fail_arr[] = '案名為必填'; - // if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; - // if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; - // if (empty($address)) $fail_arr[] = '地址為必填'; - // if (empty($salesman)) $fail_arr[] = '營業員為必填'; - // if (empty($qc)) $fail_arr[] = '請選擇QC或官檢'; - // if (count($fail_arr) > 0) { - // header("HTTP/1.1 422 Unprocessable Entity"); - // echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); - // exit(); - // } - //create facility table - $createFacilityNo = new CreateFacilityNo(); - $dailyNecessities = [ - 'MAE100' => 'X', //小機房客梯 - 'MAM200' => 'W', //無機房客梯 - 'MAH100' => 'H', //小電梯 - 'MAQ100' => 'Z', //強趨梯 - 'MAF100' => 'F', //貨梯 - 'MAP100' => '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 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(); - } - T8Insert($_POST, $facilityno, $connT8); + $created_at = date('Y-m-d H:i:s'); + $created_by = $_POST["user_id"]; + $contractno = $_POST["contractno"]; + $customer = $_POST["customer"]; + $manager = $_POST["manager"]; + $vat = $_POST["vat"]; + $case_name = $_POST["case_name"]; + $linkman = $_POST["linkman"]; + $lm_tel = $_POST["lm_tel"]; + $address = $_POST["address"]; + $salesman = $_POST["salesman"]; + $contracttype = $_POST["contracttype"]; + $elevators_nums = $_POST['nums']; + $area_no = $_POST['area_no']; + $elevators = json_decode($_POST['elevators'], JSON_UNESCAPED_UNICODE); + $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], JSON_UNESCAPED_UNICODE); + // echo "
";
+  // print_r($elevators_detail_arr);
+  // echo "
"; + // exit(); + $files = !empty($_FILES['files']) ? $_FILES['files'] : null; + $files_id = null; + + $fail_arr = []; + if (empty($contractno)) $fail_arr[] = '合約號為必填'; + if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; + if (empty($manager)) $fail_arr[] = '負責人為必填'; + // if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; + if (empty($case_name)) $fail_arr[] = '案名為必填'; + if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; + if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; + if (empty($address)) $fail_arr[] = '地址為必填'; + if (empty($salesman)) $fail_arr[] = '營業員為必填'; + // if (empty($elevators_detail_arr['qc'])) $fail_arr[] = '請選擇QC或官檢'; + if (count($fail_arr) > 0) { + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); exit(); + } + //create facility table + $createFacilityNo = new CreateFacilityNo(); + $dailyNecessities = [ + 'MAE100' => 'X', //小機房客梯 + 'MAM200' => 'W', //無機房客梯 + 'MAH100' => 'H', //小電梯 + 'MAQ100' => 'Z', //強趨梯 + 'MAF100' => 'F', //貨梯 + 'MAP100' => '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 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(); + // } + + T8Insert($_POST, $facilityno, $connT8); + // exit(); + try { $conn->beginTransaction(); //create account table @@ -122,8 +123,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $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)"; + (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,desin_spec_verify) 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,1)"; // $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')"; @@ -153,6 +154,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c // echo "
";
       // print_r($lastId);
       // echo "
"; + // exit; if (!empty($lastId)) { echo '123'; // 寫入待簽程狀態 A (營業) @@ -180,111 +182,112 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $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); - $stmt->execute(); - $saleman = $stmt->fetch(PDO::FETCH_ASSOC); - $salesman_name = $saleman['name']; - if (!empty($files)) { - $englisharr = range('a', 'z'); - $files = $_FILES['files']; - $newfiles = []; - foreach ($files as $file) { - $i = 0; //新陣列的索引編號 - foreach ($file as $key => $val) { - $newfiles[$i]['name'] = $files['name'][$key]; - $newfiles[$i]['type'] = $files['type'][$key]; - $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; - $newfiles[$i]['error'] = $files['error'][$key]; - $newfiles[$i]['size'] = $files['size'][$key]; - $i++; - } //foreach 第2層 end - } - $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) - $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 - $path = '../images/contracts/'; - if (!file_exists($path)) { - mkdir($path); - } - $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 - $datetime = (string)date('YmdHis'); - $files_id = 'm' . $datetime; // 保養=>b + 日期時間 - foreach ($newfiles as $key => $file) { - $randNum = rand(1000, 9999); - $randEnglish = $englisharr[rand(0, 25)]; - $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; - $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); - if ($msg == 1) { - $msg = '檔案傳送成功!'; - $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(':files_id', $files_id); - $stmt->bindParam(':file_name', $file_name); - $stmt->bindParam(':file_mime', $file['type']); - $stmt->bindParam(':file_size', $file['size']); - $stmt->bindParam(':created_at', $created_at); - $stmt->bindParam(':created_by', $created_by); - $stmt->execute(); - } else { - throw new PDOException('檔案上傳失敗:' . $msg); + // $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); + $stmt->execute(); + $saleman = $stmt->fetch(PDO::FETCH_ASSOC); + $salesman_name = $saleman['name']; + if (!empty($files)) { + $englisharr = range('a', 'z'); + $files = $_FILES['files']; + $newfiles = []; + foreach ($files as $file) { + $i = 0; //新陣列的索引編號 + foreach ($file as $key => $val) { + $newfiles[$i]['name'] = $files['name'][$key]; + $newfiles[$i]['type'] = $files['type'][$key]; + $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; + $newfiles[$i]['error'] = $files['error'][$key]; + $newfiles[$i]['size'] = $files['size'][$key]; + $i++; + } //foreach 第2層 end } - $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
'; - $src_name = $path . $file['name']; - if (file_exists($src_name)) { - //副檔名 - $extname = pathinfo($src_name, PATHINFO_EXTENSION); - //主檔名 - $basename = basename($src_name, '.' . $extname); + $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) + $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 + $path = '../images/contracts/'; + if (!file_exists($path)) { + mkdir($path); + } + $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 + $datetime = (string)date('YmdHis'); + $files_id = 'm' . $datetime; // 保養=>b + 日期時間 + foreach ($newfiles as $key => $file) { + $randNum = rand(1000, 9999); + $randEnglish = $englisharr[rand(0, 25)]; + $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; + $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); + if ($msg == 1) { + $msg = '檔案傳送成功!'; + $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':files_id', $files_id); + $stmt->bindParam(':file_name', $file_name); + $stmt->bindParam(':file_mime', $file['type']); + $stmt->bindParam(':file_size', $file['size']); + $stmt->bindParam(':created_at', $created_at); + $stmt->bindParam(':created_by', $created_by); + $stmt->execute(); + } else { + throw new PDOException('檔案上傳失敗:' . $msg); + } + $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
'; + $src_name = $path . $file['name']; + if (file_exists($src_name)) { + //副檔名 + $extname = pathinfo($src_name, PATHINFO_EXTENSION); + //主檔名 + $basename = basename($src_name, '.' . $extname); + } } + } else { + $files = null; } - } else { - $files = null; - } - $sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)"; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(":contract_no", $contractno); - $stmt->bindParam(":customer", $customer); - $stmt->bindParam(":manager", $manager); - $stmt->bindParam(":vat", $vat); - $stmt->bindParam(":case_name", $case_name); - $stmt->bindParam(":linkman", $linkman); - $stmt->bindParam(":lm_tel", $lm_tel); - $stmt->bindParam(":address", $address); - $stmt->bindParam(":salesman", $salesman); - $stmt->bindParam(":salesman_name", $salesman_name); - $stmt->bindParam(":files_id", $files_id); - $stmt->bindParam(":created_at", $created_at); - $stmt->bindParam(":created_by", $created_by); - $stmt->bindParam(":qc", $qc); - $stmt->execute(); + $sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(":contract_no", $contractno); + $stmt->bindParam(":customer", $customer); + $stmt->bindParam(":manager", $manager); + $stmt->bindParam(":vat", $vat); + $stmt->bindParam(":case_name", $case_name); + $stmt->bindParam(":linkman", $linkman); + $stmt->bindParam(":lm_tel", $lm_tel); + $stmt->bindParam(":address", $address); + $stmt->bindParam(":salesman", $salesman); + $stmt->bindParam(":salesman_name", $salesman_name); + $stmt->bindParam(":files_id", $files_id); + $stmt->bindParam(":created_at", $created_at); + $stmt->bindParam(":created_by", $created_by); + // $stmt->bindParam(":qc", $qc); + $stmt->execute(); - $result = $conn->commit(); - if ($result) { - header("HTTP/1.1 201 Created"); + $result = $conn->commit(); + if ($result) { + header("HTTP/1.1 201 Created"); + } } } catch (PDOException $e) { $conn->rollback(); @@ -295,109 +298,110 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c function T8Insert($data, $facilityno, $connT8) { - try { - // 引入銷售訂單 API - require_once("./T8API.php"); - - $contractno = $data['contractno']; - $partyA = $data['customer']; - $phone = $data['lm_tel']; - $vat = $data['vat']; - $partyAaddress = $data['address']; - $user_id = $data['user_id']; - $salesman = $data['salesman']; - $createAt = date("Y-m-dH-i-s"); - - - $elevators = !empty($data['elevators_detail_arr']) ? json_decode($data['elevators_detail_arr'], true) : []; //電梯 - $pay_arr = !empty($data['pay_arr']) ? json_decode($data['pay_arr'], true) : []; //電梯 - - $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' => '二次款', - '3' => '貨抵工地', - '4' => '材料其他', - '5' => '試車完工', //安裝完畢 - '6' => '交車' //交車 - ]; - - $sql = "SELECT * FROM comCustomer + // try { + // 引入銷售訂單 API + require_once("./T8API.php"); + + $contractno = $data['contractno']; + $partyA = $data['customer']; + $phone = $data['lm_tel']; + $vat = $data['vat']; + $partyAaddress = $data['address']; + $user_id = $data['user_id']; + $salesman = $data['salesman']; + $createAt = date("Y-m-dH-i-s"); + + + $elevators = !empty($data['elevators_detail_arr']) ? json_decode($data['elevators_detail_arr'], true) : []; //電梯 + $pay_arr = !empty($data['pay_arr']) ? json_decode($data['pay_arr'], true) : []; //電梯 + + $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' => '二次款', + '3' => '貨抵工地', + '4' => '材料其他', + '5' => '試車完工', //安裝完畢 + '6' => '交車' //交車 + ]; + + $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); - $result = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + + // 新增客戶 table + if (empty($result)) { + // 若 客戶資料為空,新增一筆到 comCustomer + // 新增客戶資料 - // 新增客戶 table - if (empty($result)) { - // 若 客戶資料為空,新增一筆到 comCustomer - // 新增客戶資料 - $sql = "INSERT INTO comBusinessPartner + $sql = "INSERT INTO comBusinessPartner (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:CreatorId,:CreateTime,'10')"; - // $sql = "INSERT INTO comBusinessPartner - // (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) - // VALUES('$contractno','$partyA',1,'TW','$phone',99999999,'$vat', '$partyA','$partyAaddress','$user_id',$createTime,'10')"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->bindParam(':BizPartnerName', $partyA); //客戶名稱 - $stmt->bindParam(':WorkTelNo', $phone); - $stmt->bindParam(':TaxNo', $vat); - $stmt->bindParam(':EnterpriseName', $partyA); //企業名稱 - $stmt->bindParam(':ContactAddress', $partyAaddress); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); - + // $sql = "INSERT INTO comBusinessPartner + // (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) + // VALUES('$contractno','$partyA',1,'TW','$phone',99999999,'$vat', '$partyA','$partyAaddress','$user_id',$createTime,'10')"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':BizPartnerName', $partyA); //客戶名稱 + $stmt->bindParam(':WorkTelNo', $phone); + $stmt->bindParam(':TaxNo', $vat); + $stmt->bindParam(':EnterpriseName', $partyA); //企業名稱 + $stmt->bindParam(':ContactAddress', $partyAaddress); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); - $sql = "INSERT INTO comCustomer - (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')"; - $stmt = $connT8->prepare($sql); + $sql = "INSERT INTO comCustomer + (OrgId,BizPartnerTypeId,ConditionId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId)VALUES + ('1000','10','0008','TWD',: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')"; + $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->bindParam(':PersonId', $salesman); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':InvoiceAddress', $partyAaddress); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); - } else { - // // 若客戶資料不為空,更新該客戶資訊。 - $sql = "UPDATE comCustomer SET + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':InvoiceAddress', $partyAaddress); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + } else { + // 若客戶資料不為空,更新該客戶資訊。 + $sql = "UPDATE comCustomer SET PersonId=:PersonId, ConditionId='0008', + CurrId='TWD', InvoiceAddress=:InvoiceAddress, LastOperatorId=:LastOperatorId, LastOperateTime=:LastOperateTime WHERE BizPartnerId=:BizPartnerId "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':PersonId', $salesman); - $stmt->bindParam(':InvoiceAddress', $partyAaddress); - $stmt->bindParam(':LastOperatorId', $user_id); - $stmt->bindParam(':LastOperateTime', $createTime); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':InvoiceAddress', $partyAaddress); + $stmt->bindParam(':LastOperatorId', $user_id); + $stmt->bindParam(':LastOperateTime', $createTime); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); - $sql = "UPDATE comBusinessPartner SET + $sql = "UPDATE comBusinessPartner SET BizPartnerName=:BizPartnerName, WorkTelNo=:WorkTelNo, TaxNo=:TaxNo, @@ -407,47 +411,54 @@ function T8Insert($data, $facilityno, $connT8) LastOperateTime=:LastOperateTime WHERE BizPartnerId = :BizPartnerId "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerName', $partyA); - $stmt->bindParam(':WorkTelNo', $phone); - $stmt->bindParam(':TaxNo', $vat); - $stmt->bindParam(':EnterpriseName', $partyA); - $stmt->bindParam(':ContactAddress', $partyAaddress); - // $stmt->bindParam(':EMail', $email); - $stmt->bindParam(':LastOperatorId', $user_id); - $stmt->bindParam(':LastOperateTime', $createTime); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); - } + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerName', $partyA); + $stmt->bindParam(':WorkTelNo', $phone); + $stmt->bindParam(':TaxNo', $vat); + $stmt->bindParam(':EnterpriseName', $partyA); + $stmt->bindParam(':ContactAddress', $partyAaddress); + // $stmt->bindParam(':EMail', $email); + $stmt->bindParam(':LastOperatorId', $user_id); + $stmt->bindParam(':LastOperateTime', $createTime); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); + } - $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; + $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':ProjectId', $contractno); + $stmt->execute(); + $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (empty($resultProject)) { + //新增於 comProject。合約 table + $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,CreateTime,CreatorId,IsInUsed) + VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)"; $stmt = $connT8->prepare($sql); $stmt->bindParam(':ProjectId', $contractno); + $stmt->bindParam(':ProjectName', $partyA); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->bindParam(':CreatorId', $user_id); $stmt->execute(); - $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (empty($resultProject)) { - //新增於 comProject。合約 table - $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,CreateTime,CreatorId,IsInUsed) - VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)"; + } + $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 = "SELECT * FROM comMaterial WHERE MaterialId = '$facility_no'"; $stmt = $connT8->prepare($sql); - $stmt->bindParam(':ProjectId', $contractno); - $stmt->bindParam(':ProjectName', $partyA); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->bindParam(':CreatorId', $user_id); $stmt->execute(); - } - $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']; - + $MaterialisIt = $stmt->fetch(PDO::FETCH_ASSOC); + if (empty($MaterialisIt)) { $sql = "INSERT INTO comMaterial (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime,IsInUsed) VALUES ('1000',:MaterialId,'10','A',:CreatorId,:CreateTime,1)"; @@ -456,7 +467,6 @@ function T8Insert($data, $facilityno, $connT8) $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreateTime', $createTime); $stmt->execute(); - $sql = "INSERT INTO comMaterialGroup (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime) VALUES ('10',:MaterialId,:MaterialName,'A',1,'SET',:CreatorId,:CreateTime)"; @@ -495,155 +505,159 @@ function T8Insert($data, $facilityno, $connT8) $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')); - } + } + // 階段收款資訊 + $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; } - // 設備 - $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 - ]; - $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 // 歸屬作番號 + $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'] //未核銷金額 ]; - $count++; - $SubOrder_row[] = $row1; - $SubOrder_row[] = $row2; - $SubOrder_row[] = $row3; - $count++; + $salOrderStagePay_row[] = $rows; } - $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" => "", + + // 設備 + $row1 = [ "TaxId" => "ST005", - "CreditorCompId" => "1001", - "CreditorOrgId" => "1000", - "CreatorId" => "$user_id" - // "CompId" => "1001", - // "CreditorCurrOAmount" => 1, - // "CreditorCurrLAmount" => 1 - ]; - $MainSalesOrder = [ - "name" => "MainSalesOrder", - 'rows' => [$MainSalesOrder_row] + "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 ]; - $SubOrder = [ - "name" => "SubOrder", - "rows" => $SubOrder_row + $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 = [ - "name" => "salOrderStagePay", - "rows" => $salOrderStagePay_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, //交易價格 + "CU_MaterialId" => $facility_no // 歸屬作番號 ]; + $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" => "$salesman", //業務人員 + "DueToId" => "$contractno", //債務方 + "TradeConditionId" => "", + "TaxId" => "ST005", + "CreditorCompId" => "1001", + "CreditorOrgId" => "1000", + "CreatorId" => "$user_id" + // "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 "
"; - if ($result['Status'] == 'Fails' || $result['Status'] == 'Error') { - echo $result['ErrorMsg']; - } - } else { - 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"; + // $api_url = "http://127.0.0.1:880/twWebAPI/V1/SALSALESORDER/PostERPData"; + $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALSALESORDER/PostERPData'; + + $result = T8salIncomeApply($API_body, $api_url); + echo "
";
+    print_r($result);
+    echo "
"; + if (!empty($result) && ($result['Status'] == 'Fails' || $result['Status'] == 'Error')) { + echo $result['ErrorMsg']; } - $connT8->commit(); - } catch (PDOException $e) { - $connT8->rollback(); - header("HTTP/1.1 500 Internal Server Error"); - die('Error!:' . $e->getMessage()); + } else { + echo '資料已新增過,請洽資訊人員'; + // exit(); } + $connT8->commit(); + // } catch (PDOException $e) { + // $connT8->rollback(); + // header("HTTP/1.1 500 Internal Server Error"); + // die('Error!:' . $e->getMessage()); + // } } @@ -698,7 +712,6 @@ function BounsCount($data, $conn, $facilityno) '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) { @@ -748,9 +761,6 @@ function BounsCount($data, $conn, $facilityno) $salesman, $manager ); - // echo '
';
-        // print_r($result_bonus);
-        // echo '
'; $facility_no = $facilityno[$key]; $bonus_json = [ 'contract_type' => $type, diff --git a/wms/contract/api/test copy.json b/wms/contract/api/test copy.json index b9dd2f3f..cb1ba7c7 100644 --- a/wms/contract/api/test copy.json +++ b/wms/contract/api/test copy.json @@ -3,18 +3,18 @@ "name": "MainSalesOrder", "rows": [ { - "BillNo": "M23110121", - "BillDate": 20240313, + "BillNo": "M24020076", + "BillDate": 20240320, "TypeId": "SO", "FOrgId": "1000", "OrgId": "1000", "ModeId": "M", - "BizPartnerId": "M23110121", + "BizPartnerId": "M24020076", "CurrId": "TWD", "CurrOAmount": 1, "CurrLAmount": 1, - "PersonId": "M0042", - "DueToId": "M23110121", + "PersonId": "M0073", + "DueToId": "M24020076", "TradeConditionId": "", "TaxId": "ST005", "CreditorCompId": "1001", @@ -28,315 +28,42 @@ "rows": [ { "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", + "RequirementDate": 20240320, + "ConsignmentDate": 20240320, + "BillNo": "M24020076", "RowCode": 1, "ItemType": 1, "MaterialId": "A40001", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00836" + "SPrice": 910000, + "CU_MaterialId": "4MW00001" }, { "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", + "RequirementDate": 20240320, + "ConsignmentDate": 20240320, + "BillNo": "M24020076", "RowCode": 2, "ItemType": 1, "MaterialId": "A40008", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00836" + "SPrice": 390000, + "CU_MaterialId": "4MW00001" }, { "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", + "RequirementDate": 20240320, + "ConsignmentDate": 20240320, + "BillNo": "M24020076", "RowCode": 3, "ItemType": 0, - "MaterialId": "4MH00836", + "MaterialId": "4MW00001", "SUnitId": "SET", "SQuantity": 1, "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" + "CU_MaterialId": "4MW00001" } ] }, @@ -346,52 +73,42 @@ { "PayStage": "簽約", "PlanPercentage": 0.2, - "PlanPayAmt": 976000, - "PlanPayDate": 20240413, - "BillNo": "M23110121", + "PlanPayAmt": 260000, + "PlanPayDate": 20240420, + "BillNo": "M24020076", "RowCode": 1, "RowNo": 1, - "UnWriteOffOAmount": 976000 + "UnWriteOffOAmount": 260000 }, { - "PayStage": "二次款", - "PlanPercentage": 0.4, - "PlanPayAmt": 1952000, - "PlanPayDate": 20240313, - "BillNo": "M23110121", + "PayStage": "貨抵工地", + "PlanPercentage": 0.5, + "PlanPayAmt": 650000, + "PlanPayDate": 20241220, + "BillNo": "M24020076", "RowCode": 2, "RowNo": 2, - "UnWriteOffOAmount": 1952000 + "UnWriteOffOAmount": 650000 }, { - "PayStage": "貨抵工地", + "PayStage": "試車完工", "PlanPercentage": 0.2, - "PlanPayAmt": 976000, - "PlanPayDate": 20241104, - "BillNo": "M23110121", + "PlanPayAmt": 260000, + "PlanPayDate": 20250120, + "BillNo": "M24020076", "RowCode": 3, "RowNo": 3, - "UnWriteOffOAmount": 976000 + "UnWriteOffOAmount": 260000 }, { - "PayStage": "試車完工", + "PayStage": "交車", "PlanPercentage": 0.1, - "PlanPayAmt": 488000, - "PlanPayDate": 20241204, - "BillNo": "M23110121", + "PlanPayAmt": 130000, + "PlanPayDate": 20250220, + "BillNo": "M24020076", "RowCode": 4, "RowNo": 4, - "UnWriteOffOAmount": 488000 - }, - { - "PayStage": "交車", - "PlanPercentage": 0.1, - "PlanPayAmt": 488000, - "PlanPayDate": 20250104, - "BillNo": "M23110121", - "RowCode": 5, - "RowNo": 5, - "UnWriteOffOAmount": 488000 + "UnWriteOffOAmount": 130000 } ] } diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index e9d2f04f..a77acf8b 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -66,34 +66,35 @@ require_once("../../T8_Authorization_from_bpm.php"); $api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; $validation = get_Auth(); -// $header = [ -// "CHI_Authorization :" . $validation, -// "GroupId:TEST" -// ]; -// $url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=M24020032"; +$header = [ + "CHI_Authorization :" . $validation, + "GroupId:MASADA" +]; +$url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=1000,M24020076"; -// $ch = curl_init(); -// curl_setopt($ch, CURLOPT_URL, $url); -// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -// curl_setopt($ch, CURLOPT_HTTPHEADER, $header); -// $response = curl_exec($ch); -// if ($response === false) { -// echo 'Curl error: ' . curl_error($ch); -// } else { -// $result = json_decode($response, true); -// // 若 API 傳入失敗。 -// if ($result['Status'] == 'Erroe') { -// echo 'API傳入失敗,' . $result['ErrorMsg']; -// print_r($result); -// } else { -// // print_r($result); -// print_r($result); -// } -// print_r($result); -// } +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_HTTPHEADER, $header); -// curl_close($ch); -// exit(); +$response = curl_exec($ch); +if ($response === false) { + echo 'Curl error: ' . curl_error($ch); +} else { + $result = json_decode($response, true); + // 若 API 傳入失敗。 + if ($result['Status'] == 'Erroe') { + echo 'API傳入失敗,' . $result['ErrorMsg']; + print_r($result); + } else { + // print_r($result); + print_r($result); + } + print_r($result); +} + +curl_close($ch); +exit(); $contract_no = "M24020003"; // $contract_no = "M24010109"; $MainSalesOrder_row = [ diff --git a/wms/contract/conn.php b/wms/contract/conn.php index ed80762b..bbfd1c50 100644 --- a/wms/contract/conn.php +++ b/wms/contract/conn.php @@ -34,7 +34,11 @@ try { //設定主動以警告的形式報錯 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E="); + // $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E="); + // $connT8 = new PDO("sqlsrv:Server=10.10.145.2;Database=T8MASADA", "masada", "@m222222"); + $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "@m222222"); + + if ($connT8) { $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } diff --git a/wms/contract/contract-newelevator-input.php b/wms/contract/contract-newelevator-input.php index 70d83b32..634dfd3b 100644 --- a/wms/contract/contract-newelevator-input.php +++ b/wms/contract/contract-newelevator-input.php @@ -179,7 +179,7 @@ $persons = array_map(function ($person) { 電梯速度 - + 電梯樓停 diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index 59d63b01..3ebfa73d 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -819,8 +819,6 @@ const contractNewInput = () => { lm_tel: '', address: '', salesman: '', - qc: '', - qc: '', price_total: '', //合約總價 files: [], contract_type: '1', @@ -869,7 +867,7 @@ const contractNewInput = () => { this.data.elevators_detail_arr[i].latitude = ''; // 經度 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].qc = 'QO'; // QC和官檢 this.data.elevators_detail_arr[i].contract_arrival_date = this.data.contract_arrival_date; //合約交期(到工地) // this.data.elevators_detail_arr[i].area_no = ''; //區域 } @@ -901,7 +899,7 @@ const contractNewInput = () => { this.data.lm_tel = res.data.lm_tel this.data.address = res.data.address this.data.salesman = res.data.person - this.data.qc = res.data.qc; + // this.data.qc = res.data.qc; this.data.price_total = res.data.price_total; this.data.elevators = res.data.elevators; this.data.elevators_detail_arr = res.data.elevators_detail_arr; @@ -929,7 +927,6 @@ const contractNewInput = () => { form.append('lm_tel', this.data.lm_tel); form.append('address', this.data.address); form.append('salesman', this.data.salesman); - form.append('qc', this.data.qc); form.append('signing_date', this.data.signing_date); form.append('nums', this.data.nums); form.append('price_total', this.data.price_total); @@ -961,7 +958,7 @@ const contractNewInput = () => { this.customize = false } else { - alert('儲存失敗!可能為以下錯誤:\n' + res.data) + alert('儲存失敗!') } this.isLoading = false }).catch(error => { @@ -1025,7 +1022,7 @@ const contractInput = () => { disabled: false, //資料庫是否有電梯數量資料 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 payType: '', //付款方式 - contract_type: '' + contract_type: 'new' // bonus_verson: 2.1, // manager: '', // regular_contract_manger_id: '', From 00fa59b33b508194ca8ab0774555892257e51615 Mon Sep 17 00:00:00 2001 From: 10994015 Date: Wed, 6 Mar 2024 18:02:32 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=BF=9D=E9=A4=8A=E5=83=B9=E5=AF=A90306?= =?UTF-8?q?=20=E6=96=B0=E6=A2=AF=E5=83=B9=E5=AF=A9for=20=E5=8A=A0key=20?= =?UTF-8?q?=E7=B6=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/cont/css/pricereview.css | 1 - wms/cont/css/pricereview.css.map | 2 +- wms/cont/css/pricereview.scss | 1 - wms/cont/js/pricereviewAlpine.js | 113 ++++- wms/cont/pricereviewCreate.php | 414 ++++++++---------- wms/cont/window-modal/modalElevaotr.php | 179 ++++++++ wms/cont/window-modal/otherOptionModal.php | 33 ++ .../window-modal/otherToElevatorModal.php | 36 ++ wms/crm/crmm02-index.php | 2 +- wms/mkt/assets/js/pricereviewAlpine.js | 25 +- wms/mkt/pricereviewCreate.php | 5 - .../window-modal/demolishToElevatorModal.php | 4 +- wms/mkt/window-modal/elevatorModal.php | 5 - .../window-modal/maintainToElevatorModal.php | 4 +- .../window-modal/optionToElevatorModal.php | 6 +- wms/mkt/window-modal/otherToElevatorModal.php | 4 +- 16 files changed, 571 insertions(+), 263 deletions(-) create mode 100644 wms/cont/window-modal/modalElevaotr.php create mode 100644 wms/cont/window-modal/otherOptionModal.php create mode 100644 wms/cont/window-modal/otherToElevatorModal.php diff --git a/wms/cont/css/pricereview.css b/wms/cont/css/pricereview.css index 3cd7f902..0169e645 100644 --- a/wms/cont/css/pricereview.css +++ b/wms/cont/css/pricereview.css @@ -111,7 +111,6 @@ opacity: 1; } #pricereviewCreate .container .pricreviewmain > .divitem table .copyBtn { - width: 30px; height: 30px; } #pricereviewCreate .container .pricreviewmain > .divitem table .saletd { diff --git a/wms/cont/css/pricereview.css.map b/wms/cont/css/pricereview.css.map index a5d7bedf..dd3f0e70 100644 --- a/wms/cont/css/pricereview.css.map +++ b/wms/cont/css/pricereview.css.map @@ -1 +1 @@ -{"version":3,"sources":["pricereview.css","pricereview.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACEZ;EACI,WAAA;ADAR;ACEI;EACI,gBAAA;ADAR;ACEI;EACI,wBAAA,EAAA,6BAAA;EACA,qBAAA,EAAA,eAAA;EACA,gBAAA,EAAA,SAAA;ADAR;ACEI;EACI,aAAA;ADAR;ACCQ;EACI,sBAAA;ADCZ;ACCQ;EACI,cAAA;ADCZ;ACCQ;EACI,yBAAA;ADCZ;ACKQ;EACI,sBAAA;EACA,YAAA;ADHZ;ACIY;EACI,YAAA;ADFhB;ACOY;EACI,yBAAA;ADLhB;ACQgB;EACI,eAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ADNpB;ACSY;EACI,eAAA;ADPhB;ACUQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ADRZ;ACSY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;ADPhB;ACQgB;EACI,yBAAA;EACA,WAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,WAAA;ADNpB;ACUY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ADRhB;ACSgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ADPpB;ACQoB;EACI,gBAAA;ADNxB;ACUgB;EACI,eAAA;EACA,6BAAA;ADRpB;ACSoB;EACI,eAAA;EACA,eAAA;ADPxB;ACSoB;EACI,eAAA;ADPxB;ACSoB;;;;EAEA,wBAAA;EACA,SAAA;ADLpB;ACSoB;EACI,UAAA;ADPxB;ACSoB;EACI,WAAA;EACA,YAAA;ADPxB;ACSoB;EACI,kBAAA;ADPxB;ACQwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ADN5B;ACQwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ADN5B;ACSoB;EACI,YAAA;EACA,gBAAA;ADPxB;ACWY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ADThB;ACUgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ADRpB;ACSoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ADPxB;ACSoB;EACI,YAAA;ADPxB;ACSoB;EACI,YAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ADPxB;ACaI;EACI,+CAAA;EACA,gBAAA;ADXR;;ACeA;EACI,4BAAA;EACA,WAAA;ADZJ;ACaI;EACI,gBAAA;ADXR;ACaI;EACI,yBAAA;ADXR;;ACcA;;EAGI,wBAAA;ADZJ;;ACcA;EACI,0BAAA;EACA,qBAAA;EACA,2BAAA;ADXJ;;ACaA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;ADVJ;ACYI;EACI;IACI,gCAAA;IACA,UAAA;EDVV;ECYM;IACI,gCAAA;IACA,UAAA;EDVV;AACF;ACYI;EACI,sBAAA;ADVR;ACYI;EACI,cAAA;ADVR;ACYI;EACI,yBAAA;ADVR;ACYI;EACI,gBAAA;ADVR;ACWQ;EACI,aAAA;EACA,kBAAA;ADTZ;ACYI;EACI,iBAAA;EACA,YAAA;ADVR;ACWQ;EACI,YAAA;ADTZ;ACYI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ADVR;ACWQ;EACI,iBAAA;ADTZ;ACWQ;EACI,gBAAA;ADTZ;ACWQ;EACI,gBAAA;ADTZ;ACWQ;EACI,aAAA;EACA,sBAAA;ADTZ;ACUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ADRhB;ACUY;EACI,YAAA;ADRhB;ACYI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ADVR;;ACeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ADZR;ACaQ;EACI,aAAA;EACA,gBAAA;ADXZ;ACaQ;EACI,gBAAA;ADXZ;ACaQ;EACI,sBAAA;ADXZ;ACaQ;EACI,uBAAA;ADXZ;ACYY;EACI,uBAAA;ADVhB;ACcY;EACI,yBAAA;ADZhB;ACgBY;EACI,gBAAA;ADdhB;ACgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ADdhB;ACgBY;EACI,eAAA;ADdhB;ACegB;EACI,eAAA;EACA,gBAAA;ADbpB;ACegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ADbpB","file":"pricereview.css"} \ No newline at end of file +{"version":3,"sources":["pricereview.css","pricereview.scss"],"names":[],"mappings":"AAAA,gBAAgB;ACEZ;EACI,WAAA;ADAR;ACEI;EACI,gBAAA;ADAR;ACEI;EACI,wBAAA,EAAA,6BAAA;EACA,qBAAA,EAAA,eAAA;EACA,gBAAA,EAAA,SAAA;ADAR;ACEI;EACI,aAAA;ADAR;ACCQ;EACI,sBAAA;ADCZ;ACCQ;EACI,cAAA;ADCZ;ACCQ;EACI,yBAAA;ADCZ;ACKQ;EACI,sBAAA;EACA,YAAA;ADHZ;ACIY;EACI,YAAA;ADFhB;ACOY;EACI,yBAAA;ADLhB;ACQgB;EACI,eAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ADNpB;ACSY;EACI,eAAA;ADPhB;ACUQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ADRZ;ACSY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;ADPhB;ACQgB;EACI,yBAAA;EACA,WAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ADNpB;ACQgB;EACI,yBAAA;EACA,WAAA;ADNpB;ACUY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ADRhB;ACSgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ADPpB;ACQoB;EACI,gBAAA;ADNxB;ACUgB;EACI,eAAA;EACA,6BAAA;ADRpB;ACSoB;EACI,eAAA;EACA,eAAA;ADPxB;ACSoB;EACI,eAAA;ADPxB;ACSoB;;;;EAEA,wBAAA;EACA,SAAA;ADLpB;ACSoB;EACI,UAAA;ADPxB;ACSoB;EACI,YAAA;ADPxB;ACSoB;EACI,kBAAA;ADPxB;ACQwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ADN5B;ACQwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ADN5B;ACSoB;EACI,YAAA;EACA,gBAAA;ADPxB;ACWY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ADThB;ACUgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ADRpB;ACSoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ADPxB;ACSoB;EACI,YAAA;ADPxB;ACSoB;EACI,YAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ADPxB;ACaI;EACI,+CAAA;EACA,gBAAA;ADXR;;ACeA;EACI,4BAAA;EACA,WAAA;ADZJ;ACaI;EACI,gBAAA;ADXR;ACaI;EACI,yBAAA;ADXR;;ACcA;;EAGI,wBAAA;ADZJ;;ACcA;EACI,0BAAA;EACA,qBAAA;EACA,2BAAA;ADXJ;;ACaA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;ADVJ;ACYI;EACI;IACI,gCAAA;IACA,UAAA;EDVV;ECYM;IACI,gCAAA;IACA,UAAA;EDVV;AACF;ACYI;EACI,sBAAA;ADVR;ACYI;EACI,cAAA;ADVR;ACYI;EACI,yBAAA;ADVR;ACYI;EACI,gBAAA;ADVR;ACWQ;EACI,aAAA;EACA,kBAAA;ADTZ;ACYI;EACI,iBAAA;EACA,YAAA;ADVR;ACWQ;EACI,YAAA;ADTZ;ACYI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ADVR;ACWQ;EACI,iBAAA;ADTZ;ACWQ;EACI,gBAAA;ADTZ;ACWQ;EACI,gBAAA;ADTZ;ACWQ;EACI,aAAA;EACA,sBAAA;ADTZ;ACUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ADRhB;ACUY;EACI,YAAA;ADRhB;ACYI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ADVR;;ACeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ADZR;ACaQ;EACI,aAAA;EACA,gBAAA;ADXZ;ACaQ;EACI,gBAAA;ADXZ;ACaQ;EACI,sBAAA;ADXZ;ACaQ;EACI,uBAAA;ADXZ;ACYY;EACI,uBAAA;ADVhB;ACcY;EACI,yBAAA;ADZhB;ACgBY;EACI,gBAAA;ADdhB;ACgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ADdhB;ACgBY;EACI,eAAA;ADdhB;ACegB;EACI,eAAA;EACA,gBAAA;ADbpB;ACegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ADbpB","file":"pricereview.css"} \ No newline at end of file diff --git a/wms/cont/css/pricereview.scss b/wms/cont/css/pricereview.scss index 7812e8e5..ecc890a6 100644 --- a/wms/cont/css/pricereview.scss +++ b/wms/cont/css/pricereview.scss @@ -119,7 +119,6 @@ opacity: 1; } .copyBtn{ - width: 30px; height: 30px; } .saletd{ diff --git a/wms/cont/js/pricereviewAlpine.js b/wms/cont/js/pricereviewAlpine.js index fe3df137..9536b056 100644 --- a/wms/cont/js/pricereviewAlpine.js +++ b/wms/cont/js/pricereviewAlpine.js @@ -5,6 +5,8 @@ const pricereviewCreate = ()=>{ }, modalShow:{ elevator: false, + other:false, + otherToElevator:false, }, total_spec:0, elevators:[], @@ -23,9 +25,20 @@ const pricereviewCreate = ()=>{ lastDate:'', // 上次年檢日期 yearCheckFee:'', //年檢費用 price:'', //公司發布價(月) - qty:'', //電梯數量 + qty:1, //電梯數量 sale_price:'', //契約報價 }, + otherOptions: [], + modalOtherOptionInfo:{ + pr_no:"", + name:"", + price: 0, + num:"", + }, + otherOptionKey:0, + currentOtherOptionKey:'', + toElevators:[], + toElevatorNo:'', openCreateElevatorModal(){ this.modalShow.elevator = true; body.style.overflow = 'hidden'; @@ -42,13 +55,14 @@ const pricereviewCreate = ()=>{ permitNumber:'', brand:'', m1:0, - months:'', + startDate:'', + endDate:'', cycle:'', checkYear:'', lastDate:'', yearCheckFee:'', price:'', - qty:'', + qty:1, sale_price:'', }; }, @@ -114,5 +128,98 @@ const pricereviewCreate = ()=>{ sale_price: sale_price }) }, + removeElevator(id){ + this.elevators = this.elevators.filter(elevator=> elevator.id != id) + }, + openCreateOtherOptionFn(){ + this.modalShow.other = true + body.style.overflow = 'hidden' + }, + createOtherOptionFn(){ + this.otherOptionKey ++; + this.otherOptions.push({ + id: this.otherOptionKey, + pr_no: this.modalOtherOptionInfo.pr_no, + name: this.modalOtherOptionInfo.name, + price: this.modalOtherOptionInfo.price, + num: this.modalOtherOptionInfo.num, + toElevator:[], + }) + this.modalOtherOptionInfo = { + pr_no: '', + name: '', + price: 0, + num: '', + } + this.hideCreateOtherOptionModal(); + }, + hideCreateOtherOptionModal(){ + this.modalShow.other = false + // this.$refs.createOtherOptionModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + addOtherOptionToElevator(id){ + this.currentOtherOptionKey = id; + this.toElevators = []; + this.toElevatorNo = ""; + const matchElevators = this.otherOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id) + this.toElevatorNo = matchElevators[0] + console.log(this.elevators); + this.elevators.forEach(elevator=>{ + if(elevator.price > 0){ + let model = '' + model = elevator.spec + this.toElevators.push({ + id: elevator.id, + model: model, + checked: matchElevators.includes(elevator.id) ? 1: 0, + }) + } + }) + + this.modalShow.otherToElevator = true + body.style.overflow = 'hidden' + }, + hideToOtherOptionElevatorModal(){ + this.modalShow.otherToElevator = false + body.style.overflow = 'auto' + }, + copyOtherOption(id){ + this.otherOptionKey++; + const copyOption = this.otherOptions.filter(option=> option.id === id)[0] + console.log(copyOption); + this.otherOptions.push({ + id: this.otherOptionKey, + name: copyOption.name, + price: copyOption.price, + num: copyOption.num, + toElevator: [], + pr_no: copyOption.pr_no + }) + console.log(this.otherOptions); + }, + chkOtherOptionToElevators(){ + const checkedOptions = []; + + const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] + console.log(matchElevators); + checkedOptions.push({ + id: this.toElevatorNo, + model: matchElevators['spec'], + }) + this.otherOptions.forEach(option=>{ + if(option.id == this.currentOtherOptionKey){ + option.toElevator = []; + option.toElevator.push(...checkedOptions) + } + }) + console.log(this.otherOptions); + this.currentOtherOptionKey = '' + + this.hideToOtherOptionElevatorModal(); + }, + removeOtherOption(id){ + this.otherOptions = this.otherOptions.filter(option=> option.id != id) + }, } } \ No newline at end of file diff --git a/wms/cont/pricereviewCreate.php b/wms/cont/pricereviewCreate.php index cd65c763..e2b87b9f 100644 --- a/wms/cont/pricereviewCreate.php +++ b/wms/cont/pricereviewCreate.php @@ -3,178 +3,61 @@ include_once "../header.php"; require_once "../mkt/conn.php"; +if(!(isset($_GET['vol_no']) && $_GET['vol_no'] != "")){ + echo ""; +} +$vol_no = $_GET['vol_no']; +$sql_str = "SELECT * FROM hope_contract_customer WHERE vol_no = :vol_no"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':vol_no', $vol_no); +$stmt->execute(); +$hope_customer = $stmt->fetch(PDO::FETCH_ASSOC); + +$apply_key = getApplyKey(date('ym'), 'cmea_apply_key'); +echo $apply_key; +function getApplyKey($p_yyyymm, $seq_name){ + if (empty($p_yyyymm) || empty($seq_name)) return null; + global $conn; + $sql_str = "SELECT yyyymm, prefix FROM sequence WHERE seq_name = :seq_name"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':seq_name', $seq_name); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + + $yyyymm = $result['yyyymm']; + $prefix = $result['prefix']; + + if ($p_yyyymm != $yyyymm) { + $sql_str = "UPDATE sequence SET yyyymm = :p_yyyymm, current_val = '10000' WHERE seq_name = :seq_name"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':p_yyyymm', $p_yyyymm); + $stmt->bindParam(':seq_name', $seq_name); + $stmt->execute(); + } + + $sql_str = "SELECT CONCAT(:prefix, :p_yyyymm, SUBSTRING(appwms.nextval(:seq_name), 2)) AS seq_no"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':prefix', $prefix); + $stmt->bindParam(':p_yyyymm', $p_yyyymm); + $stmt->bindParam(':seq_name', $seq_name); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + + $seq_no = $result['seq_no']; + + return $seq_no; +} ?>
-
- -
-
+
@@ -184,63 +67,58 @@ require_once "../mkt/conn.php"; - - + + - - - + - + + + - - - + + + - - - + + + + + +
評審單號價審單號 卷號現場地址 現場名稱現場地址
電梯品牌數量電梯數量 營業員保養方式 - - 當前契約期限結束
+ + + + + + + - - - - + - - - - - - - - - - + +
價格審查(契約)基本資料
契約期限開始契約期限結束契約性質 - + 介紹人
付款方式 - + 案件名稱
@@ -253,7 +131,7 @@ require_once "../mkt/conn.php"; - + @@ -288,10 +166,10 @@ require_once "../mkt/conn.php"; 項次 - + - - + + @@ -305,28 +183,9 @@ require_once "../mkt/conn.php"; - - - - - - 人乘 - - + 載重(KG) @@ -350,9 +209,22 @@ require_once "../mkt/conn.php"; - 規格 - - + 人乘 + + @@ -361,7 +233,7 @@ require_once "../mkt/conn.php"; 品牌 - + - 保養月數 + 竣工檢查年度(民國) - + + + + + + 保養開始日期 + + + + 保養結束日期 + + 保養週期 @@ -401,6 +284,15 @@ require_once "../mkt/conn.php"; + 保養方式 + + + 送M1 - + 上次年檢日期 @@ -428,7 +317,7 @@ require_once "../mkt/conn.php"; 電梯數量 - + 契約報價(月) @@ -439,6 +328,61 @@ require_once "../mkt/conn.php";
+
+
+

除外項目

+ +
+ + + + + + + + + + + + + + + + + + + + + +
詢價單號名稱單價數量複價所屬電梯功能
小計
+
diff --git a/wms/cont/window-modal/modalElevaotr.php b/wms/cont/window-modal/modalElevaotr.php new file mode 100644 index 00000000..896ea9de --- /dev/null +++ b/wms/cont/window-modal/modalElevaotr.php @@ -0,0 +1,179 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
電梯人乘載重(KG)停數
+ + + + + + + +
速度電梯許可證號品牌贈送M1
+ + + + + + + +
保養開始日期保養結束日期
保養方式保養週期竣工檢查年度上次年檢日期
+ + + + + + + +
年檢費用(元)公司發布價(月)電梯數量契約報價(月)
+ + + + + + + +
+
+
+ + +
+ \ No newline at end of file diff --git a/wms/cont/window-modal/otherOptionModal.php b/wms/cont/window-modal/otherOptionModal.php new file mode 100644 index 00000000..565ccbf5 --- /dev/null +++ b/wms/cont/window-modal/otherOptionModal.php @@ -0,0 +1,33 @@ +
+ +
+
\ No newline at end of file diff --git a/wms/cont/window-modal/otherToElevatorModal.php b/wms/cont/window-modal/otherToElevatorModal.php new file mode 100644 index 00000000..3b073176 --- /dev/null +++ b/wms/cont/window-modal/otherToElevatorModal.php @@ -0,0 +1,36 @@ +
+ +
+
\ No newline at end of file diff --git a/wms/crm/crmm02-index.php b/wms/crm/crmm02-index.php index 33e48991..a4fcc9bd 100644 --- a/wms/crm/crmm02-index.php +++ b/wms/crm/crmm02-index.php @@ -170,7 +170,7 @@ if ($data) : - + 轉價審 diff --git a/wms/mkt/assets/js/pricereviewAlpine.js b/wms/mkt/assets/js/pricereviewAlpine.js index 227b2f4c..255c8251 100644 --- a/wms/mkt/assets/js/pricereviewAlpine.js +++ b/wms/mkt/assets/js/pricereviewAlpine.js @@ -490,10 +490,14 @@ const pricereviewCreate = ()=>{ this.otherOptionKey++; }, addOptionToElevator(key){ + console.log(key); + console.log(this.selectedOptions); this.currentOptionKey = key; this.toElevators = []; this.toElevatorNo = ""; const matchElevators = this.selectedOptions.filter(option=> option.key == key)[0].toElevator.map(elevator=> elevator.id) + console.log(matchElevators); + // this.toElevatorNo = matchElevators.length > 0 ? matchElevators[0] : ''; this.toElevatorNo = matchElevators[0] this.elevators.forEach(elevator=>{ if(elevator.price > 0){ @@ -544,7 +548,9 @@ const pricereviewCreate = ()=>{ chkOptionToElevators(){ const checkedOptions = []; const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] - + console.log(this.elevators); + console.log(this.toElevatorNo); + console.log(this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)); checkedOptions.push({ id: this.toElevatorNo, model: matchElevators['model'] , @@ -590,7 +596,22 @@ const pricereviewCreate = ()=>{ return issetElevators.includes(el.id) }) }) - console.log(this.selectedOptions); + + this.otherOptions.forEach(option=>{ + option.toElevator = option.toElevator.filter(el=>{ + return issetElevators.includes(el.id) + }) + }) + this.maintainOptions.forEach(option=>{ + option.toElevator = option.toElevator.filter(el=>{ + return issetElevators.includes(el.id) + }) + }) + this.demolishOptions.forEach(option=>{ + option.toElevator = option.toElevator.filter(el=>{ + return issetElevators.includes(el.id) + }) + }) }, removeOption(key){ console.log(this.selectedOptions); diff --git a/wms/mkt/pricereviewCreate.php b/wms/mkt/pricereviewCreate.php index f9c6ba6f..72d58e0e 100644 --- a/wms/mkt/pricereviewCreate.php +++ b/wms/mkt/pricereviewCreate.php @@ -490,11 +490,6 @@ function convertDateTimeFormat($dateTimeStr) { - - - - - 請選擇規格 diff --git a/wms/mkt/window-modal/demolishToElevatorModal.php b/wms/mkt/window-modal/demolishToElevatorModal.php index da7e3974..3970c026 100644 --- a/wms/mkt/window-modal/demolishToElevatorModal.php +++ b/wms/mkt/window-modal/demolishToElevatorModal.php @@ -12,7 +12,7 @@ 規格 選擇 -