Browse Source

新梯、保養簽回&獎金

main
Cheng 1 year ago
parent
commit
79d4fecce6
  1. 39
      wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php
  2. 109
      wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php
  3. 2
      wms/contract/api/T8api.php
  4. 15
      wms/contract/api/getContractData.php
  5. 1
      wms/contract/api/postContractData.php
  6. 761
      wms/contract/api/postNewContractData.php
  7. 407
      wms/contract/api/test copy.json
  8. 2
      wms/contract/api/test.json
  9. 127
      wms/contract/api/testT8API.php
  10. 14
      wms/contract/contract-newelevator-input.php
  11. 13
      wms/contract/js/alpine.js

39
wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php

@ -35,13 +35,14 @@ result_array[
function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id){
function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id)
{
$bonus_array = [];
if ($ver == "2.0"){
if ($ver == "2.0") {
$discount = round($elevator_knockdown_price / $elevator_list_price, 3); #銷售點數,取到小數點第三位。
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
switch ($contract_type) {
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_knockdown_price * 0.007;
@ -51,7 +52,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
case "general_customer":
switch ($elevator_type) {
#客梯(passenger)、貨梯(cargo)
#客梯(passenger)、貨梯(cargo)
case ($elevator_type == "passenger" or $elevator_type == "cargo"):
switch ($discount) {
case ($discount >= 1.0):
@ -69,7 +70,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
};
break;
#小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
#小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
case ($elevator_type == "dumbwaiter" or $elevator_type == "flatbase" or $elevator_type == "positive_drive"):
switch ($discount) {
case ($discount >= 1.0):
@ -93,7 +94,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
};
#營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20%
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.2), #金額
@ -102,7 +103,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.5), #金額
@ -111,7 +112,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.3), #金額
@ -120,7 +121,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
]);
#區域經理提成獎金水庫-----訂金已收款100%,發放總獎金50%
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
@ -129,7 +130,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
]);
#區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50%
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
@ -138,12 +139,12 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
]);
$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, #金額
@ -152,13 +153,11 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"error", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
};
return $result_array;
};
?>

109
wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php

@ -41,55 +41,55 @@ require_once("elevator_new_deal_bonus_v2_0.php");
#獎金測試
$examination_array = [
#錯誤版本
["1.0","strategy_customer","passenger",1000000,1000000,"M0001", "M0003"],
["1.0", "strategy_customer", "passenger", 1000000, 1000000, "M0001", "M0003"],
#戰略客戶(strategy_customer)
["2.0","strategy_customer","passenger",1000000,1000000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數100%
["2.0","strategy_customer","passenger",1000000,900000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數90%
["2.0","strategy_customer","passenger",1000000,750000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數75%
["2.0","strategy_customer","passenger",1000000,600000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數60%
["2.0","strategy_customer","cargo",1000000,1000000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數100%
["2.0","strategy_customer","cargo",1000000,900000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數90%
["2.0","strategy_customer","cargo",1000000,750000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數75%
["2.0","strategy_customer","cargo",1000000,600000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數60%
["2.0","strategy_customer","dumbwaiter",1000000,1000000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數100%
["2.0","strategy_customer","dumbwaiter",1000000,900000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數90%
["2.0","strategy_customer","dumbwaiter",1000000,720000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數75%
["2.0","strategy_customer","dumbwaiter",1000000,600000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數60%
["2.0","strategy_customer","flatbase",1000000,1000000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數100%
["2.0","strategy_customer","flatbase",1000000,900000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數90%
["2.0","strategy_customer","flatbase",1000000,720000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數75%
["2.0","strategy_customer","flatbase",1000000,600000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數60%
["2.0","strategy_customer","positive_drive",1000000,1000000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數100%
["2.0","strategy_customer","positive_drive",1000000,900000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數90%
["2.0","strategy_customer","positive_drive",1000000,720000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數75%
["2.0","strategy_customer","positive_drive",1000000,600000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數60%
["2.0", "strategy_customer", "passenger", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數100%
["2.0", "strategy_customer", "passenger", 1000000, 900000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數90%
["2.0", "strategy_customer", "passenger", 1000000, 750000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數75%
["2.0", "strategy_customer", "passenger", 1000000, 600000, "M0001", "M0003"], #戰略客戶、客梯、銷售點數60%
["2.0", "strategy_customer", "cargo", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數100%
["2.0", "strategy_customer", "cargo", 1000000, 900000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數90%
["2.0", "strategy_customer", "cargo", 1000000, 750000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數75%
["2.0", "strategy_customer", "cargo", 1000000, 600000, "M0001", "M0003"], #戰略客戶、貨梯、銷售點數60%
["2.0", "strategy_customer", "dumbwaiter", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數100%
["2.0", "strategy_customer", "dumbwaiter", 1000000, 900000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數90%
["2.0", "strategy_customer", "dumbwaiter", 1000000, 720000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數75%
["2.0", "strategy_customer", "dumbwaiter", 1000000, 600000, "M0001", "M0003"], #戰略客戶、小電梯、銷售點數60%
["2.0", "strategy_customer", "flatbase", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數100%
["2.0", "strategy_customer", "flatbase", 1000000, 900000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數90%
["2.0", "strategy_customer", "flatbase", 1000000, 720000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數75%
["2.0", "strategy_customer", "flatbase", 1000000, 600000, "M0001", "M0003"], #戰略客戶、平台梯、銷售點數60%
["2.0", "strategy_customer", "positive_drive", 1000000, 1000000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數100%
["2.0", "strategy_customer", "positive_drive", 1000000, 900000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數90%
["2.0", "strategy_customer", "positive_drive", 1000000, 720000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數75%
["2.0", "strategy_customer", "positive_drive", 1000000, 600000, "M0001", "M0003"], #戰略客戶、強驅、銷售點數60%
#一般客戶(general_customer)
["2.0","general_customer","passenger",1000000,1000000,"M0001", "M0003"], #一般客戶、客梯、銷售點數100%
["2.0","general_customer","passenger",1000000,900000,"M0001", "M0003"], #一般客戶、客梯、銷售點數90%
["2.0","general_customer","passenger",1000000,750000,"M0001", "M0003"], #一般客戶、客梯、銷售點數75%
["2.0","general_customer","passenger",1000000,600000,"M0001", "M0003"], #一般客戶、客梯、銷售點數60%
["2.0","general_customer","cargo",1000000,1000000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數100%
["2.0","general_customer","cargo",1000000,900000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數90%
["2.0","general_customer","cargo",1000000,750000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數75%
["2.0","general_customer","cargo",1000000,600000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數60%
["2.0","general_customer","dumbwaiter",1000000,1000000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數100%
["2.0","general_customer","dumbwaiter",1000000,900000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數90%
["2.0","general_customer","dumbwaiter",1000000,720000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數75%
["2.0","general_customer","dumbwaiter",1000000,600000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數60%
["2.0","general_customer","flatbase",1000000,1000000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數100%
["2.0","general_customer","flatbase",1000000,900000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數90%
["2.0","general_customer","flatbase",1000000,720000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數75%
["2.0","general_customer","flatbase",1000000,600000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數60%
["2.0","general_customer","positive_drive",1000000,1000000,"M0001", "M0003"], #一般客戶、強驅、銷售點數100%
["2.0","general_customer","positive_drive",1000000,900000,"M0001", "M0003"], #一般客戶、強驅、銷售點數90%
["2.0","general_customer","positive_drive",1000000,720000,"M0001", "M0003"], #一般客戶、強驅、銷售點數75%
["2.0","general_customer","positive_drive",1000000,600000,"M0001", "M0003"] #一般客戶、強驅、銷售點數60%
["2.0", "general_customer", "passenger", 1000000, 1000000, "M0001", "M0003"], #一般客戶、客梯、銷售點數100%
["2.0", "general_customer", "passenger", 1000000, 900000, "M0001", "M0003"], #一般客戶、客梯、銷售點數90%
["2.0", "general_customer", "passenger", 1000000, 750000, "M0001", "M0003"], #一般客戶、客梯、銷售點數75%
["2.0", "general_customer", "passenger", 1000000, 600000, "M0001", "M0003"], #一般客戶、客梯、銷售點數60%
["2.0", "general_customer", "cargo", 1000000, 1000000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數100%
["2.0", "general_customer", "cargo", 1000000, 900000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數90%
["2.0", "general_customer", "cargo", 1000000, 750000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數75%
["2.0", "general_customer", "cargo", 1000000, 600000, "M0001", "M0003"], #一般客戶、貨梯、銷售點數60%
["2.0", "general_customer", "dumbwaiter", 1000000, 1000000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數100%
["2.0", "general_customer", "dumbwaiter", 1000000, 900000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數90%
["2.0", "general_customer", "dumbwaiter", 1000000, 720000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數75%
["2.0", "general_customer", "dumbwaiter", 1000000, 600000, "M0001", "M0003"], #一般客戶、小電梯、銷售點數60%
["2.0", "general_customer", "flatbase", 1000000, 1000000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數100%
["2.0", "general_customer", "flatbase", 1000000, 900000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數90%
["2.0", "general_customer", "flatbase", 1000000, 720000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數75%
["2.0", "general_customer", "flatbase", 1000000, 600000, "M0001", "M0003"], #一般客戶、平台梯、銷售點數60%
["2.0", "general_customer", "positive_drive", 1000000, 1000000, "M0001", "M0003"], #一般客戶、強驅、銷售點數100%
["2.0", "general_customer", "positive_drive", 1000000, 900000, "M0001", "M0003"], #一般客戶、強驅、銷售點數90%
["2.0", "general_customer", "positive_drive", 1000000, 720000, "M0001", "M0003"], #一般客戶、強驅、銷售點數75%
["2.0", "general_customer", "positive_drive", 1000000, 600000, "M0001", "M0003"] #一般客戶、強驅、銷售點數60%
];
for($i = 0; $i<count($examination_array); $i++){
for ($i = 0; $i < count($examination_array); $i++) {
$result = elevator_new_deal_bonus_v2_0(
$examination_array[$i][0],
$examination_array[$i][1],
@ -99,18 +99,27 @@ for($i = 0; $i<count($examination_array); $i++){
$examination_array[$i][5],
$examination_array[$i][6]
);
$customer = [
'strategy_customer' => '戰略客戶',
'general_customer' => '一般客戶'
];
//作番機種($elevator_type):客梯(passenger)、貨梯(cargo)、小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
$elevator = [
"passenger" => "客梯",
"cargo" => "貨梯",
"dumbwaiter" => "小電梯",
"flatbase" => "平台踢",
"positive_drive" => "強驅"
];
echo "獎金版本:" . $result["ver"] . "<br>";
echo "計算結果:" . $result["result_status"] . "<br>";
echo "參數說明: " . $customer[$examination_array[$i][1]] . " 、 " . $elevator[$examination_array[$i][2]] . "、 作番表價:" . $examination_array[$i][3] . " 、 作番賣價: " . $examination_array[$i][4] . "、 營業員員工號:" . $examination_array[$i][5] . " 、 區域經理員工號:" . $examination_array[$i][6] . "<br>";
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] . "<br>";
for($j = 0; $j<count($result["bonus_array"]); $j++){
. $examination_array[$i][5] . " " . $examination_array[$i][6] . "<br>";
for ($j = 0; $j < count($result["bonus_array"]); $j++) {
echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " "
. $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["payment_schedul_due"] . " "
. $result["bonus_array"][$j]["payment_schedul_regulation"] . "<br>";
. $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["payment_schedul_due"] . " "
. $result["bonus_array"][$j]["payment_schedul_regulation"] . "<br>";
};
echo "-------------------------" . "<br>";
};
?>

2
wms/contract/api/T8api.php

@ -7,7 +7,7 @@ function T8salIncomeApply($data, $api_url)
// $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth();
// echo '<pre>';
// print_r(json_encode($data));
// print_r(json_encode($data, JSON_UNESCAPED_UNICODE));
// echo '</pre>';
$header = [
"CHI_Authorization :" . $validation,

15
wms/contract/api/getContractData.php

@ -186,28 +186,13 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont
foreach ($other_option_arr as $key => $option) {
if ($option['item_qty'] == $result['item_qty']) {
$result['option_other_price'] += intval($option['item_unit_price']);
// echo '1..';
// echo "<pre>";
// print_r($option['item_unit_price']);
// echo "</pre>";
} else if ($option['item_qty'] / $result['item_qty'] != 1) {
$item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數
$result['option_other_price'] += intval($option['item_unit_price']) * $item_qty;
// echo '2..';
// echo "<pre>";
// print_r(intval($option['item_unit_price']) . ' *' . $item_qty . '=' . intval($option['item_unit_price']) * $item_qty);
// echo "</pre>";
} else {
$result['option_other_price'] += $option['item_unit_price'] * intval($option['item_qty']);
// echo '
}
// echo '<pre>';
// print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
// echo '</pre>';
}
// print_r($result['option_other_price']);
// exit();
}

1
wms/contract/api/postContractData.php

@ -620,6 +620,7 @@ function T8insert($data, $facilityno, $depId)
"SPrice" => intval($elevator['sold_price']),
"SQuantity" => $SQuantity,
"ProjectId" => "$contractno",
"FromBillNo" => "$contractno",
"CU_MaterialId" => "$facility_no",
"CU_EstPayDate" => intval($payDay)
];

761
wms/contract/api/postNewContractData.php

@ -1,10 +1,16 @@
<meta charset="UTF-8">
<?php
// header("Content-Type: text/html; charset=utf-8");
// echo '你好';
// exit;
require_once("../conn.php");
// include_once("../../fun_global.php");
include_once("./getFacilityNo.php");
include_once("./getComboNo.php");
include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei');
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
@ -25,10 +31,13 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$qc = $_POST["qc"];
$contracttype = $_POST["contracttype"];
$elevators_nums = $_POST['nums'];
$elevators = json_decode($_POST['elevators'], true);
$elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], true);
$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 "<pre>";
// print_r($elevators_detail_arr);
// echo "</pre>";
// exit();
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$files_id = null;
@ -67,19 +76,131 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums));
echo json_encode($facilityno);
// $bonus_result = BounsCount($_POST, $conn, $facilityno);
// if (!empty($bonus_result) && $bonus_result['status'] == "2") {
// $fail_arr[] = '獎金計算錯誤,請再檢查或連繫資訊人員';
// // header("HTTP/1.1 422 Unprocessable Entity");
// echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE);
// exit();
// }
$bonus_result = BounsCount($_POST, $conn, $facilityno);
if (!empty($bonus_result) && $bonus_result['status'] == "2") {
$fail_arr[] = '獎金計算錯誤,請再檢查或連繫資訊人員';
// header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE);
exit();
}
T8Insert($_POST, $facilityno, $connT8);
exit();
$conn->beginTransaction();
//create account table
$accounttype = "A";
$accountid = $vat;
$pwd = "123";
$name = $customer;
$tel = $lm_tel ?? '';
$sql = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, creater, create_at)
VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address , :creater, :created_at)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->bindParam(':accountid', $contractno);
$stmt->bindParam(':pwd', $pwd);
$stmt->bindParam(':name', $customer);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':creater', $created_by);
$stmt->bindParam(':created_at', $created_at);
$stmt->execute();
// exit();
//create table Wipwholestatus (作番大日程)
foreach ($elevators_detail_arr as $key => $value) {
$facilityno = $facilityno[$key]; // 作番
$weight = $value['item_weight']; // 載重
$person = $value['person']; // 人乘
$floor = $value['floor']; // 樓層
$open = $value['item_op']; // 開門方式
$speed = $value['speed']; //速度
$qc = $value['qc'];
$facility_kind = $value['spec']; //型號
$contract_arrival_date = $value['contract_arrival_date']; //到工地日期
$site_manager = $value['manage'];
$warehouseid = $value['warehouseid'];
$sql = "INSERT INTO Wipwholestatus
(contract_type,contractno,salesid,custom,accountid,site_manager,warehouseid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,area_no,address,contract_arrival_date,real_contract_arrival_date,qc_official_type,creater,create_at) VALUES
('A',:contractno,:salesid,:custom,:accountid,:site_manager,:warehouseid,:facilityno,:weight,:numberofpassenger,:numberoffloor,:opentype,:speed,:facility_kind,:area_no,:address,:contract_arrival_date,:real_contract_arrival_date,:qc_official_type,:creater,:create_at)";
// $sql = "INSERT INTO Wipwholestatus
// (contract_type,contractno,salesid,custom,accountid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,address,contract_arrival_date,qc_official_type,creater,create_at) VALUES
// ('A','$contractno','$salesman','$customer','$customer','$facilityno','$weight','$person','$floor','$open','$speed','$facility_kind','$address','$contract_arrival_date','$qc','$created_by','$created_at')";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':salesid', $salesman);
$stmt->bindParam(':custom', $customer);
$stmt->bindParam(':accountid', $customer);
$stmt->bindParam(':site_manager', $site_manager);
$stmt->bindParam(':warehouseid', $warehouseid);
$stmt->bindParam(':facilityno', $facilityno);
$stmt->bindParam(':weight', $weight);
$stmt->bindParam(':numberofpassenger', $person);
$stmt->bindParam(':numberoffloor', $floor);
$stmt->bindParam(':opentype', $open);
$stmt->bindParam(':speed', $speed);
$stmt->bindParam(':facility_kind', $facility_kind);
$stmt->bindParam(':area_no', $area_no);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':contract_arrival_date', $contract_arrival_date);
$stmt->bindParam(':real_contract_arrival_date', $contract_arrival_date);
$stmt->bindParam(':qc_official_type', $qc);
$stmt->bindParam(':creater', $created_by);
$stmt->bindParam(':create_at', $created_at);
$stmt->execute();
$lastId = $conn->lastInsertId();
// echo "<pre>";
// print_r($lastId);
// echo "</pre>";
if (!empty($lastId)) {
echo '123';
// 寫入待簽程狀態 A (營業)
do_wws_assign1($salesman, $lastId, 'A', $conn);
// // 寫入待簽程狀態 G (工務)
do_wws_assign1($warehouseid, $lastId, 'G', $conn);
}
// create table worksite (戰情室)
$latitude = $value['latitude'];
$longitude = $value['longitude'];
$sql = "INSERT INTO worksite
(latitude,longitude,facilitynum,facilityno,address,buildcompany,process,status,marchintotime,creater,create_at)VALUES
(:latitude,:longitude,'1',:facilityno,:address,:bulidcompany,'進行中','未工勘',:marchintotime,:creater,:create_at)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':latitude', $latitude);
$stmt->bindParam(':longitude', $longitude);
$stmt->bindParam(':facilityno', $facilityno);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':bulidcompany', $customer);
$stmt->bindParam(':marchintotime', $contract_arrival_date);
$stmt->bindParam(':creater', $created_by);
$stmt->bindParam(':create_at', $created_at);
$stmt->execute();
// create table schedule
$contract_begin_date = '';
$contract_end_date = ''; // 一年
$comboNo = new CreateComboNo('em', $contract_begin_date, $contract_end_date);
$comboArr = json_decode($comboNo->getComboNo(), true);
foreach ($comboArr as $combo) {
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':facilityno', $facility_no);
$stmt->bindParam(':combono', $combo[0]);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':duedate', $combo[1]);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$result = $stmt->execute();
}
}
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":accountid", $salesman);
@ -125,7 +246,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->bindParam(':file_size', $file['size']);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $created_by);
// $stmt->execute();
$stmt->execute();
} else {
throw new PDOException('檔案上傳失敗:' . $msg);
}
@ -158,7 +279,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $created_by);
$stmt->bindParam(":qc", $qc);
// $stmt->execute();
$stmt->execute();
$result = $conn->commit();
@ -194,6 +315,15 @@ function T8Insert($data, $facilityno, $connT8)
$createTime = str_replace('-', '', $createAt);
$signing_date = intval(str_replace("-", '', $data['signing_date'])); //簽訂日期
// echo
// $pay_kind = [
// '1' => '簽約',
// '2' => '二次款',
// '3' => '貨抵工地',
// '4' => '材料其他',
// '5' => '試車完工', //安裝完畢
// '6' => '交車' //交車
// ];
$pay_kind = [
'1' => '簽約',
'2' => '二次款',
@ -228,7 +358,6 @@ function T8Insert($data, $facilityno, $connT8)
$stmt->bindParam(':TaxNo', $vat);
$stmt->bindParam(':EnterpriseName', $partyA); //企業名稱
$stmt->bindParam(':ContactAddress', $partyAaddress);
// $stmt->bindParam(':EMail', $email);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
@ -236,8 +365,8 @@ function T8Insert($data, $facilityno, $connT8)
$sql = "INSERT INTO comCustomer
(OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId)
VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')";
(OrgId,BizPartnerTypeId,ConditionId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId)
VALUES('1000','10','TWD','0008',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')";
// $sql = "INSERT INTO comCustomer
// (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId)
// VALUES('1000','10','TWD','$contractno','$salesman','$user_id',1,'$partyAaddress','$createTime','35')";
@ -253,6 +382,7 @@ function T8Insert($data, $facilityno, $connT8)
// // 若客戶資料不為空,更新該客戶資訊。
$sql = "UPDATE comCustomer SET
PersonId=:PersonId,
ConditionId='0008',
InvoiceAddress=:InvoiceAddress,
LastOperatorId=:LastOperatorId,
LastOperateTime=:LastOperateTime
@ -306,176 +436,208 @@ function T8Insert($data, $facilityno, $connT8)
$stmt->bindParam(':CreatorId', $user_id);
$stmt->execute();
}
foreach ($elevators as $index => $elevator) {
$count = 1;
// 產品集成維護
$facility_no = $facilityno[$index];
$MaterialName = "$partyA($facility_no)";
$sql = "INSERT INTO comMaterial
$sql = "SELECT * FROM salSalesOrder WHERE BillNo = :BillNo";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BillNo', $contractno);
$contractT8 = $stmt->fetch(PDO::FETCH_ASSOC);
if (empty($contractT8)) {
foreach ($elevators as $index => $elevator) {
$count = 1;
// 產品集成維護
$facility_no = $facilityno[$index];
$MaterialName = "$partyA($facility_no)";
$contract_arrival_a = $elevator['contract_arrival_date'];
$sql = "INSERT INTO comMaterial
(FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime,IsInUsed)
VALUES ('1000',:MaterialId,'10','A',:CreatorId,:CreateTime,1)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comMaterialGroup
$sql = "INSERT INTO comMaterialGroup
(MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
VALUES ('10',:MaterialId,:MaterialName,'A',1,'SET',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':MaterialName', $MaterialName);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comMaterialPurchases
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':MaterialName', $MaterialName);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comMaterialPurchases
(Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO plsMaterialPlanData
$sql = "INSERT INTO plsMaterialPlanData
(PlanRangeId,MaterialId,FOrgId,MaterialTypeId,CreatorId,CreateTime,DefaultDemandOrg) VALUES
(1000,:MaterialId,1000,10,:CreatorId,:CreateTime,1000)
";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comMaterialSales
$sql = "INSERT INTO comMaterialSales
(OrgId,MAterialTypeId,MaterialId,CurrId,SUnitId,SupplyOrgId,CreatorId,CreateTime,IsInUsed) VALUES
(1000,10,:MaterialId,'TWD','SET',1000,:CreatorId,:CreateTime,1)
";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
// 階段收款資訊
$salOrderStagePay_row = [];
$equipment_total = 0;
$install_total = 0;
$equipment_total = $pay_arr['equipment_total'];
$install_total = $pay_arr['install_total'];
$count_a = 0;
$count_month = 1;
foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) {
if ($detail['kind'] == 3) {
$PlanPayDate = $contract_arrival_a;
} else if ($detail['kind'] > 3) {
$PlanPayDate = date("Y-m-d", strtotime($contract_arrival_a . '+' . $count_month . ' month'));
$count_month++;
} else {
$PlanPayDate = $signing_date;
$count_a++;
if ($count_a == 1) {
$PlanPayDate = date("Y-m-d", strtotime($signing_date . '+' . $count_a . ' month'));
}
}
$contract_arrival_date = intval(str_replace("-", '', $PlanPayDate)); //貨到工地日
$PayStage = $pay_kind[$detail['kind']];
$PlanPercentage = intval($detail['pay_scale']) / 100;
$rows = [
"PayStage" => "$PayStage", //收款階段
"PlanPercentage" => $PlanPercentage, //計劃收款比例(%)
"PlanPayAmt" => $detail['amount'], //計劃收款金額
"PlanPayDate" => $contract_arrival_date, //計劃收款日期 1.第一筆都是簽約日
"BillNo" => "$contractno",
"RowCode" => $key + 1,
"RowNo" => $key + 1,
"UnWriteOffOAmount" => $detail['amount'] //未核銷金額
];
$salOrderStagePay_row[] = $rows;
}
// 階段收款資訊
$salOrderStagePay_row = [];
$equipment_total = 0;
$install_total = 0;
$equipment_total = $pay_arr['equipment_total'];
$install_total = $pay_arr['install_total'];
foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) {
$PayStage = $pay_kind[$detail['kind']];
$PlanPercentage = intval($detail['pay_scale']) / 100;
$rows = [
"PayStage" => "$PayStage", //收款階段
"PlanPercentage" => $PlanPercentage, //計劃收款比例(%)
"PlanPayAmt" => $detail['amount'], //計劃收款金額
"PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
"BillNo" => "$contractno",
"RowCode" => $key + 1,
"RowNo" => $key + 1,
"UnWriteOffOAmount" => $detail['amount'] //未核銷金額
// 設備
$row1 = [
"TaxId" => "ST005",
"RequirementDate" => $signing_date, //出貨日期
"ConsignmentDate" => $signing_date, //發貨日期
"BillNo" => "$contractno", //合約號
"RowCode" => $count, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => $equipment_total, //交易價格
"CU_MaterialId" => $facility_no
];
$count++;
// 安裝
$row2 = [
"TaxId" => "ST005",
"RequirementDate" => $signing_date, //出貨日期
"ConsignmentDate" => $signing_date, //發貨日期
"BillNo" => "$contractno", //合約號
"RowCode" => $count, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => $install_total, //交易價格
"CU_MaterialId" => $facility_no
];
$salOrderStagePay_row[] = $rows;
$count++;
// 產品(作番)
$row3 = [
"TaxId" => "ST005",
"RequirementDate" => $signing_date, //出貨日期
"ConsignmentDate" => $signing_date, //發貨日期
"BillNo" => "$contractno", //合約號
"RowCode" => $count, //全部筆數排列
"ItemType" => 0,
"MaterialId" => "$facility_no", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 0, //交易價格
"CU_MaterialId" => $facility_no // 歸屬作番號
];
$count++;
$SubOrder_row[] = $row1;
$SubOrder_row[] = $row2;
$SubOrder_row[] = $row3;
$count++;
}
// 設備
$row1 = [
$MainSalesOrder_row = [
"BillNo" => "$contractno", //合約單號
"BillDate" => $signing_date, //簽約日期
"TypeId" => "SO", //
"FOrgId" => "1000",
"OrgId" => "1000",
"ModeId" => "M", // T汰改 M新梯
"BizPartnerId" => "$contractno", //客戶代碼
"CurrId" => "TWD",
"CurrOAmount" => 1,
"CurrLAmount" => 1,
"PersonId" => "$salesman", //業務人員
"DueToId" => "$contractno", //債務方
"TradeConditionId" => "",
"TaxId" => "ST005",
"RequirementDate" => $signing_date, //出貨日期
"ConsignmentDate" => $signing_date, //發貨日期
"BillNo" => "$contractno", //合約號
"RowCode" => $count, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => $equipment_total //交易價格
"CreditorCompId" => "1001",
"CreditorOrgId" => "1000",
"CreatorId" => "$user_id"
// "CompId" => "1001",
// "CreditorCurrOAmount" => 1,
// "CreditorCurrLAmount" => 1
];
$count++;
// 安裝
$row2 = [
"TaxId" => "ST005",
"RequirementDate" => $signing_date, //出貨日期
"ConsignmentDate" => $signing_date, //發貨日期
"BillNo" => "$contractno", //合約號
"RowCode" => $count, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => $install_total //交易價格
$MainSalesOrder = [
"name" => "MainSalesOrder",
'rows' => [$MainSalesOrder_row]
];
$count++;
// 產品(作番)
$row3 = [
"TaxId" => "ST005",
"RequirementDate" => $signing_date, //出貨日期
"ConsignmentDate" => $signing_date, //發貨日期
"BillNo" => "$contractno", //合約號
"RowCode" => $count, //全部筆數排列
"ItemType" => 0,
"MaterialId" => "$facility_no", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 0 //交易價格
$SubOrder = [
"name" => "SubOrder",
"rows" => $SubOrder_row
];
$salOrderStagePay = [
"name" => "salOrderStagePay",
"rows" => $salOrderStagePay_row
];
$count++;
$SubOrder_row[] = $row1;
$SubOrder_row[] = $row2;
$SubOrder_row[] = $row3;
$count++;
}
$MainSalesOrder_row = [
"BillNo" => "$contractno", //合約單號
"BillDate" => $signing_date, //簽約日期
"TypeId" => "SO", //
"FOrgId" => "1000",
"OrgId" => "1000",
"ModeId" => "M", // T汰改 M新梯
"BizPartnerId" => "$contractno", //客戶代碼
"CurrId" => "TWD",
"CurrOAmount" => 1,
"CurrLAmount" => 1,
"PersonId" => "$user_id", //業務人員
"DueToId" => "$contractno", //債務方
"TradeConditionId" => "",
"TaxId" => "ST005",
"CreditorCompId" => "1001",
"CreditorOrgId" => "1000",
// "CompId" => "1001",
// "CreditorCurrOAmount" => 1,
// "CreditorCurrLAmount" => 1
];
$MainSalesOrder = [
"name" => "MainSalesOrder",
'rows' => [$MainSalesOrder_row]
];
$SubOrder = [
"name" => "SubOrder",
"rows" => $SubOrder_row
];
$salOrderStagePay = [
"name" => "salOrderStagePay",
"rows" => [$salOrderStagePay_row]
];
$API_body = [];
$API_body[] = $MainSalesOrder;
$API_body[] = $SubOrder;
$API_body[] = $salOrderStagePay;
echo "<pre>";
print_r(json_encode($API_body, JSON_UNESCAPED_UNICODE));
echo "</pre>";
$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData";
$result = T8salIncomeApply($API_body, $api_url);
echo "<pre>";
print_r($result);
echo "</pre>";
$API_body = [];
$API_body[] = $MainSalesOrder;
$API_body[] = $SubOrder;
$API_body[] = $salOrderStagePay;
echo "<pre>";
print_r(json_encode($API_body, JSON_UNESCAPED_UNICODE));
echo "</pre>";
$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData";
$result = T8salIncomeApply($API_body, $api_url);
// echo "<pre>";
// print_r($result);
// echo "</pre>";
if ($result['Status'] == 'Fails' || $result['Status'] == 'Error') {
echo $result['ErrorMsg'];
}
} else {
echo '資料已新增過,請洽資訊人員';
}
$connT8->commit();
} catch (PDOException $e) {
$connT8->rollback();
@ -487,153 +649,168 @@ function T8Insert($data, $facilityno, $connT8)
function BounsCount($data, $conn, $facilityno)
{
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit;
require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php");
$dailyNecessities = [
'MAE100' => 'passenger', //小機房
'MAM200' => 'passenger', //無機房
'MAH100' => 'dumbwaiter', //小電梯
'MAQ100' => 'positive_drive', //強趨梯
'MAF100' => 'cargo', //貨梯
'MAP100' => 'flatbase', // 平台踢
];
$contractType = [
'1' => 'strategy_customer',
'2' => 'general_customer'
];
$signing_date = $data['signing_date'];
$bonus_v1_0_date = '2024-01-02';
$bonus_v2_0_date = '2024-01-03';
$contract_type = $data['contract_type'];
$total = $data['price_total'];
$type = $contractType[$contract_type]; //戰略客戶 or 一般客戶
// $elevator_knockdown_price = $data['price_total']; //受價總額
$elevators = json_decode($data['elevators_detail_arr'], true);
$contract_no = $data['contractno'];
$salesman = $data['salesman'];
$manager = $data['manager'];
$contract_kind = 1;
$create_id = $data['user_id'];
$create_at = date("Y-m-d H:i:s");
$status = 1;
$result_bonus = [];
$result_bonus_arr = [];
if ($signing_date <= $bonus_v1_0_date) {
$ver = '1.0';
foreach ($elevators as $key => $elevator) {
$elevator_knockdown_price = $elevator['elevator_price']; // 單台電梯售價
$elevator_list_price = $elevator['option_other_price'] + $elevator['option_price'] + $elevator['elevator_price']; //牌價
$result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager);
$facility_no = $facilityno[$key];
$bonus_json = [
'contract_type' => $type,
'total' => $elevator_list_price,
'fee_per_st' => $elevator_knockdown_price
];
try {
require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php");
$dailyNecessities = [
'MAE100' => 'passenger', //小機房
'MAM200' => 'passenger', //無機房
'MAH100' => 'dumbwaiter', //小電梯
'MAQ100' => 'positive_drive', //強趨梯
'MAF100' => 'cargo', //貨梯
'MAP100' => 'flatbase', // 平台踢
];
$contractType = [
'1' => 'strategy_customer',
'2' => 'general_customer'
];
$signing_date = $data['signing_date'];
$bonus_v1_0_date = '2024-01-02';
$bonus_v2_0_date = '2024-01-03';
$contract_type = $data['contract_type'];
$total = $data['price_total'];
$type = $contractType[$contract_type]; //戰略客戶 or 一般客戶
// $elevator_knockdown_price = $data['price_total']; //受價總額
$elevators = json_decode($data['elevators_detail_arr'], true);
$contract_no = $data['contractno'];
$salesman = $data['salesman'];
$manager = $data['manager'];
$contract_kind = 1;
$create_id = $data['user_id'];
$create_at = date("Y-m-d H:i:s");
$status = 1;
$result_bonus = [];
$result_bonus_arr = [];
if ($signing_date <= $bonus_v1_0_date) {
$ver = '1.0';
foreach ($elevators as $key => $elevator) {
$elevator_knockdown_price = $elevator['elevator_price']; // 單台電梯售價
$elevator_list_price = $elevator['option_other_price'] + $elevator['option_price'] + $elevator['elevator_price']; //牌價
$result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager);
$facility_no = $facilityno[$key];
$bonus_json = [
'contract_type' => $type,
'total' => $elevator_list_price,
'fee_per_st' => $elevator_knockdown_price
];
if (!empty($result_bonus)) {
if ($result_bonus['result_status'] != "error") {
foreach ($result_bonus['bonus_array'] as $i => $result) {
$bonus_type = explode('-', $result['bonus_type']);
$pay_man_type = $bonus_type[0]; //發放類別
$bonus_kind = $bonus_type[1];
$amount = $result['bonus_amount']; //獎金水庫
$bonus_receiver = $result['bonus_receiver']; //發放人員
$bonus_json['payment_schedul_due'] = $result['payment_schedul_due'];
$bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation'];
$bonus_json['bonus_kind'] = $bonus_kind;
$a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE);
$sql = "INSERT INTO bonus
if (!empty($result_bonus)) {
if ($result_bonus['result_status'] != "error") {
foreach ($result_bonus['bonus_array'] as $i => $result) {
$bonus_type = explode('-', $result['bonus_type']);
$pay_man_type = $bonus_type[0]; //發放類別
$bonus_kind = $bonus_type[1];
$amount = $result['bonus_amount']; //獎金水庫
$bonus_receiver = $result['bonus_receiver']; //發放人員
$bonus_json['payment_schedul_due'] = $result['payment_schedul_due'];
$bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation'];
$bonus_json['bonus_kind'] = $bonus_kind;
$a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE);
$sql = "INSERT INTO bonus
(bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,status,bonus_json,create_id,create_at) VALUES
($pay_man_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$bonus_receiver',$status,'$a','$create_id','$create_at')
";
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt = $conn->prepare($sql);
$stmt->execute();
}
$request = [
"status" => "1",
"data" => "Success"
];
return $request;
}
$request = [
"status" => "1",
"data" => "Success"
"status" => "2",
"data" => "create_bonus_error"
];
return $request;
}
$request = [
"status" => "2",
"data" => "create_bonus_error"
];
return $request;
}
}
} else if ($signing_date >= $bonus_v2_0_date) {
$ver = '2.0';
foreach ($elevators as $key => $elevator) {
$elevator_type = $dailyNecessities[$elevator['spec']];
$elevator_list_price = $elevator['option_other_price'] + $elevator['option_price'] + $elevator['elevator_price'];
$elevator_knockdown_price = $elevator['elevator_price'];
$commission_fee = $elevator['commission_fee'];
$result_bonus = elevator_new_deal_bonus_v2_0(
$ver,
$type,
$elevator_type,
$elevator_list_price,
$elevator_knockdown_price,
$salesman,
$manager
);
// echo '<pre>';
// print_r($result_bonus);
// echo '</pre>';
$facility_no = $facilityno[$key];
$bonus_json = [
'contract_type' => $type,
'total' => $elevator_list_price,
'fee_per_st' => $elevator_knockdown_price
];
if (!empty($result_bonus)) {
if ($result_bonus['result_status'] != "error") {
foreach ($result_bonus['bonus_array'] as $i => $result) {
$bonus_type = explode('-', $result['bonus_type']);
$pay_man_type = $bonus_type[0]; //發放類別
$bonus_kind = $bonus_type[1];
$amount = $result['bonus_amount']; //獎金水庫
$bonus_receiver = $result['bonus_receiver']; //發放人員
$bonus_json['payment_schedul_due'] = $result['payment_schedul_due'];
$bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation'];
$bonus_json['bonus_kind'] = $bonus_kind;
$a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE);
$sql = "INSERT INTO bonus
} else if ($signing_date >= $bonus_v2_0_date) {
$ver = '2.0';
foreach ($elevators as $key => $elevator) {
$option_other_price = !empty($elevator['option_other_price']) ? intval($elevator['option_other_price']) : 0;
$elevator_type = $dailyNecessities[$elevator['spec']];
$elevator_list_price = $option_other_price + $elevator['option_price'] + $elevator['elevator_price'];
$elevator_knockdown_price = $elevator['elevator_price'];
$commission_fee = $elevator['commission_fee'];
$result_bonus = elevator_new_deal_bonus_v2_0(
$ver,
$type,
$elevator_type,
$elevator_list_price,
$elevator_knockdown_price,
$salesman,
$manager
);
// echo '<pre>';
// print_r($result_bonus);
// echo '</pre>';
$facility_no = $facilityno[$key];
$bonus_json = [
'contract_type' => $type,
'total' => $elevator_list_price,
'fee_per_st' => $elevator_knockdown_price
];
if (!empty($result_bonus)) {
if ($result_bonus['result_status'] != "error") {
foreach ($result_bonus['bonus_array'] as $i => $result) {
$bonus_type = explode('-', $result['bonus_type']);
$pay_man_type = $bonus_type[0]; //發放類別
$bonus_kind = $bonus_type[1];
$amount = $result['bonus_amount']; //獎金水庫
$bonus_receiver = $result['bonus_receiver']; //發放人員
$bonus_json['payment_schedul_due'] = $result['payment_schedul_due'];
$bonus_json['payment_schedul_regulation'] = $result['payment_schedul_regulation'];
$bonus_json['bonus_kind'] = $bonus_kind;
$a = json_encode($bonus_json, JSON_UNESCAPED_UNICODE);
$sql = "INSERT INTO bonus
(bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,status,bonus_json,create_id,create_at) VALUES
($pay_man_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$bonus_receiver',$status,'$a','$create_id','$create_at')
";
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt = $conn->prepare($sql);
$stmt->execute();
}
}
$request = [
"status" => "1",
"data" => "Success"
];
} else {
$request = [
"status" => "2",
"data" => "create_bonus_error"
];
}
$request = [
"status" => "1",
"data" => "Success"
];
} else {
$request = [
"status" => "2",
"data" => "create_bonus_error"
];
}
}
}
return $request;
try {
return $request;
} catch (PDOException $e) {
header("HTTP/1.1 500 Internal Server Error");
die('Error!:' . $e->getMessage());
}
}
function do_wws_assign1($user_id, $form_id, $flow_code, $conn)
{
$tds = date("Y-m-d H:i:s");
$sql = "select appwms.nextval('form_key') form_key";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$form_key = $result['form_key'];
$sql = "INSERT INTO flow (system_id, flow_id, form_key, form_id,flow_code) VALUES ('wws', 'wws01', '$form_key', '$form_id','$flow_code');";
$stmt = $conn->prepare($sql);
$stmt->execute();
$sql = "INSERT INTO subflow (form_key, seq, current_assigner, create_date) VALUES ('$form_key', '1', '$user_id', '$tds');";
$stmt = $conn->prepare($sql);
$stmt->execute();
}

407
wms/contract/api/test copy.json

@ -3,22 +3,23 @@
"name": "MainSalesOrder",
"rows": [
{
"BillNo": "M24020076",
"BillDate": 20240305,
"BillNo": "M23110121",
"BillDate": 20240313,
"TypeId": "SO",
"FOrgId": "1000",
"OrgId": "1000",
"ModeId": "M",
"BizPartnerId": "M24020076",
"BizPartnerId": "M23110121",
"CurrId": "TWD",
"CurrOAmount": 1,
"CurrLAmount": 1,
"PersonId": "M0225",
"DueToId": "M24020076",
"PersonId": "M0042",
"DueToId": "M23110121",
"TradeConditionId": "",
"TaxId": "ST005",
"CreditorCompId": "1001",
"CreditorOrgId": "1000"
"CreditorOrgId": "1000",
"CreatorId": "M0225"
}
]
},
@ -27,87 +28,371 @@
"rows": [
{
"TaxId": "ST005",
"RequirementDate": 20240305,
"ConsignmentDate": 20240305,
"BillNo": "M24020076",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 910000
"SPrice": 3904000,
"CU_MaterialId": "4MH00836"
},
{
"TaxId": "ST005",
"RequirementDate": 20240305,
"ConsignmentDate": 20240305,
"BillNo": "M24020076",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 390000
"SPrice": 976000,
"CU_MaterialId": "4MH00836"
},
{
"TaxId": "ST005",
"RequirementDate": 20240305,
"ConsignmentDate": 20240305,
"BillNo": "M24020076",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MW00705",
"MaterialId": "4MH00836",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0
"SPrice": 0,
"CU_MaterialId": "4MH00836"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00837"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00837"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00837",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00837"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00838"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00838"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00838",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00838"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00839"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00839"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00839",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00839"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00840"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00840"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00840",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00840"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00841"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00841"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00841",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00841"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00842"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00842"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00842",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00842"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 3904000,
"CU_MaterialId": "4MH00843"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 976000,
"CU_MaterialId": "4MH00843"
},
{
"TaxId": "ST005",
"RequirementDate": 20240313,
"ConsignmentDate": 20240313,
"BillNo": "M23110121",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MH00843",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MH00843"
}
]
},
{
"name": "salOrderStagePay",
"rows": [
[
{
"PayStage": "簽約",
"PlanPercentage": 0.2,
"PlanPayAmt": 260000,
"PlanPayDate": 20240101,
"BillNo": "M24020076",
"RowCode": 0,
"RowNo": 0,
"UnWriteOffOAmount": 260000
},
{
"PayStage": "貨抵工地",
"PlanPercentage": 0.5,
"PlanPayAmt": 650000,
"PlanPayDate": 20240101,
"BillNo": "M24020076",
"RowCode": 1,
"RowNo": 1,
"UnWriteOffOAmount": 650000
},
{
"PayStage": "試車完工",
"PlanPercentage": 0.2,
"PlanPayAmt": 260000,
"PlanPayDate": 20240101,
"BillNo": "M24020076",
"RowCode": 2,
"RowNo": 2,
"UnWriteOffOAmount": 260000
},
{
"PayStage": "交車",
"PlanPercentage": 0.1,
"PlanPayAmt": 130000,
"PlanPayDate": 20240101,
"BillNo": "M24020076",
"RowCode": 3,
"RowNo": 3,
"UnWriteOffOAmount": 130000
}
]
{
"PayStage": "簽約",
"PlanPercentage": 0.2,
"PlanPayAmt": 976000,
"PlanPayDate": 20240413,
"BillNo": "M23110121",
"RowCode": 1,
"RowNo": 1,
"UnWriteOffOAmount": 976000
},
{
"PayStage": "二次款",
"PlanPercentage": 0.4,
"PlanPayAmt": 1952000,
"PlanPayDate": 20240313,
"BillNo": "M23110121",
"RowCode": 2,
"RowNo": 2,
"UnWriteOffOAmount": 1952000
},
{
"PayStage": "貨抵工地",
"PlanPercentage": 0.2,
"PlanPayAmt": 976000,
"PlanPayDate": 20241104,
"BillNo": "M23110121",
"RowCode": 3,
"RowNo": 3,
"UnWriteOffOAmount": 976000
},
{
"PayStage": "試車完工",
"PlanPercentage": 0.1,
"PlanPayAmt": 488000,
"PlanPayDate": 20241204,
"BillNo": "M23110121",
"RowCode": 4,
"RowNo": 4,
"UnWriteOffOAmount": 488000
},
{
"PayStage": "交車",
"PlanPercentage": 0.1,
"PlanPayAmt": 488000,
"PlanPayDate": 20250104,
"BillNo": "M23110121",
"RowCode": 5,
"RowNo": 5,
"UnWriteOffOAmount": 488000
}
]
}
]

2
wms/contract/api/test.json

@ -27,7 +27,7 @@
]
},
{
//salSalesOrderDetail
// salSalesOrderDetail
"name": "SubOrder",
"rows": [
{

127
wms/contract/api/testT8API.php

@ -1,9 +1,5 @@
<?php
// [
// {
// //salSalesOrder
// "name": "MainSalesOrder",
// "rows": [
// {
// "BillNo": "Z001", //合約單號
// "BillDate": 20210420, //簽約日期
@ -70,27 +66,55 @@ require_once("../../T8_Authorization_from_bpm.php");
$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData";
$validation = get_Auth();
// $header = [
// "CHI_Authorization :" . $validation,
// "GroupId:TEST"
// ];
// $url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=M24020032";
// $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" => "M24020076", //合約單號
"BillNo" => "$contract_no", //合約單號
"BillDate" => 20210420, //簽約日期
"TypeId" => "SO", //
"FOrgId" => "1000",
"OrgId" => "1000",
"ModeId" => "M", // T汰改 M新梯
"BizPartnerId" => "M24020076", //客戶代碼
"BizPartnerId" => "$contract_no", //客戶代碼
"CurrId" => "TWD",
"CurrOAmount" => 1,
"CurrLAmount" => 1,
"PersonId" => "M0225", //業務人員
"DueToId" => "M24020076", //債務方
"PersonId" => "M0177", //業務人員
"DueToId" => "$contract_no", //債務方
"TradeConditionId" => "",
"TaxId" => "ST005",
"CreditorCompId" => "1001",
"CreditorOrgId" => "1000",
// "CompId" => "1001",
// "CreditorCurrOAmount" => 1,
// "CreditorCurrLAmount" => 1
"CreatorId" => "M0225"
];
// //salSalesOrderDetail
// $SubOrder_row = [];
@ -104,13 +128,13 @@ for ($i = 0; $i < 3; $i++) {
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "M24020076", //合約號
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 50000 //交易價格
"SPrice" => 100000 //交易價格
];
}
if ($i == 1) {
@ -122,25 +146,21 @@ for ($i = 0; $i < 3; $i++) {
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "M24020076", //合約號
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 700000 //交易價格
"SPrice" => 650000 //交易價格
];
}
if ($i == 2) {
$row = [
// "SupplyCompId" => "1001",
// "SupplyOrgId" => "1000",
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "M24020076", //合約號
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 0,
"MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
@ -152,65 +172,14 @@ for ($i = 0; $i < 3; $i++) {
$SubOrder_row[] = $row;
}
// // $salOrderStagePay_row = [];
// // // for ($i = 0; $i < 2; $i) {
// // // if ($i == 0) {
// // // $row = [
// // // "BillNo" => "M24010201",
// // // "RowCode" => 1,
// // // "RowNo" => 1,
// // // "PayStage" => "簽約", //收款階段
// // // "PlanPercentage" => 0.10, //計劃收款比例(%)
// // // "PlanPayAmt" => 100000, //計劃收款金額
// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
// // // "UnWriteOffOAmount" => 100000 //未核銷金額
// // // ];
// // // }
// // // if ($i == 1) {
// // // $row = [
// // // "BillNo" => "M24010201",
// // // "RowCode" => 1,
// // // "RowNo" => 1,
// // // "PayStage" => "貨抵工地", //收款階段
// // // "PlanPercentage" => 0.40, //計劃收款比例(%)
// // // "PlanPayAmt" => 100000, //計劃收款金額
// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
// // // "UnWriteOffOAmount" => 100000 //未核銷金額
// // // ];
// // // }
// // // if ($i == 2) {
// // // $row = [
// // // "BillNo" => "M24010201",
// // // "RowCode" => 1,
// // // "RowNo" => 1,
// // // "PayStage" => "試車完工", //收款階段
// // // "PlanPercentage" => 0.30, //計劃收款比例(%)
// // // "PlanPayAmt" => 100000, //計劃收款金額
// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
// // // "UnWriteOffOAmount" => 100000 //未核銷金額
// // // ];
// // // }
// // // if ($i == 3) {
// // // $row = [
// // // "BillNo" => "M24010201",
// // // "RowCode" => 1,
// // // "RowNo" => 1,
// // // "PayStage" => "交車", //收款階段
// // // "PlanPercentage" => 0.20, //計劃收款比例(%)
// // // "PlanPayAmt" => 100000, //計劃收款金額
// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
// // // "UnWriteOffOAmount" => 100000 //未核銷金額
// // // ];
// // // }
// // // $salOrderStagePay_row[] = $row;
// // // }
$salOrderStagePay_row = [];
$roww = [
"PayStage" => "簽約", //收款階段
"PlanPercentage" => 0.5, //計劃收款比例(%)
"PlanPayAmt" => 375000, //計劃收款金額
"PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
"BillNo" => "M24020076",
"BillNo" => "$contract_no",
"RowCode" => 1,
"RowNo" => 1,
"UnWriteOffOAmount" => 375000 //未核銷金額
@ -220,12 +189,14 @@ $roww2 = [
"PlanPercentage" => 0.5,
"PlanPayAmt" => 375000,
"PlanPayDate" => 20240101,
"BillNo" => "M24020076",
"BillNo" => "$contract_no",
"RowCode" => 2,
"RowNo" => 2,
"UnWriteOffOAmount" => 375000
];
$salOrderStagePay_row[] = $roww;
$salOrderStagePay_row[] = $roww2;
$MainSalesOrder = [
"name" => "MainSalesOrder",
@ -250,9 +221,9 @@ $APIbody[] = $salOrderStagePay;
// print_r($data);
// echo "</pre>";
// echo "<pre>";
// print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
// echo "</pre>";
echo "<pre>";
print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
echo "</pre>";
// exit();
$header = [

14
wms/contract/contract-newelevator-input.php

@ -134,7 +134,17 @@ $persons = array_map(function ($person) {
</td>
</tr>
<tr>
<td style="vertical-align: middle">區域</td>
<td>
<select id="area_no" name="area_no" x-model="data.area_no">
<option value="">請選擇</option>
<option value="N">北區</option>
<option value="Y">宜蘭</option>
<option value="T">桃園</option>
<option value="C">中區</option>
<option value="K">南區</option>
</select>
</td>
</tr>
</tbody>
</template>
@ -187,7 +197,7 @@ $persons = array_map(function ($person) {
<tr>
<td style="vertical-align: middle">QC和官檢</td>
<td>
<select class="" id="qc" x-model="data.qc">
<select class="" id="qc" x-model="elevator.qc">
<option value="">請選擇QC或官檢</option>
<option value="Q">只需QC</option>
<option value="O">只需官檢</option>

13
wms/contract/js/alpine.js

@ -829,6 +829,8 @@ const contractNewInput = () => {
elevators_detail_arr: [], // 電梯台數 Array
pay_arr: [], //電梯付款種類
nums: 0, //電梯數量
area_no: 'T',
contract_arrival_date: ''
},
step: 1,
isLoading: false,
@ -868,14 +870,15 @@ const contractNewInput = () => {
this.data.elevators_detail_arr[i].longitude = ''; // 緯度
this.data.elevators_detail_arr[i].manage = ''; // 工地負責人
this.data.elevators_detail_arr[i].qc = ''; // QC和官檢
this.data.elevators_detail_arr[i].contract_arrival_date = ''; //合約交期(到工地)
this.data.elevators_detail_arr[i].contract_arrival_date = this.data.contract_arrival_date; //合約交期(到工地)
// this.data.elevators_detail_arr[i].area_no = ''; //區域
}
this.step = 3;
this.isLoading = false;
} else if (this.step == 3) {
console.log(this.data.elevators_detail_arr);
this.step = 4;
this.isLoading = false;
// this.step = 4;
// this.isLoading = false;
}
},
getContractDate() {
@ -889,7 +892,7 @@ const contractNewInput = () => {
return
}
if (!this.customize) {
console.log(res.data);
console.log(res.data.customer);
this.data.customer = res.data.company
this.data.manager = res.data.manager
this.data.vat = res.data.uscc
@ -904,6 +907,7 @@ const contractNewInput = () => {
this.data.elevators_detail_arr = res.data.elevators_detail_arr;
this.data.nums = res.data.nums;
this.data.pay_arr = res.data.pay_arr;
this.data.contract_arrival_date = res.data.facilitok_date;
}
this.step = 2
this.isLoading = false
@ -919,6 +923,7 @@ const contractNewInput = () => {
form.append('customer', this.data.customer);
form.append('manager', this.data.manager);
form.append('vat', this.data.vat);
form.append('area_no', this.data.area_no);
form.append('case_name', this.data.case_name);
form.append('linkman', this.data.linkman);
form.append('lm_tel', this.data.lm_tel);

Loading…
Cancel
Save