+
+
+
+
+
+
\ No newline at end of file
diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php
index 610da6d7..9015a83c 100644
--- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php
+++ b/wms/bonus/other/maintenance_contract_bonus_v2_1.php
@@ -43,9 +43,12 @@ 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 = 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,49 +57,49 @@ 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):
- $sales_bonus = ($fee_per_st - $commission_fee) * 0.6;
+ case ($fee_per_st < 3000):
+ $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;
+ 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):
- $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;
+ case ($fee_per_st < 3000):
+ $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;
+ 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):
- $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;
+ case ($fee_per_st < 3000):
+ $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;
+ 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):
- $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;
@@ -110,17 +113,17 @@ 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;
+ case ($fee_per_st < 3000):
+ $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;
+ 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):
- $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)
@@ -131,17 +134,17 @@ 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;
+ case ($fee_per_st < 3000):
+ $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;
+ 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):
- $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 +229,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 +252,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_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.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/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..db37fd30
--- /dev/null
+++ b/wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php
@@ -0,0 +1,311 @@
+$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" => "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")), #預計發放時間
+ "bonus_regulation" => "訂金收回後次月發放" #發放規定
+ ]);
+
+ #專任契約經理獎金
+ if ($regular_contract_manger_id != '') {
+ array_push($bonus_array, [
+ "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")), #預計發放時間
+ "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" => "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" => "每次收款後,按收款比率次月發放" #發放規定
+ ]);
+ }
+
+ 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" => "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" => "每次收款後,按收款比率次月發放" #發放規定
+ ]);
+ }
+ 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" => "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" => "每月收款後,按收款比率次月發放" #發放規定
+ ]);
+ }
+ 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" => "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" => "每月收款後,按收款比率次月發放" #發放規定
+ ]);
+ }
+ 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" => "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" => "每月收款後,按收款比率次月發放" #發放規定
+ ]);
+ }
+ 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/cont/api/getElevatorPrice.php b/wms/cont/api/getElevatorPrice.php
new file mode 100644
index 00000000..92f9d4c1
--- /dev/null
+++ b/wms/cont/api/getElevatorPrice.php
@@ -0,0 +1,44 @@
+= :person AND is_m1_bundle=:m1 ORDER bY id DESC";
+$stmt = $conn->prepare($sql_str);
+$stmt->bindParam(':elevator_type', $elevator_type);
+$stmt->bindParam(':min_speed', $speed);
+$stmt->bindParam(':person', $person);
+$stmt->bindParam(':m1', $m1);
+$stmt->execute();
+$result = $stmt->fetch(PDO::FETCH_ASSOC);
+if(!$result){
+ echo 0;
+ exit;
+}
+$differ = $stop > $result['max_floors'] ? $result['max_floors'] - $result['min_floors'] : ($stop - $result['min_floors']);
+$price = $result['base_price'] + $differ * $result['floors_price'] +$result['m1_bundle_fee'];
+if($cycle == 2){
+ $price += $price * $result['maintenance_fee_coefficient'];
+}
+if($method == "A"){
+ $price += $result['all_inclusive_fee'];
+}
+
+echo $price;
\ No newline at end of file
diff --git a/wms/cont/api/postElevatorPricereview.php b/wms/cont/api/postElevatorPricereview.php
new file mode 100644
index 00000000..e69de29b
diff --git a/wms/cont/css/pricereview.css b/wms/cont/css/pricereview.css
new file mode 100644
index 00000000..0c527544
--- /dev/null
+++ b/wms/cont/css/pricereview.css
@@ -0,0 +1,333 @@
+@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 {
+ 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;
+}
+#pricereviewCreate .dark {
+ background-color: rgb(225, 225, 225) !important;
+ font-weight: 600;
+}
+
+.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-modal-content input[type=number]::-webkit-outer-spin-button,
+.window-modal .window-modal-content input[type=number]::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+.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..668d8c66
--- /dev/null
+++ b/wms/cont/css/pricereview.css.map
@@ -0,0 +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,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;ACWQ;;EAEI,wBAAA;EACA,SAAA;ADTZ;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
new file mode 100644
index 00000000..f78743a2
--- /dev/null
+++ b/wms/cont/css/pricereview.scss
@@ -0,0 +1,352 @@
+#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{
+ 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;
+ }
+ }
+ }
+ }
+ }
+ .dark{
+ background-color: rgba(225,225,225,1) !important;
+ font-weight: 600;
+ }
+}
+
+.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;
+ }
+ }
+ input[type=number]::-webkit-outer-spin-button,
+ input[type=number]::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+ }
+ }
+ .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 `";
+}
+$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;
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+ 洽商進度
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 電梯詳細資料
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
▪️ 營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。
+
+ 報價單
+
+
+
+ 合約用印申請表
+
+
+
+
+ 下載報價單
+
+
+ 下載附表一
+
+ 保存
+ 送審
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wms/cont/window-modal/modalElevaotr.php b/wms/cont/window-modal/modalElevaotr.php
new file mode 100644
index 00000000..045362b7
--- /dev/null
+++ b/wms/cont/window-modal/modalElevaotr.php
@@ -0,0 +1,179 @@
+
\ 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/contract/api/T8salIncomeApply.php b/wms/contract/api/T8api.php
similarity index 84%
rename from wms/contract/api/T8salIncomeApply.php
rename to wms/contract/api/T8api.php
index f419d4d8..88d8dffa 100644
--- a/wms/contract/api/T8salIncomeApply.php
+++ b/wms/contract/api/T8api.php
@@ -1,17 +1,18 @@
';
- print_r(json_encode($data));
+ print_r($validation);
echo '';
+ // exit;
$header = [
"CHI_Authorization :" . $validation,
- "GroupId:TEST"
+ "GroupId:MASADA"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
@@ -19,7 +20,7 @@ function T8API($data)
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($data));
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
$response = curl_exec($ch);
if ($response === false) {
diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php
index 253e8d54..e2aedd43 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) {
+ $contract_elevator_qty = 0;
+ $sql = "SELECT * FROM pricereview_pay WHERE mid = :mid";
+ $stmt = $conn->prepare($sql);
+ $stmt->bindParam(':mid', $mid);
+ $stmt->execute();
+
+ $pay_amount = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $pay_arr = [
+ 'equipment_total' => 0, //設備款
+ 'install_total' => 0, //安裝款
+ 'elevotor_pay_detail' => []
+ ];
+ $elevotor_pay_detail = [];
+ foreach ($pay_amount as $i => $pay) {
+ if ($pay['pay_kind'] <= 4) {
+ // 設備款總價
+ $pay_arr['equipment_total'] += $pay['pay_amount'];
+ if ($pay['pay_scale'] > 0) {
+ $elevotor_pay_detail = [
+ 'kind' => $pay['pay_kind'],
+ 'pay_scale' => $pay['pay_scale'],
+ 'pay_period' => $pay['pay_period'],
+ 'amount' => $pay['pay_amount']
+ ];
+ // $elevotor_pay_detail['pay_scale'] = $pay['pay_scale'];
+ // $pay_arr['elevotor_pay_detail']['kind'] = $pay['pay_kind'];
+ // $pay_arr['elevotor_pay_detail']['pay_scale'] = $pay['pay_scale'];
+ // $pay_arr['elevotor_pay_detail']['pay_period'] = $pay['pay_period'];
+ // $pay_arr['elevotor_pay_detail']['amount'] = $pay['pay_amount'];
+ array_push($pay_arr['elevotor_pay_detail'], $elevotor_pay_detail);
+ }
+ } else {
+ $pay_arr['install_total'] += $pay['pay_amount'];
+ if ($pay['pay_scale'] > 0) {
+ $a = $pay['pay_kind'];
+ $elevotor_pay_detail = [
+ 'kind' => "$a",
+ 'pay_scale' => $pay['pay_scale'],
+ 'pay_period' => $pay['pay_period'],
+ 'amount' => $pay['pay_amount']
+ ];
+ array_push($pay_arr['elevotor_pay_detail'], $elevotor_pay_detail);
+
+ // $elevotor_pay_detail[] = $pay['pay_kind'];
+ // $pay_arr['elevotor_pay_detail']['kind'] = $pay['pay_kind'];
+ // $pay_arr['elevotor_pay_detail']['pay_scale'] = $pay['pay_scale'];
+ // $pay_arr['elevotor_pay_detail']['pay_period'] = $pay['pay_period'];
+ // $pay_arr['elevotor_pay_detail']['amount'] = $pay['pay_amount'];
+ }
+ }
+ }
+ // echo "";
+ // print_r($pay_arr);
+ // echo " ";
+
+ foreach ($elevators_results as $keys) {
+ $contract_elevator_qty += $keys['item_qty'];
+ }
+ 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;
+ // echo "";
+ // print_r($option_arr);
+ // echo " ";
+ if (!empty($option_results)) {
+ $result['option_price'] = 0;
+ // 電梯 OPTION 價格分別加到各台電梯
+ foreach ($option_results as $key => $option) {
+ if ($option['item_qty'] == $result['item_qty']) {
+ $result['option_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_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_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_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']);
+ } 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;
+ } else {
+ $result['option_other_price'] += $option['item_unit_price'] * intval($option['item_qty']);
+ }
+ }
+ }
+
+
$note = explode(',', $result['note']);
- $result['spec'] = $note[0]; //型號
+ $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);
}
}
- $count = COUNT($elevators_detail_arr);
- $contract['elevators'] = $results;
+ $count = COUNT($elevators_detail_arr);
+ $contract['elevators'] = $elevators_results;
$contract['elevators_detail_arr'] = $elevators_detail_arr;
+ $contract['pay_arr'] = $pay_arr;
$contract['nums'] = $count;
- // echo '';
- // print_r($contract);
- // echo ' ';
- // exit;
+
$contractResponse = json_encode($contract);
// 設定回應標頭為 JSON
header('Content-Type: application/json');
diff --git a/wms/contract/api/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 29038b9f..9522defe 100644
--- a/wms/contract/api/postContractData.php
+++ b/wms/contract/api/postContractData.php
@@ -1,3 +1,5 @@
+
+
prepare($sql);
@@ -65,14 +68,14 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->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[] = '合約總價為必填';
@@ -93,14 +96,20 @@ 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);
- bonusCreate($_POST, $facilityno, $conn);
+ /// 獎金計算
+ $aaa = bonusCreate($_POST, $facilityno, $conn);
+ if (!empty($aaa) && $aaa['status'] == 2) {
+ header("HTTP/1.1 422 Unprocessable Entity");
+ echo $aaa['data'];
+ exit();
+ }
//create account table
$accounttype = "A";
$accountid = $vat;
@@ -112,8 +121,6 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$create_at = date('Y-m-d H:i:s');
$conn->beginTransaction();
- // bonusCreate($_POST, $facilityno, $conn);
- // exit();
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
@@ -213,7 +220,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);
@@ -370,7 +377,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
// T8insert($_POST, $facilityno);
- // header('Content-Type: application/json');
+ header('Content-Type: application/json');
$jsonData = json_encode($files);
$conn->commit();
@@ -382,11 +389,12 @@ 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("./T8salIncomeApply.php");
+ require_once("./T8api.php");
+
$contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號
$address = !empty($data['address']) ? $data['address'] : null; // 客戶地址
@@ -409,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);
@@ -423,6 +431,7 @@ function T8insert($data, $facilityno, $depId)
echo 'Error';
exit;
}
+
if (empty($result)) {
// 若 客戶資料為空,新增一筆到 comCustomer
// 新增客戶資料
@@ -564,23 +573,26 @@ function T8insert($data, $facilityno, $depId)
// 分期代碼計算
$IncomeId = [
- 'A40006' => 1, //年繳
- 'A40007' => 4, //季繳
- 'A40003' => 12, //月繳
- 'A40004' => 6, //雙月繳
- 'A40005' => 2 //半年繳
+ 'A40006' => 12, //年繳
+ 'A40007' => 3, //季繳
+ 'A40003' => 1, //月繳
+ 'A40004' => 2, //雙月繳
+ 'A40005' => 6 //半年繳
];
- //分幾期 => 總共保養月 / 分期月
- $SQuantity = $elevator['maintain_months'] / $IncomeId[$payType];
+ // 幾年
+ // $SQuantityYear = $elevator['maintain_months'] / 12;
+ //分幾期 () => 總共保養月 / 分期月
+ $SQuantitya = $elevator['maintain_months'] / $IncomeId[$payType];
+ $SQuantity = $IncomeId[$payType];
+ // $paymonth = $IncomeId[$payType] * $SQuantity;
$date_1 = getNext25thDate($contract_begin_date);
-
// 依每台電梯去加入各個的付款項
- for ($i = 0; $i < $IncomeId[$payType]; $i++) {
+ for ($i = 1; $i <= $SQuantitya; $i++) {
$row++;
// 計算分期款的收款月份
- $paymonth = $i * $SQuantity;
+ $paymonth = $i * $IncomeId[$payType];
$countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months"));
$payDay = str_replace('-', '', $countDay);
$rows_data = [
@@ -593,13 +605,11 @@ function T8insert($data, $facilityno, $depId)
"SPrice" => intval($elevator['sold_price']),
"SQuantity" => $SQuantity,
"ProjectId" => "$contractno",
+ "FromBillNo" => "$contractno",
"CU_MaterialId" => "$facility_no",
"CU_EstPayDate" => intval($payDay)
];
$salIncomeApplyDetail_rows[] = $rows_data;
- // echo '';
- // print_r($salIncomeApplyDetail_rows);
- // echo ' ';
}
}
@@ -641,10 +651,11 @@ function T8insert($data, $facilityno, $depId)
$API_body[] = $salIncomeApplyMaster;
$API_body[] = $salIncomeApplyDetail;
// 呼叫 API
- // echo '';
- // print_r($API_body);
- // echo ' ';
- $result = T8API($API_body);
+ 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') {
@@ -658,14 +669,17 @@ 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'];
- $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;
@@ -677,26 +691,115 @@ function bonusCreate($data, $facilityno, $conn)
'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['contract_price']; //作翻契約金額
- $commission_fee = $elevator['service_expense']; //服務費(月)
+ $elevator_list_price = !empty(intval($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價
+ $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; //營業人員
$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;
+ echo $years;
+ 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;
+ }
+ $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,
+ $payment_period,
+ $elevator_list_price,
+ $fee_per_st,
+ $commission_fee,
+ $receivable_date_due,
+ $sales_id,
+ $region_director_id,
+ $regular_contract_manger_id
+ );
+ for ($i = 1; $i <= $years - 1; $i++) {
+ $contract_type = 'renew_priceissue';
+ $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_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';
+ $renew_priceissue_bonus[] = 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') {
+ // 五年以上長約
+ $results = 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,
@@ -707,22 +810,54 @@ 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
+ 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'];
+ $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();
+ }
+ }
+ 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();
+ }
+ }
}
+ $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/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/api/postNewContractData.php b/wms/contract/api/postNewContractData.php
index d94dac12..359cbbb0 100644
--- a/wms/contract/api/postNewContractData.php
+++ b/wms/contract/api/postNewContractData.php
@@ -1,163 +1,293 @@
+
';
- // print_r($elevators);
- // 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);
- exit();
- }
- //create facility table
- $createFacilityNo = new CreateFacilityNo();
- $dailyNecessities = [
- 'MAE100' => 'X',
- 'MAM200' => 'W',
- 'MAH100' => 'H',
- 'MAQ100' => 'Z',
- 'MAF100' => 'F',
- 'MAZ100' => 'B',
- ];
- $arr = [];
- // 建立作番號
- foreach ($elevators_detail_arr as $elevator) {
- // $spec = explode('-', $elevator['item_spec']);
- $arr[] = $dailyNecessities[$elevator['spec']];
- }
- $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums));
- echo '';
- print_r($facilityno);
- echo ' ';
+
+ $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();
- $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC";
- $stmt = $conn->prepare($sql_str);
- $stmt->bindParam(":accountid", $salesman);
+ //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();
- $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);
+ // 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,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')";
+ $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 " ";
+ // exit;
+ if (!empty($lastId)) {
+ echo '123';
+ // 寫入待簽程狀態 A (營業)
+ do_wws_assign1($salesman, $lastId, 'A', $conn);
+ // // 寫入待簽程狀態 G (工務)
+ do_wws_assign1($warehouseid, $lastId, 'G', $conn);
}
- $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);
+
+
+ // 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);
+ $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();
@@ -166,9 +296,11 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
}
}
-function T8Insert($data)
+function T8Insert($data, $facilityno, $connT8)
{
- require_once("../connt8.php");
+ // try {
+ // 引入銷售訂單 API
+ require_once("./T8API.php");
$contractno = $data['contractno'];
$partyA = $data['customer'];
@@ -178,53 +310,83 @@ function T8Insert($data)
$user_id = $data['user_id'];
$salesman = $data['salesman'];
$createAt = date("Y-m-dH-i-s");
- $elevators[] = $data['elevators'];
- $createTime = str_replace('-', '', $createAt);
- $connT8->beginTransaction();
+ $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) : []; //電梯
- $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId";
- $stmt = $conn->prepare($sql);
+ $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);
+
// 新增客戶 table
if (empty($result)) {
// 若 客戶資料為空,新增一筆到 comCustomer
// 新增客戶資料
+
$sql = "INSERT INTO comBusinessPartner
- (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId)
- VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')";
+ (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', $customer); //企業名稱
+ $stmt->bindParam(':EnterpriseName', $partyA); //企業名稱
$stmt->bindParam(':ContactAddress', $partyAaddress);
- $stmt->bindParam(':EMail', $email);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
-
$stmt->execute();
+
$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','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', $address);
+ $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
@@ -232,7 +394,7 @@ function T8Insert($data)
";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':PersonId', $salesman);
- $stmt->bindParam(':InvoiceAddress', $address);
+ $stmt->bindParam(':InvoiceAddress', $partyAaddress);
$stmt->bindParam(':LastOperatorId', $user_id);
$stmt->bindParam(':LastOperateTime', $createTime);
$stmt->bindParam(':BizPartnerId', $contractno);
@@ -245,7 +407,6 @@ function T8Insert($data)
TaxNo=:TaxNo,
EnterpriseName=:EnterpriseName,
ContactAddress=:ContactAddress,
- EMail=:EMail,
LastOperatorId=:LastOperatorId,
LastOperateTime=:LastOperateTime
WHERE BizPartnerId = :BizPartnerId
@@ -254,9 +415,9 @@ function T8Insert($data)
$stmt->bindParam(':BizPartnerName', $partyA);
$stmt->bindParam(':WorkTelNo', $phone);
$stmt->bindParam(':TaxNo', $vat);
- $stmt->bindParam(':EnterpriseName', $customer);
+ $stmt->bindParam(':EnterpriseName', $partyA);
$stmt->bindParam(':ContactAddress', $partyAaddress);
- $stmt->bindParam(':EMail', $email);
+ // $stmt->bindParam(':EMail', $email);
$stmt->bindParam(':LastOperatorId', $user_id);
$stmt->bindParam(':LastOperateTime', $createTime);
$stmt->bindParam(':BizPartnerId', $contractno);
@@ -274,52 +435,392 @@ function T8Insert($data)
VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':ProjectId', $contractno);
- $stmt->bindParam(':ProjectName', $customer);
+ $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) {
-function BounsCount($data, $conn)
-{
- // echo '';
- // print_r($data);
- // echo ' ';
- // exit;
- require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php");
- $signing_date = $data['signing_date'];
- $bonus_v1_0_date = '2024-01-02';
- $bonus_v2_0_date = '2024-01-03';
- $contractType = [
- '1' => 'strategy_customer',
- '2' => 'general_customer'
- ];
- $contract_type = $data['contract_type'];
+ $count = 1;
+ // 產品集成維護
+ $facility_no = $facilityno[$index];
+ $MaterialName = "$partyA($facility_no)";
+ $contract_arrival_a = $elevator['contract_arrival_date'];
- $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶
- $elevator_knockdown_price = $data['price_total']; //受價總額
+ $sql = "SELECT * FROM comMaterial WHERE MaterialId = '$facility_no'";
+ $stmt = $connT8->prepare($sql);
+ $stmt->execute();
+ $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)";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':MaterialId', $facility_no);
+ $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)";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':MaterialId', $facility_no);
+ $stmt->bindParam(':MaterialName', $MaterialName);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->bindParam(':CreateTime', $createTime);
+ $stmt->execute();
- $salesman = $data['salesman'];
- $manager = $data['manager'];
-
- $result_bonus = [];
- if ($signing_date <= $bonus_v1_0_date) {
- $ver = '1.0';
- $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager);
- } else if ($signing_date >= $bonus_v2_0_date) {
- $ver = '2.0';
- // $result_bonus = elevator_new_deal_bonus_v2_0($ver,$contract_type,);
+ $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();
+
+ $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();
+
+ $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();
+ }
+ // 階段收款資訊
+ $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 // 歸屬作番號
+ ];
+ $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";
+ // $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'];
+ }
+ } else {
+ echo '資料已新增過,請洽資訊人員';
+ // exit();
}
+ $connT8->commit();
+ // } catch (PDOException $e) {
+ // $connT8->rollback();
+ // header("HTTP/1.1 500 Internal Server Error");
+ // die('Error!:' . $e->getMessage());
+ // }
+}
- echo '';
- print_r($result_bonus);
- echo ' ';
- exit();
+
+function BounsCount($data, $conn, $facilityno)
+{
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
+ (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 $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
+ );
+ $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"
+ ];
+ }
+ }
+ }
+ 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
new file mode 100644
index 00000000..cb1ba7c7
--- /dev/null
+++ b/wms/contract/api/test copy.json
@@ -0,0 +1,115 @@
+[
+ {
+ "name": "MainSalesOrder",
+ "rows": [
+ {
+ "BillNo": "M24020076",
+ "BillDate": 20240320,
+ "TypeId": "SO",
+ "FOrgId": "1000",
+ "OrgId": "1000",
+ "ModeId": "M",
+ "BizPartnerId": "M24020076",
+ "CurrId": "TWD",
+ "CurrOAmount": 1,
+ "CurrLAmount": 1,
+ "PersonId": "M0073",
+ "DueToId": "M24020076",
+ "TradeConditionId": "",
+ "TaxId": "ST005",
+ "CreditorCompId": "1001",
+ "CreditorOrgId": "1000",
+ "CreatorId": "M0225"
+ }
+ ]
+ },
+ {
+ "name": "SubOrder",
+ "rows": [
+ {
+ "TaxId": "ST005",
+ "RequirementDate": 20240320,
+ "ConsignmentDate": 20240320,
+ "BillNo": "M24020076",
+ "RowCode": 1,
+ "ItemType": 1,
+ "MaterialId": "A40001",
+ "SUnitId": "SET",
+ "SQuantity": 1,
+ "SPrice": 910000,
+ "CU_MaterialId": "4MW00001"
+ },
+ {
+ "TaxId": "ST005",
+ "RequirementDate": 20240320,
+ "ConsignmentDate": 20240320,
+ "BillNo": "M24020076",
+ "RowCode": 2,
+ "ItemType": 1,
+ "MaterialId": "A40008",
+ "SUnitId": "SET",
+ "SQuantity": 1,
+ "SPrice": 390000,
+ "CU_MaterialId": "4MW00001"
+ },
+ {
+ "TaxId": "ST005",
+ "RequirementDate": 20240320,
+ "ConsignmentDate": 20240320,
+ "BillNo": "M24020076",
+ "RowCode": 3,
+ "ItemType": 0,
+ "MaterialId": "4MW00001",
+ "SUnitId": "SET",
+ "SQuantity": 1,
+ "SPrice": 0,
+ "CU_MaterialId": "4MW00001"
+ }
+ ]
+ },
+ {
+ "name": "salOrderStagePay",
+ "rows": [
+ {
+ "PayStage": "簽約",
+ "PlanPercentage": 0.2,
+ "PlanPayAmt": 260000,
+ "PlanPayDate": 20240420,
+ "BillNo": "M24020076",
+ "RowCode": 1,
+ "RowNo": 1,
+ "UnWriteOffOAmount": 260000
+ },
+ {
+ "PayStage": "貨抵工地",
+ "PlanPercentage": 0.5,
+ "PlanPayAmt": 650000,
+ "PlanPayDate": 20241220,
+ "BillNo": "M24020076",
+ "RowCode": 2,
+ "RowNo": 2,
+ "UnWriteOffOAmount": 650000
+ },
+ {
+ "PayStage": "試車完工",
+ "PlanPercentage": 0.2,
+ "PlanPayAmt": 260000,
+ "PlanPayDate": 20250120,
+ "BillNo": "M24020076",
+ "RowCode": 3,
+ "RowNo": 3,
+ "UnWriteOffOAmount": 260000
+ },
+ {
+ "PayStage": "交車",
+ "PlanPercentage": 0.1,
+ "PlanPayAmt": 130000,
+ "PlanPayDate": 20250220,
+ "BillNo": "M24020076",
+ "RowCode": 4,
+ "RowNo": 4,
+ "UnWriteOffOAmount": 130000
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/wms/contract/api/test.json b/wms/contract/api/test.json
index 04729705..da130a89 100644
--- a/wms/contract/api/test.json
+++ b/wms/contract/api/test.json
@@ -1,185 +1,66 @@
[
{
- "name": "salIncomeApplyMaster",
+ //salSalesOrder
+ "name": "MainSalesOrder",
"rows": [
{
- "BillNo": "B23100060",
- "BillDate": "20240122",
- "OrgId": "1000",
+ "BillNo": "Z001", //合約單號
+ "BillDate": 20210420, //簽約日期
+ "TypeId": "SO", //
"FOrgId": "1000",
- "TypeId": "RAS",
- "BpOrgId": "1000",
- "BizPartnerId": "B23100060",
+ "OrgId": "1000",
+ "ModeId": "T", // T汰改 M新梯
+ "BizPartnerId": "M0225", //創建人ID
"CurrId": "TWD",
"CurrOAmount": 1,
"CurrLAmount": 1,
- "PersonId": "M0065",
- "DtOrgId": "1000",
- "DueToId": "B23100060",
+ "PersonId": "M0225", //業務人員
+ "DueToId": "512", //業務部門
+ "TradeConditionId": "",
"TaxId": "ST005",
- "CompId": "1001",
- "CreatorId": "M0225"
+ "CreditorCompId": "1000",
+ "CreditorOrgId": "1000",
+ "CreditorCurrOAmount": 1,
+ "CreditorCurrLAmount": 1,
+ "CompId": "1000"
}
]
},
{
- "name": "salIncomeApplyDetail",
+ // salSalesOrderDetail
+ "name": "SubOrder",
"rows": [
{
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 1,
- "RowNo": 1,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 2,
- "RowNo": 2,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 3,
- "RowNo": 3,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 4,
- "RowNo": 4,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 5,
- "RowNo": 5,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 6,
- "RowNo": 6,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
+ "SupplyCompId": "1001",
+ "SupplyOrgId": "1000",
"TaxId": "ST005",
- "RowCode": 7,
- "RowNo": 7,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 8,
- "RowNo": 8,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 9,
- "RowNo": 9,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 10,
- "RowNo": 10,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
- {
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 11,
- "RowNo": 11,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
- },
+ "RequirementDate": 20210420, //出貨日期
+ "ConsignmentDate": 20210420, //發貨日期
+ "DispatchCompId": "1001",
+ "DispatchOrgId": "1000",
+ "BillNo": "Z001", //合約號
+ "RowCode": 1, //全部筆數排列
+ "ItemType": 0,
+ "MaterialId": "Z001", //作番號
+ "SUnitId": "SET",
+ "SQuantity": 1, //交易數量
+ "SPrice": 1 //交易價格
+ }
+ ]
+ },
+ {
+ //salOrderStagePay
+ "name": "salOrderStagePay",
+ "rows": [
{
- "BillNo": "B23100060",
- "IncomeId": "A40003",
- "TaxId": "ST005",
- "RowCode": 12,
- "RowNo": 12,
- "ItemType": 1,
- "SPrice": 1250,
- "SQuantity": 1,
- "ProjectId": "B23100060",
- "FromSourceTag": 0,
- "CU_MaterialId": "4TH53801"
+ "BillNo": "",
+ "RowCode": "",
+ "RowNo": "",
+ "PayStage": "ST003", //收款階段
+ "PlanPercentage": "Z001", //計劃收款比例(%)
+ "PlanPayAmt": 1, //計劃收款金額
+ "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日
+ "UnWriteOffOAmount": 1 //未核銷金額
}
]
}
diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php
index 9512cbc8..a77acf8b 100644
--- a/wms/contract/api/testT8API.php
+++ b/wms/contract/api/testT8API.php
@@ -1,36 +1,258 @@
-
-
- 地址轉經緯度
-
-
-
-
- 輸入地址以獲取經緯度
-
-
-
-
-
\ No newline at end of file
+
+// {
+// "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();
+$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);
+}
+
+curl_close($ch);
+exit();
+$contract_no = "M24020003";
+// $contract_no = "M24010109";
+$MainSalesOrder_row = [
+ "BillNo" => "$contract_no", //合約單號
+ "BillDate" => 20210420, //簽約日期
+ "TypeId" => "SO", //
+ "FOrgId" => "1000",
+ "OrgId" => "1000",
+ "ModeId" => "M", // T汰改 M新梯
+ "BizPartnerId" => "$contract_no", //客戶代碼
+ "CurrId" => "TWD",
+ "CurrOAmount" => 1,
+ "CurrLAmount" => 1,
+ "PersonId" => "M0177", //業務人員
+ "DueToId" => "$contract_no", //債務方
+ "TradeConditionId" => "",
+ "TaxId" => "ST005",
+ "CreditorCompId" => "1001",
+ "CreditorOrgId" => "1000",
+ "CreatorId" => "M0225"
+
+];
+// //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" => "$contract_no", //合約號
+ "RowCode" => $i, //全部筆數排列
+ "ItemType" => 1,
+ "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
+ "SUnitId" => "SET",
+ "SQuantity" => 1, //交易數量
+ "SPrice" => 100000 //交易價格
+ ];
+ }
+ if ($i == 1) {
+ $row = [
+ // "SupplyCompId" => "1001",
+ // "SupplyOrgId" => "1000",
+ "TaxId" => "ST005",
+ "RequirementDate" => 20210420, //出貨日期
+ "ConsignmentDate" => 20210420, //發貨日期
+ // "DispatchCompId" => "1001",
+ // "DispatchOrgId" => "1000",
+ "BillNo" => "$contract_no", //合約號
+ "RowCode" => $i, //全部筆數排列
+ "ItemType" => 1,
+ "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
+ "SUnitId" => "SET",
+ "SQuantity" => 1, //交易數量
+ "SPrice" => 650000 //交易價格
+ ];
+ }
+ if ($i == 2) {
+ $row = [
+ "TaxId" => "ST005",
+ "RequirementDate" => 20210420, //出貨日期
+ "ConsignmentDate" => 20210420, //發貨日期
+ "BillNo" => "$contract_no", //合約號
+ "RowCode" => $i, //全部筆數排列
+ "ItemType" => 0,
+ "MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
+ "SUnitId" => "SET",
+ "SQuantity" => 1, //交易數量
+ "SPrice" => 0 //交易價格
+ ];
+ }
+ $SubOrder_row[] = $row;
+}
+
+
+$salOrderStagePay_row = [];
+$roww = [
+ "PayStage" => "簽約", //收款階段
+ "PlanPercentage" => 0.5, //計劃收款比例(%)
+ "PlanPayAmt" => 375000, //計劃收款金額
+ "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
+ "BillNo" => "$contract_no",
+ "RowCode" => 1,
+ "RowNo" => 1,
+ "UnWriteOffOAmount" => 375000 //未核銷金額
+];
+$roww2 = [
+ "PayStage" => "貨抵工地",
+ "PlanPercentage" => 0.5,
+ "PlanPayAmt" => 375000,
+ "PlanPayDate" => 20240101,
+ "BillNo" => "$contract_no",
+ "RowCode" => 2,
+ "RowNo" => 2,
+ "UnWriteOffOAmount" => 375000
+];
+$salOrderStagePay_row[] = $roww;
+$salOrderStagePay_row[] = $roww2;
+
+
+$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/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-input.php b/wms/contract/contract-input.php
index 114cea2f..92aaf7d0 100644
--- a/wms/contract/contract-input.php
+++ b/wms/contract/contract-input.php
@@ -57,8 +57,10 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
業務確認項
- 返回
- 關閉分頁
+
+