From 1d3989ba9c9f6f1576d2c07c196127944df768c9 Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 26 Feb 2024 18:02:29 +0800 Subject: [PATCH 1/2] =?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 2/2] =?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++) {
項次合約類別 合約號合約名稱 作番號 獎金類別 獎金版本
契約成交價 - +

未填寫

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

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

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

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

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