15 changed files with 1789 additions and 1069 deletions
@ -0,0 +1,162 @@ |
|||
<?php |
|||
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; |
|||
$pay_arr = !empty($data['pay_arr']) ? json_decode($data['pay_arr'], true) : []; //電梯 |
|||
$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) { |
|||
$other_price = !empty($elevator['option_other_price']) ? $elevator['option_other_price'] : 0; |
|||
$elevator_knockdown_price = $elevator['elevator_price']; // 單台電梯售價 |
|||
$elevator_list_price = $other_price + $elevator['option_price'] + $elevator['elevator_price']; //牌價 |
|||
$result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $pay_arr['elevotor_pay_detail'], $salesman, $manager); |
|||
$facility_no = $facilityno[$key]; |
|||
$bonus_json = [ |
|||
'contract_type' => $type, |
|||
'total' => $elevator_list_price, |
|||
'fee_per_st' => $elevator_knockdown_price |
|||
]; |
|||
echo "<pre>"; |
|||
print_r($result_bonus); |
|||
echo "</pre>"; |
|||
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 = $result['bonus_type']; //發放類別 |
|||
// $bonus_kind = $bonus_type[1]; |
|||
$amount = round($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'] = $result['payment_schedul_due']; |
|||
$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(); |
|||
} |
|||
} else { |
|||
$status = 0; |
|||
} |
|||
} else { |
|||
$status = 0; |
|||
} |
|||
} |
|||
|
|||
if ($status == 0) { |
|||
$response = [ |
|||
"status" => "2", |
|||
"data" => "create_bonus_error" |
|||
]; |
|||
} else { |
|||
$response = [ |
|||
"status" => "1", |
|||
"data" => "Success" |
|||
]; |
|||
} |
|||
return $response; |
|||
} 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, |
|||
$pay_arr['elevotor_pay_detail'], |
|||
$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 = $result['bonus_type']; //發放類別 |
|||
$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'] = $result['payment_schedul_due']; |
|||
$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(); |
|||
} |
|||
} else { |
|||
$status = 0; |
|||
} |
|||
} else { |
|||
$status = 0; |
|||
} |
|||
} |
|||
if ($status == 0) { |
|||
$response = [ |
|||
"status" => "2", |
|||
"data" => "create_bonus_error" |
|||
]; |
|||
} else { |
|||
$response = [ |
|||
"status" => "1", |
|||
"data" => "Success" |
|||
]; |
|||
} |
|||
} |
|||
return $response; |
|||
} catch (PDOException $e) { |
|||
header("HTTP/1.1 500 Internal Server Error"); |
|||
die('Error!:' . $e->getMessage()); |
|||
} |
|||
} |
@ -0,0 +1,369 @@ |
|||
<?php |
|||
function T8Insert($data, $facilityno, $connT8) |
|||
{ |
|||
// try { |
|||
// 引入銷售訂單 API |
|||
require_once("./T8API.php"); |
|||
|
|||
$contractno = $data['contractno']; |
|||
$partyA = $data['customer']; |
|||
$phone = $data['lm_tel']; |
|||
$vat = $data['vat']; |
|||
$partyAaddress = $data['address']; |
|||
$user_id = $data['user_id']; |
|||
$salesman = $data['salesman']; |
|||
$createAt = date("Y-m-dH-i-s"); |
|||
|
|||
|
|||
$elevators = !empty($data['elevators_detail_arr']) ? json_decode($data['elevators_detail_arr'], true) : []; //電梯 |
|||
$pay_arr = !empty($data['pay_arr']) ? json_decode($data['pay_arr'], true) : []; //電梯 |
|||
|
|||
$createTime = str_replace('-', '', $createAt); |
|||
$signing_date = intval(str_replace("-", '', $data['signing_date'])); //簽訂日期 |
|||
// echo |
|||
// $pay_kind = [ |
|||
// '1' => '簽約', |
|||
// '2' => '二次款', |
|||
// '3' => '貨抵工地', |
|||
// '4' => '材料其他', |
|||
// '5' => '試車完工', //安裝完畢 |
|||
// '6' => '交車' //交車 |
|||
// ]; |
|||
|
|||
$pay_kind = [ |
|||
'1' => '簽約', |
|||
'2' => '二次款', |
|||
'3' => '貨抵工地', |
|||
'4' => '材料其他', |
|||
'5' => '試車完工', //安裝完畢 |
|||
'6' => '交車' //交車 |
|||
]; |
|||
|
|||
$sql = "SELECT * FROM comCustomer |
|||
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,CreatorId,CreateTime,BizPartnerTypeId) |
|||
VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:CreatorId,:CreateTime,'10')"; |
|||
// $sql = "INSERT INTO comBusinessPartner |
|||
// (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) |
|||
// VALUES('$contractno','$partyA',1,'TW','$phone',99999999,'$vat', '$partyA','$partyAaddress','$user_id',$createTime,'10')"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':BizPartnerId', $contractno); |
|||
$stmt->bindParam(':BizPartnerName', $partyA); //客戶名稱 |
|||
$stmt->bindParam(':WorkTelNo', $phone); |
|||
$stmt->bindParam(':TaxNo', $vat); |
|||
$stmt->bindParam(':EnterpriseName', $partyA); //企業名稱 |
|||
$stmt->bindParam(':ContactAddress', $partyAaddress); |
|||
$stmt->bindParam(':CreatorId', $user_id); |
|||
$stmt->bindParam(':CreateTime', $createTime); |
|||
$stmt->execute(); |
|||
|
|||
|
|||
$sql = "INSERT INTO comCustomer |
|||
(OrgId,BizPartnerTypeId,ConditionId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId)VALUES |
|||
('1000','10','0008','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; |
|||
// $sql = "INSERT INTO comCustomer |
|||
// (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) |
|||
// VALUES('1000','10','TWD','$contractno','$salesman','$user_id',1,'$partyAaddress','$createTime','35')"; |
|||
$stmt = $connT8->prepare($sql); |
|||
|
|||
$stmt->bindParam(':BizPartnerId', $contractno); |
|||
$stmt->bindParam(':PersonId', $salesman); |
|||
$stmt->bindParam(':CreatorId', $user_id); |
|||
$stmt->bindParam(':InvoiceAddress', $partyAaddress); |
|||
$stmt->bindParam(':CreateTime', $createTime); |
|||
$stmt->execute(); |
|||
exit(); |
|||
} else { |
|||
// 若客戶資料不為空,更新該客戶資訊。 |
|||
$sql = "UPDATE comCustomer SET |
|||
PersonId=:PersonId, |
|||
ConditionId='0008', |
|||
CurrId='TWD', |
|||
InvoiceAddress=:InvoiceAddress, |
|||
LastOperatorId=:LastOperatorId, |
|||
LastOperateTime=:LastOperateTime |
|||
WHERE BizPartnerId=:BizPartnerId |
|||
"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':PersonId', $salesman); |
|||
$stmt->bindParam(':InvoiceAddress', $partyAaddress); |
|||
$stmt->bindParam(':LastOperatorId', $user_id); |
|||
$stmt->bindParam(':LastOperateTime', $createTime); |
|||
$stmt->bindParam(':BizPartnerId', $contractno); |
|||
$stmt->execute(); |
|||
|
|||
|
|||
$sql = "UPDATE comBusinessPartner SET |
|||
BizPartnerName=:BizPartnerName, |
|||
WorkTelNo=:WorkTelNo, |
|||
TaxNo=:TaxNo, |
|||
EnterpriseName=:EnterpriseName, |
|||
ContactAddress=:ContactAddress, |
|||
LastOperatorId=:LastOperatorId, |
|||
LastOperateTime=:LastOperateTime |
|||
WHERE BizPartnerId = :BizPartnerId |
|||
"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':BizPartnerName', $partyA); |
|||
$stmt->bindParam(':WorkTelNo', $phone); |
|||
$stmt->bindParam(':TaxNo', $vat); |
|||
$stmt->bindParam(':EnterpriseName', $partyA); |
|||
$stmt->bindParam(':ContactAddress', $partyAaddress); |
|||
// $stmt->bindParam(':EMail', $email); |
|||
$stmt->bindParam(':LastOperatorId', $user_id); |
|||
$stmt->bindParam(':LastOperateTime', $createTime); |
|||
$stmt->bindParam(':BizPartnerId', $contractno); |
|||
$stmt->execute(); |
|||
} |
|||
|
|||
$sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':ProjectId', $contractno); |
|||
$stmt->execute(); |
|||
$resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
if (empty($resultProject)) { |
|||
//新增於 comProject。合約 table |
|||
$sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,CreateTime,CreatorId,IsInUsed) |
|||
VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':ProjectId', $contractno); |
|||
$stmt->bindParam(':ProjectName', $partyA); |
|||
$stmt->bindParam(':CreateTime', $createTime); |
|||
$stmt->bindParam(':CreatorId', $user_id); |
|||
$stmt->execute(); |
|||
} |
|||
$sql = "SELECT * FROM salSalesOrder WHERE BillNo = :BillNo"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':BillNo', $contractno); |
|||
$contractT8 = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
if (empty($contractT8)) { |
|||
|
|||
foreach ($elevators as $index => $elevator) { |
|||
|
|||
$count = 1; |
|||
// 產品集成維護 |
|||
$facility_no = $facilityno[$index]; |
|||
$MaterialName = "$partyA($facility_no)"; |
|||
$contract_arrival_a = $elevator['contract_arrival_date']; |
|||
|
|||
$sql = "SELECT * FROM comMaterial WHERE MaterialId = '$facility_no'"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->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(); |
|||
|
|||
$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['pay_kind'] == 3) { |
|||
$PlanPayDate = $contract_arrival_a; |
|||
} else if ($detail['pay_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['pay_kind']]; |
|||
$PlanPercentage = intval($detail['pay_scale']) / 100; |
|||
$rows = [ |
|||
"PayStage" => "$PayStage", //收款階段 |
|||
"PlanPercentage" => $PlanPercentage, //計劃收款比例(%) |
|||
"PlanPayAmt" => $detail['pay_amount'], //計劃收款金額 |
|||
"PlanPayDate" => $contract_arrival_date, //計劃收款日期 1.第一筆都是簽約日 |
|||
"BillNo" => "$contractno", |
|||
"RowCode" => $key + 1, |
|||
"RowNo" => $key + 1, |
|||
"UnWriteOffOAmount" => $detail['pay_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 "<pre>"; |
|||
print_r(json_encode($API_body, JSON_UNESCAPED_UNICODE)); |
|||
echo "</pre>"; |
|||
|
|||
// $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALSALESORDER/PostERPData'; //正式區 |
|||
$api_url = "http://60.244.87.101:880/twWebAPI/V1/SALSALESORDER/PostERPData"; //測試區 |
|||
|
|||
$result = T8salIncomeApply($API_body, $api_url); |
|||
echo "<pre>"; |
|||
print_r($result); |
|||
echo "</pre>"; |
|||
if (!empty($result) && ($result['Status'] == 'Fails' || $result['Status'] == 'Error')) { |
|||
$Error_msg = $result['ErrorMsg']; |
|||
echo "<script>alert('$Error_msg')</script>"; |
|||
exit(); |
|||
// echo $result['ErrorMsg']; |
|||
// echo "</script>"; |
|||
} |
|||
} else { |
|||
echo '資料已新增過,請洽資訊人員'; |
|||
// exit(); |
|||
} |
|||
// $connT8->commit(); |
|||
// } catch (PDOException $e) { |
|||
// $connT8->rollback(); |
|||
// header("HTTP/1.1 500 Internal Server Error"); |
|||
// die('Error!:' . $e->getMessage()); |
|||
// } |
|||
} |
@ -1,43 +1,115 @@ |
|||
[ |
|||
{ |
|||
"apply_key": "11111111", |
|||
"register_code": "B32510261185", |
|||
"elevator_brand": "1", |
|||
"elevator_kind": "E", |
|||
"spec": "MAH100", |
|||
"weight": "450", |
|||
"speed": "45.00", |
|||
"stop": "3", |
|||
"floors": "3", |
|||
"persons": "6", |
|||
"elevator_num": "0", |
|||
"useful_years": "106", |
|||
"last_check_date": "1", |
|||
"speed_governors_check_expense": "0", |
|||
"maintain_times": "1", |
|||
"is_m1_bundle": "N", |
|||
"maintainance": "B", |
|||
"maintain_months": "12", |
|||
"maintain_period": "1", |
|||
"stand_price": "1250.00", |
|||
"contract_price": "1250.00", |
|||
"sold_price": 1250, |
|||
"commission_expense": null, |
|||
"management_expense": null, |
|||
"annual_survey_expense": "0.00", |
|||
"service_expense": 0, |
|||
"cmstatus": "Y", |
|||
"updated_at": null, |
|||
"creater": null, |
|||
"created_at": "2024-02-26 15:24:23", |
|||
"discount": 100, |
|||
"latitude": "112", |
|||
"longitude": "11", |
|||
"takecertificatedate": "112", |
|||
"opendoor": "2PCO", |
|||
"useful_date": "113-01-01", |
|||
"bonus_verson": "2.0", |
|||
"manager": "M0029", |
|||
"regular_contract_manger_id": "M0054" |
|||
"name": "MainSalesOrder", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "M24020076", |
|||
"BillDate": 20240306, |
|||
"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": 20240306, |
|||
"ConsignmentDate": 20240306, |
|||
"BillNo": "M24020076", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 910000, |
|||
"CU_MaterialId": "4MW00001" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240306, |
|||
"ConsignmentDate": 20240306, |
|||
"BillNo": "M24020076", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 390000, |
|||
"CU_MaterialId": "4MW00001" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240306, |
|||
"ConsignmentDate": 20240306, |
|||
"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": 20240406, |
|||
"BillNo": "M24020076", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"UnWriteOffOAmount": 260000 |
|||
}, |
|||
{ |
|||
"PayStage": "貨抵工地", |
|||
"PlanPercentage": 0.5, |
|||
"PlanPayAmt": 650000, |
|||
"PlanPayDate": 20240306, |
|||
"BillNo": "M24020076", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"UnWriteOffOAmount": 650000 |
|||
}, |
|||
{ |
|||
"PayStage": "試車完工", |
|||
"PlanPercentage": 0.2, |
|||
"PlanPayAmt": 260000, |
|||
"PlanPayDate": 20240306, |
|||
"BillNo": "M24020076", |
|||
"RowCode": 3, |
|||
"RowNo": 3, |
|||
"UnWriteOffOAmount": 260000 |
|||
}, |
|||
{ |
|||
"PayStage": "交車", |
|||
"PlanPercentage": 0.1, |
|||
"PlanPayAmt": 130000, |
|||
"PlanPayDate": 20240306, |
|||
"BillNo": "M24020076", |
|||
"RowCode": 4, |
|||
"RowNo": 4, |
|||
"UnWriteOffOAmount": 130000 |
|||
} |
|||
] |
|||
} |
|||
] |
@ -0,0 +1,247 @@ |
|||
<?php |
|||
include('../header.php'); |
|||
require_once('./conn.php'); |
|||
$sql = "SELECT * FROM employee WHERE depart_no IN ('320','311','312','313','314','315','511','512','513','514','515') "; |
|||
$stmt = $conn->prepare($sql); |
|||
// $stmt->bindParam(':depart_no', $depart_no); |
|||
$stmt->execute(); |
|||
$contractSalesman = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
// echo '<pre>'; |
|||
// print_r($contractSalesman); |
|||
// echo '</pre>'; |
|||
?> |
|||
|
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="./semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script src="./js/alpine.js"></script> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
<script src="./js/jquery/jquery-3.1.1.min.js"></script> |
|||
<script src="./semantic/dist/semantic.min.js"></script> |
|||
|
|||
<div class="renovate_input" x-data="renovateInput"> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data"> |
|||
<input type="hidden" name="form_name" value="main_form"> |
|||
<div> |
|||
<table class="table table-borderd query-table table-striped table-bordered display compact" style="width:99%; margin-left:.5%"> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style="text-align:center">汰改合約入力</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<template x-if="step==1"> |
|||
<tbody style="font-weight:bolder; margin:botton 20px"> |
|||
<tr> |
|||
<td style="vertical-align:middle;">合約號</td> |
|||
<td colspan="6"> |
|||
<input type="text" class="form-control" @keyup="nextStepKeyupFn($event)" name="contract_no" x-model="data.contract_no"> |
|||
</td> |
|||
<td colspan="1" style="vertical-align:middle"></td> |
|||
</tr> |
|||
</tbody> |
|||
</template> |
|||
<template x-if="step==1"> |
|||
<tbody style="font-weight:bolder; margin:botton 20px" x-show="step==1"> |
|||
<tr> |
|||
<td colspan="7" style="vertical-align:middle;border-right:0px;"> |
|||
<h4>業務確認項</h4> |
|||
</td> |
|||
<td class="text-right" style="border-left:0px"> |
|||
<button type="button" id="btn_back" class="btn btn-default" onclick="location.reload()">返回</button> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align:middle">立約人</td> |
|||
<td> |
|||
<input type="text" x-model="data.customer"> |
|||
</td> |
|||
<td style="vertical-align:middle">營業員</td> |
|||
<td> |
|||
<!-- <input x-show="data.salesman" type="text" x-model="data.salesman" name="promiser"> --> |
|||
<select x-model="data.salesman" class="ui fluid search dropdown" name="salesman"> |
|||
<option value="">------</option> |
|||
<?php foreach ($contractSalesman as $salesman) : ?> |
|||
<option value="<?= $salesman['employee_no'] ?>"><?= $salesman['employee_no'] ?>--<?= $salesman['name'] ?></option> |
|||
<?php endforeach; ?> |
|||
</select> |
|||
</td> |
|||
<td style="vertical-align:middle">地址</td> |
|||
<td> |
|||
<input type="text" x-model="data.address"> |
|||
</td> |
|||
<td></td> |
|||
</tr> |
|||
<!-- 客戶款別分別如何分期 --> |
|||
<div> |
|||
<tr> |
|||
<td colspan='8' style="vertical-align:middle ">款別分期</td> |
|||
</tr> |
|||
|
|||
|
|||
<tr> |
|||
<td colspan='1'>付款辦法</td> |
|||
<td colspan='1'>款別</td> |
|||
<td colspan='1'>比例%</td> |
|||
<td colspan='2'>金額</td> |
|||
<td colspan='1'>繳款方式(月)</td> |
|||
</tr> |
|||
|
|||
|
|||
<tr> |
|||
<td rowspan="3">材料</td> |
|||
<td>1、訂金</td> |
|||
<td> |
|||
<input type="text"> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text"> |
|||
</td> |
|||
<td> |
|||
<select x-model=data.paykind[0] @change="totalFn()"> |
|||
<template x-for="pay in data.payarr" :key="pay"> |
|||
<!-- <option value=""></option> --> |
|||
<option x-text="pay"></option> |
|||
</template> |
|||
</select> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>2、二次款</td> |
|||
<td> |
|||
<input type="text"> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text"> |
|||
</td> |
|||
<td> |
|||
<select x-model=data.paykind[1] @change="totalFn()"> |
|||
<template x-for="pay in data.payarr" :key="pay"> |
|||
<!-- <option value=""></option> --> |
|||
<option x-text="pay"></option> |
|||
</template> |
|||
</select> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>3、貨到工地款</td> |
|||
<td> |
|||
<input type="text"> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text"> |
|||
</td> |
|||
<td> |
|||
<select x-model=data.paykind[2] @change="totalFn()"> |
|||
<template x-for="pay in data.payarr" :key="pay"> |
|||
<!-- <option value=""></option> --> |
|||
<option x-text="pay"></option> |
|||
</template> |
|||
</select> |
|||
</td> |
|||
</tr> |
|||
|
|||
|
|||
<tr> |
|||
<td rowspan="3">安裝</td> |
|||
<td>5、安裝完畢款</td> |
|||
<td> |
|||
<input type="text"> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text"> |
|||
</td> |
|||
<td> |
|||
<select x-model=data.paykind[4] @change="totalFn()"> |
|||
<template x-for="pay in data.payarr" :key="pay"> |
|||
<!-- <option value=""></option> --> |
|||
<option x-text="pay"></option> |
|||
</template> |
|||
</select> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>6、驗收款</td> |
|||
<td> |
|||
<input type="text"> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text"> |
|||
</td> |
|||
<td> |
|||
<select x-model=data.paykind[5] @change="totalFn()"> |
|||
<template x-for="pay in data.payarr" :key="pay"> |
|||
<!-- <option value=""></option> --> |
|||
<option x-text="pay"></option> |
|||
</template> |
|||
</select> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>7、其他</td> |
|||
<td> |
|||
<input type="text"> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text"> |
|||
</td> |
|||
<td> |
|||
<select x-model=data.paykind[6] @change="totalFn()"> |
|||
<template x-for="pay in data.payarr" :key="pay"> |
|||
<!-- <option value=""></option> --> |
|||
<option :value="pay" x-text="pay"></option> |
|||
</template> |
|||
</select> |
|||
</td> |
|||
</tr> |
|||
|
|||
<tr> |
|||
<td colspan="2">合計</td> |
|||
<td> |
|||
<input type="text" disabled> |
|||
</td> |
|||
<td colspan="2"> |
|||
<input type="text" disabled> |
|||
</td> |
|||
<td> |
|||
<input type="text" x-model="data.total" disabled> |
|||
</td> |
|||
</tr> |
|||
</div> |
|||
</tbody> |
|||
|
|||
</template> |
|||
</table> |
|||
|
|||
<button x-show="step==3" @click="save()" type="button" class="btn btn-primary btn-lg pull-right savebutton" :disabled="isLoading"> |
|||
<template x-if="!isLoading"> |
|||
<span>存檔</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<span class="loader"></span> |
|||
</template> |
|||
</button> |
|||
|
|||
<button x-show="step<2" @click="nextStepFn()" class="btn btn-primary btn-lg pull-right savebutton" :disabled="isLoading"> |
|||
<template x-if="!isLoading"> |
|||
<span>下一步</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<span class="loader"></span> |
|||
</template> |
|||
</button> |
|||
|
|||
<button x-show="step>1" @click="preStepFn()" class="btn btn-primary btn-lg pull-right savebutton" :disabled="isLoading"> |
|||
<template x-if="!isLoading"> |
|||
<span>上一步</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<span class="loaders"></span> |
|||
</template> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
Loading…
Reference in new issue