|
|
@ -1,16 +1,18 @@ |
|
|
|
<meta charset="UTF-8"> |
|
|
|
|
|
|
|
<?php |
|
|
|
header("Content-Type: text/html; charset=utf-8"); |
|
|
|
require_once("../conn.php"); |
|
|
|
// require_once("../connt8.php"); |
|
|
|
include_once("./getFacilityNo.php"); |
|
|
|
include_once("./getComboNo.php"); |
|
|
|
include_once("./upload_chk.php"); |
|
|
|
include_once("../../class/Cmail.php"); |
|
|
|
|
|
|
|
ini_set('date.timezone', 'Asia/Taipei'); |
|
|
|
//保養簽回 |
|
|
|
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { |
|
|
|
// try { |
|
|
|
$mail = new Cmail(); |
|
|
|
$created_at = date('Y-m-d H:i:s'); |
|
|
|
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
|
|
|
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|
|
@ -39,6 +41,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null; |
|
|
|
$contract_type = !empty($_POST['contract_type']) ? $_POST['contract_type'] : null; |
|
|
|
$signing_date = !empty($_POST['signing_date']) ? $_POST['signing_date'] : null; |
|
|
|
$token = !empty($_POST['token']) ? $_POST['token'] : ''; |
|
|
|
|
|
|
|
$sql = "SELECT * FROM account WHERE accountid = '$salesman'"; |
|
|
|
$stmt = $conn->prepare($sql); |
|
|
@ -66,11 +69,9 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
foreach ($elevators as $elevator) { |
|
|
|
$facility_arr[] = $dailyNecessities[$elevator['spec']]; |
|
|
|
} |
|
|
|
echo json_encode($facility_arr); |
|
|
|
// echo json_encode($facility_arr); |
|
|
|
// 電梯做番號 |
|
|
|
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); |
|
|
|
echo json_encode($facilityno); |
|
|
|
T8insert($_POST, $facilityno, $depId, $connT8); |
|
|
|
// exit(); |
|
|
|
// if ($user_id == 'M0225') { |
|
|
|
// echo '<pre>'; |
|
|
@ -79,7 +80,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
// exit(); |
|
|
|
// } |
|
|
|
$fail_arr = []; |
|
|
|
if ($contractno === '') return $fail_arr[] = '合約號為必填'; |
|
|
|
// if ($contractno === '') return $fail_arr[] = '合約號為必填'; |
|
|
|
if ($total_price == '') $fail_arr[] = '合約總價為必填'; |
|
|
|
if ($salesman == '') $fail_arr[] = '營業員為必填'; |
|
|
|
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填'; |
|
|
@ -104,9 +105,11 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
// if ($mcycle == '') $fail_arr[] = '保養頻率為必填'; |
|
|
|
if (count($fail_arr) > 0) { |
|
|
|
header("HTTP/1.1 422 Unprocessable Entity"); |
|
|
|
echo json_encode($fail_arr); |
|
|
|
echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
// T8insert($_POST, $facilityno, $depId, $connT8); |
|
|
|
|
|
|
|
/// 獎金計算 |
|
|
|
$aaa = bonusCreate($_POST, $facilityno, $conn); |
|
|
|
if (!empty($aaa) && $aaa['status'] == 2) { |
|
|
@ -143,7 +146,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$stmt->bindParam(':repairerid', $repairerid); |
|
|
|
$stmt->bindParam(':creater', $creater); |
|
|
|
$stmt->bindParam(':create_at', $create_at); |
|
|
|
// $stmt->execute(); |
|
|
|
$stmt->execute(); |
|
|
|
|
|
|
|
//create contract table |
|
|
|
|
|
|
@ -179,7 +182,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$stmt->bindParam(':end_date', $end_date); |
|
|
|
$stmt->bindParam(':creater', $creater); |
|
|
|
$stmt->bindParam(':create_at', $create_at); |
|
|
|
// $stmt->execute(); |
|
|
|
$stmt->execute(); |
|
|
|
|
|
|
|
//create facility table |
|
|
|
// $createFacilityNo = new CreateFacilityNo(); |
|
|
@ -211,16 +214,17 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
// // } |
|
|
|
// echo json_encode($facilityno); |
|
|
|
// echo '-------'; |
|
|
|
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; |
|
|
|
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid AND accounttype IN ('B','E','M','W')"; |
|
|
|
$stmt = $conn->prepare($sql_str); |
|
|
|
$stmt->bindParam(':accountid', $mworker); |
|
|
|
$stmt->execute(); |
|
|
|
$worker = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
|
$customerid = $vat; |
|
|
|
$define = "B"; |
|
|
|
$repairtype = $mtype; |
|
|
|
$repairerid = $mworker; |
|
|
|
$repairername = $worker['name']; |
|
|
|
$define = "B"; |
|
|
|
$repairername = !empty($worker) ? $worker['name'] : ''; |
|
|
|
|
|
|
|
foreach ($elevators as $idx => $elevator) { |
|
|
|
// 民國年轉換西元年 |
|
|
|
$ROCuseful_date = $elevator['useful_date']; |
|
|
@ -254,18 +258,25 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$stmt->bindParam(':area', $area); |
|
|
|
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); |
|
|
|
$stmt->bindParam(':licensedate', $ADuseful_date); |
|
|
|
// $result = $stmt->execute(); |
|
|
|
$result = $stmt->execute(); |
|
|
|
} |
|
|
|
$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; |
|
|
|
$stmt = $conn->prepare($sql); |
|
|
|
$stmt->execute(); |
|
|
|
$user_detail = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
|
|
|
|
|
//create schedule table |
|
|
|
|
|
|
|
//create schedule table |
|
|
|
// $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); |
|
|
|
// $comboArr = json_decode($comboNo->getComboNo(), true); |
|
|
|
foreach ($facilityno as $no) { |
|
|
|
foreach ($facilityno as $key => $no) { |
|
|
|
$comboNo = new CreateComboNo($maintain_times[$elevator['maintain_times']], $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)'; |
|
|
|
$sql_str = 'INSERT INTO schedule |
|
|
|
(contractno, facilityno, combono, repairerid, repairername,customer_login_name, duedate, creater, create_at) VALUES |
|
|
|
(:contractno, :facilityno, :combono, :repairerid, :repairername, :customer_login_name,:duedate, :creater, :create_at)'; |
|
|
|
$stmt = $conn->prepare($sql_str); |
|
|
|
$stmt->bindParam(':contractno', $contractno); |
|
|
|
$stmt->bindParam(':facilityno', $no); |
|
|
@ -273,10 +284,38 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$stmt->bindParam(':repairerid', $repairerid); |
|
|
|
$stmt->bindParam(':repairername', $repairername); |
|
|
|
$stmt->bindParam(':duedate', $combo[1]); |
|
|
|
$stmt->bindParam(':customer_login_name', $customer); |
|
|
|
$stmt->bindParam(':creater', $creater); |
|
|
|
$stmt->bindParam(':create_at', $create_at); |
|
|
|
// $result = $stmt->execute(); |
|
|
|
$result = $stmt->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// $regular_contract_manger_id = $elevators[$idx]['regular_contract_manger_id']; |
|
|
|
// $sql = "SELECT * FROM account WHERE accountid = '' "; |
|
|
|
$regular_contract_manger_id = !empty($elevators[$key]['regular_contract_manger_id']) ? $elevators[$key]['regular_contract_manger_id'] : ''; |
|
|
|
// if ($regular_contract_manger_id != '') { |
|
|
|
$sql = "SELECT * FROM account WHERE accountid = '$regular_contract_manger_id' "; |
|
|
|
$stmt = $conn->prepare($sql); |
|
|
|
$stmt->execute(); |
|
|
|
$regular_contract_manger_mail = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
|
|
|
|
|
|
|
|
|
$mail_title = "保養計畫 : 合約號:" . $contractno . "作番號:" . $no . "-營業經理提交至設計階段"; |
|
|
|
$mail_content = "保養計畫 : 合約號:" . $contractno . "作番號:" . $no . "-營業經理提交至設計階段 <a href='https://www.masada.com.tw/wms/schedule-index.php?contractno=$contractno&facilityno=$no&token=$token'>點我</a>"; |
|
|
|
// exit(); |
|
|
|
$mail->sendx( |
|
|
|
$mail_title, |
|
|
|
$mail_content, |
|
|
|
[ |
|
|
|
// [$user_id, $user_detail['email']], |
|
|
|
// [$regular_contract_manger_id, $regular_contract_manger_mail['mail']], |
|
|
|
['M0225', 'lkmd555@masada.com.tw'] |
|
|
|
], |
|
|
|
"永佳捷科技" |
|
|
|
); |
|
|
|
// echo 'send'; |
|
|
|
// } |
|
|
|
} |
|
|
|
// create contract_b_signed_back table |
|
|
|
$contract_type = $mtype; |
|
|
@ -383,14 +422,17 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$stmt->bindParam(':payType', $payType); |
|
|
|
$stmt->bindParam(':signing_date', $signing_date); |
|
|
|
|
|
|
|
// $stmt->execute(); |
|
|
|
$stmt->execute(); |
|
|
|
|
|
|
|
// T8insert($_POST, $facilityno); |
|
|
|
|
|
|
|
$conn->commit(); |
|
|
|
|
|
|
|
header('Content-Type: application/json'); |
|
|
|
$jsonData = json_encode($files); |
|
|
|
|
|
|
|
$conn->commit(); |
|
|
|
|
|
|
|
// Cmail->sendx; |
|
|
|
// } catch (PDOException $e) { |
|
|
|
// $conn->rollback(); |
|
|
|
// http_response_code(404); |
|
|
@ -411,19 +453,20 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
$customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱 |
|
|
|
$phone = !empty($data['phone']) ? $data['phone'] : null; //客戶電話 |
|
|
|
$vat = !empty($data['vat']) ? $data['vat'] : null; //統編 |
|
|
|
// $email = !empty($data['email']) ? $data['email'] : null; |
|
|
|
$salesman = !empty($data['salesman']) ? $data['salesman'] : null; // 銷售人員 |
|
|
|
$partyA = !empty($data['customer']) ? $data['customer'] : null; //客戶名稱 / 業務聯絡人 |
|
|
|
// $partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址 |
|
|
|
$contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : null; |
|
|
|
$contract_end_date = !empty($data['contract_end_date']) ? $data['contract_end_date'] : null; |
|
|
|
// $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量 |
|
|
|
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯 |
|
|
|
// $area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。 |
|
|
|
$payType = !empty($data['payType']) ? $data['payType'] : null; |
|
|
|
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|
|
|
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : ''; |
|
|
|
$invoice_address = !empty($_POST['invoice_address']) ? $_POST['invoice_address'] : ''; |
|
|
|
$total_price = !empty($_POST['total_price']) ? intval($_POST['total_price']) : 0; |
|
|
|
// $email = !empty($data['email']) ? $data['email'] : null; |
|
|
|
// $partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址 |
|
|
|
// $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量 |
|
|
|
// $area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。 |
|
|
|
|
|
|
|
// $connT8->beginTransaction(); |
|
|
|
|
|
|
@ -456,7 +499,6 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
$stmt->bindParam(':TaxNo', $vat); |
|
|
|
$stmt->bindParam(':EnterpriseName', $invoice); //企業名稱 //發票抬頭 |
|
|
|
$stmt->bindParam(':ContactAddress', $invoice_address); |
|
|
|
// $stmt->bindParam(':EMail', $email); |
|
|
|
$stmt->bindParam(':CreatorId', $user_id); |
|
|
|
$stmt->bindParam(':CreateTime', $createTime); |
|
|
|
$stmt->execute(); |
|
|
@ -588,10 +630,10 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
]; |
|
|
|
// 幾年 |
|
|
|
// $SQuantityYear = $elevator['maintain_months'] / 12; |
|
|
|
$price_of_month = intval($elevator['sold_price']); |
|
|
|
//分幾期 () => 總共保養月 / 分期月 |
|
|
|
$SQuantitya = $elevator['maintain_months'] / $IncomeId[$payType]; |
|
|
|
$SQuantity = $IncomeId[$payType]; |
|
|
|
// $paymonth = $IncomeId[$payType] * $SQuantity; |
|
|
|
|
|
|
|
$date_1 = getNext25thDate($contract_begin_date); |
|
|
|
|
|
|
@ -609,7 +651,7 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
"RowCode" => $row, |
|
|
|
"RowNo" => $row, |
|
|
|
"ItemType" => 1, |
|
|
|
"SPrice" => intval($elevator['sold_price']), |
|
|
|
"SPrice" => $price_of_month, |
|
|
|
"SQuantity" => $SQuantity, |
|
|
|
"ProjectId" => "$contractno", |
|
|
|
"FromBillNo" => "$contractno", |
|
|
@ -619,10 +661,18 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
$salIncomeApplyDetail_rows[] = $rows_data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// $connT8->commit(); |
|
|
|
$count_rows_data = COUNT($salIncomeApplyDetail_rows); |
|
|
|
$T8total = $price_of_month * $count_rows_data; |
|
|
|
// echo "<pre>"; |
|
|
|
// print_r($salIncomeApplyDetail_rows); |
|
|
|
// echo "</pre>"; |
|
|
|
if ($T8total != $total_price) { |
|
|
|
$difference = $T8total - $total_price; |
|
|
|
$salIncomeApplyDetail_rows[$count_rows_data - 1]['SPrice'] = $salIncomeApplyDetail_rows[$count_rows_data - 1]['SPrice'] - $difference; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// $connT8->commit(); |
|
|
|
// $insertime = settype($insertTime, 'integer'); |
|
|
|
$salIncomeApplyMaster_rows = [ |
|
|
|
"BillNo" => "$contractno", |
|
|
@ -643,7 +693,9 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
"CreatorId" => "$user_id", |
|
|
|
"CreateTime" => intval($insertTime), |
|
|
|
"DeptId" => "$depId", |
|
|
|
"IsPriceWithTax" => 1 |
|
|
|
"IsPriceWithTax" => 1, |
|
|
|
"CU_ContractStart" => intval($beginDate), |
|
|
|
"CU_ContractEnd" => intval($endDate) |
|
|
|
]; |
|
|
|
|
|
|
|
$salIncomeApplyMaster = [ |
|
|
@ -658,15 +710,15 @@ function T8insert($data, $facilityno, $depId, $connT8) |
|
|
|
$API_body[] = $salIncomeApplyMaster; |
|
|
|
$API_body[] = $salIncomeApplyDetail; |
|
|
|
// 呼叫 API |
|
|
|
echo '<pre>'; |
|
|
|
print_r(json_encode($API_body)); |
|
|
|
echo '</pre>'; |
|
|
|
// $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; |
|
|
|
$api_url = "http://60.244.87.101:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData"; |
|
|
|
// echo '<pre>'; |
|
|
|
// print_r(json_encode($API_body)); |
|
|
|
// echo '</pre>'; |
|
|
|
// $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; //正式區 |
|
|
|
$api_url = "http://60.244.87.101:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData"; //測試區 |
|
|
|
$result = T8salIncomeApply($API_body, $api_url); |
|
|
|
|
|
|
|
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { |
|
|
|
|
|
|
|
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { |
|
|
|
http_response_code(404); |
|
|
|
die('Error!:' . $result['ErrorMsg']); |
|
|
|
} |
|
|
@ -706,7 +758,7 @@ function bonusCreate($data, $facilityno, $conn) |
|
|
|
$facility_no = $facilityno[$key]; |
|
|
|
$ver = $elevator['bonus_verson']; //獎金版本 |
|
|
|
$payment_period = $payment[$payType]; //付款方式 |
|
|
|
$elevator_list_price = !empty(intval($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價 |
|
|
|
$elevator_list_price = !empty(($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價 |
|
|
|
$fee_per_st = !empty($elevator['sold_price']) ? intval(round($elevator['sold_price'] / 1.05, 2)) : ''; //作翻契約金額 (不含稅) |
|
|
|
$commission_fee = !empty($elevator['service_expense']) ? $elevator['service_expense'] : ''; //服務費(月/台) |
|
|
|
$receivable_date_due = $payDay; //第一筆保養款項收回日 |
|
|
@ -729,108 +781,111 @@ function bonusCreate($data, $facilityno, $conn) |
|
|
|
} |
|
|
|
$renew_priceissue_bonus = []; |
|
|
|
// $years = ($maintain_months % 12) == 0 ? $maintain_months / 12 : ''; |
|
|
|
|
|
|
|
// 如果保養合約 大於一年 |
|
|
|
if (!empty($maintain_months)) { |
|
|
|
if ($ver == '2.1') { |
|
|
|
if ($maintain_months > 12 && $contract_type == 'new') { |
|
|
|
// 第一年為 "新簽約" |
|
|
|
$results = maintenance_contract_bonus_v2_1( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$payment_period, |
|
|
|
$elevator_list_price, |
|
|
|
$fee_per_st, |
|
|
|
$commission_fee, |
|
|
|
$receivable_date_due, |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
for ($i = 1; $i <= $years - 1; $i++) { |
|
|
|
$contract_type = 'renew_priceissue'; |
|
|
|
$receivable_date_due_renew = date("Y-m-d", strtotime("$receivable_date_due + $i year")); |
|
|
|
// 第二年以上改 "續約" |
|
|
|
$renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$payment_period, |
|
|
|
$elevator_list_price, |
|
|
|
$fee_per_st, |
|
|
|
$commission_fee, |
|
|
|
$receivable_date_due_renew, |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
} |
|
|
|
} else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') { |
|
|
|
// 超過一年的 "續約" |
|
|
|
for ($i = 0; $i < $years; $i++) { |
|
|
|
$contract_type = 'renew_priceissue'; |
|
|
|
$renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$payment_period, |
|
|
|
$elevator_list_price, |
|
|
|
$fee_per_st, |
|
|
|
$commission_fee, |
|
|
|
$receivable_date_due, |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
} |
|
|
|
} else if ($maintain_months >= 60 && $contract_type = 'longcontract_m1_free_charge') { |
|
|
|
// 五年以上長約 |
|
|
|
$results = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$payment_period, |
|
|
|
$maintain_months, |
|
|
|
$elevator_list_price, |
|
|
|
$fee_per_st, |
|
|
|
$commission_fee, |
|
|
|
$receivable_date_due, |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
} else { |
|
|
|
$results = maintenance_contract_bonus_v2_1( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$payment_period, |
|
|
|
$elevator_list_price, |
|
|
|
$fee_per_st, |
|
|
|
$commission_fee, |
|
|
|
$receivable_date_due, |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
} |
|
|
|
} else if ($ver == '2.0') { |
|
|
|
$contract_years = $years > 2 ? 'above_two' : 'one'; |
|
|
|
// echo $contract_years; |
|
|
|
|
|
|
|
$discount = round($elevator['discount'], 2); |
|
|
|
$results = maintenance_contract_bonus_v2_0( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$contract_years, |
|
|
|
$discount, // 折扣率 |
|
|
|
$fee_per_st, //售價 |
|
|
|
$receivable_date_due, // 第一筆金額繳款時間 |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
} |
|
|
|
///////////////////////////////// |
|
|
|
// 如果保養合約 大於一年 2.0版本 |
|
|
|
// if (!empty($maintain_months)) { |
|
|
|
// if ($ver == '2.1') { |
|
|
|
// if ($maintain_months > 12 && $contract_type == 'new') { |
|
|
|
// // 第一年為 "新簽約" |
|
|
|
// $results = maintenance_contract_bonus_v2_1( |
|
|
|
// $ver, |
|
|
|
// $contract_type, |
|
|
|
// $payment_period, |
|
|
|
// $elevator_list_price, |
|
|
|
// $fee_per_st, |
|
|
|
// $commission_fee, |
|
|
|
// $receivable_date_due, |
|
|
|
// $sales_id, |
|
|
|
// $region_director_id, |
|
|
|
// $regular_contract_manger_id |
|
|
|
// ); |
|
|
|
// for ($i = 1; $i <= $years - 1; $i++) { |
|
|
|
// $contract_type = 'renew_priceissue'; |
|
|
|
// $receivable_date_due_renew = date("Y-m-d", strtotime("$receivable_date_due + $i year")); |
|
|
|
// // 第二年以上改 "續約" |
|
|
|
// $renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1( |
|
|
|
// $ver, |
|
|
|
// $contract_type, |
|
|
|
// $payment_period, |
|
|
|
// $elevator_list_price, |
|
|
|
// $fee_per_st, |
|
|
|
// $commission_fee, |
|
|
|
// $receivable_date_due_renew, |
|
|
|
// $sales_id, |
|
|
|
// $region_director_id, |
|
|
|
// $regular_contract_manger_id |
|
|
|
// ); |
|
|
|
// } |
|
|
|
// } else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') { |
|
|
|
// // 超過一年的 "續約" |
|
|
|
// for ($i = 0; $i < $years; $i++) { |
|
|
|
// $contract_type = 'renew_priceissue'; |
|
|
|
// $renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1( |
|
|
|
// $ver, |
|
|
|
// $contract_type, |
|
|
|
// $payment_period, |
|
|
|
// $elevator_list_price, |
|
|
|
// $fee_per_st, |
|
|
|
// $commission_fee, |
|
|
|
// $receivable_date_due, |
|
|
|
// $sales_id, |
|
|
|
// $region_director_id, |
|
|
|
// $regular_contract_manger_id |
|
|
|
// ); |
|
|
|
// } |
|
|
|
// } else if ($maintain_months >= 60 && $contract_type = 'longcontract_m1_free_charge') { |
|
|
|
// // 五年以上長約 |
|
|
|
// $results = maintenance_longterm_contract_m1_free_charge_bonus_v2_1( |
|
|
|
// $ver, |
|
|
|
// $contract_type, |
|
|
|
// $payment_period, |
|
|
|
// $maintain_months, |
|
|
|
// $elevator_list_price, |
|
|
|
// $fee_per_st, |
|
|
|
// $commission_fee, |
|
|
|
// $receivable_date_due, |
|
|
|
// $sales_id, |
|
|
|
// $region_director_id, |
|
|
|
// $regular_contract_manger_id |
|
|
|
// ); |
|
|
|
// } else { |
|
|
|
// $results = maintenance_contract_bonus_v2_1( |
|
|
|
// $ver, |
|
|
|
// $contract_type, |
|
|
|
// $payment_period, |
|
|
|
// $elevator_list_price, |
|
|
|
// $fee_per_st, |
|
|
|
// $commission_fee, |
|
|
|
// $receivable_date_due, |
|
|
|
// $sales_id, |
|
|
|
// $region_director_id, |
|
|
|
// $regular_contract_manger_id |
|
|
|
// ); |
|
|
|
// } |
|
|
|
// } else |
|
|
|
if ($ver == '2.0') { |
|
|
|
$contract_years = $years > 2 ? 'above_two' : 'one'; |
|
|
|
// echo $contract_years; |
|
|
|
|
|
|
|
$discount = round($elevator['discount'] / 100, 1); |
|
|
|
$results = maintenance_contract_bonus_v2_0( |
|
|
|
$ver, |
|
|
|
$contract_type, |
|
|
|
$contract_years, |
|
|
|
$discount, // 折扣率 |
|
|
|
$fee_per_st, //售價 |
|
|
|
$receivable_date_due, // 第一筆金額繳款時間 |
|
|
|
$sales_id, |
|
|
|
$region_director_id, |
|
|
|
$regular_contract_manger_id |
|
|
|
); |
|
|
|
} |
|
|
|
echo "<pre>"; |
|
|
|
print_r($results); |
|
|
|
echo "</pre>"; |
|
|
|
// } |
|
|
|
///////////////////////////////// |
|
|
|
// echo "<pre>"; |
|
|
|
// print_r($results); |
|
|
|
// echo "</pre>"; |
|
|
|
///////////////////////////////// |
|
|
|
$bonus_json = [ |
|
|
|
'contract_type' => $contract_type, |
|
|
|
'total' => $elevator_list_price, |
|
|
|