|
|
@ -35,6 +35,13 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|
|
|
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; |
|
|
|
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null; |
|
|
|
|
|
|
|
$sql = "SELECT * FROM account WHERE accountid = '$salesman'"; |
|
|
|
$stmt = $conn->prepare($sql); |
|
|
|
$stmt->execute(); |
|
|
|
$accountData = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
|
|
|
|
|
$depId = $accountData['department_id']; |
|
|
|
// validate |
|
|
|
//create facility table |
|
|
|
$createFacilityNo = new CreateFacilityNo(); |
|
|
@ -72,7 +79,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
if ($vat == '') $fail_arr[] = '統一編號為必填'; |
|
|
|
if ($mtype == '') $fail_arr[] = '維修型態為必填'; |
|
|
|
if ($phone == '') $fail_arr[] = '客戶電話為必填'; |
|
|
|
if ($email == '') $fail_arr[] = 'Email為必填'; |
|
|
|
// if ($email == '') $fail_arr[] = 'Email為必填'; |
|
|
|
if ($mworker == '') $fail_arr[] = '保養員為必填'; |
|
|
|
// if ($mcycle == '') $fail_arr[] = '保養頻率為必填'; |
|
|
|
if ($salesman == '') $fail_arr[] = '營業員為必填'; |
|
|
@ -92,7 +99,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
echo json_encode($fail_arr); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
T8insert($_POST, $facilityno); |
|
|
|
T8insert($_POST, $facilityno, $depId); |
|
|
|
bonusCreate($_POST, $facilityno, $conn); |
|
|
|
//create account table |
|
|
|
$accounttype = "A"; |
|
|
@ -199,6 +206,12 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$repairerid = $mworker; |
|
|
|
$repairername = $worker['name']; |
|
|
|
foreach ($elevators as $idx => $elevator) { |
|
|
|
// 民國年轉換西元年 |
|
|
|
$ROCuseful_date = $elevator['useful_date']; |
|
|
|
$click = explode("-", $ROCuseful_date); |
|
|
|
$click[0] = intval($click[0]) + 1911; |
|
|
|
$ADuseful_date = implode("-", $click); |
|
|
|
|
|
|
|
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) |
|
|
|
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; |
|
|
|
$stmt = $conn->prepare($sql_str); |
|
|
@ -224,7 +237,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
$stmt->bindParam(':create_at', $create_at); |
|
|
|
$stmt->bindParam(':area', $area); |
|
|
|
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); |
|
|
|
$stmt->bindParam(':licensedate', $elevator['useful_date']); |
|
|
|
$stmt->bindParam(':licensedate', $ADuseful_date); |
|
|
|
$result = $stmt->execute(); |
|
|
|
} |
|
|
|
|
|
|
@ -357,7 +370,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
|
|
|
|
// T8insert($_POST, $facilityno); |
|
|
|
|
|
|
|
header('Content-Type: application/json'); |
|
|
|
// header('Content-Type: application/json'); |
|
|
|
$jsonData = json_encode($files); |
|
|
|
|
|
|
|
$conn->commit(); |
|
|
@ -369,7 +382,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
function T8insert($data, $facilityno) |
|
|
|
function T8insert($data, $facilityno, $depId) |
|
|
|
{ |
|
|
|
require_once("../connt8.php"); |
|
|
|
// 引入 T8 API 連線 |
|
|
@ -611,7 +624,9 @@ function T8insert($data, $facilityno) |
|
|
|
"TaxId" => "ST005", |
|
|
|
"CompId" => "1001", |
|
|
|
"CreatorId" => "$user_id", |
|
|
|
"CreateTime" => intval($insertTime) |
|
|
|
"CreateTime" => intval($insertTime), |
|
|
|
"DeptId" => "$depId", |
|
|
|
"IsPriceWithTax" => 1 |
|
|
|
]; |
|
|
|
|
|
|
|
$salIncomeApplyMaster = [ |
|
|
@ -673,7 +688,7 @@ function bonusCreate($data, $facilityno, $conn) |
|
|
|
$ver = $elevator['bonus_verson']; //獎金版本 |
|
|
|
$contract_type = $elevator['contract_type']; //合約類別 |
|
|
|
$payment_period = $payment[$payType]; //付款方式 |
|
|
|
$elevator_list_price = $elevator['stand_price']; //牌價 |
|
|
|
$elevator_list_price = intval($elevator['stand_price']); //牌價 |
|
|
|
$fee_per_st = $elevator['contract_price']; //作翻契約金額 |
|
|
|
$commission_fee = $elevator['service_expense']; //服務費(月) |
|
|
|
$receivable_date_due = $payDay; //第一筆保養款項收回日 |
|
|
|