Browse Source

契約價審完成

main
Cheng 1 year ago
parent
commit
758600ebcc
  1. 4
      wms/bonus/api/postSchedule.php
  2. 140
      wms/bonus/bonus_person.php
  3. 128
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php
  4. 166
      wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php
  5. 17
      wms/bonus/maintainance_bonus.php
  6. 17
      wms/class/Cmail.php
  7. 327
      wms/contract/api/postContractData.php
  8. 112
      wms/contract/api/test copy.json
  9. 261
      wms/contract/api/testT8API.php
  10. 36
      wms/contract/contract-input.php
  11. 22
      wms/contract/js/alpine.js
  12. 248
      wms/schedule-edit.php
  13. 12
      wms/schedule-index.php

4
wms/bonus/api/postSchedule.php

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

140
wms/bonus/bonus_person.php

@ -6,34 +6,34 @@ $now = date("Y-m-d");
$oneMonthAgo = date("Y-m-d", strtotime("$now +1 months"));
$oneMonthAgo1 = date("m", strtotime($oneMonthAgo));
$clause = "";
if ($_GET['check'] == 'maintainance') {
if (!empty($_GET)) {
$month = $_GET['months_select'];
$years = $_GET['years']; // 當前年份
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $years);
$select_date = date("$years-$month-01");
$select_date1 = date("$years-$month-$days_in_month");
echo $select_date1;
$clause .= "AND pay_day_due >='$select_date' AND pay_day_due <= '$select_date1' ";
} else {
$clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
}
// if ($_GET['check'] == 'maintainance') {
if (!empty($_GET['months_select']) && !empty($_GET['years'])) {
$month = $_GET['months_select'];
$years = $_GET['years']; // 當前年份
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $years);
$select_date = date("$years-$month-01");
$select_date1 = date("$years-$month-$days_in_month");
// echo $select_date1;
$clause .= "AND pay_day_due >='$select_date' AND pay_day_due <= '$select_date1' ";
} else {
$clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
}
// $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
$sql = "SELECT a.receiver,a.amount,b.name FROM bonus AS a
// $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
$sql = "SELECT a.receiver,a.amount,b.name FROM bonus AS a
LEFT JOIN account AS b ON a.receiver = b.accountid
WHERE 1=1 AND contract_type = 3 $clause ORDER BY a.receiver ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt = $conn->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$person_arr = [];
$bonus_arr = [];
$count = 0;
$person_arr = [];
$bonus_arr = [];
$count = 0;
$a = 0;
$j = 0;
}
$a = 0;
$j = 0;
// }
for ($i = 0; $i < COUNT($results); $i++) {
$a++;
@ -86,6 +86,7 @@ for ($i = 0; $i < COUNT($results); $i++) {
</thead>
</table>
<form method='get' action=''>
<table class='table table-striped table-bordered' style='width:70%;text-align:center;margin:0 auto'>
<tbody>
@ -117,6 +118,12 @@ for ($i = 0; $i < COUNT($results); $i++) {
<input type="hidden" name="function_name" value="schedule_index">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
<a href="/wms/bonus/maintainance_bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (empty($_GET)) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<!-- <a href="/wms/bonus/bonus.php?check=1&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 應發獎金</a> -->
<a href="/wms/bonus/maintainance_bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a>
<a href="/wms/bonus/bonus_person.php?check=maintainance&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo ((isset($_GET['check']) && $_GET['check'] == 'maintainance') || !empty($_GET['months_select'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 獎金總計(人)</a>
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
@ -144,3 +151,90 @@ for ($i = 0; $i < COUNT($results); $i++) {
</tbody>
</table>
</div>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
.width_st yle_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
table-layout: fixed;
width: 100%;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
.btn-secondary {
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover {
color: #fff;
background-color: #5a6268;
border-color: #545b62;
}
.applybtn {
color: #fff;
background-color: #1484c4;
/* display: block; */
border-radius: 5px;
/* padding: 5px 2px; */
font-size: 13px;
line-height: 1;
display: grid;
place-items: center;
/* 水平和垂直居中 */
/* height: 2%vh; */
/* 100%视窗高度,可根据需要调整 */
}
.applybtncheck {
color: #fff;
background-color: #eea236;
/* display: block; */
border-radius: 4px;
padding: 4px 2px;
font-size: 13px;
line-height: 1;
display: grid;
place-items: center;
/* 水平和垂直居中 */
height: 2%vh;
/* 100%视窗高度,可根据需要调整 */
}
.applybtncheck:hover {
background-color: #f0ad4e;
color: #fff;
}
.applybtn:hover {
background-color: #1494f9;
color: #fff;
}
</style>

128
wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php

@ -0,0 +1,128 @@
<?php
/*
獎金辦法 1.0_1 說明,需要查看合約收入的款項去發放該款項的獎金
函數用法與參數
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
營業員獎金($sales_bonus)
區域經理獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、貨到工地款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_price, $elevator_pay_kind, $sales_id, $region_manger_id)
{
$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 #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"payment_schedul_due" => "9999-1-1", #預計發放時間
"payment_schedul_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
};
return $result_array;
};

166
wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php

@ -0,0 +1,166 @@
<?php
/*
獎金辦法 2.0_1 說明,需要查看合約收入的款項去發放該款項的獎金
函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番機種($elevator_type):客梯(passenger)、貨梯(cargo)、小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
作番表價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
// 銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price)
營業員獎金($sales_bonus)
區域經理提成獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id)
{
$bonus_array = [];
if ($ver == "2.0") {
$elevator_knockdown_price = round($elevator_knockdown_price / 1.05); //不含稅
$discount = round($elevator_knockdown_price / $elevator_list_price, 3); #銷售點數,取到小數點第三位。
#合約總類($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":
switch ($elevator_type) {
#客梯(passenger)、貨梯(cargo)
case ($elevator_type == "passenger" or $elevator_type == "cargo"):
switch ($discount) {
case ($discount >= 1.0):
$sales_bonus = $elevator_knockdown_price * 0.02;
break;
case ($discount >= 0.9 and $discount < 1.0):
$sales_bonus = $elevator_knockdown_price * 0.018;
break;
case ($discount >= 0.75 and $discount < 0.9):
$sales_bonus = $elevator_knockdown_price * 0.015;
break;
case ($discount < 0.75):
$sales_bonus = $elevator_knockdown_price * 0.008;
break;
};
break;
#小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
case ($elevator_type == "dumbwaiter" or $elevator_type == "flatbase" or $elevator_type == "positive_drive"):
switch ($discount) {
case ($discount >= 1.0):
$sales_bonus = $elevator_knockdown_price * 0.02;
break;
case ($discount >= 0.9 and $discount < 1.0):
$sales_bonus = $elevator_knockdown_price * 0.018;
break;
case ($discount >= 0.72 and $discount < 0.9):
$sales_bonus = $elevator_knockdown_price * 0.015;
break;
case ($discount < 0.72):
$sales_bonus = $elevator_knockdown_price * 0.008;
break;
};
break;
};
#區域經理提成獎金($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 #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"payment_schedul_due" => "9999-1-1", #預計發放時間
"payment_schedul_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
};
return $result_array;
};

17
wms/bonus/maintainance_bonus.php

@ -23,9 +23,10 @@ $bonus_status = [
'4' => '暫不發放',
'5' => '人事審核確認'
];
// print_r($user_id);
$clause = '';
if ($user_id != 'M0225' || $user_id != 'M0012' || $user_id != 'M0029') {
$clause .= "AND receiver == '$user_id'";
if ($user_id != 'M0225' && $user_id != 'M0012' && $user_id != 'M0029') {
$clause .= "AND receiver = '$user_id'";
}
if (!empty($_GET['check'])) {
// 人事發放作業,應為一個月內
@ -43,7 +44,9 @@ if (!empty($_GET['check'])) {
$sql = "SELECT a.*,b.customer FROM bonus AS a
LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no
WHERE 1=1 $clause AND a.contract_type = 3";
// echo "<pre>";
// print_r($sql);
// echo "</pre>";
$stmt = $conn->prepare($sql);
$stmt->execute();
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
@ -85,11 +88,11 @@ $id_str = implode(',', $id);
<!-- <a href="bonus_index1.php?function_name=bonus&token=<?php echo $token; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a> -->
<a href="/wms/bonus/bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<!-- <a href="/wms/bonus/bonus.php?check=1&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 應發獎金</a> -->
<a href="/wms/bonus/bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
<a href="/wms/bonus/bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
<a href="/wms/bonus/bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a>
<a href="/wms/bonus/maintainance_bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a>
<a href="/wms/bonus/bonus_person.php?check=maintainance&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 5) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 獎金總計(人)</a>

17
wms/class/Cmail.php

@ -1,4 +1,5 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
@ -11,11 +12,11 @@ class Cmail
public $smtp_user = "";
public $smtp_pwd = "";
function __construct($charset='', $fromemail='')
function __construct($charset = '', $fromemail = '')
{
include dirname(__DIR__)."/PHPMailer/Exception.php";
include dirname(__DIR__)."/PHPMailer/PHPMailer.php";
include dirname(__DIR__)."/PHPMailer/SMTP.php";
include dirname(__DIR__) . "/PHPMailer/Exception.php";
include dirname(__DIR__) . "/PHPMailer/PHPMailer.php";
include dirname(__DIR__) . "/PHPMailer/SMTP.php";
$this->charset = "UTF-8";
$this->host = "mail.masada.com.tw";
@ -24,7 +25,7 @@ class Cmail
$this->smtp_pwd = "90493119"; // 這裡填寫SMTP登入密碼
}
function sendx($subject="", $em_body="", $sendlist=array(), $from="永佳捷科技", $bcc="", $files=array())
function sendx($subject = "", $em_body = "", $sendlist = array(), $from = "永佳捷科技", $bcc = "", $files = array())
{
if (!$sendlist) return;
$em_body = nl2br($em_body);
@ -53,10 +54,10 @@ class Cmail
//$mail->addBCC("personD@gmail.com", "person D");
//$mail->addAttachment("image1.jpg", "picture.jpg"); //設定附件, 對方會看到附件名稱為 picture.jpg
//print_r($mail);exit;
if (!$mail->Send()){
// echo "Mailer error: " . $mail->ErrorInfo;
if (!$mail->Send()) {
echo "Mailer error: " . $mail->ErrorInfo;
} else {
//echo "Email sent";
echo "Email sent";
}
}
}

327
wms/contract/api/postContractData.php

@ -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,

112
wms/contract/api/test copy.json

@ -1,72 +1,40 @@
[
{
"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": 2,
"cmstatus": "Y",
"updated_at": null,
"creater": null,
"created_at": "2024-01-10 11:16:26",
"discount": 0.5301496815286625,
"bonus_verson": "2.0",
"manager": "M0137"
},
{
"apply_key": "MB24010007",
"register_code": "036B032903",
"elevator_brand": "1",
"elevator_kind": "A",
"spec": "MAE100",
"weight": 450,
"speed": 60,
"stop": 7,
"floors": 7,
"persons": 6,
"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": 2540,
"contract_price": 1666.67,
"sold_price": 1667,
"commission_expense": null,
"management_expense": null,
"annual_survey_expense": 0,
"service_expense": 2,
"cmstatus": "Y",
"updated_at": null,
"creater": null,
"created_at": "2024-01-10 11:16:26",
"discount": 0.6553818897637795,
"bonus_verson": "2.0",
"manager": "M0137"
}
]
{
"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"
}

261
wms/contract/api/testT8API.php

@ -1,258 +1,17 @@
<?php
include_once("../conn.php");
$sql = "SELECT * FROM salIncomeApplyDetail WHERE BillNo ='B24010032'";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
// {
// "BillNo": "Z001", //合約單號
// "BillDate": 20210420, //簽約日期
// "TypeId": "SO", //
// "FOrgId": "1000",
// "OrgId": "1000",
// "ModeId": "T", // T汰改 M新梯
// "BizPartnerId": "M0225", //創建人ID
// "CurrId": "TWD",
// "CurrOAmount": 1,
// "CurrLAmount": 1,
// "PersonId": "M0225", //業務人員
// "DueToId": "512", //業務部門
// "TradeConditionId": "",
// "TaxId": "ST005",
// "CreditorCompId": "1000",
// "CreditorOrgId": "1000",
// "CreditorCurrOAmount": 1,
// "CreditorCurrLAmount": 1,
// "CompId": "1000"
// }
// ]
// },
// {
// //salSalesOrderDetail
// "name": "SubOrder",
// "rows": [
// {
// "SupplyCompId": "1001",
// "SupplyOrgId": "1000",
// "TaxId": "ST005",
// "RequirementDate": 20210420, //出貨日期
// "ConsignmentDate": 20210420, //發貨日期
// "DispatchCompId": "1001",
// "DispatchOrgId": "1000",
// "BillNo": "Z001", //合約號
// "RowCode": 1, //全部筆數排列
// "ItemType": 0,
// "MaterialId": "Z001", //作番號
// "SUnitId": "SET",
// "SQuantity": 1, //交易數量
// "SPrice": 1 //交易價格
// }
// ]
// },
// {
// "name": "salOrderStagePay",
// "rows": [
// {
// "BillNo": "",
// "RowCode": "",
// "RowNo": "",
// "PayStage": "ST003", //收款階段
// "PlanPercentage": "Z001", //計劃收款比例(%)
// "PlanPayAmt": 1, //計劃收款金額
// "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日
// "UnWriteOffOAmount": 1 //未核銷金額
// }
// ]
// }
// ]
require_once("../../T8_Authorization_from_bpm.php");
$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData";
$aaa = intval($result['OAmountWithTax']) - 24;
$sql = "UPDATE salIncomeApplyDetail SET OAmountWithTax = $aaa WHERE BillNo = 'B24010032' AND RowCode = '1'";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$validation = get_Auth();
$header = [
"CHI_Authorization :" . $validation,
"GroupId:MASADA"
];
$url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=1000,M24020076";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
print_r($result);
} else {
// print_r($result);
print_r($result);
}
print_r($result);
}
curl_close($ch);
exit();
$contract_no = "M24020003";
// $contract_no = "M24010109";
$MainSalesOrder_row = [
"BillNo" => "$contract_no", //合約單號
"BillDate" => 20210420, //簽約日期
"TypeId" => "SO", //
"FOrgId" => "1000",
"OrgId" => "1000",
"ModeId" => "M", // T汰改 M新梯
"BizPartnerId" => "$contract_no", //客戶代碼
"CurrId" => "TWD",
"CurrOAmount" => 1,
"CurrLAmount" => 1,
"PersonId" => "M0177", //業務人員
"DueToId" => "$contract_no", //債務方
"TradeConditionId" => "",
"TaxId" => "ST005",
"CreditorCompId" => "1001",
"CreditorOrgId" => "1000",
"CreatorId" => "M0225"
];
// //salSalesOrderDetail
// $SubOrder_row = [];
for ($i = 0; $i < 3; $i++) {
if ($i == 0) {
$row = [
// "SupplyCompId" => "1001",
// "SupplyOrgId" => "1000",
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 100000 //交易價格
];
}
if ($i == 1) {
$row = [
// "SupplyCompId" => "1001",
// "SupplyOrgId" => "1000",
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 650000 //交易價格
];
}
if ($i == 2) {
$row = [
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 0,
"MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 0 //交易價格
];
}
$SubOrder_row[] = $row;
}
$salOrderStagePay_row = [];
$roww = [
"PayStage" => "簽約", //收款階段
"PlanPercentage" => 0.5, //計劃收款比例(%)
"PlanPayAmt" => 375000, //計劃收款金額
"PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
"BillNo" => "$contract_no",
"RowCode" => 1,
"RowNo" => 1,
"UnWriteOffOAmount" => 375000 //未核銷金額
];
$roww2 = [
"PayStage" => "貨抵工地",
"PlanPercentage" => 0.5,
"PlanPayAmt" => 375000,
"PlanPayDate" => 20240101,
"BillNo" => "$contract_no",
"RowCode" => 2,
"RowNo" => 2,
"UnWriteOffOAmount" => 375000
];
$salOrderStagePay_row[] = $roww;
$salOrderStagePay_row[] = $roww2;
$MainSalesOrder = [
"name" => "MainSalesOrder",
'rows' => [$MainSalesOrder_row]
];
$SubOrder = [
"name" => "SubOrder",
"rows" => $SubOrder_row
];
$salOrderStagePay = [
"name" => "salOrderStagePay",
"rows" => $salOrderStagePay_row
];
$APIbody = [];
$APIbody[] = $MainSalesOrder;
$APIbody[] = $SubOrder;
$APIbody[] = $salOrderStagePay;
// $data = file_get_contents('test copy.json');
// $arr = json_decode($data, true);
// echo "<pre>";
// print_r($data);
// echo "</pre>";
echo "<pre>";
print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
print_r($result['OAmountWithTax']);
echo "</pre>";
// exit();
$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($APIbody, 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'];
print_r($result);
} else {
// print_r($result);
print_r($result);
}
print_r($result);
}
curl_close($ch);

36
wms/contract/contract-input.php

@ -74,7 +74,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<select class="ui fluid search dropdown" name="promiser" x-model="data.salesman">
<option value="">選擇營業員</option>
<?php foreach ($contractpersons as $person) { ?>
<option value="<?php echo $person['accountid'] ?>"><?php echo $person['name'] ?></option>
<option value="<?php echo $person['accountid'] ?>"><?php echo $person['accountid'] . '--' . $person['name'] ?></option>
<?php } ?>
</select>
<p class="alerttext" x-show="data.salesman==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -236,6 +236,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<option value="renew_priceissue">續簽約</option>
<option value="longcontract_m1_free_charge">長約(保養+免費M1電控)</option>
</select>
<p class="alerttext" x-show="data.contract_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td></td>
<td></td>
@ -276,11 +277,11 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td>
<select class="ui search dropdown" name="spec" x-model="data.elevators[idx].spec">
<option value="">選擇規格</option>
<option value="MAE100">MAE100</option>
<option value="MAM200">MAM200</option>
<option value="MAH100">MAH100</option>
<option value="MAQ100">MAQ100</option>
<option value="MAF100">MAF100</option>
<option value="MAE100">MAE100(有機房)</option>
<option value="MAM200">MAM200(無機房)</option>
<option value="MAH100">MAH100(家庭梯)</option>
<option value="MAQ100">MAQ100(強驅梯)</option>
<option value="MAF100">MAF100(貨梯) </option>
<option value="MAZ100">MAZ100</option>
</select>
<p class="alerttext" x-show="!(data.elevators[idx].spec=='MAE100' || data.elevators[idx].spec=='MAM200' || data.elevators[idx].spec=='MAH100' || data.elevators[idx].spec=='MAQ100' || data.elevators[idx].spec=='MAF100' || data.elevators[idx].spec=='MAZ100')"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -362,7 +363,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td style="vertical-align: middle">竣檢日(民國年分)</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.elevators[idx].takecertificatedate">
<p class="alerttext" x-show="data.elevators[idx].takecertificatedate=='' || !data.elevators[idx].takecertificatedate"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<!-- <p class="alerttext" x-show="data.elevators[idx].takecertificatedate=='' || !data.elevators[idx].takecertificatedate"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
</tr>
<tr>
@ -370,14 +371,16 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td style="vertical-align: middle">許可證有效日期<br>(民國年-月-日。Ex.113-01-01)</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.elevators[idx].useful_date">
<p class="alerttext" x-show="data.elevators[idx].useful_date=='' || !data.elevators[idx].useful_date"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<!-- <p class="alerttext" x-show="data.elevators[idx].useful_date=='' || !data.elevators[idx].useful_date"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">保養頻率</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.elevators[idx].maintain_times">
<option value="">選擇保養頻率</option>
<option value="2">雙週保</option>
<option value="1">月保</option>
<option value="2">月保兩次</option>
<option value="3">雙月保(2月一次)</option>
<option value="4">季保</option>
</select>
<p class="alerttext" x-show="data.maintain_times==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
@ -422,7 +425,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td> -->
<td style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="elevator.bonus_verson">
<input type="text" x-model="elevator.bonus_verson" disabled>
</td>
<td style="vertical-align:middle">作番契約金額(月)</td>
<td><input type="text" x-model="elevator.sold_price"></td>
@ -432,9 +435,17 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td><input type="text" x-model="elevator.discount"></td>
<td style="vertical-align:middle">地區處長員工號</td>
<td><input type="text" x-model="elevator.manager"></td>
<td>
<select class="ui search dropdown" name="manage" id="manage" x-model="elevator.regular_contract_manger_id">
<option value="">請選擇</option>
<option value="M0137">劉永德</option>
<option value="M0054">陳志文</option>
<option value="M0033">吳育宗</option>
<option value="M0086">李烘銘</option>
</select>
</td>
<td style="vertical-align:middle">專任契約經理員工號</td>
<td><input type="text" x-model="elevator.regular_contract_manger_id"></td>
<td><input type="text" x-model="elevator.manager"></td>
<!-- <td style="vertical-align:middle">折扣率(%)</td>
<td colspan="2">
<input type="text" x-model='elevator.discount'>
@ -487,5 +498,6 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<script>
const user_id = '<?php echo $user_id; ?>'
const user_name = '<?php echo $user_name; ?>'
const token = '<?php echo $token ?>';
// console.log(123);
</script>

22
wms/contract/js/alpine.js

@ -830,6 +830,7 @@ const contractNewInput = () => {
area_no: 'T',
contract_arrival_date: ''
},
fail_arr: [],
step: 1,
isLoading: false,
customize: false,
@ -840,6 +841,7 @@ const contractNewInput = () => {
this.getContractDate();
} else if (this.step == 2) {
if (this.data.nums <= 0) return alert('請填寫電梯數量!')
checkInput();
this.getElevatorsData();
} else if (this.step == 3) {
this.getElevatorsData();
@ -909,11 +911,23 @@ const contractNewInput = () => {
}
this.step = 2
this.isLoading = false
}).catch(err => {
console.error(err)
this.isLoading = false
})
},
checkInput() {
// if (this.data.customer == '') this.fail_arr.push('客戶名稱為必填')
// console.log(123);
// let msg = '';
// if (this.fail_arr.length > 0) {
// for (let i = 0; i < this.fail_arr.length; i++) {
// msg += this.fail_arr[i] + "、";
// }
// }
// alert(msg)
},
save() {
this.isLoading = true
const form = new FormData();
@ -976,7 +990,7 @@ const contractNewInput = () => {
},
errorFn() {
let msg = ''
for (let i = 0; i < this.fail_arr.length; i++) {
for (let i = 0; i < JSON.parse(this.fail_arr).length; i++) {
msg += this.fail_arr[i] + '、'
}
alert(msg)
@ -1023,7 +1037,8 @@ const contractInput = () => {
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: '', //付款方式
contract_type: 'new',
signing_date: ''
signing_date: '',
token: token
// bonus_verson: 2.1,
// manager: '',
// regular_contract_manger_id: '',
@ -1119,7 +1134,7 @@ const contractInput = () => {
this.isLoading = false
return
}
console.log(res.data.service_expense);
// console.log(res.data.service_expense);
if (!this.customize) {
this.data.elevators = res.data.elevators;
for (let i = 0; i < res.data.elevators.length; i++) {
@ -1226,6 +1241,7 @@ const contractInput = () => {
form.append('num', this.data.num);
form.append('elevators', JSON.stringify(this.data.elevators));
form.append('contracttype', 'b');
form.append('token', this.data.token);
form.append('payType', this.data.payType);
form.append('contract_type', this.data.contract_type);
form.append('signing_date', this.data.signing_date);

248
wms/schedule-edit.php

@ -1,15 +1,24 @@
<?php
include "header.php";
include "header.php";
include_once "./contract/conn.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM schedule WHERE id=$id";
$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);
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
@ -24,122 +33,149 @@
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
foreach ($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="schedule-record-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']; ?>">
</div>
<div>
<label for="facilityno">作番號</label>
<input type="text" name="facilityno" id="facilityno" value="<?php echo $data['facilityno']; ?>">
</div>
<div>
<label for="combono">保養套餐編號</label>
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>">
</div>
<div>
<label for="repairerid">保養人員工號</label>
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>">
</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 class="container">
<form class="form-inline" method="post" action="schedule-record-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']; ?>">
</div>
<div>
<label for="facilityno">作番號</label>
<input type="text" name="facilityno" id="facilityno" value="<?php echo $data['facilityno']; ?>">
</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="repaire" id="repaire">
<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="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>
<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>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<div>
<br>
<button type="submit" name="update">確認</button>
<button onclick="updateRepaire(<?= $data['contractno'] ?>,<?= $data['facilityno'] ?>)" style="text-align: right;">更新此作番保養人員</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
endforeach;
include "footer.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>

12
wms/schedule-index.php

@ -4,7 +4,7 @@ include "header.php";
$tourl = $_SERVER["SCRIPT_NAME"] . "?function_name=schedule&token=" . $token;
// 工務總處可瀏覽全部資料
$sql = "select department_id, role_id from account where accountid = '$user_id'";
$sql = "select department_id, role_id from account where accountid = '$user_id' AND accounttype IN ('B','E','M','W') ";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
@ -41,7 +41,7 @@ if (!empty($sql_cmd2)) {
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
if (!$page_close) $sql .= " limit $page_from, $page_each";
//echo $sql;
// echo $sql;
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $sql);
@ -211,15 +211,17 @@ if ($data) :
<!-- <td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item_detail']; ?></td> -->
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;">
<?php //echo $data['result']; ?>
<?php //echo $data['result'];
?>
<a href="/app/app-maintenance-uploadsuccess-survey.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>">查看明細</a>
</td>
<td>
<a href="/app/app-maintenance-uploadsuccess-photo-review_v2.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>">瀏覽</a>
<a href="/app/app-maintenance-uploadsuccess-photo-review_v2.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>">瀏覽</a>
<?php if ($data['evidences']) {
// echo "<a href=\"/app/" . $data['evidences'] . "\">瀏覽</a>";
} ?></td>
} ?>
</td>
<td><?php echo $data['descriptons']; ?></td>
<!-- <td><?php echo $data['customer_login_id']; ?></td> -->
<td><?php echo $data['customer_login_name']; ?></td>

Loading…
Cancel
Save