Browse Source

契約簽回

main
Cheng 1 year ago
parent
commit
3aa59d03d5
  1. 4
      wms/bonus/api/postSchedule.php
  2. 244
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php
  3. 80
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php
  4. 38
      wms/class/T8API.php
  5. 8
      wms/contract/api/T8api.php
  6. 804
      wms/contract/api/postContractData.php
  7. 83
      wms/contract/api/test copy.json
  8. 17
      wms/contract/api/testT8API.php
  9. 10
      wms/contract/api/testocde.php
  10. 20
      wms/contract/contract-input.php
  11. 9
      wms/contract/js/alpine.js
  12. 18
      wms/schedule-edit.php
  13. 22
      wms/schedule-index.php
  14. 66
      wms/schedule-setting-repaire-update.php
  15. 192
      wms/schedule-setting-repaire.php

4
wms/bonus/api/postSchedule.php

@ -1,4 +0,0 @@
<?php
include_once "./wms/contract/conn.php";
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : '';
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : '';

244
wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php

@ -7,7 +7,9 @@
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0 作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0_1 作番賣價($elevator_knockdown_price) : 電梯合約價格收款階段比例金額
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
@ -34,80 +36,186 @@ result_array[
*/
/* paykind_arr =[
[
pay_kind -- 1=訂金、2=二次款、3=貨到工地款、4=材料其他、5=安裝完畢、6=驗收款、7=其他安裝款
pay_scale -- 百分比
pay_amount -- 金額
],
[
]
]
*/
function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_price, $elevator_pay_kind, $sales_id, $region_manger_id)
function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_pay_kind, $sales_id, $region_manger_id)
{
// echo "<pre>";
// print_r($elevator_pay_kind);
// echo "</pre>";
// exit;
$bonus_array = [];
if ($ver == "1.0") {
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type) {
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_knockdown_price * 0.007;
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_knockdown_price * 0.015;
#區域經理獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
};
#營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20%
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.2), #金額
"payment_schedul_due" => "deposit", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定
]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.5), #金額
"payment_schedul_due" => "shipping", #訂金已收款20%
"payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定
]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.3), #金額
"payment_schedul_due" => "acceptance", #訂金已收款20%
"payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定
]);
#區域經理獎金水庫-----訂金已收款100%,發放總獎金50%
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
]);
#區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50%
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
"payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
foreach ($elevator_pay_kind as $elevator_pay_kind) {
switch ($contract_type) {
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_pay_kind['pay_amount'] * 0.007;
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_pay_kind['pay_amount'] * 0.015;
#區域經理獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
};
$pay_scale = $elevator_pay_kind['pay_scale'];
// echo "<pre>";
// print_r($pay_scale);
// echo "</pre>";
switch ($elevator_pay_kind['pay_kind']) {
case '1':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "deposit", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
]);
break;
case '2':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-二次段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "twice", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '3':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "shipping", #訂金已收款20%
"payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
"payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
]);
break;
case '4':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-材料其他段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "other", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '5':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-安裝完畢段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "installed", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '6':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "acceptance", #訂金已收款20%
"payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '7':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-安裝其他段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "installOther", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
}
#營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20%
// array_push($bonus_array, [
// "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
// "bonus_receiver" => $sales_id, #發放人員
// "bonus_amount" => round($sales_bonus * 0.2), #金額
// "payment_schedul_due" => "deposit", #訂金已收款20%
// "payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定
// ]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%
// array_push($bonus_array, [
// "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
// "bonus_receiver" => $sales_id, #發放人員
// "bonus_amount" => round($sales_bonus * 0.5), #金額
// "payment_schedul_due" => "shipping", #訂金已收款20%
// "payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定
// ]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%
// array_push($bonus_array, [
// "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
// "bonus_receiver" => $sales_id, #發放人員
// "bonus_amount" => round($sales_bonus * 0.3), #金額
// "payment_schedul_due" => "acceptance", #訂金已收款20%
// "payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定
// ]);
#區域經理獎金水庫-----訂金已收款100%,發放總獎金50%
// array_push($bonus_array, [
// "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
// "bonus_receiver" => $region_manger_id, #發放人員
// "bonus_amount" => round($region_manager_bonus * 0.5), #金額
// "payment_schedul_due" => "deposit", #訂金已收款100%
// "payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
// ]);
// #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50%
// array_push($bonus_array, [
// "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
// "bonus_receiver" => $region_manger_id, #發放人員
// "bonus_amount" => round($region_manager_bonus * 0.5), #金額
// "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
// "payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
// ]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱

80
wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php

@ -1,9 +1,15 @@
<?php
/* 函數用法與參數
/*
獎金辦法 1.0_1 說明,需要查看合約收入的款項去發放該款項的獎金
函數用法與參數
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0 作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0_1 作番賣價($elevator_knockdown_price) : 電梯合約價格收款階段比例金額
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
@ -30,43 +36,77 @@ result_array[
*/
/* paykind_arr =[
[
pay_kind -- 1=訂金、2=二次款、3=貨到工地款、4=材料其他、5=安裝完畢、6=驗收款、7=其他安裝款
pay_scale -- 百分比
pay_amount -- 金額
],
[
]
]
*/
require_once("elevator_new_deal_bonus_v1_0.php");
require_once("elevator_new_deal_bonus_v1_0_1.php");
#$ver, $contract_type, $elevator_knockdown_price, $sales_id, $region_manger_id
#獎金測試
$pay_kind_arr = [
[
"pay_kind" => '1',
"pay_scale" => 20,
"pay_amount" => 318000
],
[
"pay_kind" => '3',
"pay_scale" => 50,
"pay_amount" => 795000
],
[
"pay_kind" => '5',
"pay_scale" => 20,
"pay_amount" => 318000
],
[
"pay_kind" => '6',
"pay_scale" => 10,
"pay_amount" => 159000
]
];
$examination_array = [
#錯誤版本
["2.0","strategy_customer",1000000,"M0001", "M0003"],
["1.0", "strategy_customer", ($pay_kind_arr), "M0001", "M0003"],
#戰略客戶(strategy_customer)
["1.0","strategy_customer",1000000,"M0001", "M0003"], #戰略客戶
// ["1.0", "strategy_customer", 1000000, "M0001", "M0003"], #戰略客戶
#一般客戶(general_customer)
["1.0","general_customer",1000000,"M0001", "M0003"] #一般客戶
// #一般客戶(general_customer)
["1.0", "general_customer", $pay_kind_arr, "M0001", "M0003"] #一般客戶
];
for($i = 0; $i<count($examination_array); $i++){
for ($i = 0; $i < count($examination_array); $i++) {
$result = elevator_new_deal_bonus_v1_0(
$examination_array[$i][0],
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4]
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4]
);
// echo "<pre>";
// print_r($examination_array);
// echo "</pre>";
echo "獎金版本:" . $result["ver"] . "<br>";
echo "計算結果:" . $result["result_status"] . "<br>";
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . "<br>";
for($j = 0; $j<count($result["bonus_array"]); $j++){
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . "<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>";
};
?>

38
wms/class/T8API.php

@ -0,0 +1,38 @@
<?php
require_once("../T8_Authorization_from_bpm.php");
function T8salIncomeApply($data, $api_url)
{
$validation = get_Auth();
$header = [
"CHI_Authorization :" . $validation,
"GroupId:TEST"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
return $result;
} else {
// print_r($result);
return $result;
}
return $result;
}
curl_close($ch);
}

8
wms/contract/api/T8api.php

@ -4,12 +4,8 @@ require_once("../../T8_Authorization_from_bpm.php");
function T8salIncomeApply($data, $api_url)
{
// $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth();
echo '<pre>';
print_r($validation);
echo '</pre>';
// exit;
$header = [
"CHI_Authorization :" . $validation,
"GroupId:TEST"
@ -29,7 +25,7 @@ function T8salIncomeApply($data, $api_url)
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
// echo 'API傳入失敗,' . $result['ErrorMsg'];
return $result;
} else {
// print_r($result);

804
wms/contract/api/postContractData.php

@ -1,4 +1,3 @@
<?php
header("Content-Type: text/html; charset=utf-8");
require_once("../conn.php");
@ -11,434 +10,443 @@ 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;
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null;
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
$email = !empty($_POST['email']) ? $_POST['email'] : null;
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : '';
// $mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null;
$address = !empty($_POST['address']) ? $_POST['address'] : null;
$area = !empty($_POST['area']) ? $_POST['area'] : null;
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null;
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null;
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null;
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null;
$num = !empty($_POST['num']) ? $_POST['num'] : null;
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$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);
$stmt->execute();
$accountData = $stmt->fetch(PDO::FETCH_ASSOC);
$depId = $accountData['department_id'];
// validate
//create facility table
$createFacilityNo = new CreateFacilityNo();
$dailyNecessities = [
'MAE100' => 'X',
'MAM200' => 'W',
'MAH100' => 'H',
'MAQ100' => 'Z',
'MAF100' => 'F',
'MAZ100' => '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;
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null;
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
$email = !empty($_POST['email']) ? $_POST['email'] : null;
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : '';
// $mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null;
$address = !empty($_POST['address']) ? $_POST['address'] : null;
$area = !empty($_POST['area']) ? $_POST['area'] : null;
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null;
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null;
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null;
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null;
$num = !empty($_POST['num']) ? $_POST['num'] : null;
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$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'] : '';
$maintance_manager = !empty($_POST['maintance_manager']) ? $_POST['maintance_manager'] : '';
$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();
$dailyNecessities = [
'MAE100' => 'X',
'MAM200' => 'W',
'MAH100' => 'H',
'MAQ100' => 'Z',
'MAF100' => 'F',
'MAZ100' => 'B',
];
$maintain_times = [
'1' => 'em', //月保
'2' => 'bw' // 雙周保
];
$facility_arr = [];
foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']];
}
// echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// exit();
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// }
$fail_arr = [];
// if ($contractno === '') return $fail_arr[] = '合約號為必填';
if ($total_price == '') $fail_arr[] = '合約總價為必填';
if ($salesman == '') $fail_arr[] = '營業員為必填';
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
if ($address == '') $fail_arr[] = '地址為必填';
if ($area == '') $fail_arr[] = '區域為必填';
if ($customer == '') $fail_arr[] = '客戶為必填';
if ($num == '') $fail_arr[] = '電梯數量為必填';
if ($payType == '') $fail_arr[] = '分期方式為必填';
if ($contract_type == '') $fail_arr[] = '合約類別為必填';
//-------------------
// if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
// if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
// if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
// if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
// if ($vat == '') $fail_arr[] = '統一編號為必填';
// if ($mtype == '') $fail_arr[] = '維修型態為必填';
// if ($phone == '') $fail_arr[] = '客戶電話為必填';
// if ($email == '') $fail_arr[] = 'Email為必填';
// if ($mworker == '') $fail_arr[] = '保養員為必填';
// if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE);
$maintain_times = [
'1' => 'em', //月保
'2' => 'bw' // 雙周保
];
$facility_arr = [];
foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']];
}
// echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// exit();
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// }
$fail_arr = [];
// if ($contractno === '') return $fail_arr[] = '合約號為必填';
if ($total_price == '') $fail_arr[] = '合約總價為必填';
if ($salesman == '') $fail_arr[] = '營業員為必填';
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
if ($address == '') $fail_arr[] = '地址為必填';
if ($area == '') $fail_arr[] = '區域為必填';
if ($customer == '') $fail_arr[] = '客戶為必填';
if ($num == '') $fail_arr[] = '電梯數量為必填';
if ($payType == '') $fail_arr[] = '分期方式為必填';
if ($contract_type == '') $fail_arr[] = '合約類別為必填';
if ($maintance_manager == '') $fail_arr[] = '保養經理為必填';
//-------------------
// if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
// if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
// if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
// if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
// if ($vat == '') $fail_arr[] = '統一編號為必填';
// if ($mtype == '') $fail_arr[] = '維修型態為必填';
// if ($phone == '') $fail_arr[] = '客戶電話為必填';
// if ($email == '') $fail_arr[] = 'Email為必填';
// if ($mworker == '') $fail_arr[] = '保養員為必填';
// if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE);
exit();
}
exit();
}
// T8insert($_POST, $facilityno, $depId, $connT8);
/// 獎金計算
$aaa = bonusCreate($_POST, $facilityno, $conn);
if (!empty($aaa) && $aaa['status'] == 2) {
header("HTTP/1.1 422 Unprocessable Entity");
echo $aaa['data'];
T8insert($_POST, $facilityno, $depId, $connT8);
exit();
}
// exit();
//create account table
$accounttype = "A";
$accountid = $vat;
$pwd = "123";
$name = $partyA;
$tel = $phone ?? '';
$repairerid = $mworker;
$creater = $user_id;
$create_at = date('Y-m-d H:i:s');
// exit();
/// 獎金計算
$aaa = bonusCreate($_POST, $facilityno, $conn);
if (!empty($aaa) && $aaa['status'] == 2) {
header("HTTP/1.1 422 Unprocessable Entity");
echo $aaa['data'];
exit();
}
// exit();
//create account table
$accounttype = "A";
$accountid = $vat;
$pwd = "123";
$name = $partyA;
$tel = $phone ?? '';
$repairerid = $mworker;
$creater = $user_id;
$create_at = date('Y-m-d H:i:s');
// exit();
$conn->beginTransaction();
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->bindParam(':accountid', $accountid);
$stmt->bindParam(':pwd', $pwd);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
$conn->beginTransaction();
//create contract table
$contracttype = $mtype;
$company = $partyA;
$taxid = $vat;
$tel = $phone;
$promiser = $partyA;
$contractperson = $partyA;
$contractaddress = $address;
$contracttel = $phone;
$contractemail = $email;
$contract_employee = $salesman;
$start_date = $contract_begin_date;
$end_date = $contract_end_date;
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contracttype', $contracttype);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':company', $company);
$stmt->bindParam(':taxid', $taxid);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':promiser', $promiser);
$stmt->bindParam(':contractperson', $contractperson);
$stmt->bindParam(':contractaddress', $contractaddress);
$stmt->bindParam(':contracttel', $contracttel);
$stmt->bindParam(':contractemail', $contractemail);
$stmt->bindParam(':contract_employee', $contract_employee);
$stmt->bindParam(':start_date', $start_date);
$stmt->bindParam(':end_date', $end_date);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
//create facility table
// $createFacilityNo = new CreateFacilityNo();
// $dailyNecessities = [
// 'MAE100' => 'X',
// 'MAM200' => 'W',
// 'MAH100' => 'H',
// 'MAQ100' => 'Z',
// 'MAF100' => 'F',
// 'MAZ100' => 'B',
// ];
// $maintain_times = [
// '1' => 'em', //月保
// '2' => 'bw' // 雙周保
// ];
// $facility_arr = [];
// foreach ($elevators as $elevator) {
// $facility_arr[] = $dailyNecessities[$elevator['spec']];
// }
// echo json_encode($facility_arr);
// // 電梯做番號
// $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// // if ($user_id == 'M0225') {
// // echo '<pre>';
// // print_r($facilityno);
// // echo '</pre>';
// // exit();
// // }
// echo json_encode($facilityno);
// echo '-------';
$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;
$repairtype = $mtype;
$repairerid = $mworker;
$define = "B";
$repairername = !empty($worker) ? $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)";
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':define', $define);
$stmt->bindParam(':facilityno', $facilityno[$idx]);
$stmt->bindParam(':latitude', $elevator['latitude']);
$stmt->bindParam(':longitude', $elevator['longitude']);
$stmt->bindParam(':customerid', $customerid);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':numberofpassenger', $elevator['persons']);
$stmt->bindParam(':numberofstop', $elevator['stop']);
$stmt->bindParam(':numberoffloor', $elevator['floors']);
$stmt->bindParam(':opentype', $elevator['opendoor']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':repairtype', $repairtype);
$stmt->bindParam(':maintainance', $elevator['maintainance']);
$stmt->bindParam(':facility_kind', $elevator['spec']);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->bindParam(':accountid', $accountid);
$stmt->bindParam(':pwd', $pwd);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->bindParam(':area', $area);
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
$stmt->bindParam(':licensedate', $ADuseful_date);
$result = $stmt->execute();
}
$sql = "SELECT * FROM account WHERE accountid = '$user_id' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$user_detail = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->execute();
//create contract table
//create schedule table
// $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
// $comboArr = json_decode($comboNo->getComboNo(), true);
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);
$contracttype = $mtype;
$company = $partyA;
$taxid = $vat;
$tel = $phone;
$promiser = $partyA;
$contractperson = $partyA;
foreach ($comboArr as $combo) {
$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)';
$contractaddress = $address;
$contracttel = $phone;
$contractemail = $email;
$contract_employee = $salesman;
$start_date = $contract_begin_date;
$end_date = $contract_end_date;
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contracttype', $contracttype);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':company', $company);
$stmt->bindParam(':taxid', $taxid);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':promiser', $promiser);
$stmt->bindParam(':contractperson', $contractperson);
$stmt->bindParam(':contractaddress', $contractaddress);
$stmt->bindParam(':contracttel', $contracttel);
$stmt->bindParam(':contractemail', $contractemail);
$stmt->bindParam(':contract_employee', $contract_employee);
$stmt->bindParam(':start_date', $start_date);
$stmt->bindParam(':end_date', $end_date);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
//create facility table
// $createFacilityNo = new CreateFacilityNo();
// $dailyNecessities = [
// 'MAE100' => 'X',
// 'MAM200' => 'W',
// 'MAH100' => 'H',
// 'MAQ100' => 'Z',
// 'MAF100' => 'F',
// 'MAZ100' => 'B',
// ];
// $maintain_times = [
// '1' => 'em', //月保
// '2' => 'bw' // 雙周保
// ];
// $facility_arr = [];
// foreach ($elevators as $elevator) {
// $facility_arr[] = $dailyNecessities[$elevator['spec']];
// }
// echo json_encode($facility_arr);
// // 電梯做番號
// $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// // if ($user_id == 'M0225') {
// // echo '<pre>';
// // print_r($facilityno);
// // echo '</pre>';
// // exit();
// // }
// echo json_encode($facilityno);
// echo '-------';
$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;
$repairtype = $mtype;
$repairerid = $mworker;
$define = "B";
$repairername = !empty($worker) ? $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);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':facilityno', $no);
$stmt->bindParam(':combono', $combo[0]);
$stmt->bindParam(':define', $define);
$stmt->bindParam(':facilityno', $facilityno[$idx]);
$stmt->bindParam(':latitude', $elevator['latitude']);
$stmt->bindParam(':longitude', $elevator['longitude']);
$stmt->bindParam(':customerid', $customerid);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':numberofpassenger', $elevator['persons']);
$stmt->bindParam(':numberofstop', $elevator['stop']);
$stmt->bindParam(':numberoffloor', $elevator['floors']);
$stmt->bindParam(':opentype', $elevator['opendoor']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':repairtype', $repairtype);
$stmt->bindParam(':maintainance', $elevator['maintainance']);
$stmt->bindParam(':facility_kind', $elevator['spec']);
$stmt->bindParam(':address', $address);
$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);
$stmt->bindParam(':area', $area);
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
$stmt->bindParam(':licensedate', $ADuseful_date);
$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' ";
$sql = "SELECT * FROM account WHERE accountid = '$user_id' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$regular_contract_manger_mail = $stmt->fetch(PDO::FETCH_ASSOC);
$user_detail = $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;
$company = $customer;
$customer_no = $vat;
$salesperson = $salesman;
$customer_phone = $phone;
$customer_email = $email;
$repairman = $mworker;
// $cycle = $mcycle;
$contact_person = $partyA;
$contact_address = $partyAaddress;
$contact_phone = $partyAphone;
$contract_email = $partyAemail;
$elevators_number = $num;
$bonus = 1000;
$max_bonus = 2000;
if (!empty($files)) {
$englisharr = range('a', 'z');
$file = $_FILES['files'];
$file_name = $file['name'];
$file_type = $file['type'];
$tmp_name = $file['tmp_name'];
$file_size = $file['size'];
$error = $file['error'];
$newfiles = [];
foreach ($files as $file) {
$i = 0; //新陣列的索引編號
foreach ($file as $key => $val) {
$newfiles[$i]['name'] = $files['name'][$key];
$newfiles[$i]['type'] = $files['type'][$key];
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
$newfiles[$i]['error'] = $files['error'][$key];
$newfiles[$i]['size'] = $files['size'][$key];
$i++;
} //foreach 第2層 end
}
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
$path = '../images/contracts/';
if (!file_exists($path)) {
mkdir($path);
}
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
$datetime = (string)date('YmdHis');
$files_id = 'b' . $datetime; // 保養=>b + 日期時間
foreach ($newfiles as $key => $file) {
$randNum = rand(1000, 9999);
$randEnglish = $englisharr[rand(0, 25)];
$file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
if ($msg == 1) {
$msg = '檔案傳送成功!';
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
//create schedule table
// $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
// $comboArr = json_decode($comboNo->getComboNo(), true);
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,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(':files_id', $files_id);
$stmt->bindParam(':file_name', $file_name);
$stmt->bindParam(':file_mime', $file['type']);
$stmt->bindParam(':file_size', $file['size']);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $user_id);
$stmt->execute();
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':facilityno', $no);
$stmt->bindParam(':combono', $combo[0]);
$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();
}
// $regular_contract_manger_id = $elevators[$idx]['regular_contract_manger_id'];
// $sql = "SELECT * FROM account WHERE accountid = '' ";
$sql = "SELECT * FROM account WHERE accountid = '$maintance_manager' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$maintance_manager_detail = $stmt->fetch(PDO::FETCH_ASSOC);
// 寄郵件給 輸入合約助理,請他安排保養計畫
// 北北基 : M0090
// 保養組長 桃竹 : M0223
// 中部 : M0161
// 南部 : M0077
// 保養組長之後調整
$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']],
// [$maintance_manager, $maintance_manager_detail['email']],
// ['M0012', 'Yingying@masada.com.tw']
// [$regular_contract_manger_id, $regular_contract_manger_mail['mail']],
['M0225', 'lkmd555@masada.com.tw']
// ['M0012', 'Yingying@masada.com.tw']
],
"永佳捷科技"
);
// echo 'send';
// }
}
// create contract_b_signed_back table
$contract_type = $mtype;
$company = $customer;
$customer_no = $vat;
$salesperson = $salesman;
$customer_phone = $phone;
$customer_email = $email;
$repairman = $mworker;
// $cycle = $mcycle;
$contact_person = $partyA;
$contact_address = $partyAaddress;
$contact_phone = $partyAphone;
$contract_email = $partyAemail;
$elevators_number = $num;
$bonus = 1000;
$max_bonus = 2000;
if (!empty($files)) {
$englisharr = range('a', 'z');
$file = $_FILES['files'];
$file_name = $file['name'];
$file_type = $file['type'];
$tmp_name = $file['tmp_name'];
$file_size = $file['size'];
$error = $file['error'];
$newfiles = [];
foreach ($files as $file) {
$i = 0; //新陣列的索引編號
foreach ($file as $key => $val) {
$newfiles[$i]['name'] = $files['name'][$key];
$newfiles[$i]['type'] = $files['type'][$key];
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
$newfiles[$i]['error'] = $files['error'][$key];
$newfiles[$i]['size'] = $files['size'][$key];
$i++;
} //foreach 第2層 end
}
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>';
$src_name = $path . $file['name'];
if (file_exists($src_name)) {
//副檔名
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
//主檔名
$basename = basename($src_name, '.' . $extname);
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
$path = '../images/contracts/';
if (!file_exists($path)) {
mkdir($path);
}
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
$datetime = (string)date('YmdHis');
$files_id = 'b' . $datetime; // 保養=>b + 日期時間
foreach ($newfiles as $key => $file) {
$randNum = rand(1000, 9999);
$randEnglish = $englisharr[rand(0, 25)];
$file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
if ($msg == 1) {
$msg = '檔案傳送成功!';
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':files_id', $files_id);
$stmt->bindParam(':file_name', $file_name);
$stmt->bindParam(':file_mime', $file['type']);
$stmt->bindParam(':file_size', $file['size']);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $user_id);
$stmt->execute();
}
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>';
$src_name = $path . $file['name'];
if (file_exists($src_name)) {
//副檔名
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
//主檔名
$basename = basename($src_name, '.' . $extname);
}
}
} else {
$files = null;
}
} else {
$files = null;
}
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by,signing_date)
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by,signing_date)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by,:signing_date)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contract_no", $contractno);
$stmt->bindParam(":contract_type", $contract_type);
$stmt->bindParam(":company", $company);
$stmt->bindParam(":customer_no", $customer_no);
$stmt->bindParam(":salesperson", $salesperson);
$stmt->bindParam(":contract_start_date", $contract_begin_date);
$stmt->bindParam(":contract_end_date", $contract_end_date);
$stmt->bindParam(":total_price", $total_price);
$stmt->bindParam(":customer_phone", $customer_phone);
$stmt->bindParam(":customer_email", $customer_email);
$stmt->bindParam(":repairman", $repairman);
// $stmt->bindParam(":cycle", $cycle); // 保養頻率在做番上,這邊不 insert。
$stmt->bindParam(":contact_person", $contact_person);
$stmt->bindParam(":contact_address", $contact_address);
$stmt->bindParam(":contact_phone", $contact_phone);
$stmt->bindParam(":contact_email", $contact_email);
$stmt->bindParam(":elevators_number", $elevators_number);
$stmt->bindParam(":area", $area);
$stmt->bindParam(":address", $address);
$stmt->bindParam(":files_id", $files_id);
$stmt->bindParam(":bonus", $bonus);
$stmt->bindParam(":max_bonus", $max_bonus);
$stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $user_id);
$stmt->bindParam(':payType', $payType);
$stmt->bindParam(':signing_date', $signing_date);
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contract_no", $contractno);
$stmt->bindParam(":contract_type", $contract_type);
$stmt->bindParam(":company", $company);
$stmt->bindParam(":customer_no", $customer_no);
$stmt->bindParam(":salesperson", $salesperson);
$stmt->bindParam(":contract_start_date", $contract_begin_date);
$stmt->bindParam(":contract_end_date", $contract_end_date);
$stmt->bindParam(":total_price", $total_price);
$stmt->bindParam(":customer_phone", $customer_phone);
$stmt->bindParam(":customer_email", $customer_email);
$stmt->bindParam(":repairman", $repairman);
// $stmt->bindParam(":cycle", $cycle); // 保養頻率在做番上,這邊不 insert。
$stmt->bindParam(":contact_person", $contact_person);
$stmt->bindParam(":contact_address", $contact_address);
$stmt->bindParam(":contact_phone", $contact_phone);
$stmt->bindParam(":contact_email", $contact_email);
$stmt->bindParam(":elevators_number", $elevators_number);
$stmt->bindParam(":area", $area);
$stmt->bindParam(":address", $address);
$stmt->bindParam(":files_id", $files_id);
$stmt->bindParam(":bonus", $bonus);
$stmt->bindParam(":max_bonus", $max_bonus);
$stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $user_id);
$stmt->bindParam(':payType', $payType);
$stmt->bindParam(':signing_date', $signing_date);
$stmt->execute();
$stmt->execute();
// T8insert($_POST, $facilityno);
// T8insert($_POST, $facilityno);
$conn->commit();
$conn->commit();
header('Content-Type: application/json');
$jsonData = json_encode($files);
header('Content-Type: application/json');
$jsonData = json_encode($files);
// Cmail->sendx;
// } catch (PDOException $e) {
// $conn->rollback();
// http_response_code(404);
// echo $e->getMessage();
// die('Error!:' . $e->getMessage());
// }
// Cmail->sendx;
} catch (PDOException $e) {
$conn->rollback();
http_response_code(404);
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
};
function T8insert($data, $facilityno, $depId, $connT8)
@ -630,7 +638,10 @@ function T8insert($data, $facilityno, $depId, $connT8)
];
// 幾年
// $SQuantityYear = $elevator['maintain_months'] / 12;
// 單台電梯契約報價
$price_of_month = intval($elevator['sold_price']);
print_r($price_of_month);
exit;
//分幾期 () => 總共保養月 / 分期月
$SQuantitya = $elevator['maintain_months'] / $IncomeId[$payType];
$SQuantity = $IncomeId[$payType];
@ -710,14 +721,17 @@ function T8insert($data, $facilityno, $depId, $connT8)
$API_body[] = $salIncomeApplyMaster;
$API_body[] = $salIncomeApplyDetail;
// 呼叫 API
// echo '<pre>';
// print_r(json_encode($API_body));
// echo '</pre>';
echo '<pre>';
print_r(json_encode($API_body));
echo '</pre>';
// exit();
// $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);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
// exit();
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') {
http_response_code(404);
die('Error!:' . $result['ErrorMsg']);

83
wms/contract/api/test copy.json

@ -1,40 +1,43 @@
{
"apply_key": "MB24010007",
"register_code": "036B017432",
"elevator_brand": "1",
"elevator_kind": "A",
"spec": "MAE100",
"weight": 550,
"speed": 60,
"stop": 12,
"floors": 12,
"persons": 8,
"elevator_num": 0,
"useful_years": 83,
"last_check_date": 1121109,
"speed_governors_check_expense": 0,
"maintain_times": 1,
"is_m1_bundle": "N",
"maintainance": "A",
"maintain_months": 12,
"maintain_period": 1,
"stand_price": 3140,
"contract_price": 1666.67,
"sold_price": 1667,
"commission_expense": null,
"management_expense": null,
"annual_survey_expense": 0,
"service_expense": 8,
"cmstatus": "Y",
"updated_at": null,
"creater": null,
"created_at": "2024-01-10 11:16:26",
"discount": 53,
"opendoor": "2S",
"latitude": "112",
"longitude": "11",
"takecertificatedate": "112",
"useful_date": "113-01-01",
"bonus_verson": "2.0",
"manager": "M0137"
}
[
{
"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"
}
]

17
wms/contract/api/testT8API.php

@ -1,17 +0,0 @@
<?php
include_once("../conn.php");
$sql = "SELECT * FROM salIncomeApplyDetail WHERE BillNo ='B24010032'";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$aaa = intval($result['OAmountWithTax']) - 24;
$sql = "UPDATE salIncomeApplyDetail SET OAmountWithTax = $aaa WHERE BillNo = 'B24010032' AND RowCode = '1'";
$stmt = $connT8->prepare($sql);
$stmt->execute();
echo "<pre>";
print_r($result['OAmountWithTax']);
echo "</pre>";

10
wms/contract/api/testocde.php

@ -0,0 +1,10 @@
<?php
include_once("../conn.php");
$sql = "SELECT * FROM pricereview_pay WHERE mid = '441'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$pay_kind = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<pre>";
print_r($pay_kind);
echo "</pre>";

20
wms/contract/contract-input.php

@ -214,13 +214,23 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<input type="text" x-model="data.address" />
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養員</td>
<td style="vertical-align: middle">保養經理</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mworker">
<option value="">選擇保養員</option>
<?php foreach ($workers as $worker) { ?>
<select class="ui search dropdown" name="repairer_name" x-model="data.maintance_manager">
<option value="">選擇保養經理</option>
<option value="M0090">M0090--顏慶豪(北北基)</option>
<option value="M0223">M0223--鄭登元(桃竹)</option>
<option value="M0161">M0161--鄭永典(中區)</option>
<option value="M0077">M0077--鍾玉龍(南區)</option>
<!-- <?php foreach ($workers as $worker) {
// 北北基 : M0090
// 保養組長 桃竹 : M0223
// 中部 : M0161
// 南部 : M0077
?>
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option>
<?php } ?>
<?php } ?> -->
</select>
<!-- <p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>

9
wms/contract/js/alpine.js

@ -1012,7 +1012,7 @@ const contractInput = () => {
},
cities: [],
data: {
contractno: 'B24010030',
contractno: '',
total_price: '', //合約總價
vat: '', //統一編號
mtype: 'A', //維修型態
@ -1038,7 +1038,8 @@ const contractInput = () => {
payType: '', //付款方式
contract_type: 'new',
signing_date: '',
token: token
token: token,
maintance_manager: ''
// bonus_verson: 2.1,
// manager: '',
// regular_contract_manger_id: '',
@ -1138,7 +1139,7 @@ const contractInput = () => {
if (!this.customize) {
this.data.elevators = res.data.elevators;
for (let i = 0; i < res.data.elevators.length; i++) {
// 合約總價格。
// 合約總價格 (月)
this.data.total_price = Math.round(Number(res.data.elevators[i].sold_price) + Number(this.data.total_price));
// 服務費 (以單筆合約記,但計算獎金須傳入單月服務費)
@ -1148,6 +1149,7 @@ const contractInput = () => {
this.data.elevators[i].sold_price = Math.round(res.data.elevators[i].sold_price);
}
console.log(this.data.elevators);
// 合約總價
this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price;
this.data.salesman = res.data.salesman
this.data.contract_begin_date = res.data.contract_begin_date
@ -1245,6 +1247,7 @@ const contractInput = () => {
form.append('payType', this.data.payType);
form.append('contract_type', this.data.contract_type);
form.append('signing_date', this.data.signing_date);
form.append('maintance_manager', this.data.maintance_manager);
// 如果有附件檔案,可以逐一加入
for (var i = 0; i < this.data.files.length; i++) {

18
wms/schedule-edit.php

@ -149,7 +149,7 @@ foreach ($data as $data) :
<div>
<br>
<button type="submit" name="update">確認</button>
<button onclick="updateRepaire(<?= $data['contractno'] ?>,<?= $data['facilityno'] ?>)" style="text-align: right;">更新此作番保養人員</button>
<!-- <button onclick="updateRepaire(<?= $data['contractno'] ?>,<?= $data['facilityno'] ?>)" style="text-align: right;">更新此作番保養人員</button> -->
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
@ -160,22 +160,10 @@ foreach ($data as $data) :
endforeach;
include "footer.php";
include_once "./bonus/api/postSchedule.php"
// include_once "./bonus/api/postSchedule.php"
?>
<script src="../contract-repair/js/axios/axios.min.js"></script>
<script>
function updateRepaire(contractno, facilityno) {
const form = new FormData();
form.append("contractno", contractno);
form.append("facilityno", facilityno);
axios.post('./bonus/api/postSchedule.php', form).then((res) => {
if (res.data == 'Success') {
alert('更新成功');
location.reload();
}
}).catch((err) => {
})
}
</script>

22
wms/schedule-index.php

@ -36,10 +36,14 @@ if (!empty($sql_cmd2)) {
else $sql_cmd .= $sql_cmd2;
$page_close = 1; // 不分頁
}
$clause = "WHERE id IN (
SELECT MIN(id)
FROM schedule
GROUP BY contractno
)";
//$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
$sql = "SELECT DISTINCT contractno, schedule.* FROM schedule $sql_cmd ORDER BY CASE WHEN repairerid IS NULL THEN 0 ELSE 1 END, id";
// $sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
if (!$page_close) $sql .= " limit $page_from, $page_each";
// echo $sql;
@ -192,7 +196,8 @@ if ($data) :
<th>建檔時間</th>
<?php if ($user_auth & 2) { ?>
<th>修改</th>
<th>刪除</th>
<!-- <th>刪除</th> -->
<th>安排保養計畫人員</th>
<?php } ?>
</tr>
</thead>
@ -250,11 +255,16 @@ if ($data) :
</p>
</td>
<td>
<p>
<!-- <p>
<a href="schedule-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</p> -->
<?php if (empty($data['repairerid'])) { ?>
<p>
<a href="schedule-setting-repaire.php?id=<?= $data['id'] ?>&<?php echo $token_link; ?>"" class=" btn btn-info btn-sm">安排</a>
</p>
<?php } ?>
</td>
<?php } ?>
</tr>

66
wms/schedule-setting-repaire-update.php

@ -0,0 +1,66 @@
<?php
include "header.php";
include_once "./contract/conn.php";
if (isset($_POST['update'])) {
function user_input($data)
{
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$sql = "SELECT * FROM schedule WHERE id = '$id'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$checkRepaireIsit = $stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($checkRepaireIsit)) {
echo "<script type ='text/JavaScript'>";
echo "alert('此單號已經有保養人員');";
echo "location.href='schedule-index.php?function_name=schedule&" . $token_link . "';";
echo "</script>";
}
$contractno = user_input($_POST["contractno"]);
$facilityno = user_input($_POST["facilityno"]);
$repairerid = user_input($_POST["repairerid"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$sql = "SELECT name FROM account WHERE accountid = '$repairerid'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$account = $stmt->fetch(PDO::FETCH_ASSOC);
$repairername = $account['name'];
$db_query = "UPDATE schedule set
repairerid = '$repairerid',
repairername = '$repairername',
updater = '$creater',
update_at = '$create_at' WHERE contractno='$contractno' AND facilityno='$facilityno'";
$stmt = $conn->prepare($db_query);
$stmt->execute();
$affected = $stmt->rowCount();
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='schedule-index.php?function_name=schedule&" . $token_link . "';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='schedule-index.php?function_name=schedule&" . $token_link . "';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: ";
}
}

192
wms/schedule-setting-repaire.php

@ -0,0 +1,192 @@
<?php
include "header.php";
include_once "./contract/conn.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM schedule WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $db_query);
$sql = "SELECT * FROM account WHERE accounttype = 'B' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$repaire = $stmt->fetchAll(PDO::FETCH_ASSOC);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach ($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="schedule-setting-repaire-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="contractno">合約號</label>
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>" disabled>
</div>
<div>
<label for="facilityno">作番號</label>
<input type="text" name="facilityno" id="facilityno" value="<?php echo $data['facilityno']; ?>" disabled>
</div>
<!--
<div>
<label for="combono">保養套餐編號</label>
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>">
</div> -->
<div>
<label for="repairerid">保養人員工號</label>
<select name="repairerid" id="repairerid">
<option value=""></option>
<?php
foreach ($repaire as $repaire) {
?>
<option value="<?= $repaire['accountid'] ?>"><?php echo $repaire['accountid'] . '---' . $repaire['name'] ?></option>
<?php
}
?>
</select>
</div>
<!--
<div>
<label for="repairername">保養人員姓名</label>
<input type="text" name="repairername" id="repairername" value="<?php echo $data['repairername']; ?>">
</div> -->
<!--
<div>
<label for="duedate">應保養日期</label>
<input type="text" name="duedate" id="duedate" value="<?php echo $data['duedate']; ?>">
</div>
<div>
<label for="actualdate">實際保養日期</label>
<input type="text" name="actualdate" id="actualdate" data-date-format="yyyy-mm-dd" value="<?php echo $data['actualdate']; ?>">
</div>
<div>
<label for="item">保養項目編號</label>
<input type="text" name="item" id="item" value="<?php echo $data['item']; ?>">
</div>
<div>
<label for="item_detail">保養項目內容</label>
<input type="text" name="item_detail" id="item_detail" value="<?php echo $data['item_detail']; ?>">
</div> -->
<!-- <div>
<label for="result">保養結果</label>
<input type="text" name="result" id="result" value="<?php echo $data['result']; ?>">
</div> -->
<!--
<div>
<label for="evidences">上傳照片</label>
<input type="text" name="evidences" id="evidences" >
</div>
-->
<!-- <div>
<label for="descriptons">說明</label>
<input type="text" name="descriptons" id="descriptons" value="<?php echo $data['descriptons']; ?>">
</div>
<div>
<label for="customer_login_id">客戶評價登入帳號</label>
<input type="text" name="customer_login_id" id="customer_login_id" value="<?php echo $data['customer_login_id']; ?>">
</div>
<div>
<label for="customer_login_name">客戶姓名</label>
<input type="text" name="customer_login_name" id="customer_login_name" value="<?php echo $data['customer_login_name']; ?>">
</div>
<div>
<label for="stars">保養品質/評價等級(1-5星)</label>
<input type="text" name="stars" id="stars" onkeyup="if(value<0)value=0;if(value>5)value=5;value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" value="<?php echo $data['stars_c1']; ?>">
</div>
<div>
<label for="stars2">服務態度/評價等級(1-5星)</label>
<input type="text" name="stars2" id="stars2" onkeyup="if(value<0)value=0;if(value>5)value=5;value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" value="<?php echo $data['stars_c2']; ?>">
</div>
<div>
<label for="details">內容</label>
<input type="text" name="details" id="details" value="<?php echo $data['details']; ?>">
</div> -->
<!--
<div>
<label for="customer_signature">簽名檔</label>
<input type="text" name="customer_signature" id="customer_signature" value="<?php echo $data['customer_signature']; ?>">
</div>
-->
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update">確認</button>
<!-- <button onclick="updateRepaire(<?= $data['contractno'] ?>,<?= $data['facilityno'] ?>,<?= $user_id ?>)" style="text-align: right;">更新此作番保養人員</button> -->
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="hidden" name="reqaire" id="reqaire" value="">
</form>
</div>
<?php
endforeach;
include "footer.php";
// include_once "./bonus/api/postSchedule.php"
?>
<script src="./contract-repair/js/axios/axios.min.js"></script>
<script>
document.getElementById('repairerid').onchange = function() {
var repaireridValue = this.value;
// 根據選擇的值做相應的處理
document.getElementById('reqaire').value = repaireridValue;
console.log(repaireridValue);
};
// function updateRepaire(contractno, facilityno, user_id) {
// const form = new FormData();
// form.append("contractno", contractno);
// form.append("facilityno", facilityno);
// form.append("user_id", user_id)
// axios.post('./bonus/api/postSchedule.php', form).then((res) => {
// if (res.data == 'Success') {
// alert('更新成功');
// location.reload();
// }
// }).catch((err) => {
// })
// }
</script>
Loading…
Cancel
Save