Browse Source

新梯架審更新20240217

main
10994015 1 year ago
parent
commit
bb76cb6c55
  1. 176
      wms/T8-purReceive-submit.php
  2. 176
      wms/T8-purchase-submit.php
  3. 8
      wms/T8_Authorization.php
  4. 6
      wms/T8_Authorization_from_bpm.php
  5. BIN
      wms/WriteOff.xlsx
  6. BIN
      wms/account-receivable-.xlsx
  7. 201
      wms/account-receivable-check.php
  8. 2817
      wms/account-receivable-contract.php
  9. 70
      wms/account-receivable-index.php
  10. 1
      wms/account-receivable-invoice.php
  11. 124
      wms/account-receivable-received-create.php
  12. 142
      wms/account-receivable-received-edit.php
  13. 96
      wms/account-receivable-received-submit.php
  14. 61
      wms/account-receivable-renovate-excel.php
  15. 773
      wms/account-receivable-renovate-index-ing.php
  16. 185
      wms/account-receivable-renovate-index.php
  17. BIN
      wms/account-receivable-renovate.xlsx
  18. 485
      wms/account-receivable-repair-index.php
  19. BIN
      wms/account-receivable-repair.xlsx
  20. 64
      wms/account-receivable-test.php
  21. 75
      wms/bons/api/get.php
  22. 399
      wms/bons/maintainance_contract_payment_status.php
  23. 87
      wms/bonus/api/get.php
  24. 11
      wms/bonus/api/getAccount.php
  25. 111
      wms/bonus/api/postCalBouns.php
  26. 27
      wms/bonus/api/updateBonus.php
  27. 301
      wms/bonus/bonus.php
  28. 117
      wms/bonus/bonus_detail.php
  29. 378
      wms/bonus/bonus_index1.php
  30. 15
      wms/bonus/connT8.php
  31. 0
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0.php
  32. 0
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php
  33. 0
      wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php
  34. 0
      wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php
  35. 307
      wms/bonus/insertBonus.php
  36. 0
      wms/bonus/maintance/maintenance_contract_bonus_v2_0.php
  37. 0
      wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php
  38. 159
      wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1.php
  39. 83
      wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1_examination.php
  40. 160
      wms/bonus/other/elevator_renew_withinstallment_bonus_v2_1.php
  41. 85
      wms/bonus/other/elevator_renew_withinstallment_bonus_v2_1_examination.php
  42. 299
      wms/bonus/other/maintenance_contract_bonus_v2_1.php
  43. 291
      wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php
  44. 196
      wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php
  45. 101
      wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php
  46. 62
      wms/class/Cmail.php
  47. 109
      wms/class/Cnotice.php
  48. BIN
      wms/cont/.DS_Store
  49. 648
      wms/cont/MICalculator.php
  50. 644
      wms/cont/MSCalculator.php
  51. 1716
      wms/cont/apply_form.php
  52. 1787
      wms/cont/apply_form2.php
  53. 42
      wms/cont/conn.php
  54. 1020
      wms/cont/query_form.php
  55. 1152
      wms/cont/sign_form.php
  56. 157
      wms/cont/submit.php
  57. 168
      wms/cont/t.php
  58. 13
      wms/contract-repair/api/getContractData.php
  59. 7
      wms/contract-repair/api/postContractData.php
  60. 263
      wms/contract-repair/contract-renovate-input.php
  61. 6
      wms/contract-repair/contract-repair-input.php
  62. 2
      wms/contract-repair/contract-repair-management.php
  63. 289
      wms/contract-repair/js/alpine.js
  64. 20
      wms/contract/api/testT8API.php
  65. 5
      wms/contract/conn.php
  66. 2
      wms/contract/connt8.php
  67. 6
      wms/contract/contract-new-apply.php
  68. BIN
      wms/contract/option/option2.xlsx
  69. 2
      wms/crm/crmm06_submit.php
  70. 6
      wms/excel/import.php
  71. 1
      wms/frame/api_getdata.php
  72. 62
      wms/fun_global.php
  73. 46
      wms/mkt/api/getElevatorMi.php
  74. 38
      wms/mkt/api/postPricereviewSign.php
  75. 183
      wms/mkt/assets/js/pricereviewAlpine.js
  76. 43
      wms/mkt/css/pricereview.css
  77. 2
      wms/mkt/css/pricereview.css.map
  78. 50
      wms/mkt/css/pricereview.scss
  79. 31
      wms/mkt/pricereview-check.php
  80. 45
      wms/mkt/pricereview-create.php
  81. 51
      wms/mkt/pricereview-edit.php
  82. 22
      wms/mkt/pricereview-index.php
  83. 12
      wms/mkt/pricereview-record-submit.php
  84. 715
      wms/mkt/pricereviewCheck.php
  85. 77
      wms/mkt/pricereview_mi-api.php
  86. 2
      wms/mkt/pricereview_repair-check.php
  87. 15
      wms/mkt/pricereview_repair-create.php
  88. 27
      wms/mkt/pricereview_repair-record-submit.php
  89. 3
      wms/rib01-check.php
  90. 22
      wms/rib01-edit.php
  91. 150
      wms/rib01-index.php
  92. 107
      wms/rib02-edit.php
  93. 18
      wms/rib02-submit.php

176
wms/rib02-purReceive-submit.php → wms/T8-purReceive-submit.php

@ -1,89 +1,89 @@
<?php <?php
include "T8_Authorization.php"; include "T8_Authorization.php";
echo "收貨申請單"; echo "收貨申請單";
?> ?>
<script> <script>
console.log(<?= $now ?>); console.log(<?= $now ?>);
get_Auth(); get_Auth();
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
var validation = event.data; var validation = event.data;
console.log("event"); console.log("event");
console.log(validation); console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; // var corsurl = 'http://cors-anywhere.herokuapp.com/';
var apiurl = 'http://60.244.87.101:880//twWebAPI/V1/PURRECEIVINGORDER/PostERPData'; var apiurl = 'http://60.244.87.101:880//twWebAPI/V1/PURRECEIVINGORDER/PostERPData';
headerParam = { headerParam = {
CHI_Authorization: `${validation}`, CHI_Authorization: `${validation}`,
}; };
var body = [ var body = [
{ {
"name": "purReceivingOrderMaster", "name": "purReceivingOrderMaster",
"rows": [ "rows": [
{ {
"BillNo": "Z003", "BillNo": "Z003",
"BillDate": 20210420, "BillDate": 20210420,
"ReceiveOrgId": "1000", "ReceiveOrgId": "1000",
"OrgId": "1000", "OrgId": "1000",
"DemandOrgId": "1000", "DemandOrgId": "1000",
"TypeId": "MA", "TypeId": "MA",
"FromSourceTag":"PO", "FromSourceTag":"PO",
"FromTransId":"Z003", "FromTransId":"Z003",
// "BizPartnerId": "16547907", // "BizPartnerId": "16547907",
// "PersonId": "M0122", // "PersonId": "M0122",
// "CurrId": "TWD", // "CurrId": "TWD",
// "CurrOAmount": 1, // "CurrOAmount": 1,
// "CurrLAmount": 1, // "CurrLAmount": 1,
// "ReciveDate": 20210420, // "ReciveDate": 20210420,
// "DueToId": "Z001", // "DueToId": "Z001",
// "TaxId": "ST005", // "TaxId": "ST005",
// "DebtorOrgId": "1000", // "DebtorOrgId": "1000",
// "DebtorCurrOAmount": 1, // "DebtorCurrOAmount": 1,
// "DebtorCurrLAmount": 1, // "DebtorCurrLAmount": 1,
// "ReceiveCompId": "1000", // "ReceiveCompId": "1000",
// "DebtorCompId": "1000", // "DebtorCompId": "1000",
// "DemandCompId": "1000", // "DemandCompId": "1000",
"InStoreState":2, "InStoreState":2,
"CurrentState":2 "CurrentState":2
} }
] ]
}, },
{ {
"name": "purReceivingOrderDetail", "name": "purReceivingOrderDetail",
"rows": [ "rows": [
{ {
// "TaxId": "ST005", // "TaxId": "ST005",
"FromSourceTag":"PO", "FromSourceTag":"PO",
"FromBillNo":"Z003", "FromBillNo":"Z003",
"BillNo": "Z002", "BillNo": "Z002",
"RowCode": "1", "RowCode": "1",
"ItemType": 0, "ItemType": 0,
"MaterialId": "MX01030018", "MaterialId": "MX01030018",
"ReceivingSQty": 1, "ReceivingSQty": 1,
// "SUnitId": "SET", // "SUnitId": "SET",
"SPrice": "100" "SPrice": "100"
} }
] ]
} }
] ]
; ;
var json = JSON.stringify(body); var json = JSON.stringify(body);
obj = { obj = {
type: 'POST', type: 'POST',
// url: `${corsurl}${apiurl}`, // url: `${corsurl}${apiurl}`,
url: `${apiurl}`, url: `${apiurl}`,
// dataType: 'json', // dataType: 'json',
headers: headerParam, headers: headerParam,
data: json, data: json,
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
console.log(res.Status); console.log(res.Status);
console.log(res.ErrorMsg); console.log(res.ErrorMsg);
console.log(res.Data); console.log(res.Data);
} }
}; };
jQuery.ajax(obj); jQuery.ajax(obj);
} }
}) })
</script> </script>

176
wms/rib02-purchase-submit.php → wms/T8-purchase-submit.php

@ -1,89 +1,89 @@
<?php <?php
include "T8_Authorization.php"; include "T8_Authorization.php";
echo "採購單"; echo "採購單";
echo "111"; echo "111";
?> ?>
<script> <script>
console.log(<?= $now ?>); console.log(<?= $now ?>);
get_Auth(); get_Auth();
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
var validation = event.data; var validation = event.data;
console.log("event"); console.log("event");
console.log(validation); console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; // var corsurl = 'http://cors-anywhere.herokuapp.com/';
var apiurl = 'http://60.244.87.101:880//twWebAPI/V1/PURPURCHASEORDER/PostERPData'; var apiurl = 'http://60.244.87.101:880//twWebAPI/V1/PURPURCHASEORDER/PostERPData';
headerParam = { headerParam = {
CHI_Authorization: `${validation}`, CHI_Authorization: `${validation}`,
}; };
var body = [{ var body = [{
"name": "purBillOrderMaster", "name": "purBillOrderMaster",
"rows": [{ "rows": [{
"BillNo": "Z004", "BillNo": "Z004",
"BillDate": 20210420, "BillDate": 20210420,
"TypeId": "PO", "TypeId": "PO",
"OrgId": "1000", "OrgId": "1000",
"FOrgId": "1000", "FOrgId": "1000",
"BizPartnerId": "33709933", "BizPartnerId": "33709933",
"CurrId": "TWD", "CurrId": "TWD",
"CurrOAmount": 1.00000, "CurrOAmount": 1.00000,
"CurrLAmount": 1.00000, "CurrLAmount": 1.00000,
"PersonId": "M0122", "PersonId": "M0122",
"DueToId": "33709933", "DueToId": "33709933",
"TaxId": "ST005", "TaxId": "ST005",
// "DebtorOrgId": "1000", // "DebtorOrgId": "1000",
// "DebitorCurrId": "TWD", // "DebitorCurrId": "TWD",
// "DebtorCurrOAmount": 1.00000, // "DebtorCurrOAmount": 1.00000,
// "DebtorCurrLAmount": 1.00000, // "DebtorCurrLAmount": 1.00000,
"CompId": "1001", "CompId": "1001",
// "DebtorCompId": "1001", // "DebtorCompId": "1001",
"CurrentState": 2, "CurrentState": 2,
"FlowState": 2, "FlowState": 2,
"PermitState": 2, "PermitState": 2,
"Remark":"testtest", "Remark":"testtest",
"CreatorId": "M0122", "CreatorId": "M0122",
"IsPriceWithTax":1 "IsPriceWithTax":1
}] }]
}, },
{ {
"name": "purBillOrderDetail", "name": "purBillOrderDetail",
"rows": [{ "rows": [{
"DemandOrgId": "1000", "DemandOrgId": "1000",
"TaxId": "ST005", "TaxId": "ST005",
"DeliveryDate": 20210420, "DeliveryDate": 20210420,
"ReceiveOrgId": "1000", "ReceiveOrgId": "1000",
"DebtorOrgId": "1000", "DebtorOrgId": "1000",
"ReceiveCompId": "1001", "ReceiveCompId": "1001",
"DemandCompId": "1001", "DemandCompId": "1001",
"BillNo": "Z004", "BillNo": "Z004",
"RowCode": 1, "RowCode": 1,
"ItemType": 0, "ItemType": 0,
"MaterialId": "MX23010003", "MaterialId": "MX23010003",
// "MaterialSpec": "LY-08/紅光/1", // "MaterialSpec": "LY-08/紅光/1",
"SQuantity": 1.00000, "SQuantity": 1.00000,
"PresentSQty":1, "PresentSQty":1,
"SPrice": 100 "SPrice": 100
}] }]
} }
]; ];
var json = JSON.stringify(body); var json = JSON.stringify(body);
obj = { obj = {
type: 'POST', type: 'POST',
// url: `${corsurl}${apiurl}`, // url: `${corsurl}${apiurl}`,
url: `${apiurl}`, url: `${apiurl}`,
// dataType: 'json', // dataType: 'json',
headers: headerParam, headers: headerParam,
data: json, data: json,
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
console.log(res.Status); console.log(res.Status);
console.log(res.ErrorMsg); console.log(res.ErrorMsg);
console.log(res.Data); console.log(res.Data);
} }
}; };
jQuery.ajax(obj); jQuery.ajax(obj);
} }
}) })
</script> </script>

8
wms/T8_Authorization.php

@ -14,12 +14,13 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
var validation = ""; var validation = "";
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; // var corsurl = 'http://cors-anywhere.herokuapp.com/';
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; // var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth' // var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
headerParam = { headerParam = {
UserId: 'M0000', UserId: 'M0000',
Pwd: 'M012290493119', Pwd: 'M012290493119',
TimestampUTC: <?= $now ?>, TimestampUTC: <?= $now ?>,
Sign: '<?= $sign ?>' Sign: '<?= $sign ?>',
GroupId: 'TEST',
}; };
obj = { obj = {
type: 'get', type: 'get',
@ -30,7 +31,7 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
success: function(res) { success: function(res) {
validation = res.Data['CHI_Authorization']; validation = res.Data['CHI_Authorization'];
console.log(validation); console.log(validation);
// console.log(res); console.log(res);
// console.log() // console.log()
// window.parent.postMessage(validation,'http://localhost:3000'); // window.parent.postMessage(validation,'http://localhost:3000');
// window.parent.postMessage(validation,'https://masada.com.tw'); // window.parent.postMessage(validation,'https://masada.com.tw');
@ -40,4 +41,5 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
jQuery.ajax(obj); jQuery.ajax(obj);
// return jQuery.ajax(obj); // return jQuery.ajax(obj);
} }
get_Auth();
</script> </script>

6
wms/T8_Authorization_from_bpm.php

@ -24,11 +24,13 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
// $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; // $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
//GroupId : TEST測試區 ; MASADA正式區
$headerParam = [ $headerParam = [
"UserId: $user_id", "UserId: $user_id",
"Pwd: $user_password", "Pwd: $user_password",
"TimestampUTC: $now", "TimestampUTC: $now",
"Sign: $sign" "Sign: $sign",
"GroupId: TEST"
]; ];
$ch = curl_init(); $ch = curl_init();
@ -51,4 +53,4 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
curl_close($ch); curl_close($ch);
} }
// $data = []; // $data = [];
// get_Auth(); get_Auth();

BIN
wms/WriteOff.xlsx

Binary file not shown.

BIN
wms/account-receivable-.xlsx

Binary file not shown.

201
wms/account-receivable-check.php

@ -1,201 +0,0 @@
<?php
include "./header.php";
$BillNo = $_GET['BillNo'];
echo $BillNo;
//企業名稱 統一編號 聯絡地址
// $Bill = $_POST['Bill'];
// $Bill = json_decode($Bill, true);
// $sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
// $pay_received = mysqli_query($link, $sql_received);
// $had_received = 0;
// if (mysqli_num_rows($pay_received) == 0) {
// foreach ($pay_received as $received) {
// $had_received += $received['received_amount'];
// }
// }
// $unreceived = $Bill[12] - $had_received;
// $data = json_encode($Bill);
?>
<style>
th {
text-align: center;
}
td {
text-align: right;
}
</style>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-home"></span>
</a>
</div>
</div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong><?= $Bill[4] ?></strong></h3>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptId">部門</label>
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="Manager">經理</label>
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled>
</div>
</div>
<div>
<label for="detail">狀態</label>
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea>
</div>
</form>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>目前應收</th>
<th>已開發票金額</th>
<th>未開發票金額</th>
<th>已收金額</th>
<th>未收金額</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[12])) ?></td>
<td><?= number_format(round($Bill[19])) ?></td>
<td><?= number_format(round($Bill[21])) ?></td>
<td><?= number_format(round($Bill[20])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td>
</tr>
</tbody>
</table>
</div>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>簽約款</th>
<th>二次款</th>
<th>貨抵工地款</th>
<th>安裝款</th>
<th>試車款</th>
<th>官檢款</th>
<th>交車款</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[5])) ?></td>
<td><?= number_format(round($Bill[6])) ?></td>
<td><?= number_format(round($Bill[7])) ?></td>
<td><?= number_format(round($Bill[8])) ?></td>
<td><?= number_format(round($Bill[9])) ?></td>
<td><?= number_format(round($Bill[10])) ?></td>
<td><?= number_format(round($Bill[11])) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
include "./footer.php";
?>
<?php
if ($user_id == "M0122") {
?>
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button>
<?php
}
?>
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>發票日期</th>
<th>發票金額</th>
<th>收款日期</th>
<th>收款金額</th>
<th>說明</th>
<th style="width: 10%;">功能</th>
</tr>
</thead>
<tbody>
<?php if ($pay_received) {
foreach ($pay_received as $received) { ?>
<tr>
<td><?= $received['invoice_date'] ?></td>
<td><?= number_format($received['invoice_amount']) ?></td>
<td><?= $received['received_date'] ?></td>
<td><?= number_format($received['received_amount']) ?></td>
<td><?= $received['remark'] ?></td>
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?>
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
<span class="glyphicon glyphicon-pencil"></span></button>
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<span class=" glyphicon glyphicon-trash"></span>
</a>
<?php } ?>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
<script>
function create(type, pay_id) {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
if (type === 'create') {
form.action = "account-receivable-received-create.php?<?= $token_link ?>";
} else {
form.action = "account-receivable-received-edit.php?pay_id=" + pay_id + "&<?= $token_link ?>";
}
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(BillData);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
</script>

2817
wms/account-receivable-contract.php

File diff suppressed because it is too large

70
wms/account-receivable-index.php

@ -17,32 +17,38 @@ $follower = find_follow($user_id);
$arrayData = []; $arrayData = [];
$receivable_array = []; $receivable_array = [];
// T8發票 (有專案的發票) // T8發票 (有專案的發票)
$sql_invoice = "SELECT DISTINCT $sql_invoice = "SELECT
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, Detail.BillNo AS InvoiceBillNo,
b.ProjectId Detail.MaterialId,
FROM arSellInvoice as a Detail.LAmountWithTax,
LEFT JOIN arSellInvoiceMaterial as b Main.InvoiceNo,
ON a.BillNo=b.BillNo CheckAll.FromSalSalesOrder AS BillNo
WHERE DATALENGTH(b.ProjectId)>0"; FROM arSellInvoiceMaterial AS Detail
LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo
LEFT JOIN (
SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo
FROM arCheckBillDetail AS CheckDetail )
AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo
WHERE Detail.ItemType=0 AND Main.InvoiceState!=2";
// T8核銷 // T8核銷
$sql_received = "SELECT $sql_received = "SELECT
a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount, CheckDetail.OrderBillNo,
b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee, arWriteOffBillDetail.FromBillNo AS CheckBillNo,
c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate arWriteOffBillDetail.FromRowCode AS CheckRowCode,
FROM arWriteOffBill AS a arWriteOffBillDetail.CurrStandOffOAmount
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo FROM arWriteOffBillDetail
LEFT JOIN LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail (SELECT
LEFT JOIN arCheckBillDetail.BillNo,
(SELECT arCheckBillDetail.RowCode,
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo arCheckBillDetail.FromSalSalesOrder AS OrderBillNo,
FROM arCheckBill salSalesOrder.TypeId
LEFT JOIN arCheckBillInvInfo FROM arCheckBillDetail
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 LEFT JOIN salSalesOrder
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder )
ON a.BillNo=c.BillNo AS CheckDetail
WHERE DATALENGTH(c.OrderBillNo) >0"; ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode";
//T8 銷售訂單 階段收款計畫 //T8 銷售訂單 階段收款計畫
$sql_contract = "SELECT a.BillNo,s.BillDate, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, $sql_contract = "SELECT a.BillNo,s.BillDate, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId,
@ -508,7 +514,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { if (isset($arrayData[$wip['contractno']]['delivery'][0]) && $arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']); $estimate_delivery_time = strtotime($wip['delivery_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime); $month = collect_month($arrivetime);
@ -972,9 +978,9 @@ foreach ($wipwhole_array as $wip) {
} }
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號] // [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號]
foreach ($invoice_data as $invoice) { foreach ($invoice_data as $invoice) {
if (isset($arrayData[$invoice['ProjectId']])) { if (isset($arrayData[$invoice['BillNo']])) {
$arrayData[$invoice['ProjectId']]['invoice_budget'] += intval($invoice['OAmountWithTax']); $arrayData[$invoice['BillNo']]['invoice_budget'] += intval($invoice['OAmountWithTax']);
$arrayData[$invoice['ProjectId']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; $arrayData[$invoice['BillNo']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']];
} }
} }
@ -987,11 +993,13 @@ foreach ($received_array as $received) {
} else { } else {
$BillNo = $received['OrderBillNo']; $BillNo = $received['OrderBillNo'];
}; };
if (isset($arrayData[$BillNo])) { if (isset($arrayData[$BillNo])) {
if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { $arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount'];
$arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; // if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) {
array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); // $arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount'];
} // array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']);
// }
} }
} }

1
wms/account-receivable-invoice.php

@ -1 +0,0 @@
<?php

124
wms/account-receivable-received-create.php

@ -1,124 +0,0 @@
<?php
include "./header.php";
$Bill = $_POST['Bill'];
$BillData = json_decode($Bill, true);
?>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div>
</div>
<div class="container">
<div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3>
<h4>新增收款資訊</h4>
</div>
<form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=create&<?= $token_link ?>" enctype="multipart/form-data">
<div class="form-group" style="margin-left: 1%;margin-right: 1%;">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptName">部門</label>
<input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="ManagerName">經理</label>
<input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="InvoiceDate">發票開立日期</label>
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate">
</div>
<div class="col-md-3">
<label for="InvoiceAmount">發票金額</label>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount">
</div>
<div class="col-md-3">
<label for="InvoiceNo">發票號碼</label>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo">
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="ReceivedDate">收款日期</label>
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate">
</div>
<div class="col-md-3">
<label for="ReceivedAmount">收款金額</label>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount">
</div>
<div class="col-md-3">
<label for="remark">備註</label>
<input type="text" class="form-control" id="remark" name="remark">
</div>
</div>
<input type="hidden" name="DeptId" value="<?= $BillData[17] ?>">
<input type="hidden" name="PersonId" value="<?= $BillData[18] ?>">
<input type="hidden" name="CustName" value="<?= $BillData[4] ?>">
<input type="hidden" name="Bill" id="Bill" value="">
</div>
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
<button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button>
</div>
</div>
</form>
</div>
<script>
function backToIndex() {
var Bill = <?= $Bill ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(Bill);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function send() {
event.preventDefault();
$("#BillNo").prop("disabled", false);
$("#DeptName").prop("disabled", false);
$("#ManagerName").prop("disabled", false);
$("#PersonName").prop("disabled", false);
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script>

142
wms/account-receivable-received-edit.php

@ -1,142 +0,0 @@
<?php
include "./header.php";
$Bill = $_POST['Bill'];
$BillData = json_decode($Bill, true);
$pay_id = $_GET['pay_id'];
// echo $pay_id."<br>";
// print_r($BillData);
$sql_pay = "SELECT * from account_received where pay_id = '$pay_id'";
$pay = mysqli_query($link, $sql_pay);
$pay = mysqli_fetch_assoc($pay);
?>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div>
</div>
<div class="container">
<div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3>
<h4>編輯收款資訊</h4>
</div>
<form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=edit&<?= $token_link ?>" enctype="multipart/form-data">
<div class="form-group" style="margin-left: 1%;margin-right: 1%;">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptName">部門</label>
<input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="ManagerName">經理</label>
<input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="InvoiceDate">發票開立日期</label>
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" value="<?= $pay['invoice_date'] ?>">
</div>
<div class="col-md-3">
<label for="InvoiceAmount">發票金額</label>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" value="<?= $pay['invoice_amount'] ?>">
</div>
<div class="col-md-3">
<label for="InvoiceNo">發票號碼</label>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" value="<?= $pay['invoice_no'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="ReceivedDate">收款日期</label>
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" value="<?= $pay['received_date'] ?>">
</div>
<div class="col-md-3">
<label for="ReceivedAmount">收款金額</label>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" value="<?= $pay['received_amount'] ?>">
</div>
<div class="col-md-3">
<label for="remark">備註</label>
<input type="text" class="form-control" id="remark" name="remark" value="<?= $pay['remark'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="status" style="color: red;">狀態</label>
<select id="status" name="status">
<option value=0 <?php if ($pay['status'] == 0) echo "selected" ?>>進行中</option>
<option value=1 <?php if ($pay['status'] == 1) echo "selected" ?>>催收</option>
<option value=2 <?php if ($pay['status'] == 2) echo "selected" ?>>法務件 (發函)</option>
<option value=3 <?php if ($pay['status'] == 3) echo "selected" ?>>法務件 (訴訟)</option>
<option value=4 <?php if ($pay['status'] == 4) echo "selected" ?>>折讓</option>
<option value=5 <?php if ($pay['status'] == 5) echo "selected" ?>>壞帳</option>
<option value=99 <?php if ($pay['status'] == 99) echo "selected" ?>>完成</option>
</select>
</div>
</div>
<input type="hidden" name="pay_id" value="<?= $pay['pay_id'] ?>">
<input type="hidden" name="Bill" id="Bill" value="">
</div>
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
<button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button>
</div>
</div>
</form>
</div>
<script>
function backToIndex() {
var Bill = <?= $Bill ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(Bill);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function send() {
event.preventDefault();
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script>

96
wms/account-receivable-received-submit.php

@ -1,96 +0,0 @@
<?php
include "./header.php";
$type = $_GET['type'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? '' : str_replace('-', '', trim($_POST['InvoiceNo']));
$InvoiceDate = isset($_POST['InvoiceDate']) ? $_POST['InvoiceDate'] : '';
$Bill = $_POST['Bill'];
$invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
$received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount'];
$received_date = isset($_POST['ReceivedDate']) ? $_POST['ReceivedDate'] : '';
$remark = isset($_POST['remark']) ? $_POST['remark'] : '';
if ($type == 'edit') {
$pay_id = $_POST['pay_id'];
$status = $_POST['status'];
$sql_query_pay = "SELECT * from account_received where pay_id = $pay_id";
$pay = mysqli_query($link, $sql_query_pay);
$pay = mysqli_fetch_assoc($pay);
$sql1 = "UPDATE account_received SET ";
if ($InvoiceNo !== $pay['invoice_no']) {
$sql1 .= "invoice_no = '$InvoiceNo',";
}
if ($InvoiceDate != $pay['invoice_date']) {
$sql1 .= "invoice_date = '$InvoiceDate',";
}
if ($invoice_amount != $pay['invoice_amount']) {
$sql1 .= "invoice_amount = $invoice_amount,";
}
if ($received_amount != $pay['received_amount']) {
$sql1 .= "received_amount = $received_amount,";
}
if ($received_date != $pay['received_date']) {
$sql1 .= "received_date = '$received_date',";
}
if ($remark != $pay['remark']) {
$sql1 .= "remark = '$remark',";
}
if ($status != $pay['status']) {
$sql1 .= "status = $status,";
}
// $sql1 = substr($sql1, 0, -1);
$sql = $sql1 . "LastOperatorId = '$user_id' WHERE pay_id = $pay_id";
} else {
$BillNo = $_POST['BillNo'];
$dept_id = $_POST['DeptId'];
$dept_name = $_POST['DeptName'];
$manager_name = $_POST['ManagerName'];
$person_id = $_POST['PersonId'];
$person_name = $_POST['PersonName'];
$cust_name = $_POST['CustName'];
$sql1 = "INSERT INTO account_received (
BillNo,dept_id,dept_name,manager_name,person_id,person_name,cust_name";
$sql2 = ",CreatorId) VALUES ('$BillNo','$dept_id','$dept_name','$manager_name','$person_id','$person_name','$cust_name'";
if (isset($InvoiceNo)) {
$sql1 .= ",invoice_no";
$sql2 .= ",'$InvoiceNo'";
}
if ((!empty($InvoiceDate))) {
$sql1 .= ",invoice_date";
$sql2 .= ",'$InvoiceDate'";
}
if (isset($invoice_amount)) {
$sql1 .= ",invoice_amount";
$sql2 .= ",$invoice_amount";
}
if (isset($received_amount)) {
$sql1 .= ",received_amount";
$sql2 .= ",$received_amount";
}
if (!(empty($received_date))) {
$sql1 .= ",received_date";
$sql2 .= ",'$received_date'";
}
if (!(empty($remark))) {
$sql1 .= ",remark";
$sql2 .= ",'$remark'";
}
$sql = $sql1 . $sql2 . ",'$user_id')";
}
mysqli_query($link, $sql);
?>
<script>
var Bill = <?= $Bill ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(Bill);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
</script>

61
wms/account-receivable-renovate-excel.php

@ -13,30 +13,51 @@ $Bill = json_decode(file_get_contents("php://input"), true);
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet(); $sheet = $spreadsheet->getActiveSheet();
// file_put_contents('account-receivable.txt', json_encode($Bill)); // file_put_contents('account-receivable.txt', json_encode($Bill));
if ($type == 'repair') {
$colomnHeader = [
'合約號', '合約日期', '客戶編號', '客戶名稱',
'部門', '契約人員工號', '契約人員名稱',
'主管工號', '主管名稱',
'合約總金額', '應收金額',
'已開金額', '未開金額',
'已收金額', '催收金額', '催收次數'
];
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($Bill as $key => $value) {
$colomnHeader = [ $sheet->fromArray($value, NULL, 'A' . $rowIndex);
'合約號', '作番號', '部門編號', '部門名稱', '主管工號','主管名稱', '營業員工號', '營業員名稱', '客戶名稱', '抬頭', '統編', '通訊地址', $column = [
'收款階段名稱', '應收日期','是否應收', '應收金額', '已開金額','未開金額', '已收金額','催收金額', '催收次數' 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q'
]; ];
$sheet->fromArray($colomnHeader, NULL, 'A1'); foreach ($column as $col) {
$rowIndex = 2; $sheet->getColumnDimension($col)->setAutoSize(true);
foreach ($Bill as $key => $value) { }
$rowIndex++;
$sheet->fromArray($value, NULL, 'A' . $rowIndex); }
$column = [ $writer = new Xlsx($spreadsheet);
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S','T' $excelFileName = 'account-receivable-repair.xlsx';
} else {
$colomnHeader = [
'合約號', '作番號', '部門編號', '部門名稱', '主管工號', '主管名稱', '營業員工號', '營業員名稱', '客戶名稱', '抬頭', '統編', '通訊地址',
'收款階段名稱', '應收日期', '是否應收', '應收金額', '已開金額', '未開金額', '已收金額', '催收金額', '催收次數'
]; ];
foreach ($column as $col) { $sheet->fromArray($colomnHeader, NULL, 'A1');
$sheet->getColumnDimension($col)->setAutoSize(true); $rowIndex = 2;
foreach ($Bill as $key => $value) {
$sheet->fromArray($value, NULL, 'A' . $rowIndex);
$column = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'
];
foreach ($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
$rowIndex++;
} }
$rowIndex++; $writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-renovate.xlsx';
} }
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-renovate.xlsx';
$writer->save($excelFileName); $writer->save($excelFileName);
echo $excelFileName; echo $excelFileName;
?>
<!-- <script>
window.location.href = "account-receivable-index.php?<?= $token_link ?>";
</script> -->

773
wms/account-receivable-renovate-index-ing.php

@ -0,0 +1,773 @@
<?php
include "header.php";
$sum_facility = 0;
// M1
$sum_A40002 = 0;
// 設備
$sum_A40009 = 0;
// 安裝
$sum_A40010 = 0;
$sum_total_budget = 0;
$average_budget = 0;
$average_A40002 = 0;
$average_A40009 = 0;
$average_A40010 = 0;
$follower = find_follow($user_id);
$arrayData = [];
$receivable_array = [];
// T8所有合約號
$sql_contractNumber = "SELECT Distinct BillNo FROM salSalesOrder WHERE ModeId = 'T' AND (CurrentState=2 OR CurrentState=4) ";
// T8發票 (有專案的發票)
$sql_invoice = "SELECT DISTINCT
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState,
b.FromSalSalesOrder
FROM arSellInvoice as a
LEFT JOIN (SELECT CH.FromSalSalesOrder, SE.* FROM arSellInvoiceMaterial AS SE
LEFT JOIN arCheckBillDetail AS CH ON SE.FromBillNo=CH.BillNo) as b
ON a.BillNo=b.BillNo
WHERE DATALENGTH(b.FromSalSalesOrder)>0
ORDER BY InvoiceTime ASC";
// T8核銷
$sql_received = "SELECT
a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount,
b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee,
c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate
FROM arWriteOffBill AS a
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
FROM arCheckBill
LEFT JOIN arCheckBillInvInfo
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
ON a.BillNo=c.BillNo
WHERE DATALENGTH(c.OrderBillNo) >0";
// 期初收款資訊
$sql_opening = "
SELECT * FROM account_received ";
// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的
if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210')))) {
} else {
$sql_opening .= " OR person_id = '$user_id'";
$sql_contractNumber .= " AND (PersonId = '$user_id'";
if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
$column_str .= "')";
$sql_contractNumber .= " OR PersonId IN $column_str)";
$sql_opening .= " OR person_id IN $column_str)";
} else {
$sql_opening .= ")";
$sql_contractNumber .= ")";
};
}
$contractNumbers = array();
$query_contract_number = $conn->query($sql_contractNumber);
foreach ($query_contract_number as $contract_numbers) {
array_push($contractNumbers, $contract_numbers['BillNo']);
$str_numbers = "('" . implode("','", $contractNumbers) . "')";
}
//作番大日程
$sql = "SELECT
tmp2.*,
d.name AS depart_name
FROM(
SELECT
a.manager,
a2.name as manager_name,
a.name,
a.department_id,
w.salesid,
w.contractno,
w.facilityno,
w.estimated_shipping_date,
w.real_contract_arrival_date,
w.actual_tofactory_date,
w.real_arrival_date,
w.install_end_date,
w.tryrun_end_date,
w.official_check_date,
w.delivery_date
from wipwholestatus AS w
left join account AS a
ON w.salesid = a.accountid
left join account AS a2
ON a2.accountid = a.manager
where w.status = '1' AND w.contract_type='B'
)AS tmp2
left join (
SELECT DISTINCT
department_id,
name
FROM department
) AS d
ON d.department_id = tmp2.department_id";
//T8 銷售訂單 階段收款計畫
$sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, s.DeptId, s.DeptName,
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a
LEFT JOIN (SELECT O.*, DE.DeptName FROM salSalesOrder AS O LEFT JOIN comDepartment AS DE ON O.DeptId=DE.DeptId) AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId ";
if (isset($str_numbers)) {
$sql_contract .= "WHERE s.BillNo IN $str_numbers ";
}
// T8 銷售訂單 作番金額
$sql_contract_budget = "SELECT A.BillNo,A.MaterialId, A.OAmountWithTax,A.CU_MaterialId FROM salSalesOrderDetail AS A
LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo
WHERE B.ModeId='T' AND A.ItemType=1 ";
if (isset($str_numbers)) {
$sql_contract_budget .= "AND A.BillNo IN $str_numbers ";
}
$contract = $conn->query($sql_contract);
$contract_data = array();
// 將T8合約收款階段資料依據款別分類放進arraData裡
foreach ($contract as $cont) {
$BillNo = $cont['BillNo'];
$BillDate = $cont['BillDate'];
$PayStage = $cont['PayStage'];
$PlanPayDate = $cont['PlanPayDate'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
$EnterpriseName = $cont['EnterpriseName'];
$TaxNo = $cont['TaxNo'];
$ContactAddress = $cont['ContactAddress'];
$RowNo = $cont['RowNo'];
$salesId = $cont['PersonId'];
//['type'] A:比照新梯、B:純分期、C:其他
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期
//['tryrun'] 0 試車款名 1試車金額 2 試車收款日期 ['check'] 0 官檢款名 1 官檢金額 2 官檢收款日期 ['delivery'] 0 交車款名 1 交車金額 2 交車收款日期 ['final'] 0 尾款名 1 尾款金額 2 尾款收款日期
//['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if (!(isset($arrayData[$BillNo]))) {
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$arrayData[$BillNo][0] = $cont['DeptId'];
$arrayData[$BillNo][1] = $cont['DeptName'];
$arrayData[$BillNo][3] = $salesId;
$arrayData[$BillNo][5] = $partnerName;
$arrayData[$BillNo][6] = $EnterpriseName;
$arrayData[$BillNo][7] = $TaxNo;
$arrayData[$BillNo][8] = $ContactAddress;
$arrayData[$BillNo][9] = $BillDate;
$arrayData[$BillNo][10] = $BillNo;
$arrayData[$BillNo]['total_budget'] = 0;
$arrayData[$BillNo]['invoice'] = array();
$arrayData[$BillNo]['received_budget'] = 0;
$arrayData[$BillNo]['invoice_budget'] = 0;
$arrayData[$BillNo]['A40002'] = $arrayData[$BillNo]['A40009'] = $arrayData[$BillNo]['A40010'] = 0;
$arrayData[$BillNo]['total_facility_num'] = 0;
}
$arrayData[$BillNo]['PayStage'][$RowNo]['type'] = 0;
$arrayData[$BillNo]['PayStage'][$RowNo]['name'] = $PayStage;
$arrayData[$BillNo]['PayStage'][$RowNo]['PlanPayDate'] = $PlanPayDate;
$arrayData[$BillNo]['PayStage'][$RowNo]['PayAmount'] = $PayAmount;
// 判斷type
$wipStage = ['簽約', '訂金', '貨抵工地', '完工', '試車', '安裝', '驗收', '完工', '交車', '尾款', '合約'];
foreach ($wipStage as $wipstage) {
if (strpos($PayStage, $wipstage) !== false) {
$arrayData[$BillNo]['PayStage'][$RowNo]['type'] = "A";
}
}
$haveNumber = (int) filter_var(str_replace('-', '', $PayStage), FILTER_SANITIZE_NUMBER_INT);
if ($haveNumber > 0 && $arrayData[$BillNo]['PayStage'][$RowNo]['type'] === 0) {
$arrayData[$BillNo]['PayStage'][$RowNo]['type'] = "B";
} elseif ($haveNumber > 0 && $arrayData[$BillNo]['PayStage'][$RowNo]['type'] == 'A') {
$arrayData[$BillNo]['PayStage'][$RowNo]['type'] = "C";
}
}
$received_array = $conn->query($sql_received);
$opening_data = mysqli_query($link, $sql_opening);
$invoice_data = $conn->query($sql_invoice);
$contract_budget_data = $conn->query($sql_contract_budget);
// 查WMS 契約員主管
$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A
LEFT JOIN account AS B ON A.manager = B.accountid ";
$managers = mysqli_query($link, $sql_manager);
$find_manager = array();
foreach ($managers as $manager) {
$find_manager[$manager['accountid']] = $manager;
}
// 將T8銷售訂單明細 每個作番金額存入arrayData
$contract_budget = array();
foreach ($contract_budget_data as $cont) {
$BillNo = $cont['BillNo'];
if (isset($arrayData[$BillNo])) {
$salesid = $arrayData[$BillNo][3];
if (isset($find_manager[$salesid])) {
$arrayData[$BillNo][2] = $find_manager[$salesid]['manager_name'];
$arrayData[$BillNo][4] = $find_manager[$salesid]['name'];
$arrayData[$BillNo][11] = $find_manager[$salesid]['manager'];
}
$arrayData[$BillNo]['total_budget'] += $cont['OAmountWithTax'];
$sum_total_budget += $cont['OAmountWithTax'];
$arrayData[$BillNo][$cont['MaterialId']] += $cont['OAmountWithTax'];
switch ($cont['MaterialId']) {
case "A40002":
$sum_A40002 += $cont['OAmountWithTax'];
break;
case "A40009":
$sum_A40009 += $cont['OAmountWithTax'];
break;
case "A40010":
$sum_A40010 += $cont['OAmountWithTax'];
break;
}
if (isset($arrayData[$BillNo]['facility'][$cont['CU_MaterialId']])) {
$arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['total_budget'] += $cont['OAmountWithTax'];
$arrayData[$BillNo]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] += $cont['OAmountWithTax'];
} else {
$sum_facility += 1;
$arrayData[$BillNo]['total_facility_num'] += 1;
$arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['total_budget'] = $cont['OAmountWithTax'];
$arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['A40002'] = $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['A40009'] = $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['A40010'] = 0;
$arrayData[$BillNo]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] = $cont['OAmountWithTax'];
}
}
if (isset($contract_budget[$cont['BillNo']])) {
$contract_budget[$cont['BillNo']]['total'] += $cont['OAmountWithTax'];
} else {
$contract_budget[$cont['BillNo']]['total'] = $cont['OAmountWithTax'];
}
if (isset($contract_budget[$cont['BillNo']][$cont['MaterialId']])) {
$contract_budget[$cont['BillNo']][$cont['MaterialId']] += $cont['OAmountWithTax'];
} else {
$contract_budget[$cont['BillNo']][$cont['MaterialId']] = $cont['OAmountWithTax'];
}
if (isset($contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']])) {
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['total'] += $cont['OAmountWithTax'];
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] += $cont['OAmountWithTax'];
} else {
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['total'] = $cont['OAmountWithTax'];
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['A40002'] = 0;
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['A40009'] = 0;
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['A40010'] = 0;
$contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] = $cont['OAmountWithTax'];
};
}
/*計算作番佔合約的金額比例
@param $facility_no string => 作番號
@param $contract_budget_billno array => $contract_budget[合約號]
return float */
function get_contract_ratio($facility_no, $contract_budget_billno)
{
$ratio = 0;
if (isset($contract_budget_billno['facility'][$facility_no])) {
if (empty($contract_budget_billno['total'])) {
} else {
$ratio += $contract_budget_billno['facility'][$facility_no]['total'] / $contract_budget_billno['total'];
}
}
return $ratio;
}
/* 比較應收日期
@param $a array
@param $b array
return int */
function comparePlanPayDate($a, $b)
{
return strtotime($a['PlanPayDate']) - strtotime($b['PlanPayDate']);
}
//取作番大日程作番與時程 進arrayData
// real_contract_arrival_date 預計出貨日
// real_arrival_date 實際出貨日
$today = strtotime(date('Ymd'));
$wipwhole_array = mysqli_query($link, $sql);
$wipwhole_status = array();
foreach ($wipwhole_array as $wip) {
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if (isset($arrayData[$wip['contractno']])) {
// 整理合約資料
// $arrayData[$wip['contractno']][0] = $wip['department_id'];;
// $arrayData[$wip['contractno']][1] = $wip['depart_name'];
// $arrayData[$wip['contractno']][2] = $wip['manager_name'];
// $arrayData[$wip['contractno']][3] = $wip['salesid'];
// $arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno'];
$arrayData[$wip['contractno']]['A40002'] = (isset($contract_budget[$wip['contractno']]['A40002']) && !is_null($contract_budget[$wip['contractno']]['A40002'])) ? $contract_budget[$wip['contractno']]['A40002'] : 0;
$arrayData[$wip['contractno']]['A40009'] = (isset($contract_budget[$wip['contractno']]['A40009']) && !is_null($contract_budget[$wip['contractno']]['A40009'])) ? $contract_budget[$wip['contractno']]['A40009'] : 0;
// [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno'];
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = "";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['total_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['receivable_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['collect_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40002'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40002']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40002'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40002'] : 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40009'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40009']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40009'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40009'] : 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40010'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40010']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40010'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40010'] : 0;
}
$wipwhole_status[$wip['facilityno']] = $wip;
}
// 整理arrayData[合約]['PayStage']進 (新增) arrayData[合約]['facility'][作番號][PayStage]
$sign_array = ['訂金', '簽約', '合約'];
// 將所有facility的paystage放入一個array以便計算順序
$allPayStages = [];
foreach ($arrayData as &$value) {
if (isset($value['facility']) && is_iterable($value['facility'])) {
foreach ($value['facility'] as $fakey => &$facility) {
if (isset($contract_budget[$value[10]])) {
$ratio = get_contract_ratio($fakey, $contract_budget[$value[10]]);
for ($stage = 1; $stage < (count($value['PayStage']) + 1); $stage++) {
$facility['PayStage'][$stage] = $value['PayStage'][$stage];
$facility['PayStage'][$stage]['facilityno'] = $fakey;
//算每個作番的金額
$facility['PayStage'][$stage]['PayAmount'] = $value['PayStage'][$stage]['PayAmount'] * $ratio;
//算每個作番每個收款階段的收款時間
switch ($facility['PayStage'][$stage]['type']) {
case "A":
switch ($facility['PayStage'][$stage]['name']) {
case (stristr($facility['PayStage'][$stage]['name'], '試車')):
if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['tryrun_end_date']));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '完工')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date']));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '尾款')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date']));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '交車')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date']));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '驗收')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date']));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '安裝')):
if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['install_end_date']));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')):
if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_arrival_date']));
} elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) {
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date']));
}
break;
default:
break;
};
case "B":
break;
case "C":
switch ($facility['PayStage'][$stage]['name']) {
case (stristr($facility['PayStage'][$stage]['name'], '試車')):
if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['tryrun_end_date'])));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '完工')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date'])));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '尾款')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date'])));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '交車')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date'])));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '驗收')):
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date'])));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '安裝')):
if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['install_end_date'])));
}
break;
case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')):
if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_arrival_date'])));
} elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) {
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1;
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date'])));
}
break;
default:
break;
};
default:
break;
}
}
if (isset($allPayStages[$value[10]])) {
$allPayStages[$value[10]] = array_merge($allPayStages[$value[10]], $facility['PayStage']);
} else {
$allPayStages[$value[10]] = $facility['PayStage'];
}
}
}
}
}
foreach ($allPayStages as $paykey => $pay) {
uasort($allPayStages[$paykey], 'comparePlanPayDate');
}
foreach ($allPayStages as &$payStage) {
$sequenceNumber = 1;
foreach ($payStage as $tk => &$pstage) {
$pstage['sequenceNumber'] = $sequenceNumber;
$sequenceNumber += 1;
}
}
// 整理好的收款階段
$final_paystage = array();
foreach ($allPayStages as $key => &$payStage) {
if (is_iterable($payStage)) {
foreach ($payStage as $key2 => $pstage) {
$final_paystage[$key][$pstage['sequenceNumber']] = $pstage;
}
}
}
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號]
foreach ($invoice_data as $invoice) {
if (isset($arrayData[$invoice['FromSalSalesOrder']])) {
$arrayData[$invoice['FromSalSalesOrder']]['invoice_budget'] += intval($invoice['OAmountWithTax']);
$arrayData[$invoice['FromSalSalesOrder']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']];
}
}
// 把核銷單的內容補到發票資料中
foreach ($received_array as $received) {
$BillNo = $received['OrderBillNo'];
if (isset($arrayData[$BillNo])) {
if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) {
$arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount'];
array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']);
}
}
}
// $final_paystage ['type'] ['PlanPayDate'] ['PayAmount'] ['facilityno'] ['sequenceNumber'] ['name'] ['InvoiceAmount'] ['receivedAmount']
foreach ($final_paystage as $key => &$payStage) {
if (isset($arrayData[$key]['invoice_budget']) && isset($arrayData[$key]['received_budget'])) {
$tmpInvoice = $arrayData[$key]['invoice_budget'];
$tmpReceived = $arrayData[$key]['received_budget'];
for ($sequence = 1; $sequence <= count($payStage); $sequence++) {
$collect_month = collect_month(strtotime($payStage[$sequence]['PlanPayDate']));
if ($tmpInvoice > $payStage[$sequence]['PayAmount']) {
$payStage[$sequence]['InvoiceAmount'] = $payStage[$sequence]['PayAmount'];
$tmpInvoice -= $payStage[$sequence]['PayAmount'];
} else {
$payStage[$sequence]['InvoiceAmount'] = $tmpInvoice;
$tmpInvoice = 0;
}
if ($tmpReceived > $payStage[$sequence]['PayAmount']) {
$payStage[$sequence]['receivedAmount'] = $payStage[$sequence]['PayAmount'];
$tmpReceived -= $payStage[$sequence]['PayAmount'];
} else {
$payStage[$sequence]['receivedAmount'] = $tmpReceived;
$tmpReceived = 0;
}
if ($collect_month > 0) {
// $arrayData[$key]['facility'][$payStage[$sequence]['facilityno']]['receivable_budget']+=$payStage[$sequence]['PayAmount'];
}
if ($collect_month > 0 && $payStage[$sequence]['PayAmount'] > $payStage[$sequence]['receivedAmount']) {
$payStage[$sequence]['collect_month'] = $collect_month;
} else {
$payStage[$sequence]['collect_month'] = 0;
}
}
}
}
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號
// 0 合約號 1 作番號 2 部門id 3 部門名稱 4 經理名稱 5 營業員id 6 營業員名稱 7 客戶名稱 8 抬頭 9 統編 10 通訊地址
// 11 收款階段名稱 12 應收日期 13 收款金額 14 已開金額 15 已收金額 16 催收次數
$excel_aray = array();
$today = strtotime(date('Ymt'));
foreach ($arrayData as $key => $value) {
if (isset($final_paystage[$key])) {
for ($sequence = 1; $sequence <= count($final_paystage[$key]); $sequence++) {
$value[4] = (isset($value[4]) && !empty($value[4])) ? $value[4] : '--';
$value[5] = (isset($value[5]) && !empty($value[5])) ? $value[5] : '--';
$value[6] = (isset($value[6]) && !empty($value[6])) ? $value[6] : '--';
$value[7] = (isset($value[7]) && !empty($value[7])) ? $value[7] : '--';
$value[8] = (isset($value[8]) && !empty($value[8])) ? $value[8] : '--';
$value[11] = (isset($value[11]) && !empty($value[11])) ? $value[11] : '--';
$value[12] = (isset($value[12]) && !empty($value[12])) ? date('Y/m/d', strtotime($value[12])) : '--';
$thisPayStage = $final_paystage[$key][$sequence];
$keyname = $key . "/" . $final_paystage[$key][$sequence]['facilityno'] . "/" . $value[5];
$havetopay = ($today >= strtotime($thisPayStage['PlanPayDate'])) ? "V" : "--";
switch ($havetopay) {
case "V":
$unInvoiceAmount = $thisPayStage['PayAmount'] - $thisPayStage['InvoiceAmount'];
$unReceivedAmount = $thisPayStage['PayAmount'] - $thisPayStage['receivedAmount'];
break;
default:
$unInvoiceAmount = 0;
$unReceivedAmount = 0;
break;
}
$excel_aray[$keyname] = [
$value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8],
$thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay,
number_format(round($thisPayStage['PayAmount'])),
number_format(round($thisPayStage['InvoiceAmount'])), number_format(round($unInvoiceAmount)),
number_format(round($thisPayStage['receivedAmount'])), number_format(round($unReceivedAmount)),
number_format(round($thisPayStage['collect_month']))
];
}
}
}
$total_data = json_encode($excel_aray);
//計算總作番數、金額、A40002、A40009、A40010金額與平均
$average_budget = round($sum_total_budget / $sum_facility);
$average_A40002 = round($sum_A40002 / $sum_facility);
$average_A40009 = round($sum_A40009 / $sum_facility);
$average_A40010 = round($sum_A40010 / $sum_facility);
foreach($arrayData as $key=> $data){
echo $key."<br>";
print_r($data);
echo "<br>-----------------------------<br>";
}
exit();
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
.hiddenTable {
display: none;
}
.hidden {
display: none;
}
</style>
<div style="width: 98%;margin: 1%;">
<div class="btn-group btn-group-md " style="padding:10 px; width: 100%;">
<button type="button" style="width: 12%;" onclick="downloadData()" class="btn btn-success">下載 <span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong>合約 (汰改)統整資訊</strong></h3>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<label for="sum_total_budget">合約總金額</label>
<input type="text" class="form-control" id="sum_total_budget" name="sum_total_budget" value="<?= number_format($sum_total_budget) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40002">M1總金額</label>
<input type="text" class="form-control" id="sum_A40002" name="sum_A40002" value="<?= number_format($sum_A40002) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40009">設備總金額</label>
<input type="text" class="form-control" id="sum_A40009" name="sum_A40009" value="<?= number_format($sum_A40009) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40010">安裝總金額</label>
<input type="text" class="form-control" id="sum_A40010" name="sum_A40010" value="<?= number_format($sum_A40010) ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<label for="sum_facility">總台數</label>
<input type="text" class="form-control" id="sum_facility" name="sum_facility" value="<?= number_format($sum_facility) ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="average_budget">平均金額</label>
<input type="text" class="form-control" id="average_budget" name="average_budget" value="<?= number_format($average_budget) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40002">M1平均金額</label>
<input type="text" class="form-control" id="average_A40002" name="average_A40002" value="<?= number_format($average_A40002) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40009">設備平均金額</label>
<input type="text" class="form-control" id="average_A40009" name="average_A40009" value="<?= number_format($average_A40009) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40010">安裝平均金額</label>
<input type="text" class="form-control" id="average_A40010" name="average_A40010" value="<?= number_format($average_A40010) ?>" disabled>
</div>
</div>
</form>
</div>
<?php
include "./footer.php";
?>
<div style="width: 20%;float:right;margin-right:5%; ">
<label>查詢條件</label>
<input type="text" id="search" name="search" class="form-control" placeholder="請輸入合約號/作番號/客戶名稱" oninput="searchData()">
</div>
<div style="width: 98%; margin:1%;" style="overflow-x:auto;">
<table class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th style='text-align:center;vertical-align: middle;width:120px'>合約號</th>
<th style='text-align:center;vertical-align: middle;width:120px'>作番號</th>
<th style='text-align:center;vertical-align: middle;width:110px'>部門</th>
<th style='text-align:center;vertical-align: middle;'>主管</th>
<th style='text-align:center;vertical-align: middle;'>契約員</th>
<th style='text-align:center;vertical-align: middle;width:130px'>客戶名稱</th>
<th style='text-align:center;vertical-align: middle;'>收款階段</th>
<th style='text-align:center;vertical-align: middle;'>應收日期</th>
<th style='text-align:center;vertical-align: middle;'>是否應收</th>
<th style='text-align:end;vertical-align: middle;'>應收金額</th>
<th style='text-align:end;vertical-align: middle;'>已開金額</th>
<th style='text-align:end;vertical-align: middle;'>未開金額</th>
<th style='text-align:end;vertical-align: middle;'>已收金額</th>
<th style='text-align:end;vertical-align: middle;'>催收金額</th>
<th style='text-align:center;vertical-align: middle;'>催收次數</th>
</tr>
</thead>
<tbody>
<?php foreach ($excel_aray as $key => $row) { ?>
<tr class="data-row" style="display: '';" id="<?= $key; ?>">
<td><?= $row[0]; ?></td>
<td><?= $row[1]; ?></td>
<td><?= $row[2] . "<br>" . $row[3]; ?></td>
<td><?= $row[4] . "<br>" . $row[5]; ?></td>
<td><?= $row[6] . "<br>" . $row[7]; ?></td>
<td><?= $row[8]; ?></td>
<td><?= $row[12]; ?></td>
<td><?= $row[13]; ?></td>
<td><?= $row[14]; ?></td>
<td><?= $row[15]; ?></td>
<td><?= $row[16]; ?></td>
<td><?= $row[17]; ?></td>
<td><?= $row[18]; ?></td>
<td><?= $row[19]; ?></td>
<td><?= $row[20]; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<script>
function searchData() {
var searchTerm = document.getElementById('search').value.toLowerCase();
var rows = document.getElementsByClassName('data-row');
for (var i = 0; i < rows.length; i++) {
var rowText = rows[i].textContent.toLowerCase();
// var rowText = rows[i].id.toLowerCase();
if (rowText.includes(searchTerm)) {
console.log(rowText);
rows[i].style.display = '';
} else {
rows[i].style.display = 'none';
}
}
}
function downloadData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-renovate-excel.php?type=all&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
var name = "汰改應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-renovate.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $total_data ?>
}));
}
function check(searchname) {
console.log(searchname);
}
</script>

185
wms/account-receivable-renovate-index.php

@ -14,78 +14,151 @@ $average_budget = 0;
$average_A40002 = 0; $average_A40002 = 0;
$average_A40009 = 0; $average_A40009 = 0;
$average_A40010 = 0; $average_A40010 = 0;
$start_date = empty($_POST['date_start']) ? null : $_POST['date_start'];
$end_date = empty($_POST['date_end']) ? null : $_POST['date_end'];
// 查WMS 契約員主管
$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A
LEFT JOIN account AS B ON A.manager = B.accountid ";
$managers = mysqli_query($link, $sql_manager);
$find_manager = array();
if (is_iterable($managers)) {
foreach ($managers as $manager) {
$find_manager[$manager['accountid']] = $manager;
}
}
$follower = find_follow($user_id); $follower = find_follow($user_id);
$arrayData = []; $arrayData = [];
$receivable_array = []; $receivable_array = [];
// T8所有合約號 // T8所有合約號
$sql_contractNumber = "SELECT Distinct BillNo FROM salSalesOrder WHERE ModeId = 'T' AND (CurrentState=2 OR CurrentState=4) "; $sql_contractNumber = "SELECT MainAll.* ,
Person.PersonName,
// T8發票 (有專案的發票) Dept.DeptName FROM
$sql_invoice = "SELECT DISTINCT (SELECT
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, Main.BillNo,
b.FromSalSalesOrder Main.BillDate,
FROM arSellInvoice as a Main.BizPartnerId,
LEFT JOIN (SELECT CH.FromSalSalesOrder, SE.* FROM arSellInvoiceMaterial AS SE Biz.ShortName,
LEFT JOIN arCheckBillDetail AS CH ON SE.FromBillNo=CH.BillNo) as b Biz.BizPartnerName,
ON a.BillNo=b.BillNo Biz.ContactAddress,
WHERE DATALENGTH(b.FromSalSalesOrder)>0 Main.OAmountWithTax,
ORDER BY InvoiceTime ASC"; Main.PersonId,
Main.DeptId,
// T8核銷 Main.TypeId,
$sql_received = "SELECT Main.ModeId,
a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount, Main.CurrentState
b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee, FROM salSalesOrder AS Main
c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId) AS MainAll
FROM arWriteOffBill AS a LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId= Person.PersonId
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo LEFT JOIN comDepartment AS Dept ON MainAll.DeptId= Dept.DeptId
LEFT JOIN WHERE MainAll.ModeId = 'T' AND (MainAll.CurrentState=2 OR MainAll.CurrentState=4) ";
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN if (!is_null($start_date)) {
(SELECT $start_date = (int)date('Ymd', strtotime($start_date));
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo $sql_contractNumber .= " AND MainAll.BillDate >= $start_date ";
FROM arCheckBill }
LEFT JOIN arCheckBillInvInfo if (!is_null($end_date)) {
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 $end_date = (int)date('Ymd', strtotime($end_date));
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c $sql_contractNumber .= " AND MainAll.BillDate <= $end_date ";
ON a.BillNo=c.BillNo }
WHERE DATALENGTH(c.OrderBillNo) >0"; if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) {
//ORDER BY contractno
// 期初收款資訊
$sql_opening = "
SELECT * FROM account_received ";
// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的
if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210')))) {
} else { } else {
// $sql_received .= " AND (PersonId = '$user_id'"; $sql_contractNumber .= " AND (MainAll.PersonId = '$user_id'";
$sql_opening .= " OR person_id = '$user_id'";
$sql_contractNumber .= " AND (PersonId = '$user_id'";
if (count($follower) > 0) { if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'"; $column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower); $column_str .= implode("','", $follower);
$column_str .= "')"; $column_str .= "')";
$sql_contractNumber .= " OR PersonId IN $column_str)"; $sql_contractNumber .= " OR MainAll.PersonId IN $column_str)";
// $sql_contract .= " OR s.PersonId IN $column_str)";
// $sql_received .= " OR PersonId IN $column_str)";
$sql_opening .= " OR person_id IN $column_str)";
// $sql_contract_budget .= " OR PersonId IN $column_str )ORDER BY BillNo, CU_MaterialId";
} else { } else {
// $sql_received .= ")";
$sql_opening .= ")";
$sql_contractNumber .= ")"; $sql_contractNumber .= ")";
// $sql_contract_budget .= ")";
}; };
} }
// T8發票 (有專案的發票)
$sql_invoice = "SELECT
Detail.BillNo AS InvoiceBillNo,
Detail.MaterialId,
Detail.LAmountWithTax,
Main.InvoiceNo,
CheckAll.FromSalSalesOrder AS BillNo
FROM arSellInvoiceMaterial AS Detail
LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo
LEFT JOIN (
SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo
FROM arCheckBillDetail AS CheckDetail )
AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo
WHERE Detail.ItemType=0 AND Main.InvoiceState!=2";
// T8核銷
$sql_received = "SELECT
CheckDetail.OrderBillNo,
arWriteOffBillDetail.FromBillNo AS CheckBillNo,
arWriteOffBillDetail.FromRowCode AS CheckRowCode,
arWriteOffBillDetail.CurrStandOffOAmount,
CheckDetail.TypeId
FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBillDetail.BillNo,
arCheckBillDetail.RowCode,
arCheckBillDetail.FromSalSalesOrder AS OrderBillNo,
salSalesOrder.TypeId,
salSalesOrder.ModeId
FROM arCheckBillDetail
LEFT JOIN salSalesOrder
ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder )
AS CheckDetail
ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode
WHERE CheckDetail.ModeId = 'T'";
// 期初收款資訊
$sql_opening = "
SELECT * FROM account_received ";
$contractNumbers = array(); $contractNumbers = array();
$query_contract_number = $conn->query($sql_contractNumber); $query_contract_number = $conn->query($sql_contractNumber);
foreach ($query_contract_number as $contract_numbers) { foreach ($query_contract_number as $contract_numbers) {
array_push($contractNumbers, $contract_numbers['BillNo']); $billNo = $contract_numbers['BillNo'];
switch ($contract_numbers['BillNo']) {
case 'SO20230701001':
$billNo = 'M220104';
break;
case 'SO20230701002':
$billNo = 'M230098';
break;
case 'SO20230701003':
$billNo = 'M230159';
break;
case 'SO20230901001':
$billNo = 'M230992';
break;
case 'SO20231110001':
$billNo = 'M230492';
break;
case 'SO20231110002':
$billNo = 'M230557';
break;
case 'SO20231110003':
$billNo = 'M230496';
break;
case 'SP20240108001':
$billNo = 'M230683';
break;
case 'SP20240116004':
$billNo = 'B230726';
break;
case 'T220035':
$billNo = 'M220035';
break;
case 'T230098':
$billNo = 'M230098';
break;
}
array_push($contractNumbers, $billNo);
$str_numbers = "('" . implode("','", $contractNumbers) . "')"; $str_numbers = "('" . implode("','", $contractNumbers) . "')";
} }
//作番大日程 //作番大日程
@ -469,7 +542,7 @@ foreach ($allPayStages as $key => &$payStage) {
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號] // [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號]
foreach ($invoice_data as $invoice) { foreach ($invoice_data as $invoice) {
if (isset($arrayData[$invoice['FromSalSalesOrder']])) { if (isset($invoice['FromSalSalesOrder']) && isset($arrayData[$invoice['FromSalSalesOrder']])) {
$arrayData[$invoice['FromSalSalesOrder']]['invoice_budget'] += intval($invoice['OAmountWithTax']); $arrayData[$invoice['FromSalSalesOrder']]['invoice_budget'] += intval($invoice['OAmountWithTax']);
$arrayData[$invoice['FromSalSalesOrder']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; $arrayData[$invoice['FromSalSalesOrder']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']];
} }
@ -479,7 +552,7 @@ foreach ($invoice_data as $invoice) {
foreach ($received_array as $received) { foreach ($received_array as $received) {
$BillNo = $received['OrderBillNo']; $BillNo = $received['OrderBillNo'];
if (isset($arrayData[$BillNo])) { if (isset($arrayData[$BillNo])) {
if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { if (isset($received['InvoiceNo']) && isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) {
$arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; $arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount'];
array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']);
} }
@ -626,7 +699,7 @@ include "./footer.php";
<label>查詢條件</label> <label>查詢條件</label>
<input type="text" id="search" name="search" class="form-control" placeholder="請輸入合約號/作番號/客戶名稱" oninput="searchData()"> <input type="text" id="search" name="search" class="form-control" placeholder="請輸入合約號/作番號/客戶名稱" oninput="searchData()">
</div> </div>
<div style="width: 98%; margin:1%;" <div style="overflow-x:auto;"> <div style="width: 98%; margin:1%;" style="overflow-x:auto;">
<table class="table table-striped table-bordered" style="width:100%"> <table class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <tr>

BIN
wms/account-receivable-renovate.xlsx

Binary file not shown.

485
wms/account-receivable-repair-index.php

@ -0,0 +1,485 @@
<?php
include "header.php";
$sum_total_budget = 0;
$start_date = empty($_POST['date_start']) ? null : $_POST['date_start'];
$end_date = empty($_POST['date_end']) ? null : $_POST['date_end'];
/* 比較應收日期
@param $a array
@param $b array
return int */
function comparePlanPayDate($a, $b)
{
return strtotime($a['PlanPayDate']) - strtotime($b['PlanPayDate']);
}
// 查WMS 契約員主管
$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A
LEFT JOIN account AS B ON A.manager = B.accountid ";
$managers = mysqli_query($link, $sql_manager);
$find_manager = array();
if (is_iterable($managers)) {
foreach ($managers as $manager) {
$find_manager[$manager['accountid']] = $manager;
}
}
$follower = find_follow($user_id);
$arrayData = array();
$receivable_array = [];
// T8所有合約號
$sql_contractNumber = "SELECT MainAll.* ,
Person.PersonName,
Dept.DeptName FROM
(SELECT
Main.BillNo,
Main.BillDate,
Main.BizPartnerId,
Biz.ShortName,
Biz.BizPartnerName,
Biz.ContactAddress,
Main.OAmountWithTax,
Main.PersonId,
Main.DeptId,
Main.TypeId,
Main.CurrentState
FROM salSalesOrder AS Main
LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId) AS MainAll
LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId= Person.PersonId
LEFT JOIN comDepartment AS Dept ON MainAll.DeptId= Dept.DeptId
WHERE MainAll.TypeId = 'SP' AND (MainAll.CurrentState=2 OR MainAll.CurrentState=4) ";
if (!is_null($start_date)) {
$start_date = (int)date('Ymd', strtotime($start_date));
$sql_contractNumber .= " AND MainAll.BillDate >= $start_date ";
}
if (!is_null($end_date)) {
$end_date = (int)date('Ymd', strtotime($end_date));
$sql_contractNumber .= " AND MainAll.BillDate <= $end_date ";
}
if ((in_array($user_id, array('M0008', 'M0012'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '501')))) {
} else {
$sql_contractNumber .= " AND (MainAll.PersonId = '$user_id'";
if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
$column_str .= "')";
$sql_contractNumber .= " OR MainAll.PersonId IN $column_str)";
} else {
$sql_contractNumber .= ")";
};
}
$contractNumbers = array();
$query_contract_number = $conn->query($sql_contractNumber);
if (is_iterable($query_contract_number)) {
foreach ($query_contract_number as $contract_numbers) {
array_push($contractNumbers, $contract_numbers['BillNo']);
$arrayData[$contract_numbers['BillNo']]['BillNo'] = isset($contract_numbers['BillNo']) ? $contract_numbers['BillNo'] : '--';
$arrayData[$contract_numbers['BillNo']]['BillDate'] = isset($contract_numbers['BillDate']) ? $contract_numbers['BillDate'] : '--';
$arrayData[$contract_numbers['BillNo']]['CustomerId'] = isset($contract_numbers['BizPartnerId']) ? $contract_numbers['BizPartnerId'] : '--';
$arrayData[$contract_numbers['BillNo']]['CustomerName'] = isset($contract_numbers['BizPartnerName']) ? $contract_numbers['BizPartnerName'] : '--';
$arrayData[$contract_numbers['BillNo']]['CustomerAddress'] = isset($contract_numbers['ContactAddress']) ? $contract_numbers['ContactAddress'] : '--';
$arrayData[$contract_numbers['BillNo']]['OAmountWithTax'] = isset($contract_numbers['OAmountWithTax']) ? $contract_numbers['OAmountWithTax'] : 0;
$arrayData[$contract_numbers['BillNo']]['PersonId'] = isset($contract_numbers['PersonId']) ? $contract_numbers['PersonId'] : '--';
$arrayData[$contract_numbers['BillNo']]['DeptId'] = isset($contract_numbers['DeptId']) ? $contract_numbers['DeptId'] : '--';
$arrayData[$contract_numbers['BillNo']]['PersonName'] = isset($contract_numbers['PersonName']) ? $contract_numbers['PersonName'] : '--';
$arrayData[$contract_numbers['BillNo']]['DeptName'] = isset($contract_numbers['DeptName']) ? $contract_numbers['DeptName'] : '--';
$arrayData[$contract_numbers['BillNo']]['ShortName'] = isset($contract_numbers['ShortName']) ? $contract_numbers['ShortName'] : '--';
$arrayData[$contract_numbers['BillNo']]['ManagerId'] = !empty($find_manager[$contract_numbers['PersonId']]['manager']) ? $find_manager[$contract_numbers['PersonId']]['manager'] : '--';
$arrayData[$contract_numbers['BillNo']]['ManagerName'] = !empty($find_manager[$contract_numbers['PersonId']]['manager_name']) ? $find_manager[$contract_numbers['PersonId']]['manager_name'] : '--';
$arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0;
$arrayData[$contract_numbers['BillNo']]['received_budget'] = 0;
$arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0;
$sum_total_budget += $contract_numbers['OAmountWithTax'];
}
$str_numbers = "('" . implode("','", $contractNumbers) . "')";
}
// T8發票
$sql_invoice = "SELECT
Detail.BillNo AS InvoiceBillNo,
Detail.MaterialId,
Detail.LAmountWithTax,
Main.InvoiceNo,
CheckAll.FromSalSalesOrder AS BillNo
FROM arSellInvoiceMaterial AS Detail
LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo
LEFT JOIN (
SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo
FROM arCheckBillDetail AS CheckDetail )
AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo
WHERE Detail.ItemType=0 AND Main.InvoiceState!=2";
// T8核銷
$sql_received = "SELECT
CheckDetail.OrderBillNo,
arWriteOffBillDetail.FromBillNo AS CheckBillNo,
arWriteOffBillDetail.FromRowCode AS CheckRowCode,
arWriteOffBillDetail.CurrStandOffOAmount
FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBillDetail.BillNo,
arCheckBillDetail.RowCode,
arCheckBillDetail.FromSalSalesOrder AS OrderBillNo,
salSalesOrder.TypeId
FROM arCheckBillDetail
LEFT JOIN salSalesOrder
ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder )
AS CheckDetail
ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode
WHERE CheckDetail.TypeId = 'SP'";
//T8 銷售訂單 階段收款計畫
$sql_paystage = "SELECT * from salOrderStagePay";
if (isset($str_numbers)) {
$sql_paystage .= " WHERE BillNo IN $str_numbers ";
$sql_invoice .= " AND CheckAll.FromSalSalesOrder IN $str_numbers ";
}
$PayStage = $conn->query($sql_paystage);
$received_array = $conn->query($sql_received);
$invoice_data = $conn->query($sql_invoice);
$allPayStages = array();
foreach ($PayStage as $stage) {
$allPayStages[$stage['BillNo']][$stage['PayStage']]['PlanPayAmt'] = $stage['PlanPayAmt'];
$allPayStages[$stage['BillNo']][$stage['PayStage']]['PlanPayDate'] = $stage['PlanPayDate'];
$month = collect_month(strtotime($stage['PlanPayDate']));
if (strtotime($stage['PlanPayDate']) > strtotime(date('Y-m-t', strtotime('now')))) {
$allPayStages[$stage['BillNo']][$stage['PayStage']]['receivable_ornot'] = '--';
} else {
$allPayStages[$stage['BillNo']][$stage['PayStage']]['receivable_ornot'] = 'Y';
}
$allPayStages[$stage['BillNo']][$stage['PayStage']]['month'] = $month;
$allPayStages[$stage['BillNo']][$stage['PayStage']]['received'] = 0;
$allPayStages[$stage['BillNo']][$stage['PayStage']]['invoice'] = 0;
}
foreach ($allPayStages as $paykey => $pay) {
uasort($allPayStages[$paykey], 'comparePlanPayDate');
}
foreach ($allPayStages as &$payStage) {
$sequenceNumber = 1;
foreach ($payStage as $tk => &$pstage) {
$pstage['sequenceNumber'] = $sequenceNumber;
$sequenceNumber += 1;
}
}
// 整理好的收款階段
$final_paystage = array();
foreach ($allPayStages as $key => &$payStage) {
if (is_iterable($payStage)) {
foreach ($payStage as $key2 => $pstage) {
if (isset($arrayData[$key])) {
$arrayData[$key]['PayStage'][$pstage['sequenceNumber']] = $pstage;
if (isset($pstage['receivable_ornot']) && $pstage['receivable_ornot'] == 'Y') {
$arrayData[$key]['receivable_budget'] += $pstage['PlanPayAmt'];
}
}
}
}
}
foreach ($invoice_data as $inv) {
if (isset($arrayData[$inv['BillNo']])) {
$arrayData[$inv['BillNo']]['invoice_budget'] += $inv['LAmountWithTax'];
if (isset($arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']])) {
$arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']] += $inv['LAmountWithTax'];
} else {
$arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']] = $inv['LAmountWithTax'];
}
}
}
foreach ($received_array as $received) {
if (isset($arrayData[$received['OrderBillNo']]) && isset($received['CurrStandOffOAmount']) && $received['CurrStandOffOAmount'] > 0) {
$arrayData[$received['OrderBillNo']]['received_budget'] += $received['CurrStandOffOAmount'];
}
}
foreach ($arrayData as $key => &$value) {
if (!isset($value['PayStage'])) {
$value['receivable_budget'] = $value['OAmountWithTax'];
} else {
$tmpReceived = $value['received_budget'];
$tmpInvoice = $value['invoice_budget'];
if (is_iterable($value['PayStage'])) {
for ($sequence = 1; $sequence <= count($value['PayStage']); $sequence++) {
if ($value['PayStage'][$sequence]['PlanPayAmt'] > $tmpInvoice) {
$value['PayStage'][$sequence]['invoice'] = $tmpInvoice;
$tmpInvoice = 0;
} else {
$value['PayStage'][$sequence]['invoice'] = $value['PayStage'][$sequence]['PlanPayAmt'];
$tmpInvoice -= $value['PayStage'][$sequence]['PlanPayAmt'];
}
if ($value['PayStage'][$sequence]['PlanPayAmt'] > $tmpReceived) {
$value['PayStage'][$sequence]['received'] = $tmpReceived;
$tmpReceived = 0;
} else {
$value['PayStage'][$sequence]['received'] = $value['PayStage'][$sequence]['PlanPayAmt'];
$tmpReceived -= $value['PayStage'][$sequence]['PlanPayAmt'];
}
}
}
$value['received_budget'] = $tmpReceived;
}
if ($value['receivable_budget'] > 0 && $value['received_budget'] < $value['receivable_budget']) {
$value['month'] = collect_month(strtotime($value['BillDate']));
} else {
$value['month'] = 0;
}
}
$excel_aray = array();
foreach ($arrayData as $key => $value) {
$uninvoice_budget = $value['OAmountWithTax'] - $value['invoice_budget'];
$unreceive_budget = $value['receivable_budget'] - $value['received_budget'];
$excel_aray[$key] = [
$value['BillNo'], date('Y-m-d', strtotime($value['BillDate'])), $value['CustomerId'], $value['CustomerName'],
$value['DeptName'], $value['PersonId'], $value['PersonName'],
$value['ManagerId'], $value['ManagerName'],
number_format(round($value['OAmountWithTax'])), number_format(round($value['receivable_budget'])),
number_format(round($value['invoice_budget'])), number_format(round($uninvoice_budget)),
number_format(round($value['received_budget'])), $unreceive_budget, $value['month']
];
}
$total_data = json_encode($excel_aray);
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
.hiddenTable {
display: none;
}
.hidden {
display: none;
}
</style>
<div style="width: 98%;margin: 1%;">
<div class="btn-group btn-group-md " style="padding:10 px; width: 100%;">
<button type="button" style="width: 12%;" onclick="downloadData()" class="btn btn-success">下載 <span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong> 零件 & 維修 應收帳款</strong></h3>
</div>
<form class="form-horizontal" id='myForm' method='post' action='account-receivable-repair-index.php?<?= $token_link ?>'>
<table class="table table-striped table-bordered" style='width:98%;text-align:center;margin:0 auto'>
<tbody>
<tr>
<th class="text-center" style="vertical-align: middle;">合約日期</th>
<td colspan="2">
<input type="date" class='form-control' id='date_start' name='date_start' style='width:40%;display:inline;'>
<input type="date" class='form-control' id='date_end' name='date_end' style='width:40%;display:inline;'>
<button type="submit" class="btn btn-primary btn-sm">搜尋</button>
</td>
</tr>
<tr>
<th class="text-center" style="vertical-align: middle;">合約總金額</th>
<td colspan="2">
<input type="text" class="form-control" id="sum_total_budget" name="sum_total_budget" value="<?= number_format($sum_total_budget) ?> 元" disabled>
</td>
</tr>
</tbody>
</table>
</form>
<hr>
<div class="form-group">
<div class="col-md-4">
<label for="search_contract">查詢合約號</label>
<input type="text" id="search_contract" name="search_contract" class="form-control" placeholder="請輸入合約號" oninput="searchFront('contract')">
</div>
<div class="col-md-4">
<label for="search_customerid">查詢客戶編號</label>
<input type="text" id="search_customerid" name="search_customerid" class="form-control" placeholder="請輸入客戶編號" oninput="searchFront('customerid')">
</div>
<div class="col-md-4">
<label for="search_customername">查詢客戶名稱</label>
<input type="text" id="search_customername" name="search_customername" class="form-control" placeholder="請輸入客戶名稱" oninput="searchFront('customername')">
</div>
</div>
<div class="form-group">
<div class="col-md-4">
<label for="search_department">查詢部門</label>
<input type="text" id="search_department" name="search_department" class="form-control" placeholder="請輸入部門" oninput="searchFront('department')">
</div>
<div class="col-md-4">
<label for="search_personId">查詢契約員</label>
<input type="text" id="search_personId" name="search_personId" class="form-control" placeholder="請輸入契約員工號/姓名" oninput="searchFront('personId')">
</div>
<div class="col-md-4">
<label for="search_manager">查詢主管</label>
<input type="text" id="search_manager" name="search_manager" class="form-control" placeholder="請輸入主管工號/姓名" oninput="searchFront('manager')">
</div>
</div>
<div class="form-group">
<div class="col-md-2">
<input type="text" id="search_manager" name="search_manager" class="form-control" placeholder="請輸入主管工號/姓名" oninput="searchFront('manager')">
</div>
<div class="col-md-2">
<input class="form-control" value="催收次數" disabled>
</div>
</div>
</div>
<?php
include "./footer.php";
?>
<div style="width: 20%;float:right;margin-right:5%; ">
<label>查詢條件</label>
<input type="text" id="search" name="search" class="form-control" placeholder="請輸入合約號/客戶名稱" oninput="searchData()">
</div>
<div style="width: 98%; margin:1%;" style="overflow-x:auto;">
<table class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th style='text-align:center;vertical-align: middle;width:140px'>合約號</th>
<th style='text-align:center;vertical-align: middle;width:100px'>合約日期</th>
<th style='text-align:center;vertical-align: middle;'>客戶編號</th>
<th style='text-align:center;vertical-align: middle;width:140px'>客戶名稱</th>
<th style='text-align:center;vertical-align: middle;width:110px'>部門</th>
<th style='text-align:center;vertical-align: middle;'>主管</th>
<th style='text-align:center;vertical-align: middle;'>契約員</th>
<th style='text-align:center;vertical-align: middle;'>合約總金額</th>
<th style='text-align:center;vertical-align: middle;'>應收金額</th>
<th style='text-align:center;vertical-align: middle;'>已開金額</th>
<th style='text-align:center;vertical-align: middle;'>未開金額</th>
<th style='text-align:center;vertical-align: middle;'>已收金額</th>
<th style='text-align:center;vertical-align: middle;'>催收金額</th>
<th style='text-align:center;vertical-align: middle;'>催收次數</th>
</tr>
</thead>
<tbody>
<?php foreach ($excel_aray as $key => $row) { ?>
<tr class="data-row" style="display: '';" id="<?= $key; ?>">
<td style='text-align:center;vertical-align: middle;' class="contract"><?= $row[0]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="contractdate"><?= $row[1]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="customerid"><?= $row[2] ?></td>
<td style='text-align:center;vertical-align: middle;' class="customername"><?= $row[3] ?></td>
<td style='text-align:center;vertical-align: middle;' class="department"><?= $row[4] ?></td>
<td style='text-align:center;vertical-align: middle;' class="manager"><?= $row[7] . "<br>" . $row[8]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="personId"><?= $row[5] . "<br>" . $row[6]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="total_budget"><?= $row[9]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="receivable_budget"><?= $row[10]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="invoice_budget"><?= $row[11]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="un_invoice_budget"><?= $row[12]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="received_budget"><?= $row[13]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="un_received_budget"><?= $row[14]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="collect_month"><?= $row[15]; ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</div>
<script>
function searchData() {
var searchTerm = document.getElementById('search').value.toLowerCase();
var rows = document.getElementsByClassName('data-row');
for (var i = 0; i < rows.length; i++) {
var rowText = rows[i].textContent.toLowerCase();
if (rowText.includes(searchTerm)) {
console.log(rowText);
rows[i].style.display = '';
} else {
rows[i].style.display = 'none';
}
}
}
function searchFront(area) {
var term = 'search_' + area;
var searchTerm = document.getElementById(term).value.toLowerCase();
var searchArea = document.getElementsByClassName(area);
var rows = document.getElementsByClassName('data-row');
for (var i = 0; i < rows.length; i++) {
var rowText = searchArea[i].textContent.toLowerCase();
if (rowText.includes(searchTerm)) {
rows[i].style.display = '';
} else {
rows[i].style.display = 'none';
}
}
}
function downloadData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-renovate-excel.php?type=repair&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
var name = "零件&修理應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-repair.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $total_data ?>
}));
}
function check(searchname) {
console.log(searchname);
}
</script>

BIN
wms/account-receivable-repair.xlsx

Binary file not shown.

64
wms/account-receivable-test.php

@ -381,10 +381,62 @@ $P_all = "
// echo $value['PayStage'] .";".$value['BillNo']. "<br>"; // echo $value['PayStage'] .";".$value['BillNo']. "<br>";
// } // }
$sql = "SELECT A.BillNo,B.CU_MaterialId, B.ProjectId FROM salSalesOrder AS A // $sql = "SELECT A.BillNo,B.CU_MaterialId, B.ProjectId FROM salSalesOrder AS A
LEFT JOIN salSalesOrderDetail AS B ON A.BillNo=B.BillNo // LEFT JOIN salSalesOrderDetail AS B ON A.BillNo=B.BillNo
WHERE A.ModeId='T' AND B.ItemType=0 AND A.BillNo != B.ProjectId AND A.CurrentState=4"; // WHERE A.ModeId='T' AND B.ItemType=0 AND A.BillNo != B.ProjectId AND A.CurrentState=4";
// $query = $conn->query($sql);
// foreach($query as $key => $value) {
// echo $value['BillNo'] .";".$value['CU_MaterialId'].";".$value['ProjectId']. "<br>";
// }
// 發貨單 沒有ProjectId的資料
// $sql = "SELECT DISTINCT salDispatchListMaster.BillNo, salDispatchListMaster.ModeId,salDispatchListMaster.BillDate FROM salDispatchListDetail
// LEFT JOIN salDispatchListMaster ON salDispatchListMaster.BillNo=salDispatchListDetail.BillNo
// WHERE salDispatchListDetail.ItemType=0 AND LEN(salDispatchListDetail.ProjectId)=0";
// $query = $conn->query($sql);
// foreach($query as $key => $value) {
// switch($value['ModeId']) {
// case 'B':
// $mode = '保養';
// break;
// case 'T':
// $mode = '汰改';
// break;
// case 'M':
// $mode = '新梯';
// break;
// case 'Z':
// $mode = '維修';
// break;
// }
// echo $value['BillNo'] .";".$mode.";".$value['BillDate']. "<br>";
// }
// 銷售訂單 沒有ProjectId的資料
$sql = "SELECT Main.*, comBusinessPartner.BizPartnerName, salDispatchListMaster.BillNo AS DispBillNo , salDispatchListMaster.BillDate AS DispBillDate FROM
(SELECT DISTINCT salSalesOrder.BillNo,salSalesOrder.BizPartnerId, salSalesOrder.TypeId, salSalesOrder.ModeId, salSalesOrderDetail.ProjectId, salSalesOrderDetail.CU_MaterialId FROM salSalesOrderDetail
LEFT JOIN salSalesOrder ON salSalesOrder.BillNo= salSalesOrderDetail.BillNo
WHERE (LEN(salSalesOrderDetail.ProjectId)=0 AND salSalesOrderDetail.ItemType=0) OR LEN(salSalesOrderDetail.CU_MaterialId)=0 ) AS Main
LEFT JOIN comBusinessPartner ON comBusinessPartner.BizPartnerId = Main.BizPartnerId
LEFT JOIN salDispatchListMaster ON salDispatchListMaster.FromBillNo= Main.BillNo
WHERE salDispatchListMaster.BillDate >20231031 OR salDispatchListMaster.BillDate IS NULL";
$query = $conn->query($sql); $query = $conn->query($sql);
foreach($query as $key => $value) { foreach ($query as $key => $value) {
echo $value['BillNo'] .";".$value['CU_MaterialId'].";".$value['ProjectId']. "<br>"; $mode = '';
} switch ($value['ModeId']) {
case 'B':
$mode = '保養';
break;
case 'T':
$mode = '汰改';
break;
case 'M':
$mode = '新梯';
break;
case 'Z':
$mode = '維修';
break;
}
echo $value['BillNo'] . ";" . $mode . ";" . $value['BizPartnerId'] .";".$value['BizPartnerName'].";".$value['ProjectId']. ";".$value['CU_MaterialId']. ";".$value['DispBillNo'].";" . $value['DispBillDate'] ."<br>";
}

75
wms/bons/api/get.php

@ -1,75 +0,0 @@
<?php
require_once('../../contract/connt8.php');
// if (!empty($_GET['contract_no'])) {
// $contract_no = $_GET['contract_no'];
$contract_no = 'Q23080067';
$sql = "SELECT
a.BillNo,
b.OTaxAmt as amount,
a.CU_EstPayDate as createDate,
b.PersonId as personId,
c.BillNo as CBno,
c.CU_MaterialId as facility
FROM salIncomeApplyDetail as a
LEFT JOIN salIncomeApplyMaster as b ON a.BillNo = b.BillNo
LEFT JOIN (
SELECT aMaster.BillNo,aMaster.BizPartnerId,aDetail.CU_MaterialId FROM arCheckBill as aMaster
LEFT JOIN arCheckBillDetail as aDetail ON aMaster.BizPartnerId = aDetail.FromBillNo
WHERE aMaster.BizPartnerId = 'Q23080067' AND aMaster.TypeId = 'RVS'
) AS c ON a.BillNo = c.BizPartnerId
WHERE a.BillNo = 'Q23080067'
AND a.RowNo = '1'
";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
$data['amount'] = intval($data['amount']);
$checkBillNo = $data['CBno'];
$sql = "SELECT
c.BillDate AS CheckBillDate
FROM arWriteOffBill AS a
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
FROM arCheckBill
LEFT JOIN arCheckBillInvInfo
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
ON a.BillNo=c.BillNo
WHERE c.checkBillNo = '$checkBillNo'
";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$check = $stmt->fetch(PDO::FETCH_ASSOC);
$CU_MaterialId = $data['facility'];
$sql = "SELECT SQuantity FROM salIncomeApplyDetail WHERE BillNo = :contract_no AND CU_MaterialId = :CU_MaterialId";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':contract_no', $contract_no);
$stmt->bindParam(':CU_MaterialId', $CU_MaterialId);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = COUNT($result);
$data['maintain_month'] = intval($count * $result[0]['SQuantity']);
if (!empty($check['CheckBillDate'])) {
header('Content-Type: application/json');
echo json_encode($data);
} else {
echo false;
exit;
}
// }

399
wms/bons/maintainance_contract_payment_status.php

@ -1,399 +0,0 @@
<?php
include "header.php";
include "css/view/wipwhole-index.php";
// 設置一個空陣列來放資料
$data = array();
$contractno = empty($_POST['contractno']) ? null : $_POST['contractno'];
$contractno = getContractnoDetails($link, $user_id, $contractno);
$sql = "
SELECT
siamd.RowNo,
siamd.RowCode,
siam.BillNo,
siamd.CU_EstPayDate,
siamd.UnTransCheckBLAmtWTax ,
siamd.HadTransCheckBLAmtWTax,
siamd.CU_MaterialId,
acb_tmp.BillNo2,
acb_tmp.RowCode2,
asim.BillNo AS BillNo3,
asim.InvoiceName,
asim.OAmountWithTax,
asi.InvoiceNo
FROM salIncomeApplyMaster AS siam -- 收入申請單
LEFT JOIN salIncomeApplyDetail AS siamd -- 收入申請單明細
ON siam.BillNo = siamd.BillNo
LEFT JOIN (
SELECT
acbd.FromRowCode,
acb.FromBillNo,
acbd.BillNo AS BillNo2,
acbd.RowCode AS RowCode2
FROM arCheckBill AS acb -- 應收確認單
LEFT JOIN arCheckBillDetail AS acbd -- 應收確認單明細
ON acb.BillNo = acbd.BillNo
WHERE 1 = 1
AND acb.TypeId = 'RVS'
";
$sql .= !empty($contractno) ? " AND acb.FromBillNo IN ($contractno) " : "";
$sql .= "
) AS acb_tmp
ON siamd.RowNo = acb_tmp.FromRowCode
AND siamd.BillNo = acb_tmp.FromBillNo
LEFT JOIN arSellInvoiceMaterial AS asim -- 買賣發票明細
ON asim.FromBillNo = acb_tmp.BillNo2
AND asim.RowCode = acb_tmp.RowCode2
LEFT JOIN arSellInvoice AS asi
ON asim.BillNo = asi.BillNo
WHERE 1 = 1
";
$sql .= !empty($contractno) ? " AND siam.BillNo IN ($contractno)" : "";
$data = $conn->query($sql);
function getContractnoDetails($link, $user_id, $contractno = null)
{
$sql = "
SELECT
c.contractno
FROM contract AS c
LEFT JOIN con_maintance_examine_apply AS cmea
ON c.contractno = cmea.vol_no
WHERE 1 = 1
AND cmea.salesman IN (" . getAccountids($link, $user_id) . ")
";
if (!empty($contractno)) {
$sql .= "
AND c.contractno = '$contractno'
";
}
$result = mysqli_query($link, $sql);
$data = [];
foreach ($result as $row) {
array_push($data, $row['contractno']);
}
return "'" . implode("','", $data) . "'";
}
function getSalesmanNo($link, $contractno)
{
$sql = "
SELECT
cmea.salesman
FROM contract AS c
LEFT JOIN con_maintance_examine_apply AS cmea
ON c.contractno = cmea.vol_no
WHERE 1 = 1
AND c.contractno IN ('$contractno')
";
$result = mysqli_query($link, $sql);
$data = [];
foreach ($result as $row)
return $row['salesman'];
return "";
}
function getSalesmanName($link, $contractno)
{
$sql = "
SELECT
a.name
FROM contract AS c
LEFT JOIN con_maintance_examine_apply AS cmea
ON c.contractno = cmea.vol_no
LEFT JOIN account AS a
ON cmea.salesman = a.accountid
WHERE 1 = 1
AND c.contractno IN ('$contractno')
";
$result = mysqli_query($link, $sql);
$data = [];
foreach ($result as $row)
return $row['name'];
return "";
}
function getAccountids($link, $user_id)
{
$sql = "
SELECT
accountid
FROM account
WHERE 1 = 1
AND (accountid = '$user_id'
OR accountid IN (
SELECT
accountid
FROM account
WHERE 1 = 1
AND manager = '$user_id'
AND accounttype IN ('B','E','M','W')
)
)
";
$result = mysqli_query($link, $sql);
$data = [];
foreach ($result as $row) {
array_push($data, $row['accountid']);
}
return "'" . implode("','", $data) . "'";
}
function checkArCheckBillStatus($row)
{
$CU_EstPayDate = $row['CU_EstPayDate'];
$BillNo2 = $row['BillNo2'];
if (substr($CU_EstPayDate, 0, 6) <= date("Ym")) {
if (empty($BillNo2)) {
return "<span class='text-danger'>未轉應收確認單</span>";
} else {
return "<span class='text-primary'>已轉應收確認單</span>";
}
} else {
return "時間未到";
}
}
function arSellInvoiceMaterial($row)
{
$CU_EstPayDate = $row['CU_EstPayDate'];
$InvoiceName = $row['InvoiceName'];
if (substr($CU_EstPayDate, 0, 6) <= date("Ym")) {
if (empty($InvoiceName)) {
return "<span class='text-danger'>未開發票</span>";
} else {
return "<span class='text-primary'>已開發票</span>";
}
} else {
return "時間未到";
}
}
function checkArWriteOffBill($conn, $row)
{
$BillNo = $row['BillNo2'];
$sql = "
SELECT
*
-- a.BillNo,
-- a.WriteOffBizPartnerId,
-- a.PayWriteOffOAmount,
-- b.FromBillDate AS ReceivedDate,
-- b.CurrWOFeeOAmt AS Fee,
-- c.OrderBillNo,
-- c.checkBillNo,
-- c.InvoiceNo,
-- c.BillDate AS CheckBillDate
FROM arWriteOffBill AS a
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
FROM arCheckBill
LEFT JOIN arCheckBillInvInfo
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
ON a.BillNo=c.BillNo
WHERE c.checkBillNo = '$BillNo'
";
$del = $conn->query($sql);
$i = 0;
foreach ($del as $row)
$i++;
if (empty($i)) {
return "<span class='text-danger'>未收款</span>";
} else {
return "<span class='text-primary'>已收款</span>";
}
}
?>
<?php if ($user_auth & 2) { ?>
<!-- <p>
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p> -->
<?php
}
if ($data) :
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
</style>
<div style="overflow-x:auto;">
<form id='myForm' method='post' action='maintainance_contract_payment_status.php?<?= $token_link ?>'>
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'>
<thead>
<tr>
<td colspan="5">
<h3 style='text-align:center'>保養合約-應收款項明細</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<th style='text-align:center;vertical-align: middle;'>合約號</th>
<td style='text-align:center;vertical-align: middle;'>
<input type="text" class='form-control' id='contractno' name='contractno' value="">
</td>
<td style='text-align:left;vertical-align: middle;'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th style='text-align:center;vertical-align: middle;'>營業人員/契約人員</th>
<th style='text-align:center;vertical-align: middle;'>合約號</th>
<th style='text-align:center;vertical-align: middle;width:50px;'>標示號</th>
<th style='text-align:center;vertical-align: middle;'>電梯編號</th>
<th style='text-align:center;vertical-align: middle;'>預計請款日</th>
<th style='text-align:center;vertical-align: middle;width:50px;'>催收次數</th>
<th style='text-align:center;vertical-align: middle;'>應收申請單狀態</th>
<th style='text-align:center;vertical-align: middle;'>請款金額(未轉應收)</th>
<th style='text-align:center;vertical-align: middle;'>請款金額(已轉應收)</th>
<th style='text-align:center;vertical-align: middle;'>應收申請單號</th>
<th style='text-align:center;vertical-align: middle;'>發票狀態</th>
<th style='text-align:center;vertical-align: middle;width:50px;'>發票單標示號</th>
<th style='text-align:center;vertical-align: middle;'>發票單號</th>
<th style='text-align:center;vertical-align: middle;'>發票明細</th>
<th style='text-align:center;vertical-align: middle;width:80px;'>發票金額</th>
<th style='text-align:center;vertical-align: middle;width:120px;'>發票號碼</th>
<th style='text-align:center;vertical-align: middle;'>核銷</th>
<!-- <th style='text-align:center;vertical-align: middle;'>核銷日期</th>
<th style='text-align:center;vertical-align: middle;'>未核銷金額</th>
<th style='text-align:center;vertical-align: middle;'>已核銷金額</th> -->
</tr>
</thead>
<tbody>
<?php foreach ($data as $row) { ?>
<tr>
<td>
<?php
echo getSalesmanNo($link, $row['BillNo']);
echo "<br/>";
echo getSalesmanName($link, $row['BillNo']);
?>
</td>
<td>
<?php echo $row['BillNo']; ?>
</td>
<td>
<?php echo $row['RowNo']; ?>
</td>
<td>
<?php echo $row['CU_MaterialId']; ?>
</td>
<td>
<?php echo date('Y/m/d', strtotime($row['CU_EstPayDate'])); ?>
</td>
<td>
<?php echo collect_month(strtotime($row['CU_EstPayDate'])); ?>
</td>
<td>
<?php echo checkArCheckBillStatus($row); ?>
</td>
<td>
<?php echo number_format(intval($row['UnTransCheckBLAmtWTax']), 0, '', ','); ?>
</td>
<td>
<?php echo number_format(intval($row['HadTransCheckBLAmtWTax']), 0, '', ','); ?>
</td>
<td>
<?php echo $row['BillNo2']; ?>
</td>
<td>
<?php echo arSellInvoiceMaterial($row); ?>
</td>
<td>
<?php echo $row['RowCode2']; ?>
</td>
<td>
<?php echo $row['BillNo3']; ?>
</td>
<td>
<?php echo $row['InvoiceName']; ?>
</td>
<td>
<?php echo number_format(intval($row['OAmountWithTax']), 0, '', ','); ?>
</td>
<td>
<?php echo $row['InvoiceNo']; ?>
</td>
<td>
<?php
echo checkArWriteOffBill($conn, $row)
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<script>
$(function() {
document.getElementById('loadingOverlay').classList.add('hidden');
})
</script>
<?php
else :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

87
wms/bonus/api/get.php

@ -0,0 +1,87 @@
<?php
require_once('../../contract/connt8.php');
if (!empty($_GET['contract_no'])) {
try {
$contract_no = $_GET['contract_no'];
// $contract_no = 'Q23080067';
$sql = "SELECT
a.BillNo,
b.OTaxAmt as amount,
a.CU_EstPayDate as createDate,
b.PersonId as personId,
c.BillNo as CBno,
c.CU_MaterialId as facility
FROM salIncomeApplyDetail as a
LEFT JOIN salIncomeApplyMaster as b ON a.BillNo = b.BillNo
LEFT JOIN (
SELECT aMaster.BillNo,aMaster.BizPartnerId,aDetail.CU_MaterialId FROM arCheckBill as aMaster
LEFT JOIN arCheckBillDetail as aDetail ON aMaster.BizPartnerId = aDetail.FromBillNo
WHERE aMaster.BizPartnerId = 'Q23080067' AND aMaster.TypeId = 'RVS'
) AS c ON a.BillNo = c.BizPartnerId
WHERE a.BillNo = '$contract_no'
AND a.RowNo = '1'
";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
// $data['amount'] = intval($data['amount']);
if (!empty($data['CBno']) && $data['CBno'] != '') {
$checkBillNo = $data['CBno'];
$sql = "SELECT
c.BillDate AS CheckBillDate
FROM arWriteOffBill AS a
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
FROM arCheckBill
LEFT JOIN arCheckBillInvInfo
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
ON a.BillNo=c.BillNo
WHERE c.checkBillNo = '$checkBillNo'
";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$check = $stmt->fetch(PDO::FETCH_ASSOC);
// $CU_MaterialId = $data['facility'];
// $sql = "SELECT SQuantity FROM salIncomeApplyDetail WHERE BillNo = :contract_no AND CU_MaterialId = :CU_MaterialId";
// $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':contract_no', $contract_no);
// $stmt->bindParam(':CU_MaterialId', $CU_MaterialId);
// $stmt->execute();
// $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
// $count = COUNT($result);
// $data['maintain_month'] = intval($count * $result[0]['SQuantity']);
$reult = true;
echo '1';
// return true;
} else {
$result = false;
echo '2';
// return false;
}
} catch (PDOException $e) {
echo '111';
return false;
// exit;
}
// if (($check['CheckBillDate']) !== '') {
// header('Content-Type: application/json');
// echo $check['CheckBillDate'];
// } else {
// echo false;
// exit;
// }
} else {
exit();
}

11
wms/bonus/api/getAccount.php

@ -0,0 +1,11 @@
<?php
require('../../contract-repair/conn.php');
$accountid = empty($_GET['accountid']) ? '' : $_GET['accountid'];
$sql = "SELECT name,manager FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':accountid', $accountid);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
header('Content-Type: application/json');
echo json_encode($result);

111
wms/bonus/api/postCalBouns.php

@ -0,0 +1,111 @@
<?php
require_once("../../contract/conn.php");
require_once("../other/maintenance_contract_bonus_v2_1.php");
if (!empty($_POST)) {
$contract_no = empty($_POST['contract_no']) ? '' : $_POST['contract_no'];
$bonuns_verson = empty($_POST['bonuns_verson']) ? '' : $_POST['bonuns_verson'];
$client_type = empty($_POST['client_type']) ? '' : $_POST['client_type'];
$maintain_month = empty($_POST['maintain_month']) ? '' : $_POST['maintain_month'];
$maintain_price_total = empty($_POST['maintain_price_total']) ? '' : $_POST['maintain_price_total'];
$payDay = empty($_POST['payDay']) ? '' : $_POST['payDay'];
$receiver = empty($_POST['receiver']) ? '' : $_POST['receiver'];
$manager = empty($_POST['manager']) ? '' : $_POST['manager'];
$contract_manger = empty($_POST['contract_manger']) ? '' : $_POST['contract_manger'];
$pay_kind = empty($_POST['paykind']) ? '' : $_POST['paykind'];
$maintain_price_month = empty($_POST['maintain_price_month']) ? '' : $_POST['maintain_price_month'];
$commission_fee = empty($_POST['commission_fee']) ? '0' : $_POST['commission_fee'];
$checkbox = empty($_POST['checkbox']) ? '' : $_POST['checkbox'];
$fail_arr = [];
// if ($client_type == '') $fail_arr[] = '合約類行為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
// 合約類型
$clientType = [
'1' => 'new',
'2' => 'free_to_charge',
'3' => 'renew_priceissue'
];
// 分期方式
$paykind = [
'1' => 'monthly',
'2' => 'bimonthly',
'3' => 'quarterly',
'6' => 'semiannually',
'12' => 'annually'
];
// 應付日期
$day = DateTime::createFromFormat('Ymd', $payDay);
$pay_day = $day->format('Y-m-d');
$years = $maintain_month / 12;
$contract_years = ($years >= 2) ? 'above_two' : 'one';
if ($checkbox == 13) {
// 保養獎金計算
$results = maintenance_contract_bonus_v2_1(
$bonuns_verson,
$clientType[$client_type],
$paykind[$pay_kind],
$maintain_price_month,
$maintain_price_total,
$commission_fee,
$pay_day,
$receiver,
$manager,
$contract_manger
);
if ($results['result_status'] != 'error') {
array_push($bonus_json, [
'maintain_type' => $maintain_type,
'total' => $maintain_price_month,
'fee_per_st' => $maintain_price_total,
'commission_fee' => $commission_fee,
'paykind' => $paykind[$pay_kind],
'receivable_date_due' => $pay_day,
]);
}
if (!empty($_POST['status']) && $_POST['status'] == 'save') {
foreach ($results['bonus_array'] as $i => $result) {
// echo '<pre>';
// print_r($result);
// echo '</pre>';
$bonus_type = $result['bonus_type'];
$pay_day = $result['pay_day_due'];
$amount = $result['bonus_amount'];
$receiver = $result['bonus_receiver'];
$discount = $result['discount'];
foreach ($bonus_json as $json) {
$json['discount'] = "$discount";
$a = json_encode($json);
}
echo '<pre>';
print_r($a);
echo '</pre>';
// exit();
// $sql = "INSERT INTO bonus
// (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day,status,bonus_json,create_id,create_at) VALUES
// ($bonus_type,'$bonus_verson','$contract_no',$contract_type,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')";
// $stmt = $conn->prepare($sql);
// $stmt->execute();
// $count++;
// echo '<pre>';
// print_r($count . '-- > Success');
// echo '</pre>';
// exit;
}
} else {
header('Content-Type: application/json');
echo json_encode($results);
}
}
}

27
wms/bonus/api/updateBonus.php

@ -0,0 +1,27 @@
;<?php
require('../../contract-repair/conn.php');
if (!empty($_POST)) {
$contract_no = empty($_POST['contract_no']) ? '' : $_POST['contract_no'];
$facility_no = empty($_POST['facility_no']) ? '' : $_POST['facility_no'];
$bonuns_verson = empty($_POST['bonuns_verson']) ? '' : $_POST['bonuns_verson'];
$user_id = empty($_POST['user_id']) ? '' : $_POST['user_id'];
$bonusArr = empty($_POST['bonusArr']) ? '' : json_decode($_POST['bonusArr'], true);
$contract_type = 3;
$date = date('Y-m-d');
$sql = "INSERT INTO bonus
(bonus_type,bonus_verson,conreact_no,contract_type,facility_no,amount,receiver,pay_day,review_hr,review_at,create_id,create_at) VALUES
(:bonus_type,:bonus_verson,:conreact_no,:facility_no,:contract_type,:amount,:receiver,:pay_day,:review_hr,:review_at,:create_id,:create_at)
";
foreach ($bonusArr as $data) {
$bonus_type = $data['bonus_type'];
$bonus_receiver = $data['bonus_receiver'];
$bonus_amount = $data['bonus_amount'];
$pay_day_due = $data['pay_day_due'];
$bonus_regulation = $data['bonus_regulation'];
$stmt = $conn->prepare($sql);
$stmt->bindParam(':bonus_type', $bonus_type);
$stmt->bindParam(':bonus_verson', $bonus_verson);
$stmt->bindParam('conreact_no', $contract_no);
$stmt->bindParam(':contract_type', $contract_type);
}
}

301
wms/bonus/bonus.php

@ -0,0 +1,301 @@
<?php
include_once("../header.php");
// require_once('./connT8.php');
require("../contract/conn.php");
$contract_type = [
'1' => '新梯',
'2' => '汰改',
'3' => '保養'
];
$bonus_type = [
'1' => '契約人獎金',
'2' => '區經理獎金',
'3' => '專任契約經理獎金'
];
$clause = '';
if (!empty($_GET['check'])) {
if ($_GET['check'] == 1) {
$clause .= "AND pay_day > DATE_SUB(NOW(), INTERVAL 1 MONTH)";
} else if ($_GET['check'] == 2) {
$clause .= "AND status = 1";
} else if ($_GET['check'] == 3) {
$clause .= "AND status = 2";
}
}
$sql = "SELECT * FROM bonus WHERE 1=1 $clause LIMIT 50";
$stmt = $conn->prepare($sql);
$stmt->execute();
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
$now = new DateTime();
$oneMonthAgo = $now->modify('+1 month');
// 查看 T8 是否有收款明細
// require("./api/get.php");
function isPay($contract_no, $connT8)
{
// echo $contract_no;
$sql = "SELECT
a.BillNo,
b.OTaxAmt as amount,
a.CU_EstPayDate as createDate,
b.PersonId as personId,
c.BillNo as CBno,
c.CU_MaterialId as facility
FROM salIncomeApplyDetail as a
LEFT JOIN salIncomeApplyMaster as b ON a.BillNo = b.BillNo
LEFT JOIN (
SELECT aMaster.BillNo,aMaster.BizPartnerId,aDetail.CU_MaterialId FROM arCheckBill as aMaster
LEFT JOIN arCheckBillDetail as aDetail ON aMaster.BizPartnerId = aDetail.FromBillNo
WHERE aMaster.BizPartnerId = '$contract_no' AND aMaster.TypeId = 'RVS'
) AS c ON a.BillNo = c.BizPartnerId
WHERE a.BillNo = '$contract_no'
AND a.RowNo = '1'
";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
// $data['amount'] = intval($data['amount']);
if (!empty($data['CBno']) && $data['CBno'] != '') {
$checkBillNo = $data['CBno'];
$sql = "SELECT
c.BillDate AS CheckBillDate
FROM arWriteOffBill AS a
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
FROM arCheckBill
LEFT JOIN arCheckBillInvInfo
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
ON a.BillNo=c.BillNo
WHERE c.checkBillNo = '$checkBillNo'
";
$stmt = $connT8->prepare($sql);
$stmt->execute();
return '1';
} else {
return '2';
}
}
?>
<link rel="stylesheet" href="../contract-repair/styles/style.css">
<link rel="stylesheet" href="../contract-repair/semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script defer src="../contract-repair/js/alpinejs/cdn.min.js"></script>
<script src="../contract-repair/js/alpine.js"></script>
<script src="../contract-repair/js/axios/axios.min.js"></script>
<!-- <script src="../contract-repair/js/jquery/jquery-3.1.1.min.js"></script> -->
<script src="../contract-repair/semantic/dist/semantic.min.js"></script>
<div class="bonus_index">
<!-- <input type="button" hidden x-ref="initbtn" @click="isPay()" /> -->
<div style="overflow-x:auto;margin-top:12px">
<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/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>
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>合約類別</th>
<th>合約號</th>
<th>作番號</th>
<th>獎金類別</th>
<th>獎金版本</th>
<th>作番總價</th>
<th>牌價</th>
<th>服務費</th>
<th>應發人員</th>
<th>預計發放時間</th>
<th>獎金水庫</th>
<!-- <th>是否發放</th> -->
<th>狀態</th>
<th>檢視/發放</th>
</tr>
</thead>
<tbody>
<?php if (!empty($datas)) {
foreach ($datas as $key => $data) :
$contract_no = $data['contract_no'];
$json = json_decode($data['bonus_json']);
$total = empty($json->total) ? 0 : $json->total;
$fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st;
$commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee;
$isPay = isPay($data['contract_no'], $connT8);
?>
<tr>
<td><?= $data['id'] ?></td>
<td><?= $contract_type[$data['contract_type']] ?></td>
<td><?= $data['contract_no'] ?></td>
<td><?= $data['facility_no'] ?></td>
<td><?= $bonus_type[$data['bonus_type']] ?></td>
<td><?= $data['bonus_verson'] ?></td>
<td><?= $total ?></td>
<td><?= $fee_per_st ?></td>
<td><?= $commission_fee ?></td>
<td><?= $data['receiver'] ?></td>
<td><?= $data['pay_day'] ?></td>
<td><?= $data['amount'] ?></td>
<!-- <td><?= ($data['status'] == 1) ? '未發放' : '已發放' ?></td> -->
<td>
<!-- <input type="text" x-model="isPays[<?php echo $key; ?>]" /> -->
<span><?= ($isPay == 1) ? '已收款' : '未收款' ?></span>
</td>
<td>
<?php
// 判斷時間是否為一個月內
$payday = new DateTime($data['pay_day']);
if ($isPay == 1) {
?>
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtn" style="">發放獎金</a>
<?php
} else if ($payday < $oneMonthAgo) {
?>
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a>
<?php
}
?>
</td>
</tr>
<?php
endforeach;
} ?>
</tbody>
</table>
</div>
</div>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
.width_style_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>
<script>
const datas = <?php echo json_encode($datas); ?>;
// function init() {
// this.isPay();
// }
// const bonusIndex = () => {
// return {
// async isPay() {
// // console.log(123)
// for (let i = 0; i < datas.length; i++) {
// await axios.get('./api/get.php?contract_no=' + datas[i].contract_no).then(res => {
// let isPay = res.data;
// // this.data.isPay.push(isPay); // 更新 x-data 中的数据
// this.isPays.push(isPay);
// }).catch(err => {
// })
// }
// console.log(this.isPays);
// }
// }
// }
</script>

117
wms/bons/bons_index.php → wms/bonus/bonus_detail.php

@ -1,6 +1,30 @@
<?php <?php
include('../header.php'); include('../header.php');
require_once('../contract-repair/conn.php'); require_once('../contract-repair/conn.php');
$sql = "SELECT * FROM bonus WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':id', $_GET['id']);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
// echo '<pre>';
// print_r($result['bonus_json']);
// echo '</pre>';
$bonus_json = json_decode($result['bonus_json']);
$paykind = [
'monthly' => '月繳',
'bimonthly' => '雙月繳',
'quarterly' => '季繳',
'semiannually' => '半年繳',
'annually' => '年繳'
];
$maintain_type = [
'new' => '新簽約',
'free_to_charge' => '免保轉有費',
'renew_priceissue' => '續簽約'
];
?> ?>
<link rel="stylesheet" href="../contract-repair/styles/style.css"> <link rel="stylesheet" href="../contract-repair/styles/style.css">
@ -12,7 +36,7 @@ require_once('../contract-repair/conn.php');
<script src="../contract-repair/js/jquery/jquery-3.1.1.min.js"></script> <script src="../contract-repair/js/jquery/jquery-3.1.1.min.js"></script>
<script src="../contract-repair/semantic/dist/semantic.min.js"></script> <script src="../contract-repair/semantic/dist/semantic.min.js"></script>
<div class="bons_index" x-data="bonsIndex"> <div class="bonuns_index" x-data="bonunsIndex">
<div class="form" method="post" id="form" enctype="multipart/form-data"> <div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name="form_name" value="main_form"> <input type="hidden" name="form_name" value="main_form">
<div> <div>
@ -24,7 +48,7 @@ require_once('../contract-repair/conn.php');
</td> </td>
</tr> </tr>
</thead> </thead>
<template x-if="step==1"> <!-- <template x-if="step==1">
<tbody style="font-weight: bolder;margin: botton 20px;"> <tbody style="font-weight: bolder;margin: botton 20px;">
<tr> <tr>
<td style="vertical-align: middle;">合約號</td> <td style="vertical-align: middle;">合約號</td>
@ -34,9 +58,9 @@ require_once('../contract-repair/conn.php');
<td colspan="2" style="vertical-align:middle"></td> <td colspan="2" style="vertical-align:middle"></td>
</tr> </tr>
</tbody> </tbody>
</template> </template> -->
<template x-if="step==2"> <template x-if="step==1">
<tbody style="font-weight: bolder;margin-bottom:20px"> <tbody style="font-weight: bolder;margin-bottom:20px">
<tr> <tr>
<td colspan="7" style="vertical-align:middle;border-right:0px"> <td colspan="7" style="vertical-align:middle;border-right:0px">
@ -54,12 +78,13 @@ require_once('../contract-repair/conn.php');
</td> </td>
<td style="vertical-align:middle">合約類別</td> <td style="vertical-align:middle">合約類別</td>
<td> <td>
<select id="client_type" x-model="data.client_type"> <select id="contract_type" x-model="data.contract_type" disabled="disabled">
<option value="">--請選擇--</option> <option value="">--請選擇--</option>
<option value="1">簽約</option> <option value="1"></option>
<option value="2">免保轉有費</option> <option value="2">汰改</option>
<option value="3">續簽約</option> <option value="3">保養</option>
</select> </select>
<p class="alerttext" x-show="data.contract_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align:middle">作番號</td> <td style="vertical-align:middle">作番號</td>
<td> <td>
@ -68,53 +93,59 @@ require_once('../contract-repair/conn.php');
<td style="vertical-align:middle">獎金適用版本</td> <td style="vertical-align:middle">獎金適用版本</td>
<td> <td>
<input type="text" x-model="data.bons_verson" disabled="disabled"> <input type="text" x-model="data.bonus_verson" disabled="disabled">
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align:middle">獎金發放人員</td> <td style="vertical-align:middle">保養類別</td>
<td>
<input type="text" x-model="data.maintain_type" disabled>
</td>
<td style="vertical-align:middle">付款方式</td>
<td> <td>
<input type="text" x-model="data.receiver" disabled="disabled"> <input type="text" x-model="data.pay_kind" disabled>
</td> </td>
<td style="vertical-align:middle">保養月份</td> <td style="vertical-align:middle">合約付款日</td>
<td> <td>
<input type="text" x-model="data.maintain_month" disabled="disabled"> <input type="text" x-model="data.receivable_date_due" disabled>
</td> </td>
<td style="vertical-align:middle">保養總額</td> <td style="vertical-align:middle">應發獎金</td>
<td> <td>
<input type="text" x-model="data.maintain_price_toal" disabled="disabled"> <input type="text" x-model="data.maintain_price_total" disabled>
</td> </td>
</tr> </tr>
</tbody>
</template>
<!-- 獎金計算頁面 -->
<template x-if="step == 3">
<tbody style="font-weight: bolder;margin-bottom:20px">
<tr> <tr>
<td colspan="7" style="vertical-align:middle;border-right:0px"> <td style="vertical-align:middle">作番總價</td>
<h4>獎金確認項</h4> <td>
<input type="text" x-model="data.total" disabled>
</td> </td>
<td class="text-right" style="border: left 0px;"> <td style="vertical-align:middle">牌價</td>
<button type="button" id="btn_back" class="btn btn-default" onclick="window.history.back();">返回</button> <td>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button> <input type="text" x-model="data.fee_per_st" disabled>
</td> </td>
</tr> <td style="vertical-align:middle">服務費</td>
<tr> <td>
<td style="vertical-align:middle"></td> <input type="text" x-model="data.commission_fee" disabled>
</td>
<td style="vertical-align:middle">價率</td>
<td>
<input type="text" x-model="data.discount" disabled>
</td>
</tr> </tr>
</tbody> </tbody>
</template> </template>
</table> </table>
<button x-show="step==3" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> <button x-show=" step==1" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading"> <template x-if="!isLoading">
<span>存檔</span> <span>確認</span>
</template> </template>
<template x-if="isLoading"> <template x-if="isLoading">
<div class="loader"></div> <div class="loader"></div>
</template> </template>
</button> </button>
<button x-show="step<=2" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading"> <!-- <button x-show="step<=2" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading">
<template x-if="!isLoading"> <template x-if="!isLoading">
<span>下一步</span> <span>下一步</span>
</template> </template>
@ -129,7 +160,27 @@ require_once('../contract-repair/conn.php');
<template x-if="isLoading"> <template x-if="isLoading">
<div class="loader"></div> <div class="loader"></div>
</template> </template>
</button> </button> -->
</div> </div>
</div> </div>
</div> </div>
<script>
const user_id = '<?= $user_id ?>';
const id = '<?= $_GET['id'] ?>';
const contract_no = '<?= $result['contract_no'] ?>';
const facility_no = '<?= $result['facility_no'] ?>';
const bonus_verson = '<?= $result['bonus_verson'] ?>';
const receiver = '<?= $result['receiver'] ?>';
const payDaydue = '<?= $result['pay_day'] ?>';
const maintain_price_total = '<?= $result['amount'] ?>';
const contract_type = '<?= $result['contract_type'] ?>';
// const bonus_verson = '<?= $result['bonus_verson'] ?>';
const maintain_type = '<?= $maintain_type[$bonus_json->maintain_type] ?>';
const pay_kind = '<?= $paykind[$bonus_json->paykind] ?>';
const receivable_date_due = '<?= $bonus_json->receivable_date_due ?>';
const total = '<?= $bonus_json->total ?>';
const fee_per_st = '<?= $bonus_json->fee_per_st ?>';
const commission_fee = '<?= $bonus_json->commission_fee ?>';
const discount = '<?= $bonus_json->discount ?>'
</script>

378
wms/bonus/bonus_index1.php

@ -0,0 +1,378 @@
<?php
include('../header.php');
require_once('../contract-repair/conn.php');
?>
<link rel="stylesheet" href="../contract-repair/styles/style.css">
<link rel="stylesheet" href="../contract-repair/semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="../contract-repair/js/alpine.js"></script>
<script defer src="../contract-repair/js/alpinejs/cdn.min.js"></script>
<script src="../contract-repair/js/axios/axios.min.js"></script>
<script src="../contract-repair/js/jquery/jquery-3.1.1.min.js"></script>
<script src="../contract-repair/semantic/dist/semantic.min.js"></script>
<div class="bonuns_index" x-data="bonunsIndexTest">
<div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name="form_name" value="main_form">
<div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>獎金計算</h3>
</td>
</tr>
</thead>
<template x-if="step==1">
<tbody style="font-weight: bolder;margin: botton 20px;">
<tr>
<td style="vertical-align: middle;">獎金類型</td>
<td colspan="7">
<div>
<input type="radio" name="contact" x-model="data.checkbox" value=11>
<label for="new_v1">新梯_V1</label><br>
<input type="radio" name="contact" x-model="data.checkbox" value=12>
<label for="new_v2">新梯_V2</label><br>
<input type="radio" name="contact" x-model="data.checkbox" value=13>
<label for="maintain">保養</label>
</div>
</td>
<!-- <td colspan="2" style="vertical-align:middle"></td> -->
</tr>
</tbody>
</template>
<!-- 獎金計算 新梯V1 -->
<template x-if="checkbox==11">
<tbody style="font-weight: bolder;margin-bottom:20px" x-show="step==11">
<tr>
<td colspan="7" style="vertical-align:middle;border-right:0px">
<h4>獎金確認項(新梯V1)</h4>
</td>
<td class="text-right" style="border: left 0px;">
<button type="button" id="btn_back" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button>
</td>
</tr>
<tr>
<td style="vertical-align:middle">合約類別</td>
<td>
<select id="client_type" x-model="data.client_type">
<option value="">--請選擇--</option>
<option value="1">新簽約</option>
<option value="2">免保轉有費</option>
<option value="3">續簽約</option>
</select>
<p class="alerttext" x-show="data.client_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<!-- <td style="vertical-align:middle">作番號</td>
<td>
<input type="text" x-model="data.facility_no" disabled="disabled">
</td> -->
<td style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="data.bonus_verson" disabled="disabled">
</td>
<td style="vertical-align:middle">契約人員</td>
<td>
<input type="text" x-model="data.receiver">
</td>
<td style="vertical-align:middle">付款方式(月/次)</td>
<td>
<select x-model="data.paykind">
<template x-for="paykind in data.paykindArr" :key="paykind">
<option x-text="paykind"></option>
</template>
</select>
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養月份</td>
<td>
<input type="text" x-model="data.maintain_month">
</td>
<td style="vertical-align:middle">應收款日期(月/次)</td>
<td>
<input type="text" x-model="data.payDay">
<p>(Ex:20240101)</p>
</td>
<td style="vertical-align:middle">地區經理經理員</td>
<td>
<input type="text" x-model="data.manager">
</td>
<td style="vertical-align:middle">專任契約經理員</td>
<td>
<input type="text" x-model="data.contract_manger">
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養金額(月)</td>
<td>
<input type="text" x-model="data.maintain_price_month">
</td>
<td style="vertical-align:middle">牌價</td>
<td colspan='3'>
<input type="text" x-model="data.maintain_price_total">
<p>標準價+Option價格+與其他電梯共同分擔的費用貨價格</p>
</td>
<td style="vertical-align:middle" @click="test()">服務費</td>
<td>
<input type="text" x-model="data.commission_fee">
</td>
<!-- <td></td>
<td></td> -->
</tr>
</tbody>
</template>
<!-- 獎金計算,新梯V2 -->
<template x-if="step==12">
<tbody style="font-weight: bolder;margin-bottom:20px" x-show="step==12">
<tr>
<td colspan="7" style="vertical-align:middle;border-right:0px">
<h4>獎金確認項(新梯V2)</h4>
</td>
<td class="text-right" style="border: left 0px;">
<button type="button" id="btn_back" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button>
</td>
</tr>
<tr>
<td style="vertical-align:middle">合約類別</td>
<td>
<select id="client_type" x-model="data.client_type">
<option value="">--請選擇--</option>
<option value="1">新簽約</option>
<option value="2">免保轉有費</option>
<option value="3">續簽約</option>
</select>
<p class="alerttext" x-show="data.client_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<!-- <td style="vertical-align:middle">作番號</td>
<td>
<input type="text" x-model="data.facility_no" disabled="disabled">
</td> -->
<td style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="data.bonus_verson" disabled="disabled">
</td>
<td style="vertical-align:middle">契約人員</td>
<td>
<input type="text" x-model="data.receiver">
</td>
<td style="vertical-align:middle">付款方式(月/次)</td>
<td>
<select x-model="data.paykind">
<template x-for="paykind in data.paykindArr" :key="paykind">
<option x-text="paykind"></option>
</template>
</select>
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養月份</td>
<td>
<input type="text" x-model="data.maintain_month">
</td>
<td style="vertical-align:middle">應收款日期(月/次)</td>
<td>
<input type="text" x-model="data.payDay">
<p>(Ex:20240101)</p>
</td>
<td style="vertical-align:middle">地區經理經理員</td>
<td>
<input type="text" x-model="data.manager">
</td>
<td style="vertical-align:middle">專任契約經理員</td>
<td>
<input type="text" x-model="data.contract_manger">
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養金額(月)</td>
<td>
<input type="text" x-model="data.maintain_price_month">
</td>
<td style="vertical-align:middle">牌價</td>
<td colspan='3'>
<input type="text" x-model="data.maintain_price_total">
<p>標準價+Option價格+與其他電梯共同分擔的費用貨價格</p>
</td>
<td style="vertical-align:middle" @click="test()">服務費</td>
<td>
<input type="text" x-model="data.commission_fee">
</td>
<!-- <td></td>
<td></td> -->
</tr>
</tbody>
</template>
<template x-if=" (checkbox==13&&step==2); ">
<tbody style="font-weight: bolder;margin-bottom:20px" x-show="(checkbox==13&&step==2)">
<tr>
<td colspan="7" style="vertical-align:middle;border-right:0px">
<h4>獎金確認項(保養)</h4>
</td>
<td class="text-right" style="border: left 0px;">
<button type="button" id="btn_back" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button>
</td>
</tr>
<tr>
<td style="vertical-align:middle">合約類別</td>
<td>
<select id="client_type" x-model="data.client_type">
<option value="">--請選擇--</option>
<option value="1">新簽約</option>
<option value="2">免保轉有費</option>
<option value="3">續簽約</option>
</select>
<p class="alerttext" x-show="data.client_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<!-- <td style="vertical-align:middle">作番號</td>
<td>
<input type="text" x-model="data.facility_no" disabled="disabled">
</td> -->
<td style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="data.bonus_verson" disabled="disabled">
</td>
<td style="vertical-align:middle">契約人員</td>
<td>
<input type="text" x-model="data.receiver">
</td>
<td style="vertical-align:middle">付款方式(月/次)</td>
<td>
<select x-model="data.paykind">
<template x-for="paykind in data.paykindArr" :key="paykind">
<option x-text="paykind"></option>
</template>
</select>
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養月份</td>
<td>
<input type="text" x-model="data.maintain_month">
</td>
<td style="vertical-align:middle">應收款日期(月/次)</td>
<td>
<input type="text" x-model="data.payDay">
<p>(Ex:20240101)</p>
</td>
<td style="vertical-align:middle">地區經理經理員</td>
<td>
<input type="text" x-model="data.manager">
</td>
<td style="vertical-align:middle">專任契約經理員</td>
<td>
<input type="text" x-model="data.contract_manger">
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養金額(月)</td>
<td>
<input type="text" x-model="data.maintain_price_month">
</td>
<td style="vertical-align:middle">牌價</td>
<td colspan='3'>
<input type="text" x-model="data.maintain_price_total">
<p>標準價+Option價格+與其他電梯共同分擔的費用貨價格</p>
</td>
<td style="vertical-align:middle" @click="test()">服務費</td>
<td>
<input type="text" x-model="data.commission_fee">
</td>
<!-- <td></td>
<td></td> -->
</tr>
</tbody>
</template>
<!-- 獎金計算頁面 -->
<template x-if="step == 3">
<template x-for="(bonusArr,index) in data.bonusArr" :key="">
<tbody style="font-weight: bolder;margin-bottom:20px" x-show="step==3">
<!-- <tr x-if="index % 3 == 0 || index == 0">
<td colspan=8>
<p x-text="'獎金' + Number(index+1)"></p>
</td>
</tr> -->
<tr>
<td style="vertical-align:middle">獎金類型</td>
<td>
<input type="text" x-model="data.bonusArr[index].bonus_type">
</td>
<td style="vertical-align:middle">發放人員</td>
<td>
<input type="text" x-model="data.bonusArr[index].bonus_receiver">
</td>
<td style="vertical-align:middle;">發放金額</td>
<td>
<input type="text" x-model="data.bonusArr[index].bonus_amount">
</td>
<td style="vertical-align:middle">預計發放時間</td>
<td>
<input type="text" x-model="data.bonusArr[index].pay_day_due">
</td>
</tr>
<tr>
<td style="vertical-align:middle">發放規定</td>
<td colspan="5">
<input type="text" x-model="data.bonusArr[index].bonus_regulation">
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</template>
</template>
</table>
<button x-show="step == 3" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>存檔</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step<=2" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading">
<template x-if="!isLoading">
<span>下一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>上一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
</div>
</div>
</div>
<script>
const user_id = '<?= $user_id ?>';
</script>

15
wms/bonus/connT8.php

@ -0,0 +1,15 @@
<?php
require_once dirname(__FILE__) . "/../../mkt/database.php";
include_once '../fun_global.php';
// phpinfo();
// exit();
try {
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8masada", "M0225", "IFFBU1E=");
if ($connT8) {
$connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
} catch (PDOException $e) {
// echo "fail";
// echo $e->getMessage();
die("ERROR!!!: " . $e->getMessage());
}

0
wms/bons/elevator_new/elevator_new_deal_bonus_v1_0.php → wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0.php

0
wms/bons/elevator_new/elevator_new_deal_bonus_v1_0_examination.php → wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php

0
wms/bons/elevator_new/elevator_new_deal_bonus_v2_0.php → wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php

0
wms/bons/elevator_new/elevator_new_deal_bonus_v2_0_examination.php → wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_examination.php

307
wms/bonus/insertBonus.php

@ -0,0 +1,307 @@
<?php
include('../header.php');
require_once('../contract-repair/conn.php');
require_once("./other/maintenance_contract_bonus_v2_1.php");
$create_id = $user_id;
$create_at = date('Y-m-d H:i:s');
// echo $create_id;
$examination_array = [
#錯誤版本
["1.0", "new", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"],
#新簽約
#月繳(monthly)
["2.1", "new", "monthly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "new", "monthly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "new", "monthly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "new", "monthly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "new", "monthly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "new", "monthly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "new", "monthly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "new", "monthly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "new", "monthly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "new", "monthly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "new", "monthly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "new", "monthly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#2月1次繳(bimonthly)
["2.1", "new", "bimonthly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "new", "bimonthly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "new", "bimonthly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "new", "bimonthly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "new", "bimonthly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "new", "bimonthly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "new", "bimonthly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "new", "bimonthly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "new", "bimonthly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "new", "bimonthly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "new", "bimonthly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "new", "bimonthly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#季付(quarterly)
["2.1", "new", "quarterly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "new", "quarterly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "new", "quarterly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "new", "quarterly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "new", "quarterly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "new", "quarterly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "new", "quarterly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "new", "quarterly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "new", "quarterly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "new", "quarterly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "new", "quarterly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "new", "quarterly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#半年付(semiannually)
["2.1", "new", "semiannually", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "new", "semiannually", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "new", "semiannually", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "new", "semiannually", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "new", "semiannually", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "new", "semiannually", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "new", "semiannually", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "new", "semiannually", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "new", "semiannually", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "new", "semiannually", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "new", "semiannually", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "new", "semiannually", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#年付(annually)
["2.1", "new", "annually", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "new", "annually", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "new", "annually", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "new", "annually", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "new", "annually", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "new", "annually", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "new", "annually", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "new", "annually", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "new", "annually", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "new", "annually", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "new", "annually", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "new", "annually", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#免保轉有費(free_to_charge)
#月繳(monthly)
["2.1", "free_to_charge", "monthly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "free_to_charge", "monthly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "free_to_charge", "monthly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "free_to_charge", "monthly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "free_to_charge", "monthly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "free_to_charge", "monthly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "free_to_charge", "monthly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "free_to_charge", "monthly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "free_to_charge", "monthly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "free_to_charge", "monthly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "free_to_charge", "monthly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "free_to_charge", "monthly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#2月1次繳(bimonthly)
["2.1", "free_to_charge", "bimonthly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "free_to_charge", "bimonthly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "free_to_charge", "bimonthly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "free_to_charge", "bimonthly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "free_to_charge", "bimonthly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "free_to_charge", "bimonthly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "free_to_charge", "bimonthly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "free_to_charge", "bimonthly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "free_to_charge", "bimonthly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "free_to_charge", "bimonthly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "free_to_charge", "bimonthly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "free_to_charge", "bimonthly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#季付(quarterly)
["2.1", "free_to_charge", "quarterly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "free_to_charge", "quarterly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "free_to_charge", "quarterly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "free_to_charge", "quarterly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "free_to_charge", "quarterly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "free_to_charge", "quarterly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "free_to_charge", "quarterly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "free_to_charge", "quarterly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "free_to_charge", "quarterly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "free_to_charge", "quarterly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "free_to_charge", "quarterly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "free_to_charge", "quarterly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#半年付(semiannually)
["2.1", "free_to_charge", "semiannually", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "free_to_charge", "semiannually", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "free_to_charge", "semiannually", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "free_to_charge", "semiannually", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "free_to_charge", "semiannually", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "free_to_charge", "semiannually", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "free_to_charge", "semiannually", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "free_to_charge", "semiannually", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "free_to_charge", "semiannually", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "free_to_charge", "semiannually", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "free_to_charge", "semiannually", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "free_to_charge", "semiannually", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#年付(annually)
["2.1", "free_to_charge", "annually", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "free_to_charge", "annually", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "free_to_charge", "annually", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "free_to_charge", "annually", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "free_to_charge", "annually", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "free_to_charge", "annually", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "free_to_charge", "annually", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "free_to_charge", "annually", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "free_to_charge", "annually", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "free_to_charge", "annually", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "free_to_charge", "annually", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "free_to_charge", "annually", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#續簽約(原價或僅契約金額異動)(renew_priceissue)
#月繳(monthly)
["2.1", "renew_priceissue", "monthly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "renew_priceissue", "monthly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "renew_priceissue", "monthly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "renew_priceissue", "monthly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "renew_priceissue", "monthly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "renew_priceissue", "monthly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "renew_priceissue", "monthly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "renew_priceissue", "monthly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "renew_priceissue", "monthly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "renew_priceissue", "monthly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "renew_priceissue", "monthly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "renew_priceissue", "monthly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#2月1次繳(bimonthly)
["2.1", "renew_priceissue", "bimonthly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "renew_priceissue", "bimonthly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "renew_priceissue", "bimonthly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "renew_priceissue", "bimonthly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "renew_priceissue", "bimonthly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "renew_priceissue", "bimonthly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "renew_priceissue", "bimonthly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "renew_priceissue", "bimonthly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "renew_priceissue", "bimonthly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "renew_priceissue", "bimonthly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "renew_priceissue", "bimonthly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "renew_priceissue", "bimonthly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#季付(quarterly)
["2.1", "renew_priceissue", "quarterly", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "renew_priceissue", "quarterly", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "renew_priceissue", "quarterly", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "renew_priceissue", "quarterly", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "renew_priceissue", "quarterly", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "renew_priceissue", "quarterly", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "renew_priceissue", "quarterly", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "renew_priceissue", "quarterly", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "renew_priceissue", "quarterly", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "renew_priceissue", "quarterly", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "renew_priceissue", "quarterly", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "renew_priceissue", "quarterly", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#半年付(semiannually)
["2.1", "renew_priceissue", "semiannually", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "renew_priceissue", "semiannually", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "renew_priceissue", "semiannually", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "renew_priceissue", "semiannually", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "renew_priceissue", "semiannually", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "renew_priceissue", "semiannually", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "renew_priceissue", "semiannually", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "renew_priceissue", "semiannually", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "renew_priceissue", "semiannually", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "renew_priceissue", "semiannually", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "renew_priceissue", "semiannually", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "renew_priceissue", "semiannually", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#年付(annually)
["2.1", "renew_priceissue", "annually", 3000, 3000, 600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1", "renew_priceissue", "annually", 3000, 3001, 601, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1", "renew_priceissue", "annually", 3000, 3500, 1100, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1", "renew_priceissue", "annually", 3000, 4000, 1600, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1", "renew_priceissue", "annually", 3000, 3000, 1200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1", "renew_priceissue", "annually", 3000, 3001, 1201, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1", "renew_priceissue", "annually", 3000, 3500, 1700, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1", "renew_priceissue", "annually", 3000, 4000, 2200, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1", "renew_priceissue", "annually", 3000, 3000, 1230, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1", "renew_priceissue", "annually", 3000, 3001, 1231, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1", "renew_priceissue", "annually", 3000, 3500, 1730, "2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1", "renew_priceissue", "annually", 3000, 4000, 2230, "2014-07-01", "M0001", "M0002", "M0003"] #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
];
$bonus_json = [];
$count = 0;
foreach ($examination_array as $key => $value) {
$bonus_verson = $value[0];
$maintain_type = $value[1];
$paykind = $value[2];
$elevator_list_price = $value[3]; //標準價格 / 月
$fee_per_st = $value[4]; //牌價 / 月
$commission_fee = $value[5]; //服務費 / 年
$receivable_date_due = $value[6]; // 應收時間
$sal = $value[7]; // 銷售人員
$mang = $value[8]; //經理
$controct_mang = $value[9];
$contract_no = 'TEST0' . $key;
$contract_type = 3;
$facility_no = 'TEST' . $key;
$status = 1;
$results = maintenance_contract_bonus_v2_1(
$bonus_verson,
$maintain_type,
$paykind,
$elevator_list_price,
$fee_per_st,
$commission_fee,
$receivable_date_due,
$sal,
$mang,
$controct_mang
);
if ($results['result_status'] == 'error') {
} else {
array_push($bonus_json, [
'maintain_type' => $maintain_type,
'total' => $elevator_list_price,
'fee_per_st' => $fee_per_st,
'commission_fee' => $commission_fee,
'paykind' => $paykind,
'receivable_date_due' => $receivable_date_due,
]);
// foreach ($bonus_json as $json) {
// $a = json_encode($json);
// }
foreach ($results['bonus_array'] as $i => $result) {
// echo '<pre>';
// print_r($result);
// echo '</pre>';
$bonus_type = $result['bonus_type'];
$pay_day = $result['pay_day_due'];
$amount = $result['bonus_amount'];
$receiver = $result['bonus_receiver'];
$discount = $result['discount'];
foreach ($bonus_json as $json) {
$json['discount'] = "$discount";
$a = json_encode($json);
}
// echo '<pre>';
// print_r($a);
// echo '</pre>';
// exit();
$sql = "INSERT INTO bonus
(bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day,status,bonus_json,create_id,create_at) VALUES
($bonus_type,'$bonus_verson','$contract_no',$contract_type,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')";
$stmt = $conn->prepare($sql);
$stmt->execute();
$count++;
echo '<pre>';
print_r($count . '-- > Success');
echo '</pre>';
// exit;
}
}
// $sql = "INSERT INTO bonus
// (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day,status,bonus_json,create_id,create_at) VALUES
// ($bonus_type,'$bonus_verson','$contract_no',$contract_type,'$facility_no',$amount,'$receiver','$pay_day',$status,'$bonus_json','$create_id','$create_at')";
// echo '<pre>';
// print_r($sql);
// echo '</pre>';
// if ($key == 2) {
// exit;
// }
}

0
wms/bons/maintance/maintenance_contract_bonus_v2_0.php → wms/bonus/maintance/maintenance_contract_bonus_v2_0.php

0
wms/bons/maintance/maintenance_contract_bonus_v2_0_examination.php → wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php

159
wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1.php

@ -0,0 +1,159 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
簽約價格($elevator_knockdown_price):電梯的合約最後成交價
該作番所佔的服務費金額($commission_fee)
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
一般客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price) - 服務費($commission_fee)】 除以 牌價($elevator_list_price) *100%
戰略客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price)】 除以 牌價($elevator_list_price) *100%
營業員獎金($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_renew_noninstallment_bonus_v2_1($ver, $contract_type, $elevator_list_price, $elevator_knockdown_price, $commission_fee, $sales_id, $region_manger_id){
$bonus_array = [];
if ($ver == "2.1"){
$discount = round(($elevator_knockdown_price - $commission_fee) / $elevator_list_price, 2); #銷售點數,取到小數點第2位。
#折扣率
switch ($discount) {
case ($discount >= 0.8):
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.018;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
}
break;
case ($discount >= 0.60 and $discount < 0.8):
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.0144;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 300;
break;
}
break;
case ($discount < 0.60):
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 200;
break;
}
break;
};
#營銷人員銷售獎金水庫-----訂金已收款100%,發放總獎金30%
array_push($bonus_array,[
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.3), #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,發放總獎金30%" #發放規定
]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款100%,發放總獎金50%
array_push($bonus_array,[
"bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.5), #金額
"payment_schedul_due" => "shipping", #出貨前期所有款項已收齊,且出貨款已收款100%
"payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款100%,發放總獎金50%" #發放規定
]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款100%,發放總獎金30%
array_push($bonus_array,[
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus) - round($sales_bonus * 0.3) - round($sales_bonus * 0.5), #金額
"payment_schedul_due" => "acceptance", #驗收前期所有款項已收齊,且驗收款已收款100%
"payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款100%,發放總獎金20%" #發放規定
]);
#區域經理提成獎金水庫-----訂金已收款100%,發放總獎金100%
array_push($bonus_array,[
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => $region_manager_bonus, #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,次月發放" #發放規定
]);
$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;
};
?>

83
wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1_examination.php

@ -0,0 +1,83 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
簽約價格($elevator_knockdown_price):電梯的合約最後成交價
該作番所佔的服務費金額($commission_fee)
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
一般客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price) - 服務費($commission_fee)】 除以 牌價($elevator_list_price) *100%
戰略客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price)】 除以 牌價($elevator_list_price) *100%
營業員獎金($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 #所有獎金水庫
];
*/
require_once("elevator_renew_noninstallment_bonus_v2_1.php");
#$ver, $contract_type, $elevator_list_price, $elevator_knockdown_price, $commission_fee, $sales_id, $region_manger_id
#獎金測試
$examination_array = [
#錯誤版本
["1.0","strategy_customer",1000000,1000000,100000,"M0001", "M0003"],
#戰略客戶(strategy_customer)
["2.1","strategy_customer",1000000,900000,100000,"M0001", "M0003"], #戰略客戶、折扣率80%
["2.1","strategy_customer",1000000,700000,100000,"M0001", "M0003"], #戰略客戶、折扣率60%
["2.1","strategy_customer",1000000,690000,100000,"M0001", "M0003"], #戰略客戶、折扣率59%
#一般客戶(general_customer)
["2.1","general_customer",1000000,900000,100000,"M0001", "M0003"], #一般客戶、折扣率80%
["2.1","general_customer",1000000,700000,100000,"M0001", "M0003"], #一般客戶、折扣率60%
["2.1","general_customer",1000000,690000,100000,"M0001", "M0003"] #一般客戶、折扣率59%
];
for($i = 0; $i<count($examination_array); $i++){
$result = elevator_renew_noninstallment_bonus_v2_1(
$examination_array[$i][0],
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4],
$examination_array[$i][5],
$examination_array[$i][6]
);
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] . " "
. $examination_array[$i][5] . " " . $examination_array[$i][6] . "<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>";
};
echo "-------------------------" . "<br>";
};
?>

160
wms/bonus/other/elevator_renew_withinstallment_bonus_v2_1.php

@ -0,0 +1,160 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
簽約價格($elevator_knockdown_price):電梯的合約最後成交價
該作番所佔的服務費金額($commission_fee)
總支付期數$payment_period_amount: 總支付期數,依規定至少13期,
第一筆保養款項應收回日($receivable_date_due, array)
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
一般客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price) - 服務費($commission_fee)】 除以 牌價($elevator_list_price) *100%
戰略客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price)】 除以 牌價($elevator_list_price) *100%
營業員獎金($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_renew_withinstallment_bonus_v2_1($ver, $contract_type, $payment_period_amount, $elevator_list_price, $elevator_knockdown_price, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id){
$bonus_array = [];
if ($ver == "2.1"){
$discount = round(($elevator_knockdown_price - $commission_fee) / $elevator_list_price, 2); #銷售點數,取到小數點第2位。
#折扣率
switch ($discount) {
case ($discount >= 0.8):
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.018;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
}
break;
case ($discount >= 0.60 and $discount < 0.8):
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.0144;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 300;
break;
}
break;
case ($discount < 0.60):
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 200;
break;
}
break;
};
#產生契約員每個月的獎金應發比例
$payment_ratio_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payment_ratio_due_array, 1/$payment_period_amount);
};
$payday_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payday_due_array, $i+1 );
};
for($i = 0; $i < count($payment_ratio_due_array); $i++) {
if($i < count($payment_ratio_due_array) - 1){
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
}else{
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array,[
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"payment_schedul_due" => date("Y-m-d",strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"payment_schedul_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
};
#區域經理提成獎金水庫-----訂金已收款100%,發放總獎金100%
array_push($bonus_array,[
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => $region_manager_bonus, #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,次月發放" #發放規定
]);
$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;
};
?>

85
wms/bonus/other/elevator_renew_withinstallment_bonus_v2_1_examination.php

@ -0,0 +1,85 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
簽約價格($elevator_knockdown_price):電梯的合約最後成交價
該作番所佔的服務費金額($commission_fee)
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
一般客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price) - 服務費($commission_fee)】 除以 牌價($elevator_list_price) *100%
戰略客戶汰改折扣率($discount):【簽約價格($elevator_knockdown_price)】 除以 牌價($elevator_list_price) *100%
營業員獎金($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 #所有獎金水庫
];
*/
require_once("elevator_renew_withinstallment_bonus_v2_1.php");
#$ver, $contract_type, $payment_period_amount, $elevator_list_price, $elevator_knockdown_price, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id
#獎金測試
$examination_array = [
#錯誤版本
["1.0","strategy_customer",13,1000000,1000000,100000,"2014-07-01","M0001", "M0003"],
#戰略客戶(strategy_customer)
["2.1","strategy_customer",13,1000000,900000,100000,"2014-07-01","M0001", "M0003"], #戰略客戶、折扣率80%
["2.1","strategy_customer",13,1000000,700000,100000,"2014-07-01","M0001", "M0003"], #戰略客戶、折扣率60%
["2.1","strategy_customer",13,1000000,690000,100000,"2014-07-01","M0001", "M0003"], #戰略客戶、折扣率59%
#一般客戶(general_customer)
["2.1","general_customer",13,1000000,900000,100000,"2014-07-01","M0001", "M0003"], #一般客戶、折扣率80%
["2.1","general_customer",13,1000000,700000,100000,"2014-07-01","M0001", "M0003"], #一般客戶、折扣率60%
["2.1","general_customer",13,1000000,690000,100000,"2014-07-01","M0001", "M0003"] #一般客戶、折扣率59%
];
for($i = 0; $i<count($examination_array); $i++){
$result = elevator_renew_withinstallment_bonus_v2_1(
$examination_array[$i][0],
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4],
$examination_array[$i][5],
$examination_array[$i][6],
$examination_array[$i][7],
$examination_array[$i][8]
);
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] . " "
. $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . "<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>";
};
echo "-------------------------" . "<br>";
};
?>

299
wms/bonus/other/maintenance_contract_bonus_v2_1.php

@ -0,0 +1,299 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
該作番所佔的服務費金額($commission_fee)
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) ; 契約折扣率=(簽約價格-服務費)/牌價
付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually)
第一筆保養款項應收回日($receivable_date_due, array)
契約員員工號($sales_id)
地區處長員工號($region_director_id)
專任契約經理員工號($regular_contract_manger_id)
【2.函數中的變數說明】
契約員獎金($sales_bonus)
地區處長獎金($region_director_bonus)
專任契約經理獎金($regular_contract_manger_bonus)
獎金預計發放比例($payment_ratio_due_array)
當次應發獎金($current_bonus)
獎金預計發放日($payday_due_array)
獎金預計發放規定($payday_due_regulation):合約簽回及保養款項收回的次月一次性發
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
pay_day_due:預計發放時間
bonus_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
function 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)
{
$bonus_array = [];
if ($ver == "2.1") {
$discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) {
case "new":
#契約員獎金($sales_bonus)
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount >= 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.6;
break;
case ($fee_per_st >= 3000 and $fee_per_st < 3500):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st < 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.8;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.9;
break;
};
break;
case ($discount >= 0.6 and $discount < 0.8):
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.48;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.56;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.64;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.72;
break;
};
break;
case ($discount < 0.6):
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.42;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.49;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.56;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.63;
break;
};
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
case "free_to_charge":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.45;
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
case "renew_priceissue":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.25;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4;
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
};
#地區處長獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "第1次款項收回後,次月發放", #發放規定
'discount' => $discount //折扣率
]);
#專任契約經理獎金
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "第1次款項收回後,次月發放", #發放規定
'discount' => $discount //折扣率
]);
#契約員獎金
switch ($payment_period) {
#年付
case "annually":
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放", #發放規定
'discount' => $discount //折扣率
]);
break;
#半年付
case "semiannually":
$payment_ratio_due_array = array(0.5, 0.5);
$payday_due_array = array(1, 7);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放", #發放規定
'discount' => $discount //折扣率
]);
}
break;
#季付
case "quarterly":
$payment_ratio_due_array = array(0.25, 0.25, 0.25, 0.25);
$payday_due_array = array(1, 4, 7, 10);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放", #發放規定
'discount' => $discount //折扣率
]);
}
break;
#2月1次
case "bimonthly":
$payment_ratio_due_array = array(0.166, 0.166, 0.166, 0.166, 0.166, 0.166);
$payday_due_array = array(1, 3, 5, 7, 9, 11);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放", #發放規定
'discount' => $discount //折扣率
]);
}
break;
#月付
case "monthly":
$payment_ratio_due_array = array(0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083, 0.083);
$payday_due_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放", #發放規定
'discount' => $discount //折扣率
]);
}
break;
}
$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, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};

291
wms/bonus/other/maintenance_contract_bonus_v2_1_examination.php

@ -0,0 +1,291 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
該作番所佔的服務費金額($commission_fee)
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) ; 契約折扣率=(簽約價格-服務費)/牌價
付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually)
第一筆保養款項應收回日($receivable_date_due, array)
契約員員工號($sales_id)
地區處長員工號($region_director_id)
專任契約經理員工號($regular_contract_manger_id)
【2.函數中的變數說明】
契約員獎金($sales_bonus)
地區處長獎金($region_director_bonus)
專任契約經理獎金($regular_contract_manger_bonus)
獎金預計發放比例($payment_ratio_due_array)
當次應發獎金($current_bonus)
獎金預計發放日($payday_due_array)
獎金預計發放規定($payday_due_regulation):合約簽回及保養款項收回的次月一次性發
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
pay_day_due:預計發放時間
bonus_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
require_once("maintenance_contract_bonus_v2_1.php");
#$ver, $contract_type, $payment_period, $discount, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id
#獎金測試
$examination_array = [
#錯誤版本
["1.0","new","one",0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"],
#新簽約
#月繳(monthly)
["2.1","new","monthly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","new","monthly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","new","monthly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","new","monthly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","new","monthly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","new","monthly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","new","monthly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","new","monthly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","new","monthly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","new","monthly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","new","monthly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","new","monthly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、月繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#2月1次繳(bimonthly)
["2.1","new","bimonthly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","new","bimonthly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","new","bimonthly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","new","bimonthly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","new","bimonthly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","new","bimonthly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","new","bimonthly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","new","bimonthly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","new","bimonthly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","new","bimonthly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","new","bimonthly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","new","bimonthly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2月1次繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#季付(quarterly)
["2.1","new","quarterly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","new","quarterly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","new","quarterly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","new","quarterly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","new","quarterly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","new","quarterly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","new","quarterly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","new","quarterly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","new","quarterly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","new","quarterly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","new","quarterly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","new","quarterly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、季付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#半年付(semiannually)
["2.1","new","semiannually",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","new","semiannually",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","new","semiannually",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","new","semiannually",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","new","semiannually",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","new","semiannually",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","new","semiannually",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","new","semiannually",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","new","semiannually",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","new","semiannually",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","new","semiannually",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","new","semiannually",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、半年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#年付(annually)
["2.1","new","annually",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","new","annually",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","new","annually",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","new","annually",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","new","annually",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","new","annually",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","new","annually",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","new","annually",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","new","annually",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","new","annually",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","new","annually",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","new","annually",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#免保轉有費(free_to_charge)
#月繳(monthly)
["2.1","free_to_charge","monthly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","free_to_charge","monthly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","free_to_charge","monthly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","free_to_charge","monthly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","free_to_charge","monthly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","free_to_charge","monthly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","free_to_charge","monthly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","free_to_charge","monthly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","free_to_charge","monthly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","free_to_charge","monthly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","free_to_charge","monthly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","free_to_charge","monthly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、月繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#2月1次繳(bimonthly)
["2.1","free_to_charge","bimonthly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","free_to_charge","bimonthly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","free_to_charge","bimonthly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","free_to_charge","bimonthly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","free_to_charge","bimonthly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","free_to_charge","bimonthly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","free_to_charge","bimonthly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","free_to_charge","bimonthly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","free_to_charge","bimonthly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","free_to_charge","bimonthly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","free_to_charge","bimonthly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","free_to_charge","bimonthly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、2月1次繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#季付(quarterly)
["2.1","free_to_charge","quarterly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","free_to_charge","quarterly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","free_to_charge","quarterly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","free_to_charge","quarterly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","free_to_charge","quarterly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","free_to_charge","quarterly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","free_to_charge","quarterly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","free_to_charge","quarterly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","free_to_charge","quarterly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","free_to_charge","quarterly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","free_to_charge","quarterly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","free_to_charge","quarterly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、季付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#半年付(semiannually)
["2.1","free_to_charge","semiannually",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","free_to_charge","semiannually",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","free_to_charge","semiannually",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","free_to_charge","semiannually",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","free_to_charge","semiannually",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","free_to_charge","semiannually",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","free_to_charge","semiannually",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","free_to_charge","semiannually",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","free_to_charge","semiannually",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","free_to_charge","semiannually",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","free_to_charge","semiannually",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","free_to_charge","semiannually",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、半年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#年付(annually)
["2.1","free_to_charge","annually",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","free_to_charge","annually",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","free_to_charge","annually",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","free_to_charge","annually",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","free_to_charge","annually",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","free_to_charge","annually",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","free_to_charge","annually",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","free_to_charge","annually",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","free_to_charge","annually",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","free_to_charge","annually",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","free_to_charge","annually",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","free_to_charge","annually",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #免保轉有費、年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#續簽約(原價或僅契約金額異動)(renew_priceissue)
#月繳(monthly)
["2.1","renew_priceissue","monthly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","renew_priceissue","monthly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","renew_priceissue","monthly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","renew_priceissue","monthly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","renew_priceissue","monthly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","renew_priceissue","monthly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","renew_priceissue","monthly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","renew_priceissue","monthly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","renew_priceissue","monthly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","renew_priceissue","monthly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","renew_priceissue","monthly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","renew_priceissue","monthly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、月繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#2月1次繳(bimonthly)
["2.1","renew_priceissue","bimonthly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","renew_priceissue","bimonthly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","renew_priceissue","bimonthly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","renew_priceissue","bimonthly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","renew_priceissue","bimonthly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","renew_priceissue","bimonthly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","renew_priceissue","bimonthly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","renew_priceissue","bimonthly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","renew_priceissue","bimonthly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","renew_priceissue","bimonthly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","renew_priceissue","bimonthly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","renew_priceissue","bimonthly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、2月1次繳、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#季付(quarterly)
["2.1","renew_priceissue","quarterly",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","renew_priceissue","quarterly",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","renew_priceissue","quarterly",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","renew_priceissue","quarterly",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","renew_priceissue","quarterly",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","renew_priceissue","quarterly",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","renew_priceissue","quarterly",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","renew_priceissue","quarterly",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","renew_priceissue","quarterly",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","renew_priceissue","quarterly",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","renew_priceissue","quarterly",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","renew_priceissue","quarterly",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、季付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#半年付(semiannually)
["2.1","renew_priceissue","semiannually",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","renew_priceissue","semiannually",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","renew_priceissue","semiannually",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","renew_priceissue","semiannually",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","renew_priceissue","semiannually",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","renew_priceissue","semiannually",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","renew_priceissue","semiannually",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","renew_priceissue","semiannually",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","renew_priceissue","semiannually",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","renew_priceissue","semiannually",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","renew_priceissue","semiannually",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","renew_priceissue","semiannually",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、半年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
#年付(annually)
["2.1","renew_priceissue","annually",3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","renew_priceissue","annually",3000,3001,601,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3001元、服務費601元(折扣率0.8)
["2.1","renew_priceissue","annually",3000,3500,1100,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3500元、服務費1100元(折扣率0.8)
["2.1","renew_priceissue","annually",3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","renew_priceissue","annually",3000,3000,1200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","renew_priceissue","annually",3000,3001,1201,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3001元、服務費1201元(折扣率0.6)
["2.1","renew_priceissue","annually",3000,3500,1700,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3500元、服務費1700元(折扣率0.6)
["2.1","renew_priceissue","annually",3000,4000,2200,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","renew_priceissue","annually",3000,3000,1230,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","renew_priceissue","annually",3000,3001,1231,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3001元、服務費1231元(折扣率0.59)
["2.1","renew_priceissue","annually",3000,3500,1730,"2014-07-01", "M0001", "M0002", "M0003"], #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價3500元、服務費1730元(折扣率0.59)
["2.1","renew_priceissue","annually",3000,4000,2230,"2014-07-01", "M0001", "M0002", "M0003"] #續簽約(原價或僅契約金額異動)、年付、牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
];
for($i = 0; $i<count($examination_array); $i++){
$result = maintenance_contract_bonus_v2_1(
$examination_array[$i][0],
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4],
$examination_array[$i][5],
$examination_array[$i][6],
$examination_array[$i][7],
$examination_array[$i][8],
$examination_array[$i][9]
);
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] . " "
. $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7]. " " . $examination_array[$i][8] . " "
. $examination_array[$i][9] . "<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]["pay_day_due"] . " "
. $result["bonus_array"][$j]["bonus_regulation"] . "<br>";
};
echo "-------------------------" . "<br>";
};
?>

196
wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php

@ -0,0 +1,196 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge)
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
該作番所佔的服務費金額($commission_fee)
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) ; 契約折扣率=(簽約價格-服務費)/牌價
總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期,
第一筆保養款項應收回日($receivable_date_due, array)
契約員員工號($sales_id)
地區處長員工號($region_director_id)
專任契約經理員工號($regular_contract_manger_id)
【2.函數中的變數說明】
契約員獎金($sales_bonus)
地區處長獎金($region_director_bonus)
專任契約經理獎金($regular_contract_manger_bonus)
獎金預計發放比例($payment_ratio_due_array)
當次應發獎金($current_bonus)
獎金預計發放日($payday_due_array)
獎金預計發放規定($payday_due_regulation):合約簽回及保養款項收回的次月一次性發
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
pay_day_due:預計發放時間
bonus_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id){
$bonus_array = [];
if ($ver == "2.1"){
$discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
#契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge)
switch ($contract_type){
case "longcontract_m1_free_charge":
#契約員獎金($sales_bonus)
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount >= 0.8):
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.6;
break;
case ($fee_per_st > 300 and $fee_per_st <= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.7;
break;
case ($fee_per_st > 4000 and $fee_per_st <= 5000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.8;
break;
case ($fee_per_st > 5000 and $fee_per_st <= 6000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.9;
break;
case ($fee_per_st > 6000):
$sales_bonus = ($fee_per_st - $commission_fee) * 1.0;
break;
};
break;
case ($discount >= 0.6 and $discount < 0.8):
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.42;
break;
case ($fee_per_st > 300 and $fee_per_st <= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.49;
break;
case ($fee_per_st > 4000 and $fee_per_st <= 5000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.56;
break;
case ($fee_per_st > 5000 and $fee_per_st <= 6000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.63;
break;
case ($fee_per_st > 6000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.7;
break;
};
break;
case ($discount < 0.6):
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3;
break;
case ($fee_per_st > 300 and $fee_per_st <= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35;
break;
case ($fee_per_st > 4000 and $fee_per_st <= 5000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4;
break;
case ($fee_per_st > 5000 and $fee_per_st <= 6000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.45;
break;
case ($fee_per_st > 6000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.5;
break;
};
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
};
#地區處長獎金、專任契約經理、契約員獎金
switch ($payment_period_amount){
#簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金
#總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期,
case $payment_period_amount >= 60:
#地區處長獎金
array_push($bonus_array,[
"bonus_type" => "地區處長獎金", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "訂金收回後次月發放" #發放規定
]);
#專任契約經理獎金
array_push($bonus_array,[
"bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "訂金收回後次月發放" #發放規定
]);
#產生契約員每個月的獎金應發比例
$payment_ratio_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payment_ratio_due_array, 1/$payment_period_amount);
}
$payday_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payday_due_array, $i+1 );
}
for($i = 0; $i < count($payment_ratio_due_array); $i++) {
if($i < count($payment_ratio_due_array) - 1){
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
}else{
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array,[
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
}
$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, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"error", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
];
}
return $result_array;
};
?>

101
wms/bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_examination.php

@ -0,0 +1,101 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.1
契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
該作番所佔的服務費金額($commission_fee)
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) ; 契約折扣率=(簽約價格-服務費)/牌價
付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually)
第一筆保養款項應收回日($receivable_date_due, array)
契約員員工號($sales_id)
地區處長員工號($region_director_id)
專任契約經理員工號($regular_contract_manger_id)
【2.函數中的變數說明】
契約員獎金($sales_bonus)
地區處長獎金($region_director_bonus)
專任契約經理獎金($regular_contract_manger_bonus)
獎金預計發放比例($payment_ratio_due_array)
當次應發獎金($current_bonus)
獎金預計發放日($payday_due_array)
獎金預計發放規定($payday_due_regulation):合約簽回及保養款項收回的次月一次性發
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
pay_day_due:預計發放時間
bonus_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
require_once("maintenance_longterm_contract_m1_free_charge_bonus_v2_1.php");
#$ver, $contract_type, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id
#獎金測試
$examination_array = [
#錯誤版本
["1.0","longcontract_m1_free_charge",60,0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"],
#60期
["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費600元(折扣率0.8)
["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費1600元(折扣率0.8)
["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費2600元(折扣率0.8)
["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費3600元(折扣率0.8)
["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費4600元(折扣率0.8)
["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1200元(折扣率0.6)
["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2200元(折扣率0.6)
["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3200元(折扣率0.6)
["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4200元(折扣率0.6)
["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價7000元、服務費5200元(折扣率0.6)
["2.1","longcontract_m1_free_charge",60,3000,3000,600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價3000元、服務費1230元(折扣率0.59)
["2.1","longcontract_m1_free_charge",60,3000,4000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價4000元、服務費2230元(折扣率0.59)
["2.1","longcontract_m1_free_charge",60,3000,5000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價5000元、服務費3230元(折扣率0.59)
["2.1","longcontract_m1_free_charge",60,3000,6000,1600,"2014-07-01", "M0001", "M0002", "M0003"], #牌價3000、簽約價6000元、服務費4230元(折扣率0.59)
["2.1","longcontract_m1_free_charge",60,3000,7000,1600,"2014-07-01", "M0001", "M0002", "M0003"] #牌價3000、簽約價7000元、服務費5230元(折扣率0.59)
];
for($i = 0; $i<count($examination_array); $i++){
$result = maintenance_longterm_contract_m1_free_charge_bonus_v2_1(
$examination_array[$i][0],
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4],
$examination_array[$i][5],
$examination_array[$i][6],
$examination_array[$i][7],
$examination_array[$i][8],
$examination_array[$i][9]
);
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] . " "
. $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7]. " " . $examination_array[$i][8] . " "
. $examination_array[$i][9] . "<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]["pay_day_due"] . " "
. $result["bonus_array"][$j]["bonus_regulation"] . "<br>";
};
echo "-------------------------" . "<br>";
};
?>

62
wms/class/Cmail.php

@ -1,62 +0,0 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
class Cmail
{
public $charset = "";
public $host = "";
public $port = "";
public $smtp_user = "";
public $smtp_pwd = "";
function __construct($charset='', $fromemail='')
{
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";
$this->port = 25;
$this->smtp_user = "notice"; // 這裡填寫SMTP登入帳號, 例如 your.gmail.name@gmail.com 則填寫your.gmail.name
$this->smtp_pwd = "90493119"; // 這裡填寫SMTP登入密碼
}
function sendx($subject="", $em_body="", $sendlist=array(), $from="永佳捷科技", $bcc="", $files=array())
{
if (!$sendlist) return;
$em_body = nl2br($em_body);
$em_body .= "<p>※此信件為系統發出信件,請勿直接回覆。</p>";
$mail = new PHPMailer(true);
$mail->IsHTML(true); //設定是否使用HTML格式
$mail->CharSet = $this->charset;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = $this->host;
$mail->Port = $this->port;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //使用SSL, 如果是TLS 請改為 PHPMailer::ENCRYPTION_STARTTLS
$mail->Username = $this->smtp_user;
$mail->Password = $this->smtp_pwd;
$mail->SMTPSecure = "";
$mail->From = "notice@masada.com.tw";
$mail->FromName = $from;
$mail->Subject = $subject;
$mail->Body = $em_body;
foreach ($sendlist as $v) { // $sendlist[0]=['M0044', 'jrbin@masada.com.tw']
list($name, $email) = $v;
if ($email) $mail->addAddress($email, $name);
}
//$mail->addCC("personC@gmail.com", "person C");
//$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;
} else {
//echo "Email sent";
}
}
}

109
wms/class/Cnotice.php

@ -1,109 +0,0 @@
<?php
//ini_set('display_errors', 'on');
class Cnotice
{
function __construct()
{
}
function connectionDB()
{
$envFile = __DIR__ . '/../../.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
putenv("$key=$value");
}
}
}
date_default_timezone_set("Asia/Taipei");
$host = getenv('DB_HOST');
$dbport = getenv('DB_PORT');
$dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE');
try {
$options = [
PDO::ATTR_PERSISTENT => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
];
$pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options);
$pdo->exec('SET CHARACTER SET utf8mb4');
return $pdo;
} catch (PDOException $e) {
die("Something wrong: {$e->getMessage()}");
}
}
/**
* 結束資料庫連線
*/
function endConnectionDB($pdo)
{
unset($pdo);
}
/**
* 提交消息 notice
* @param string $kind : 類別 1=系統 2=會議
* @param int $related_id : 關聯序號
* @param string $title : 標題
* @param string $title : 內容
* @param string $permission : 瀏覽權限 員編/ALL=全體
* @param string $creater : 建立者
* @param string $create_at : 建立時間
*/
function sendx($data)
{
$kind = $data['kind'];
$related_id = $data['related_id'];
$title = $data['title'];
$content = $data['content'];
$permission = $data['permission'];
$creater = $data['creater'];
$create_at = $data['create_at'];
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$str = "
INSERT INTO `notice` (`kind`, `related_id`, `title`, `content`, `permission`, `creater`, `create_at`)
VALUES (?,?,?,?,?,?,?)
";
$sth = $pdo->prepare($str);
$sth->bindValue(1, $kind);
$sth->bindValue(2, $related_id);
$sth->bindValue(3, $title);
$sth->bindValue(4, $content);
$sth->bindValue(5, $permission);
$sth->bindValue(6, $creater);
$sth->bindValue(7, $create_at);
$sth->execute();
$this->endConnectionDB($pdo);
}
}
// $cn = new Cnotice();
// $data = array(
// 'kind' => 1,
// 'related_id' => 1,
// 'title' => "標題",
// 'content' => "內容",
// 'permission' => "M0117",
// 'creater' => "M0117",
// 'create_at' => date("Y-m-d H:i:s")
// );
// $cn->sendx($data);

BIN
wms/cont/.DS_Store

Binary file not shown.

648
wms/cont/MICalculator.php

@ -1,324 +1,324 @@
<?php <?php
require_once '../../workflow/lib/DB.php'; require_once '../../workflow/lib/DB.php';
class MICalculator class MICalculator
{ {
/** /**
* 計算MI * 計算MI
* *
* @param array $param * @param array $param
* @return void * @return void
*/ */
public function cal(array $param) public function cal(array $param)
{ {
$elevator_type = $param['elevator_type']; $elevator_type = $param['elevator_type'];
$func = $elevator_type . "_price"; $func = $elevator_type . "_price";
if (method_exists($this, $elevator_type . "_price")) { if (method_exists($this, $elevator_type . "_price")) {
return call_user_func([$this, $func], $param); return call_user_func([$this, $func], $param);
} }
return self::error(); return self::error();
} }
/** /**
* 客梯報價 maintain_kind='A' * 客梯報價 maintain_kind='A'
* 1.每月2次保養價格*1.25倍 * 1.每月2次保養價格*1.25倍
* 2.全包價格按半包價+1500元/臺 * 2.全包價格按半包價+1500元/臺
* 3.簽5年長約免費送M1係統的+2600元/臺" * 3.簽5年長約免費送M1係統的+2600元/臺"
* @return void * @return void
*/ */
public function A_price(array $item) public function A_price(array $item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_mi_option where from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['speed'] . " between min_speed and max_speed and " . $item['speed'] . " between min_speed and max_speed
and " . $item['persons'] . " between min_persons and max_persons and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
* 貨梯報價 * 貨梯報價
* *
* @return void * @return void
*/ */
public function B_price($item) public function B_price($item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_mi_option where from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
* 病床梯報價 * 病床梯報價
* *
* @return void * @return void
*/ */
public function C_price($item) public function C_price($item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_mi_option where from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
* 無機房報價 * 無機房報價
* *
* @return void * @return void
*/ */
public function D_price($item) public function D_price($item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_mi_option where from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
*家用梯報價 *家用梯報價
* *
* @return void * @return void
*/ */
public function E_price(array $item) public function E_price(array $item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_mi_option where from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_period= " . $item['maintain_period'] . " and maintain_period= " . $item['maintain_period'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
// echo $sql_get_price; // echo $sql_get_price;
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
public function error() public function error()
{ {
return [ return [
'status' => 'fail', 'status' => 'fail',
'message' => '無此項目,請聯係業務部創建MI' 'message' => '無此項目,請聯係業務部創建MI'
]; ];
} }
public function success($price) public function success($price)
{ {
return [ return [
'status' => 'ok', 'status' => 'ok',
'price' => $price 'price' => $price
]; ];
} }
} }

644
wms/cont/MSCalculator.php

@ -1,322 +1,322 @@
<?php <?php
require_once '../../workflow/lib/DB.php'; require_once '../../workflow/lib/DB.php';
class MSCalculator class MSCalculator
{ {
/** /**
* 計算报价 * 計算报价
* *
* @param array $param * @param array $param
* @return void * @return void
*/ */
public function cal(array $param) public function cal(array $param)
{ {
$elevator_type = $param['elevator_type']; $elevator_type = $param['elevator_type'];
$func = $elevator_type . "_price"; $func = $elevator_type . "_price";
if (method_exists($this, $elevator_type . "_price")) { if (method_exists($this, $elevator_type . "_price")) {
return call_user_func([$this, $func], $param); return call_user_func([$this, $func], $param);
} }
return self::error(); return self::error();
} }
/** /**
* 客梯成本maintain_kind='A' * 客梯成本maintain_kind='A'
* 1.每月2次保養價格*1.25倍 * 1.每月2次保養價格*1.25倍
* 2.全包價格按半包價+1500元/臺 * 2.全包價格按半包價+1500元/臺
* 3.簽5年長約免費送M1係統的+2600元/臺" * 3.簽5年長約免費送M1係統的+2600元/臺"
* @return void * @return void
*/ */
public function A_price(array $item) public function A_price(array $item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
SELECT select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_standard_option where from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['speed'] . " between min_speed and max_speed and " . $item['speed'] . " between min_speed and max_speed
and " . $item['persons'] . " between min_persons and max_persons and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
* 貨梯成本 * 貨梯成本
* *
* @return void * @return void
*/ */
public function B_price($item) public function B_price($item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_standard_option where from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
* 病床梯成本 * 病床梯成本
* *
* @return void * @return void
*/ */
public function C_price($item) public function C_price($item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_standard_option where from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
* 無機房成本 * 無機房成本
* *
* @return void * @return void
*/ */
public function D_price($item) public function D_price($item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_standard_option where from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . " and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
/** /**
*家用梯成本 *家用梯成本
* *
* @return void * @return void
*/ */
public function E_price(array $item) public function E_price(array $item)
{ {
$floors = $item['floors']; $floors = $item['floors'];
$maintain_times = $item['maintain_times']; $maintain_times = $item['maintain_times'];
$sql_get_price = " $sql_get_price = "
select select
elevator_type, elevator_type,
base_price, base_price,
floors_price, floors_price,
min_floors, min_floors,
min_maintain_times, min_maintain_times,
maintain_months, maintain_months,
maintain_kind, maintain_kind,
maintain_period, maintain_period,
is_m1_bundle, is_m1_bundle,
all_inclusive_fee, all_inclusive_fee,
maintenance_fee_coefficient, maintenance_fee_coefficient,
m1_bundle_fee m1_bundle_fee
from maintain_standard_option where from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "' elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_period= " . $item['maintain_period'] . " and maintain_period= " . $item['maintain_period'] . "
and maintain_kind='" . $item['maintain_kind'] . "' and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "' and is_m1_bundle='" . $item['is_m1_bundle'] . "'
"; ";
list($row) = DB::result($sql_get_price); list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error(); if (empty($row)) return self::error();
#1基礎價格 #1基礎價格
$floors = $item['floors'] - $row['min_floors']; $floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; $price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1; // echo $price1;
#判斷是否全包 #判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; $price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2; // echo $price2;
#判斷是否五年M1套餐 #判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; $price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3; // echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times #判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3; $price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; $price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
} }
return self::success($price4); return self::success($price4);
} }
public function error() public function error()
{ {
return [ return [
'status' => 'fail', 'status' => 'fail',
'message' => '無此項目,請聯係業務部創建標準成本' 'message' => '無此項目,請聯係業務部創建標準成本'
]; ];
} }
public function success($price) public function success($price)
{ {
return [ return [
'status' => 'ok', 'status' => 'ok',
'price' => $price 'price' => $price
]; ];
} }
} }

1716
wms/cont/apply_form.php

File diff suppressed because it is too large

1787
wms/cont/apply_form1.php → wms/cont/apply_form2.php

File diff suppressed because it is too large

42
wms/cont/conn.php

@ -1,42 +0,0 @@
<?php
$envFile = __DIR__ . '/.env'; // .env 文件的路径
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
// 设置环境变量
putenv("$key=$value");
}
}
}
$db_hostname = getenv('DB_HOST'); //資料庫主機名稱
$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號
$db_password = getenv('DB_PASSWORD'); //登入密碼
$db_name = getenv('DB_DATABASE'); //使用的資料庫
$db_charset = 'utf8'; //設定字元編碼
//建立PDO的指定工作
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset";
try {
//使用PDO連接到MySQL資料庫,建立PDO物件
$conn = new PDO($dsn, $db_username, $db_password);
//當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException)
//PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定
//PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊
//PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。
//設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//如果連接錯誤,將抛出一個PDOException異常對象
} catch (PDOException $e) {
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作
die("ERROR!!!: " . $e->getMessage());
}
//$conn = null; //關閉資料庫的連線

1020
wms/cont/query_form.php

File diff suppressed because it is too large

1152
wms/cont/sign_form.php

File diff suppressed because it is too large

157
wms/cont/submit.php

@ -1,79 +1,78 @@
<?php <?php
//require_once "../database.php"; //require_once "../database.php";
require_once './wf_common.php'; require_once './wf_common.php';
require_once './model/ConMaintanceExamineApplyModel.php'; require_once './model/ConMaintanceExamineApplyModel.php';
require_once './model/ConMaintanceExamineClearModel.php'; require_once './model/ConMaintanceExamineClearModel.php';
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST; //print_r($_POST);exit;
// print_r($request); $request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
// exit; $tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交
$tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交
if ($request["form_src"] == "apply_form" && $tosign && (!isset($request["register_code"]) || empty($request["register_code"][0]) || !isset($request["next_users"]) || empty($request["next_users"]))) {
if ($request["form_src"] == "apply_form" && $tosign && (!isset($request["register_code"]) || empty($request["register_code"][0]) || !isset($request["next_users"]) || empty($request["next_users"]))) { echo "<script type = 'text/JavaScript'>";
echo "<script type = 'text/JavaScript'>"; echo "alert('請確認電梯資料或未選擇下位簽核者!');";
echo "alert('請確認電梯資料或未選擇下位簽核者!');"; echo "history.go(-1);";
echo "history.go(-1);"; echo "</script>";
echo "</script>"; exit;
exit; }
}
//更新表单ConMaintanceExamineApplyModel
//更新表单ConMaintanceExamineApplyModel $cmea = new ConMaintanceExamineApplyModel();
$cmea = new ConMaintanceExamineApplyModel(); $apply_key=$request['apply_key'];
$apply_key = $request['apply_key']; $cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => '']));
$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => ''])); //更新电梯列表
//更新电梯列表 if (!empty($request["reg_del"])) {
if (!empty($request["reg_del"])) { $register_code_del_arr = explode(",", rtrim($request["reg_del"], ","));
$register_code_del_arr = explode(",", rtrim($request["reg_del"], ",")); foreach ($register_code_del_arr as $val) {
foreach ($register_code_del_arr as $val) { $sql = "update con_maintance_examine_clear set cmstatus = 'D' where apply_key = '$apply_key' and register_code = '$val' and cmstatus <> 'D'";
$sql = "UPDATE con_maintance_examine_clear SET cmstatus = 'D' WHERE apply_key = '$apply_key' AND register_code = '$val' AND cmstatus <> 'D'"; DB::query($sql);
DB::query($sql); }
} }
} if (!empty($request['register_code']) && count($request['register_code']) > 0) {
if (!empty($request['register_code']) && count($request['register_code']) > 0) { $cmec = new ConMaintanceExamineClearModel();
$cmec = new ConMaintanceExamineClearModel(); for ($i = 0; $i < count($request['register_code']); $i++) {
for ($i = 0; $i < count($request['register_code']); $i++) { $data = [
$data = [ 'apply_key' => $request['apply_key']
'apply_key' => $request['apply_key'] ];
]; $cols = array_diff($cmec->fillable, ['apply_key']);
$cols = array_diff($cmec->fillable, ['apply_key']); foreach ($cols as $col) {
foreach ($cols as $col) { $data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i];
$data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i]; if ($col=="annual_survey_expense") $data[$col] = '0.00';
if ($col == "annual_survey_expense") $data[$col] = '0.00'; }
} $cmec->create($data);
$cmec->create($data); }
} }
}
//var_dump($_POST);
//var_dump($_POST); //var_dump($_GET);
//var_dump($_GET);
if ($tosign) {
if ($tosign) { #流程开始,var_dump($request);
#流程开始,var_dump($request); $flow = new Flow($request['form_key']);
$flow = new Flow($request['form_key']); // 当前节点签核开始
// 当前节点签核开始 $wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']);
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']); $wf->setFormData($request);
$wf->setFormData($request); $wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']);
$wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']); //当前节点签核结束
//当前节点签核结束 $responses['flowName'] = $wf->getFlowName();
$responses['flowName'] = $wf->getFlowName(); $responses['form_key'] = $request['form_key'];
$responses['form_key'] = $request['form_key']; //var_dump($request);
//var_dump($request); #結案發通知給營業員
#結案發通知給營業員 if ($request['assign_status'] == 'F4') {
if ($request['assign_status'] == 'F4') {
list($salesman, $case_name ) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key. "' ");
list($salesman, $case_name) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key . "' "); $ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`)
$ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`) VALUES ( '1', '契約價審單結案通知(" .$case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')";
VALUES ( '1', '契約價審單結案通知(" . $case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')"; DB::query($ins_notice_sql);
DB::query($ins_notice_sql); // echo $ins_notice_sql;
// echo $ins_notice_sql; }
} }
} echo "<script type = 'text/JavaScript'>";
echo "<script type = 'text/JavaScript'>"; //echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>";
//echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>"; if ($tosign) {
if ($tosign) { echo "alert('成功提交');";
echo "alert('成功提交');"; echo "location.href='../cont/sign_list.php?function_name=sign_list&token=".$request['token']."';";
echo "location.href='../wms/index.php.php?function_name=sign_list&token=" . $request['token'] . "';"; } else {
} else { echo "alert('資料已保存');";
echo "alert('資料已保存');"; echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=".$request['token']."';";
echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=" . $request['token'] . "';"; }
} echo "</script>";
echo "</script>";

168
wms/cont/t.php

@ -1,84 +1,84 @@
<?php <?php
error_reporting(E_ALL); error_reporting(E_ALL);
ini_set('dispaly_errors', "On"); ini_set('dispaly_errors', "On");
require_once './MSCalculator.php'; require_once './MSCalculator.php';
//客梯 //客梯
$param = [ $param = [
'elevator_type' => 'A', 'elevator_type' => 'A',
'floors' => 7, 'floors' => 7,
'speed' => 1, 'speed' => 1,
'persons' => 6, 'persons' => 6,
'weight' => 1000, 'weight' => 1000,
'maintain_times' => 1, 'maintain_times' => 1,
'maintain_months' => 12, 'maintain_months' => 12,
'maintain_kind' => 2, 'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N', 'is_m1_bundle' => 'N',
]; ];
//货梯 //货梯
$param = [ $param = [
'elevator_type' => 'B', 'elevator_type' => 'B',
'floors' => 7, 'floors' => 7,
'speed' => 1, 'speed' => 1,
'persons' => 6, 'persons' => 6,
'weight' => 1000, 'weight' => 1000,
'maintain_times' => 1, 'maintain_times' => 1,
'maintain_months' => 12, 'maintain_months' => 12,
'maintain_kind' => 2, 'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N', 'is_m1_bundle' => 'N',
]; ];
//病床梯 //病床梯
$param = [ $param = [
'elevator_type' => 'C', 'elevator_type' => 'C',
'floors' => 28, 'floors' => 28,
'speed' => 1, 'speed' => 1,
'persons' => 6, 'persons' => 6,
'weight' => 1000, 'weight' => 1000,
'maintain_times' => 2, //病床梯一月2次保养 'maintain_times' => 2, //病床梯一月2次保养
'maintain_months' => 12, 'maintain_months' => 12,
'maintain_kind' => 2, 'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N', 'is_m1_bundle' => 'N',
]; ];
//无机房 //无机房
$param = [ $param = [
'elevator_type' => 'D', 'elevator_type' => 'D',
'floors' => 3, 'floors' => 3,
'speed' => 1, 'speed' => 1,
'persons' => 6, 'persons' => 6,
'weight' => 1000, 'weight' => 1000,
'maintain_times' => 1, //病床梯一月2次保养 'maintain_times' => 1, //病床梯一月2次保养
'maintain_months' => 12, 'maintain_months' => 12,
'maintain_kind' => 3, 'maintain_kind' => 3,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N', 'is_m1_bundle' => 'N',
]; ];
//家用梯 //家用梯
$param = [ $param = [
'elevator_type' => 'E', 'elevator_type' => 'E',
'floors' => 3, 'floors' => 3,
'speed' => 1, 'speed' => 1,
'persons' => 6, 'persons' => 6,
'weight' => 1000, 'weight' => 1000,
'maintain_times' => 1, //病床梯一月2次保养 'maintain_times' => 1, //病床梯一月2次保养
'maintain_months' => 60, 'maintain_months' => 60,
'maintain_kind' => 2, 'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'Y', 'is_m1_bundle' => 'Y',
]; ];
$mic = new MSCalculator(); $mic = new MSCalculator();
$price = $mic->cal($_GET); $price = $mic->cal($_GET);
echo json_encode($price); echo json_encode($price);

13
wms/contract-repair/api/getContractData.php

@ -120,3 +120,16 @@ if (isset($_GET['repair_no']) && $_GET['repair_no'] != '' && isset($_GET['contra
die("ERROR!!:" . $e->getMessage()); die("ERROR!!:" . $e->getMessage());
} }
} }
if (isset($_GET['contract_no']) && $_GET['contract_no'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 't') {
$contract_no = $_GET['contract_no'];
try {
$sql = "SELECT * FROM pricereview_main AS a
LEFT JOIN pricereview_pay as b ON a.id = b.mid
WHERE a.kind='汰改' AND a.contract_no = :contract_no AND a.status='YY'
";
header('Content-Type: application/json');
} catch (PDOException $e) {
die("ERROR!!!: " . $e->getMessage());
}
}

7
wms/contract-repair/api/postContractData.php

@ -377,7 +377,9 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c
sign_date, sign_date,
contract_status, contract_status,
create_user, create_user,
create_date) VALUES( create_date,
delete_status)
VALUES(
:repair_no, :repair_no,
:contractno, :contractno,
:company, :company,
@ -391,7 +393,8 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c
:sign_date, :sign_date,
:contract_status, :contract_status,
:create_userid, :create_userid,
:create_date :create_date,
1
)"; )";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->bindParam(":repair_no", $repair_no); $stmt->bindParam(":repair_no", $repair_no);

263
wms/contract-repair/contract-renovate-input.php

@ -0,0 +1,263 @@
<?php
include('../header.php');
require_once('./conn.php');
$sql = "SELECT * FROM employee WHERE depart_no IN ('320','311','312','313','314','315','511','512','513','514','515') ";
$stmt = $conn->prepare($sql);
// $stmt->bindParam(':depart_no', $depart_no);
$stmt->execute();
$contractSalesman = $stmt->fetchAll(PDO::FETCH_ASSOC);
// echo '<pre>';
// print_r($contractSalesman);
// echo '</pre>';
?>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="./semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="./js/alpine.js"></script>
<script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script>
<script src="./js/jquery/jquery-3.1.1.min.js"></script>
<script src="./semantic/dist/semantic.min.js"></script>
<div class="renovate_input" x-data="renovateInput">
<div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name="form_name" value="main_form">
<div>
<table class="table table-borderd query-table table-striped table-bordered display compact" style="width:99%; margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style="text-align:center">汰改合約入力</h3>
</td>
</tr>
</thead>
<template x-if="step==1">
<tbody style="font-weight:bolder; margin:botton 20px">
<tr>
<td style="vertical-align:middle;">合約號</td>
<td colspan="6">
<input type="text" class="form-control" @keyup="nextStepKeyupFn($event)" name="contract_no" x-model="data.contract_no">
</td>
<td colspan="1" style="vertical-align:middle"></td>
</tr>
</tbody>
</template>
<template x-if="step==1">
<tbody style="font-weight:bolder; margin:botton 20px" x-show="step==1">
<tr>
<td colspan="7" style="vertical-align:middle;border-right:0px;">
<h4>業務確認項</h4>
</td>
<td class="text-right" style="border-left:0px">
<button type="button" id="btn_back" class="btn btn-default" onclick="location.reload()">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button>
</td>
</tr>
<tr>
<td style="vertical-align:middle">立約人</td>
<td>
<input type="text" x-model="data.customer">
</td>
<td style="vertical-align:middle">營業員</td>
<td>
<!-- <input x-show="data.salesman" type="text" x-model="data.salesman" name="promiser"> -->
<select x-model="data.salesman" class="ui fluid search dropdown" name="salesman">
<option value="">------</option>
<?php foreach ($contractSalesman as $salesman) : ?>
<option value="<?= $salesman['employee_no'] ?>"><?= $salesman['name'] ?></option>
<?php endforeach; ?>
</select>
</td>
<td style="vertical-align:middle">地址</td>
<td>
<input type="text" x-model="data.address">
</td>
<td></td>
</tr>
<!-- 客戶款別分別如何分期 -->
<div>
<tr>
<td colspan='8' style="vertical-align:middle ">款別分期</td>
</tr>
<tr>
<td colspan='1'>付款辦法</td>
<td colspan='1'>款別</td>
<td colspan='1'>比例%</td>
<td colspan='2'>金額</td>
<td colspan='1'>繳款方式(月)</td>
</tr>
<tr>
<td rowspan="4">材料</td>
<td>1、訂金</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[0] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option x-text="pay"></option>
</template>
</select>
</td>
</tr>
<tr>
<td>2、二次款</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[1] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option x-text="pay"></option>
</template>
</select>
</td>
</tr>
<tr>
<td>3、貨到工地款</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[2] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option x-text="pay"></option>
</template>
</select>
</td>
</tr>
<!-- <tr>
<td>4、其他</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[3] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option x-text="pay"></option>
</template>
</select>
</td>
</tr> -->
<tr>
<td rowspan="3">安裝</td>
<td>5、安裝完畢款</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[4] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option x-text="pay"></option>
</template>
</select>
</td>
</tr>
<tr>
<td>6、驗收款</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[5] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option x-text="pay"></option>
</template>
</select>
</td>
</tr>
<tr>
<td>7、其他</td>
<td>
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td>
<select x-model=data.paykind[6] @change="totalFn()">
<template x-for="pay in data.payarr" :key="pay">
<!-- <option value=""></option> -->
<option :value="pay" x-text="pay"></option>
</template>
</select>
</td>
</tr>
<tr>
<td colspan="2">合計</td>
<td>
<input type="text" disabled>
</td>
<td colspan="2">
<input type="text" disabled>
</td>
<td>
<input type="text" x-model="data.total" disabled>
</td>
</tr>
</div>
</tbody>
</template>
</table>
<button x-show="step==3" @click="save()" type="button" class="btn btn-primary btn-lg pull-right savebutton" :disabled="isLoading">
<template x-if="!isLoading">
<span>存檔</span>
</template>
<template x-if="isLoading">
<span class="loader"></span>
</template>
</button>
<button x-show="step<2" @click="nextStepFn()" class="btn btn-primary btn-lg pull-right savebutton" :disabled="isLoading">
<template x-if="!isLoading">
<span>下一步</span>
</template>
<template x-if="isLoading">
<span class="loader"></span>
</template>
</button>
<button x-show="step>1" @click="preStepFn()" class="btn btn-primary btn-lg pull-right savebutton" :disabled="isLoading">
<template x-if="!isLoading">
<span>上一步</span>
</template>
<template x-if="isLoading">
<span class="loaders"></span>
</template>
</button>
</div>
</div>
</div>

6
wms/contract-repair/contract-repair-input.php

@ -14,6 +14,7 @@ $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype', $accounttype); $stmt->bindParam(':accounttype', $accounttype);
$stmt->execute(); $stmt->execute();
$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
$persons = array_map(function ($person) { $persons = array_map(function ($person) {
return [ return [
'view' => $person['accountid'] . '-' . $person['name'], 'view' => $person['accountid'] . '-' . $person['name'],
@ -21,6 +22,9 @@ $persons = array_map(function ($person) {
'name' => $person['name'] 'name' => $person['name']
]; ];
}, $contractpersons); }, $contractpersons);
// echo '<pre>';
// print_r($persons);
// echo '</pre>';
$contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"]; $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"];
?> ?>
@ -81,7 +85,7 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修
<td style="vertical-align: middle">維保人員</td> <td style="vertical-align: middle">維保人員</td>
<td style="vertical-align: middle"> <td style="vertical-align: middle">
<select class="repaireid" id="repaireid" x-model="data.repairerid"> <select class="repaireid" id="repaireid" x-model="data.repairerid">
<option value="<?php echo $contract['repaireid'] ?>"><?php echo $contract['repairerid'] . '-' . $contract['name'] ?></option> <option value=""><?php echo $contractpersons['accontid'] . '-' . $contractpersons['name'] ?></option>
<?php foreach ($persons as $person) : ?> <?php foreach ($persons as $person) : ?>
<option value="<?php echo $person['value']; ?>"><?php echo $person['view']; ?></option> <option value="<?php echo $person['value']; ?>"><?php echo $person['view']; ?></option>
<?php endforeach ?> <?php endforeach ?>

2
wms/contract-repair/contract-repair-management.php

@ -64,7 +64,7 @@ $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '修理完成'; echo '修理完成';
} }
?></th> ?></th>
<td><?php echo $contract['create_userid'] ?></td> <td><?php echo $contract['create_user'] ?></td>
<td><?php echo $contract['create_date'] ?></td> <td><?php echo $contract['create_date'] ?></td>
<td style="width:30px"> <td style="width:30px">
<p> <p>

289
wms/contract-repair/js/alpine.js

@ -320,7 +320,7 @@ const contractRepair = () => {
repair_no: '', repair_no: '',
total_price: '', total_price: '',
sign_date: '', sign_date: '',
contract_status: '' contract_status: '',
}, },
step: 1, step: 1,
isLoading: false, isLoading: false,
@ -874,16 +874,34 @@ const contract_edit = () => {
} }
const bonsIndex = () => { const bonunsIndex = () => {
return { return {
data: { data: {
contract_no: 'Q23080067', contract_no: contract_no,
client_type: '', facility_no: facility_no,
facility_no: '', bonus_verson: bonus_verson,
bons_verson: '', receiver: receiver,
receiver: '',
maintain_month: '', maintain_month: '',
maintain_price_toal: '' maintain_price_total: maintain_price_total,
payDaydue: payDaydue,
bonusArr: [],
contract_type: contract_type,
manager: '',
bonus_type: '',
bouns_receiver: '',
bouns_amount: '',
payDay: '',
bouns_regulation: '',
contract_manger: 'M0001',
user_id: user_id,
maintain_type: maintain_type,
pay_kind: pay_kind,
receivable_date_due: receivable_date_due,
total: total,
fee_per_st: fee_per_st,
commission_fee: commission_fee,
discount: discount
}, },
step: 1, step: 1,
isLoading: false, isLoading: false,
@ -921,29 +939,203 @@ const bonsIndex = () => {
if (!this.customize) { if (!this.customize) {
this.data.contract_no = res.data.BillNo; this.data.contract_no = res.data.BillNo;
this.data.facility_no = res.data.facility; this.data.facility_no = res.data.facility;
this.data.bons_verson = res.data.bons_verson; this.data.bonus_verson = res.data.bonuns_verson;
this.data.receiver = res.data.personId; this.data.receiver = res.data.personId;
this.data.maintain_price_toal = res.data.amount; this.data.maintain_price_total = res.data.amount;
this.data.bons_verson = 2; // this.data.bonuns_verson = 2;
this.data.maintain_month = res.data.maintain_month; this.data.maintain_month = res.data.maintain_month;
} this.data.payDay = res.data.payDay;
axios.get('./api/getAccount.php?accountid=' + res.data.personId).then(res => {
this.data.manager = res.data.manager;
}).catch(err => {
console.log(err);
})
};
this.step = 2; this.step = 2;
this.isLoading = false; this.isLoading = false;
}).catch(err => { }).catch(err => {
errorFn();
}) })
// axios.get('./api/getAccount.php?accountid=' + this.data.receiver).then(res => {
// console.log(res);
// this.data.manager = res.result.manager;
// }).catch(err => {
// console.log(err);
// })
},
save() {
if (this.step == 1) {
window.history.back();
}
},
calBons() {
console.log(this.step);
const form = new FormData();
form.append('cotract_no', this.data.contract_no);
form.append('bonuns_verson', this.data.bonus_verson);
form.append('contract_type', this.data.contract_type);
form.append('maintain_month', this.data.maintain_month);
form.append('maintain_price_total', this.data.maintain_price_total);
form.append('payDay', this.data.payDay);
form.append('receiver', this.data.receiver);
form.append('manager', this.data.manager);
axios.post('./api/postCalBouns.php', form).then(res => {
// console.log(res);
this.data.bonusArr = res.data.bonus_array;
console.log(this.data.bonusArr);
this.step = 3;
this.isLoading = false;
}).catch(err => {
console.log(err.response.data);
alert(err.response.data);
this.step = 2;
})
},
errorFn() {
let msg = '';
for (let i = 0; i < this.fail_arr.length; i++) {
msg += this.fail_arr[i] + '、';
}
alert(msg);
}, },
preStepFn() {
this.step = 1
if (this.step == 2) {
}
}
const bonunsIndexTest = () => {
return {
data: {
bonus_verson: '2.1',
receiver: 'M0225',
maintain_month: '12',
client_type: '',
maintain_price_month: '3000',
maintain_price_total: '3000',
commission_fee: '0',
bonusArr: [],
manager: 'M0008',
bonus_type: '',
bouns_receiver: '',
bouns_amount: '',
payDay: '20240101',
bouns_regulation: '',
contract_manger: 'M0001',
paykindArr: ['請選擇月份', 1, 2, 3, 6, 12],
paykind: '',
checkbox: '',
},
checkbox: 0,
step: 1,
isLoading: false,
fail_arr: [],
test() {
console.log(this.data.paykind);
},
nextStepFn() {
if (this.step == 1) {
this.checkbox = Number(this.data.checkbox);
this.step = 2;
} else if (this.step == 2) {
this.isLoading = true;
this.calBons();
} }
// this.step = 3;
console.log(this.step);
console.log(this.checkbox);
},
nextStepKeyupFn(e) {
if (e.keyCode !== 13) return;
if (this.step == 1) {
this.step = 2;
} else if (this.step == 2) {
this.step = 3;
}
},
getContractData() {
axios.get('./api/get.php?contract_no=' + this.data.contract_no).then(res => {
if (!res.data) {
this.step = 2;
this.isLoading = false;
return;
}
if (!this.customize) {
this.data.contract_no = res.data.BillNo;
this.data.facility_no = res.data.facility;
this.data.bonus_verson = res.data.bonuns_verson;
this.data.receiver = res.data.personId;
this.data.maintain_price_total = res.data.amount;
// this.data.bonuns_verson = 2;
this.data.maintain_month = res.data.maintain_month;
this.data.payDay = res.data.payDay;
axios.get('./api/getAccount.php?accountid=' + res.data.personId).then(res => {
this.data.manager = res.data.manager;
}).catch(err => {
console.log(err);
})
};
this.step = 2;
this.isLoading = false;
}).catch(err => {
errorFn();
})
// axios.get('./api/getAccount.php?accountid=' + this.data.receiver).then(res => {
// console.log(res);
// this.data.manager = res.result.manager;
// }).catch(err => {
// console.log(err);
// })
}, },
save() { save() {
if (this.step == 3) {
const form = new FormData();
form.append('status', 'save');
form.append('checkbox', this.data.checkbox);
form.append('bonuns_verson', this.data.bonus_verson);
form.append('contract_type', this.data.contract_type);
form.append('maintain_month', this.data.maintain_month);
form.append('maintain_price_total', this.data.maintain_price_total);
form.append('payDay', this.data.payDay);
form.append('receiver', this.data.receiver);
form.append('manager', this.data.manager);
form.append('paykind', this.data.paykind);
form.append('contract_manger', this.data.contract_manger);
form.append('maintain_price_month', this.data.maintain_price_month);
form.append('commission_fee', this.data.commission_fee);
form.append('client_type', this.data.client_type);
axios.post('./api/postCalBouns.php', form).then(res => {
console.log(res.data);
}).catch(err => {
console.log(err.response.data);
})
}
}, },
calBons() { calBons() {
console.log('123'); const form = new FormData();
form.append('checkbox', this.data.checkbox);
form.append('bonuns_verson', this.data.bonus_verson);
form.append('contract_type', this.data.contract_type);
form.append('maintain_month', this.data.maintain_month);
form.append('maintain_price_total', this.data.maintain_price_total);
form.append('payDay', this.data.payDay);
form.append('receiver', this.data.receiver);
form.append('manager', this.data.manager);
form.append('paykind', this.data.paykind);
form.append('contract_manger', this.data.contract_manger);
form.append('maintain_price_month', this.data.maintain_price_month);
form.append('commission_fee', this.data.commission_fee);
form.append('client_type', this.data.client_type);
axios.post('./api/postCalBouns.php', form).then(res => {
// console.log(res);
this.data.bonusArr = res.data.bonus_array;
console.log(this.data.bonusArr);
this.step = 3;
this.isLoading = false;
}).catch(err => {
console.log(err.response.data);
alert(err.response.data);
this.step = 1;
})
}, },
errorFn() { errorFn() {
let msg = ''; let msg = '';
@ -953,5 +1145,66 @@ const bonsIndex = () => {
alert(msg); alert(msg);
}, },
}
}
const renovateInput = () => {
return {
data: {
contract_no: '',
customer: '',
salesman: '',
address: '',
paykind: [0, 0, 0, 0, 0, 0, 0],
payarr: ['', 1, 2, 6, 12],
total: '',
// paykindTotal: this.total(),
},
step: 1,
isLoading: false,
nextStepFn() {
if (this.step == 1) {
if (this.data.contract_no == '') return alert('請輸入合約號');
this.isLoading = true;
this.getContractData();
} else if (this.step == 2) {
console.log('1111');
}
// this.step = 3;
},
// 計算總共分期月數
totalFn() {
let total = 0
for (let i = 0; i < this.data.paykind.length; i++) {
if (this.data.paykind[i] != '0') {
total += Number(this.data.paykind[i]);
}
}
// console.log(123);
this.data.total = total;
},
nextStepKeyupFn() {
},
preStepFn() {
this.step -= 1;
console.log(this.step);
},
getContractData() {
axios.get('../api/getContractData.php?contracttype=t&contract_no=' + this.data.contract_no, (res) => {
})
},
save() {
},
getContractData() {
this.step = 2;
this.isLoading = false;
console.log(this.step);
}
} }
} }

20
wms/contract/api/testT8API.php

@ -1,19 +1,21 @@
<?php <?php
$date = Date('Y-m-d'); $date = Date('Y-m-d');
$date1 = Date('Y-m-d', strtotime("$date +1 months")); $date1 = Date('Y-m-d', strtotime("$date +1 months"));
// $paymonth = $i * $SQuantity;
// $countDay = date('Y-m-d', strtotime("$date + $paymonth months"));
// $payDay = str_replace('-', '', $countDay);
// $countDay = date('Ymd', strtotime("$date1 + 1 months")); // $countDay = date('Ymd', strtotime("$date1 + 1 months"));
// echo '<pre>'; // echo '<pre>';
// print_r($countDay); // print_r($countDay);
// echo '</pre>'; // echo '</pre>';
// exit(); // exit();
$a = 0; $SQuantity = 2;
// $b = 24 / $a; // $b = 24 / $a;
for ($i = 0; $i < 2; $i++) { for ($i = 0; $i < 12; $i++) {
for ($j = 0; $j < 12; $j++) { $paymonth = $i * $SQuantity;
$a++; $countDay = date('Y-m-d', strtotime("$date + $paymonth months"));
echo '<pre>'; $payDay = str_replace('-', '', $countDay);
print_r($a); echo '<pre>';
echo '</pre>'; print_r($payDay);
} echo '</pre>';
} }

5
wms/contract/conn.php

@ -33,6 +33,11 @@ try {
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。
//設定主動以警告的形式報錯 //設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8masada", "M0225", "IFFBU1E=");
if ($connT8) {
$connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
//如果連接錯誤,將抛出一個PDOException異常對象 //如果連接錯誤,將抛出一個PDOException異常對象
} catch (PDOException $e) { } catch (PDOException $e) {
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作

2
wms/contract/connt8.php

@ -4,7 +4,7 @@ include "/Users/LO_2342/Desktop/httpdocs/wms/fun_global.php";
// phpinfo(); // phpinfo();
// exit(); // exit();
try { try {
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8masada", "M0225", "IFFBU1E="); $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8test", "M0225", "IFFBU1E=");
if ($connT8) { if ($connT8) {
$connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} }

6
wms/contract/contract-new-apply.php

@ -708,9 +708,9 @@ $para = "function_name=pricereview&" . $token_link;
<script> <script>
const donwloadDraft = () => { const donwloadDraft = () => {
if('<?php echo $status ?>' >=0 ){ if ('<?php echo $status ?>' >= 0) {
window.location.href='./contract-download.php?id=<?php echo $id . '&' . $para ?>' window.location.href = './contract-download.php?id=<?php echo $id . '&' . $para ?>'
}else{ } else {
alert("請先暫存或送審文件!") alert("請先暫存或送審文件!")
} }
} }

BIN
wms/contract/option/option2.xlsx

Binary file not shown.

2
wms/crm/crmm06_submit.php

@ -17,4 +17,4 @@ foreach ($cols as $col) {
$hecm->create($data); $hecm->create($data);
echo "<script>alert('已保存');</script>"; echo "<script>alert('已保存');</script>";
header("Location:" . "https://www.masada.com.tw/wms/crm/crmm02-index.php?token=" . $request['token']); header("Location:" . "localhost/wms/crm/crmm02-index.php?token=" . $request['token']);

6
wms/excel/import.php

@ -1,5 +1,6 @@
<?php <?php
require 'vendor/autoload.php'; require 'vendor/autoload.php';
namespace PhpOffice\PhpSpreadsheet; namespace PhpOffice\PhpSpreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\IReader; use PhpOffice\PhpSpreadsheet\Reader\IReader;
@ -30,7 +31,7 @@ abstract class IOFactory
public const WRITER_CSV = 'Csv'; public const WRITER_CSV = 'Csv';
public const WRITER_HTML = 'Html'; public const WRITER_HTML = 'Html';
/** @var string[] */ /** @var string[] */
private static $readers = [ private static $readers = [
self::READER_XLSX => Reader\Xlsx::class, self::READER_XLSX => Reader\Xlsx::class,
self::READER_XLS => Reader\Xls::class, self::READER_XLS => Reader\Xls::class,
@ -54,6 +55,7 @@ abstract class IOFactory
return new $className(); return new $className();
} }
}
$object = new IOFactory(); $object = new IOFactory();
$spreadsheet = $object::createReader('Xlsx')->load('1.xlsx'); $spreadsheet = $object::createReader('Xlsx')->load('1.xlsx');
echo "success"; echo "success";

1
wms/frame/api_getdata.php

@ -22,7 +22,6 @@
*/ */
$json = array("st" => "ok", "err" => "", "errCode" => ""); $json = array("st" => "ok", "err" => "", "errCode" => "");
echo '123';
/** /**
* 表單列表 * 表單列表
*/ */

62
wms/fun_global.php

@ -14,6 +14,9 @@ function sql_myself($user_id, $column = "creater")
global $link; global $link;
$follower_arr = []; // 下屬列表 $follower_arr = []; // 下屬列表
if($user_id == 'M0105'){
$user_id = "M0137";
}
$sql_cmd = "where ($column = '$user_id'"; $sql_cmd = "where ($column = '$user_id'";
$follower_arr = find_follow($user_id); $follower_arr = find_follow($user_id);
if (count($follower_arr) > 0) { if (count($follower_arr) > 0) {
@ -99,36 +102,37 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0)
return $ret; return $ret;
exit; exit;
} else { } else {
// 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。 // // 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。
if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) { // if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) {
$ret[1] = $user_id . ",,"; // $ret[1] = $user_id . ",,";
// $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理 // $ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) { // if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理 // $ret[4] = "M0006,,"; // 總經理
} // }
return $ret; // return $ret;
exit; // exit;
} // }
if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") { // if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") {
// 新梯的部分 桃竹本該給陳家文,改為劉永德 // // 新梯的部分 桃竹本該給陳家文,改為劉永德
if ($row["manager"] == 'M0029') { // if ($row["manager"] == 'M0029') {
$ret[1] = "M0137,,"; // $ret[1] = "M0137,,";
$i++; // $i++;
pricereview_class($rate, $row["manager"], $ret, $special_fee, $i); // pricereview_class($rate, $row["manager"], $ret, $special_fee, $i);
} else { // } else {
$ret[1] = $row["manager"] . ",,"; // $ret[1] = $row["manager"] . ",,";
$i++; // $i++;
pricereview_class($rate, $row["manager"], $ret, $special_fee, $i); // pricereview_class($rate, $row["manager"], $ret, $special_fee, $i);
} // }
} else { // } else {
// $ret[1] = '';
// $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理 // $ret[2] = '';
if ($rate < 80 || $special_fee > 0) { $ret[3] = "M0060,,"; // 業務協理
$ret[4] = "M0006,,"; // 總經理 if ($rate < 80 || $special_fee > 0) {
} $ret[4] = "M0006,,"; // 總經理
} }
// }
return $ret; return $ret;
} }

46
wms/mkt/api/getElevatorMi.php

@ -0,0 +1,46 @@
<?php
require_once('../conn.php');
$spec = $_GET['spec'];
$person = $_GET['person'];
$stop = $_GET['stop'];
$open = $_GET['open'];
$speed = $_GET['speed'];
$weight = $_GET['weight'];
$sql_str = "SELECT * FROM elevator_mi_option WHERE elevator_type = :elevator_type AND max_weight = :max_weight AND max_speed = :max_speed ORDER BY id DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $spec);
$stmt->bindParam(':max_weight', $weight);
$stmt->bindParam(':max_speed', $speed);
$stmt->execute();
$mi = $stmt->fetch(PDO::FETCH_ASSOC);
if(!$mi){
echo false;
exit;
}
$stop = $stop > $mi['max_floors'] ? $mi['max_floors'] : $stop;
$stop = $stop < 2 ? 2 : $stop;
$equipment_fee = round($mi['purchase_cost'] + ($stop - $mi['base_floor']) * $mi['material_plus']);
$customs_shipping_fee = round($equipment_fee * 0.09);
$unloading_fee = round($mi['unloading']);
$transport_site_fee = round($mi['transport_site']);
$install_fee = round(($mi['install_price'] + ($stop - $mi['base_floor']) * $mi['install_plus']) + $mi['trial_price'] + ($stop - $mi['base_floor']) * $mi['trial_plus']);
$free1y_fee = round($mi['free1y']);
$other_fee = round($mi['crane'] + $mi['wooden_box'] + $mi['consumables']);
$newMI = [
'equipment_fee'=>$equipment_fee,
'customs_shipping_fee'=>$customs_shipping_fee,
'unloading_fee'=>$unloading_fee,
'transport_site_fee'=>$transport_site_fee,
'install_fee'=>$install_fee,
'free1y_fee'=>$free1y_fee,
'other_fee'=>$other_fee
];
echo json_encode($newMI);

38
wms/mkt/api/postPricereviewSign.php

@ -0,0 +1,38 @@
<?php
require_once('../conn.php');
date_default_timezone_set("Asia/Taipei");
$sign = $_POST['sign'];
$mid = $_POST['mid'];
$result = $_POST['result'];
$signOff = '';
if($result == 'YY' ){
$signOff = 'YY';
}elseif($result == 'YN'){
$signOff = 'N';
}elseif($result == 'YS'){
$signOff = 'Y';
}
try{
$user_id = $_POST['user_id'];
$sign_result = $user_id . "," . $signOff . "," . date("Y-m-d H:i:s");
$sql_str = "UPDATE pricereview_sign SET sign" . $sign . "=:sign WHERE mid = :mid ";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':sign', $sign_result);
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$sql_str = "UPDATE pricereview_main SET status=:status WHERE id = :id ";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':status', $result);
$stmt->bindParam(':id', $mid);
$stmt->execute();
echo 1;
}catch(PDOException $e){
echo $e->getMessage();
}

183
wms/mkt/assets/js/pricereviewAlpine.js

@ -593,8 +593,187 @@ const pricereviewCreate = ()=>{
const pricereviewCheck = ()=>{ const pricereviewCheck = ()=>{
return { return {
init(){ init(){
console.log(123) this.elevators = items.filter(item=> item.item_group =='A');
this.elevators.forEach(el=>{
el.options = []
el.optionsTotalPrice = 0;
el.otherOptions = []
el.otherOptionsTotalPrice = 0;
el.maintainOptions = []
el.maintainOptionsTotalPrice = 0;
})
this.options = options;
this.otherOptions = items.filter(item=> item.item_group =='E');
this.maintainOptions = items.filter(item=> item.item_group =='D');
console.log(this.options);
this.elevators.forEach((elevator, idx)=>{
this.options.forEach(option=>{
if(option.option_relate_spec == elevator.item_no){
elevator.optionsTotalPrice += option.option_mi * option.item_qty
this.elevators[idx].options.push({
'id': option.id,
'item_spec': option.item_spec.trim(),
'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty,
'mi': Math.round(option.option_mi),
})
}
})
this.otherOptions.forEach(option=>{
if(option.option_relate_spec == elevator.item_no){
elevator.otherOptionsTotalPrice += option.item_unit_price * option.item_qty
this.elevators[idx].otherOptions.push({
'id': option.id,
'item_spec': option.item_spec.trim(),
'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty,
'mi': Math.round(option.item_unit_price),
})
}
})
this.maintainOptions.forEach(option=>{
if(option.option_relate_spec == elevator.item_no){
elevator.maintainOptionsTotalPrice += option.item_unit_price * option.item_qty
this.elevators[idx].maintainOptions.push({
'id': option.id,
'item_spec': option.item_spe.trim(),
'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty,
'mi': Math.round(option.item_unit_price),
})
}
})
this.qty += Number(elevator.item_qty);
this.elevators_total_price += Number(elevator.item_qty) * Number(elevator.item_unit_price);
//MAE100-15*24-CO105
const model = elevator.item_spec;
let spec = model.split('-')[0];
let person = model.split('-')[1].split('*')[0];
let stop = model.split('-')[1].split('*')[1].split('-')[0];
let open = model.split('-')[2];
let speed = '';
for(let i=0;i<this.openFn.length;i++){
if(open.includes(this.openFn[i])){
speed = open.replace(this.openFn[i], '')
open = this.openFn[i];
break;
}
}
this.getElevatorMi(idx, spec, person, stop, open, speed, elevator.item_weight)
})
},
async getElevatorMi(idx, spec, person, stop, open, speed, item_weight){
try{
const res = await axios.get('./api/getElevatorMi.php', {params: {
spec: spec,
person: person,
stop: stop,
open: open,
speed: speed,
weight: item_weight
}})
console.log('---->',res.data);
if(res.data){
this.elevators[idx].mi = res.data
this.elevators[idx].totalMi = res.data['equipment_fee'] + res.data['customs_shipping_fee'] + res.data['free1y_fee'] + res.data['install_fee'] + res.data['other_fee'] + res.data['transport_site_fee'] + res.data['unloading_fee'];
}else{
this.isNotfoundMi = true;
this.elevators[idx].mi = {
'equipment_fee': 0,
'customs_shipping_fee': 0,
'free1y_fee': 0,
'install_fee': 0,
'other_fee': 0,
'transport_site_fee': 0,
'unloading_fee': 0
}
}
console.log(this.elevators[idx]);
}catch (error) {
console.error("Error fetching elevator price:", error);
}
},
isNotfoundMi:false,
openFn:[
'CO', '2S', '2U', '4PCO', '6PCO'
],
is_renovate: false,
elevators_total_price: 0,
contractno: contractno,
person_name: person_name,
company: company,
case_name: case_name,
address: address,
price_lowest: price_lowest,
price_total: price_total,
special_fee: special_fee,
predeal_date: predeal_date,
facilitok_date: facilitok_date,
penalty: penalty,
deposit_rate: deposit_rate,
keep_rate: keep_rate,
warranty_rate: warranty_rate,
memo: memo,
qty: 0,
pays: pays,
elevators:[],
options: [],
otherOptions: [],
maintainOptions: [],
mid: mid,
user_id: user_id,
optionsTotalPrice(){
return this.options.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
otherOptionsTotalPrice(){
return this.otherOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
maintainOptionsTotalPrice(){
return this.maintainOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
totalScale(){
return this.pays.reduce((total, option) => {
return total + Number(option.pay_scale );
}, 0);
},
check(sign, status){
console.log(sign);
const form = new FormData();
form.append('sign', sign);
form.append('mid', this.mid);
form.append('result', status);
form.append('user_id', this.user_id);
axios.post('./api/postPricereviewSign.php', form).then(res=>{
console.log(res.data);
if(res.data == 1){
alert("簽核成功!");
window.location.reload()
}
})
},
agree(sign){
console.log(sign);
},
closeCase(sign){
console.log(sign);
}, },
} }
} }

43
wms/mkt/css/pricereview.css

@ -226,4 +226,47 @@
.window-modal .window-modal-content .window-modal-body { .window-modal .window-modal-content .window-modal-body {
overflow-y: scroll; overflow-y: scroll;
height: 400px; height: 400px;
}
#pricereviewCheck > .container {
background-color: #F2F2F2;
border-radius: 15px;
padding: 20px;
}
#pricereviewCheck > .container textarea {
resize: vertical;
}
#pricereviewCheck > .container table, #pricereviewCheck > .container th, #pricereviewCheck > .container td {
border: 1px #ccc solid;
}
#pricereviewCheck > .container table.noborder {
border: none !important;
}
#pricereviewCheck > .container table.noborder th, #pricereviewCheck > .container table.noborder td {
border: none !important;
}
#pricereviewCheck > .container .customerinfo-table input {
background-color: #EEE5E5;
}
#pricereviewCheck > .container .mi-table th {
font-weight: 600;
}
#pricereviewCheck > .container .mi-table input[type=text] {
background-color: #EEEEEE;
cursor: not-allowed;
padding: 6px 12px;
font-size: 14px;
}
#pricereviewCheck > .container .mi-table .mi-info {
font-size: 14px;
}
#pricereviewCheck > .container .mi-table .mi-info span {
font-size: 15px;
font-weight: 600;
}
#pricereviewCheck > .container .mi-table .mi-info .line {
width: 100%;
height: 0.5px;
margin: 30px 0;
background-color: #ccc;
}/*# sourceMappingURL=pricereview.css.map */ }/*# sourceMappingURL=pricereview.css.map */

2
wms/mkt/css/pricereview.css.map

@ -1 +1 @@
{"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,aAAA;ACAR;ADCQ;EACI,sBAAA;ACCZ;ADCQ;EACI,cAAA;ACCZ;ADCQ;EACI,yBAAA;ACCZ;ADKQ;EACI,sBAAA;EACA,aAAA;ACHZ;ADIY;EACI,YAAA;ACFhB;ADMY;EACI,yBAAA;ACJhB;ADOgB;EACI,eAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACLpB;ADQY;EACI,eAAA;ACNhB;ADSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ACPZ;ADQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,iBAAA;EACA,eAAA;ACNhB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACPhB;ADQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACNpB;ADOoB;EACI,gBAAA;ACLxB;ADSgB;EACI,eAAA;EACA,6BAAA;ACPpB;ADQoB;EACI,eAAA;ACNxB;ADQoB;;;;EAEA,wBAAA;EACA,SAAA;ACJpB;ADQoB;EACI,UAAA;ACNxB;ADQoB;EACI,kBAAA;ACNxB;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACL5B;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ACL5B;ADQoB;EACI,YAAA;EACA,gBAAA;ACNxB;ADUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ACRhB;ADSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ACPpB;ADQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ACNxB;ADQoB;EACI,YAAA;ACNxB;ADQoB;EACI,WAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ACNxB;;ADcA;EACI,4BAAA;EACA,WAAA;ACXJ;ADYI;EACI,gBAAA;ACVR;ADYI;EACI,yBAAA;ACVR;;ADcA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;EACA,aAAA;ACXJ;ADYI;EACI;IACI,gCAAA;IACA,UAAA;ECVV;EDYM;IACI,gCAAA;IACA,UAAA;ECVV;AACF;ADYI;EACI,sBAAA;ACVR;ADYI;EACI,cAAA;ACVR;ADYI;EACI,yBAAA;ACVR;ADYI;EACI,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,aAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,gBAAA;EACA,8BAAA;ACVR;ADWQ;EACI,aAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,aAAA;EACA,sBAAA;ACTZ;ADUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACRhB;ADUY;EACI,YAAA;ACRhB;ADWQ;EACI,kBAAA;EACA,aAAA;ACTZ","file":"pricereview.css"} {"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,aAAA;ACAR;ADCQ;EACI,sBAAA;ACCZ;ADCQ;EACI,cAAA;ACCZ;ADCQ;EACI,yBAAA;ACCZ;ADKQ;EACI,sBAAA;EACA,aAAA;ACHZ;ADIY;EACI,YAAA;ACFhB;ADMY;EACI,yBAAA;ACJhB;ADOgB;EACI,eAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACLpB;ADQY;EACI,eAAA;ACNhB;ADSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ACPZ;ADQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,iBAAA;EACA,eAAA;ACNhB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACPhB;ADQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACNpB;ADOoB;EACI,gBAAA;ACLxB;ADSgB;EACI,eAAA;EACA,6BAAA;ACPpB;ADQoB;EACI,eAAA;ACNxB;ADQoB;;;;EAEA,wBAAA;EACA,SAAA;ACJpB;ADQoB;EACI,UAAA;ACNxB;ADQoB;EACI,kBAAA;ACNxB;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACL5B;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ACL5B;ADQoB;EACI,YAAA;EACA,gBAAA;ACNxB;ADUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ACRhB;ADSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ACPpB;ADQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ACNxB;ADQoB;EACI,YAAA;ACNxB;ADQoB;EACI,WAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ACNxB;;ADcA;EACI,4BAAA;EACA,WAAA;ACXJ;ADYI;EACI,gBAAA;ACVR;ADYI;EACI,yBAAA;ACVR;;ADcA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;EACA,aAAA;ACXJ;ADYI;EACI;IACI,gCAAA;IACA,UAAA;ECVV;EDYM;IACI,gCAAA;IACA,UAAA;ECVV;AACF;ADYI;EACI,sBAAA;ACVR;ADYI;EACI,cAAA;ACVR;ADYI;EACI,yBAAA;ACVR;ADYI;EACI,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,aAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,gBAAA;EACA,8BAAA;ACVR;ADWQ;EACI,aAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,aAAA;EACA,sBAAA;ACTZ;ADUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACRhB;ADUY;EACI,YAAA;ACRhB;ADWQ;EACI,kBAAA;EACA,aAAA;ACTZ;;ADeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ACZR;ADaQ;EACI,gBAAA;ACXZ;ADaQ;EACI,sBAAA;ACXZ;ADaQ;EACI,uBAAA;ACXZ;ADYY;EACI,uBAAA;ACVhB;ADcY;EACI,yBAAA;ACZhB;ADgBY;EACI,gBAAA;ACdhB;ADgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ACdhB;ADgBY;EACI,eAAA;ACdhB;ADegB;EACI,eAAA;EACA,gBAAA;ACbpB;ADegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ACbpB","file":"pricereview.css"}

50
wms/mkt/css/pricereview.scss

@ -238,4 +238,54 @@
height: 400px; height: 400px;
} }
} }
}
#pricereviewCheck{
>.container{
background-color: #F2F2F2;
border-radius: 15px;
padding: 20px;
textarea{
resize: vertical;
}
table, th, td{
border:1px #ccc solid;
}
table.noborder{
border:none !important;
th ,td{
border:none !important;
}
}
.customerinfo-table{
input{
background-color: #EEE5E5;
}
}
.mi-table{
th{
font-weight: 600;
}
input[type=text]{
background-color: #EEEEEE;
cursor: not-allowed;
padding: 6px 12px;
font-size: 14px;
}
.mi-info{
font-size: 14px;
span{
font-size: 15px;
font-weight: 600;
}
.line{
width: 100%;
height: .5px;
margin:30px 0;
background-color: #ccc;
}
}
}
}
} }

31
wms/mkt/pricereview-check.php

@ -205,6 +205,7 @@ foreach ($res as $data) {
} }
mysqli_free_result($res_spec); mysqli_free_result($res_spec);
} elseif ($row['item_group'] == "B") { } elseif ($row['item_group'] == "B") {
$option_arr[$row['item_no']]['price_id'] = $row['price_id'];
$option_arr[$row['item_no']]['item_spec'] = $row['item_spec']; $option_arr[$row['item_no']]['item_spec'] = $row['item_spec'];
$option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; $option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price'];
$option_arr[$row['item_no']]['item_qty'] = $row['item_qty']; $option_arr[$row['item_no']]['item_qty'] = $row['item_qty'];
@ -321,14 +322,14 @@ foreach ($res as $data) {
function getMI(id) { function getMI(id) {
var formdata = new FormData(); var formdata = new FormData();
formdata.append('pa', id); formdata.append('pa', id);
// formdata.append('user_id', <?= $user_id ?>);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
console.log(this.responseText);
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText); data = JSON.parse(this.responseText);
console.log(data); console.log(data);
if(data.err == "notfoundmi"){ if (data.err == "notfoundmi") {
for(let i=0;i<document.getElementsByClassName('total_mi_fix').length;i++){ for (let i = 0; i < document.getElementsByClassName('total_mi_fix').length; i++) {
document.getElementsByClassName('total_mi_fix')[i].value = "找不到此MI" document.getElementsByClassName('total_mi_fix')[i].value = "找不到此MI"
} }
} }
@ -339,8 +340,8 @@ foreach ($res as $data) {
} }
// console.log(data.content); // console.log(data.content);
Object.keys(data.content).forEach(function(k) { Object.keys(data.content).forEach(function(k) {
console.log('k=>', k); // console.log('k=>', k);
console.log(data.content); // console.log(data.content);
//console.log(data.content[k][0]); //console.log(data.content[k][0]);
// 有值表示先前已寫入MI // 有值表示先前已寫入MI
if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") { if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") {
@ -362,7 +363,7 @@ foreach ($res as $data) {
mihtml += "<li>一年免保:" + commafy(data.content[k][6]) + "</li>"; mihtml += "<li>一年免保:" + commafy(data.content[k][6]) + "</li>";
mihtml += "<li>起吊+木箱+耗材:" + commafy(data.content[k][7]) + "</li>"; mihtml += "<li>起吊+木箱+耗材:" + commafy(data.content[k][7]) + "</li>";
//mihtml += "<li>加價:"+commafy(data.content[k][9])+"</li>"; //mihtml += "<li>加價:"+commafy(data.content[k][9])+"</li>";
mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台" ; mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台";
mihtml += "<hr>"; mihtml += "<hr>";
mihtml += "<h5>OPTION</h5>"; mihtml += "<h5>OPTION</h5>";
total_mi = total_mi + data.content[k][12]; total_mi = total_mi + data.content[k][12];
@ -386,14 +387,14 @@ foreach ($res as $data) {
total_mi += data.content[k][13]; total_mi += data.content[k][13];
if(total_mi == ""){ if (total_mi == "") {
console.log("undefided!!!"); console.log("undefided!!!");
} }
$("#tb1").find("tr[name=facil_templ2]").eq(k).find('td').eq(1).html(mihtml); $("#tb1").find("tr[name=facil_templ2]").eq(k).find('td').eq(1).html(mihtml);
//$("#tb1").find("input[name=mi_fix]").eq(k).closest('td').append(mihtml); //$("#tb1").find("input[name=mi_fix]").eq(k).closest('td').append(mihtml);
console.log(document.getElementsByClassName('total_mi_fix')[k]); console.log(document.getElementsByClassName('total_mi_fix')[k]);
document.getElementsByClassName('total_mi_fix')[k].value = commafy(total_mi) document.getElementsByClassName('total_mi_fix')[k].value = commafy(total_mi)
// document.getElementsByClassName('item_price_ct')[k].value =commafy(total_mi) // document.getElementsByClassName('item_price_ct')[k].value =commafy(total_mi)
document.getElementsByClassName('gross_profit')[k].value = commafy(Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) - total_mi) document.getElementsByClassName('gross_profit')[k].value = commafy(Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) - total_mi)
document.getElementsByClassName('gross_profit_rate')[k].value = Math.round((Number(document.getElementsByClassName('gross_profit')[k].value.replace(/[,]+/g, "")) / Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) * 100) * 10) / 10 document.getElementsByClassName('gross_profit_rate')[k].value = Math.round((Number(document.getElementsByClassName('gross_profit')[k].value.replace(/[,]+/g, "")) / Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) * 100) * 10) / 10
@ -586,16 +587,16 @@ foreach ($res as $data) {
foreach ($item_arr as $item_no => $val) { foreach ($item_arr as $item_no => $val) {
$item_amt_A_all += $val["item_price_bp"]; $item_amt_A_all += $val["item_price_bp"];
if ($viewmi) { if ($viewmi) {
for ($i = 0; $i < $val["item_qty"]; $i++) { // for ($i = 0; $i < $val["item_qty"]; $i++) {
?> ?>
<tr name="facil_templ"> <tr name="facil_templ">
<td><?php echo $idx; ?><input type="hidden" name="item_no" value="<?php echo $item_no; ?>"><input type="hidden" name="sub_item_id" value="<?php if (isset($val["sub_item_id"])) echo implode("@", $val["sub_item_id"]); ?>"></td> <td><?php echo $idx; ?><input type="hidden" name="item_no" value="<?php echo $item_no; ?>"><input type="hidden" name="sub_item_id" value="<?php if (isset($val["sub_item_id"])) echo implode("@", $val["sub_item_id"]); ?>"></td>
<td nowrap><a href="" data-toggle="modal"><?= $val["item_spec"]; ?> [規調]</a></td> <td nowrap><a href="" data-toggle="modal"><?= $val["item_spec"]; ?> [規調]</a></td>
<td><input type="text" name="item_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td> <td><input type="text" name="item_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td>
<td><input type="text" name="item_qty" class="form-control" size="2" value="1"></td> <td><input type="text" name="item_qty" class="form-control" size="2" value="<?php echo $val["item_qty"]; ?>"></td>
<td><input type="text" name="item_price_bp" class="form-control dollar-right" size="9" value="<?= number_format(1 * $val['item_unit_price']); ?>"></td> <td><input type="text" name="item_price_bp" class="form-control dollar-right" size="9" value="<?= number_format($val["item_qty"] * $val['item_unit_price']); ?>"></td>
<td><input type="text" name="mi_fix" class="form-control dollar-right total_mi_fix" size="9" value="<?php echo ($val["mi_fix"]) ? number_format($val["mi_fix"]) : ""; ?>" disabled></td> <td><input type="text" name="mi_fix" class="form-control dollar-right total_mi_fix" size="9" value="<?php echo ($val["mi_fix"]) ? number_format($val["mi_fix"]) : ""; ?>" disabled></td>
<td><input type="text" name="item_price_ct" class="form-control dollar-right item_price_ct" size="9" value="<?= number_format($val["item_price_ct"] / $val["item_qty"]); ?>"></td> <td><input type="text" name="item_price_ct" class="form-control dollar-right item_price_ct" size="9" value="<?= number_format($val["item_price_ct"]); ?>"></td>
<!--<td><input type="text" name="item_price" class="form-control dollar-right" size="8" value="<?php echo ($val["item_price"]) ? number_format($val["item_price"]) : ""; ?>"></td> <!--<td><input type="text" name="item_price" class="form-control dollar-right" size="8" value="<?php echo ($val["item_price"]) ? number_format($val["item_price"]) : ""; ?>"></td>
<td><input type="text" name="pv_rate" class="form-control" size="1" value="<?= $val["pv_rate"]; ?>"></td> <td><input type="text" name="pv_rate" class="form-control" size="1" value="<?= $val["pv_rate"]; ?>"></td>
<td><input type="text" name="allocate" class="form-control" size="6" value="<?= $val["allocate"]; ?>"></td>--> <td><input type="text" name="allocate" class="form-control" size="6" value="<?= $val["allocate"]; ?>"></td>-->
@ -608,7 +609,7 @@ foreach ($res as $data) {
<td colspan="4"></td> <td colspan="4"></td>
</tr> </tr>
<?php <?php
} #item_qty end. //} #item_qty end.
} else { } else {
?> ?>
<tr name="facil_templ"> <tr name="facil_templ">
@ -641,6 +642,7 @@ foreach ($res as $data) {
</tr> </tr>
<tr> <tr>
<th nowrap>項次</th> <th nowrap>項次</th>
<th>OPTION ID</th>
<th>選配規格</th> <th>選配規格</th>
<th>單價</th> <th>單價</th>
<th>數量</th> <th>數量</th>
@ -663,6 +665,7 @@ foreach ($res as $data) {
?> ?>
<tr> <tr>
<td><?php echo $idx; ?></td> <td><?php echo $idx; ?></td>
<td><?php echo $val['price_id'] ?></td>
<td><input type="text" name="option_seat" class="form-control" size="30" value="<?= str_replace("()", "", str_replace("&amp;", "", str_replace("&lt;br&gt;", "", str_replace("&amp;lt;br&amp;gt;", "", $val['item_spec'])))); ?>"></td> <td><input type="text" name="option_seat" class="form-control" size="30" value="<?= str_replace("()", "", str_replace("&amp;", "", str_replace("&lt;br&gt;", "", str_replace("&amp;lt;br&amp;gt;", "", $val['item_spec'])))); ?>"></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td>
<td><input type="text" name="option_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td> <td><input type="text" name="option_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td>
@ -676,7 +679,7 @@ foreach ($res as $data) {
?> ?>
<?php if ($total_qty > 0) : ?> <?php if ($total_qty > 0) : ?>
<tr> <tr>
<td colspan="4">小計</td> <td colspan="5">小計</td>
<td colspan="3"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_B_all); ?>"></td> <td colspan="3"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_B_all); ?>"></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>

45
wms/mkt/pricereview-create.php

@ -43,7 +43,7 @@ if ($row[0] > 0) {
// 退回重填價審,帶出上次價審內容 // 退回重填價審,帶出上次價審內容
$last_pr_arr = $last_pritem_arr = $last_prpay_arr = []; $last_pr_arr = $last_pritem_arr = $last_prpay_arr = [];
$sql = "select * from pricereview_main where contractno = '$vol_no' and status in ('YN', 'D') order by id limit 1"; $sql = "SELECT * FROM pricereview_main WHERE contractno = '$vol_no' AND status in ('YN', 'D') ORDER BY id DESC limit 1";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) { if ($row = mysqli_fetch_assoc($res)) {
$last_pr_arr = $row; $last_pr_arr = $row;
@ -1931,6 +1931,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
</tr> </tr>
<tr> <tr>
<th>選配規格</th> <th>選配規格</th>
<th>OPTION ID</th>
<th>單價</th> <th>單價</th>
<th>數量</th> <th>數量</th>
<th>複價</th> <th>複價</th>
@ -1959,8 +1960,9 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<a href="" name="option_href" data-toggle="modal"><?php echo $v["item_spec"]; ?></a> <a href="" name="option_href" data-toggle="modal"><?php echo $v["item_spec"]; ?></a>
<?php } ?> <?php } ?>
</td> </td>
<td><input type="text" name="option_price_id" class="form-control dollar-right" size="8" value="<?php echo $v['price_id']; ?>" readonly></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_unit_price"]); ?>" readonly></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_unit_price"]); ?>" readonly></td>
<td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo $v["item_qty"]; ?>"></td> <td><input type="text" name="option_qty" class="form-control" size="3" maxlength="3" value="<?php echo $v["item_qty"]; ?>"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_price_bp"]); ?>" readonly> <td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_price_bp"]); ?>" readonly>
<input type="hidden" name="item_group" value="B"><input type="hidden" name="op_id" value="<?php echo $v["id"]; ?>"> <input type="hidden" name="item_group" value="B"><input type="hidden" name="op_id" value="<?php echo $v["id"]; ?>">
</td> </td>
@ -1979,8 +1981,9 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<td name="option_seat"> <td name="option_seat">
<a href="" name="option_href" data-toggle="modal"><?php echo (isset($v["seat"])) ? $v["seat"] : ""; ?></a> <a href="" name="option_href" data-toggle="modal"><?php echo (isset($v["seat"])) ? $v["seat"] : ""; ?></a>
</td> </td>
<td><input type="text" name="option_price_id" class="form-control dollar-right" size="8" value="<?php echo isset($v['price_id']) ? $v['price_id'] : ''; ?>" readonly></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"])) ? number_format($v["option_price"]) : 0; ?>" readonly></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"])) ? number_format($v["option_price"]) : 0; ?>" readonly></td>
<td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo (isset($v["option_num"])) ? $v["option_num"] : 0; ?>"></td> <td><input type="text" name="option_qty" class="form-control" size="3" maxlength="3" value="<?php echo (isset($v["option_num"])) ? $v["option_num"] : 0; ?>"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"]) && isset($v["option_num"])) ? number_format($v["option_price"] * $v["option_num"]) : 0; ?>" readonly> <td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"]) && isset($v["option_num"])) ? number_format($v["option_price"] * $v["option_num"]) : 0; ?>" readonly>
<input type="hidden" name="item_group" value="B"> <input type="hidden" name="item_group" value="B">
<input type="hidden" name="op_id" class="optionshow" value="<?php echo isset($v['id']) ? $v['id'] : ""; ?>"> <input type="hidden" name="op_id" class="optionshow" value="<?php echo isset($v['id']) ? $v['id'] : ""; ?>">
@ -2002,8 +2005,9 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<td name="option_seat"> <td name="option_seat">
<a href="" name="option_href" data-toggle="modal" @click="searchtext = ''">點選</a> <a href="" name="option_href" data-toggle="modal" @click="searchtext = ''">點選</a>
</td> </td>
<td><input type="text" name="option_price_id" class="form-control dollar-right" size="8" value="<?php echo isset($v['price_id']) ? $v['price_id'] : ''; ?>" readonly></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"])) ? number_format($v["option_price"]) : 0; ?>" readonly></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"])) ? number_format($v["option_price"]) : 0; ?>" readonly></td>
<td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo (isset($v["option_num"])) ? $v["option_num"] : 0; ?>"></td> <td><input type="text" name="option_qty" class="form-control" size="3" maxlength="3" value="<?php echo (isset($v["option_num"])) ? $v["option_num"] : 0; ?>"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"]) && isset($v["option_num"])) ? number_format($v["option_price"] * $v["option_num"]) : 0; ?>" readonly> <td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo (isset($v["option_price"]) && isset($v["option_num"])) ? number_format($v["option_price"] * $v["option_num"]) : 0; ?>" readonly>
<input type="hidden" name="item_group" value="B"> <input type="hidden" name="item_group" value="B">
<input type="hidden" name="op_id" value=""> <input type="hidden" name="op_id" value="">
@ -2016,7 +2020,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
</tr> </tr>
<?php } ?> <?php } ?>
<tr> <tr>
<td colspan="3">小計</td> <td colspan="4">小計</td>
<td colspan="4"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" readonly></td> <td colspan="4"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" readonly></td>
</tr> </tr>
</tbody> </tbody>
@ -2519,7 +2523,6 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<input type="hidden" name="option_price_bp_all" id="option_price_bp_all"> <input type="hidden" name="option_price_bp_all" id="option_price_bp_all">
<input type="hidden" name="option_memo_all" id="option_memo_all"> <input type="hidden" name="option_memo_all" id="option_memo_all">
<input type="hidden" name="option_relate_facil_all" id="option_relate_facil_all"> <input type="hidden" name="option_relate_facil_all" id="option_relate_facil_all">
<input type="hidden" name="Exclusions_all" id="Exclusions_all">
<input type="hidden" name="mn_id_all" id="mn_id_all"> <input type="hidden" name="mn_id_all" id="mn_id_all">
<input type="hidden" name="mn_kind_all" id="mn_kind_all"> <input type="hidden" name="mn_kind_all" id="mn_kind_all">
<input type="hidden" name="mn_seat_all" id="mn_seat_all"> <input type="hidden" name="mn_seat_all" id="mn_seat_all">
@ -2535,6 +2538,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<input type="hidden" name="except_unit_price_all" id="except_unit_price_all"> <input type="hidden" name="except_unit_price_all" id="except_unit_price_all">
<input type="hidden" name="except_qty_all" id="except_qty_all"> <input type="hidden" name="except_qty_all" id="except_qty_all">
<input type="hidden" name="except_price_bp_all" id="except_price_bp_all"> <input type="hidden" name="except_price_bp_all" id="except_price_bp_all">
<input type="hidden" name="Exclusions_all" id="Exclusions_all">
<input type="hidden" name="pmstatus"> <input type="hidden" name="pmstatus">
<input type="hidden" name="case_name" value="<?php echo $case_name; ?>"> <input type="hidden" name="case_name" value="<?php echo $case_name; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
@ -2549,20 +2553,21 @@ include "../footer.php";
<script> <script>
const options = [...<?php echo json_encode($options); ?>]; const options = [...<?php echo json_encode($options); ?>];
function selectOptionFn(pobj, jobj){ function selectOptionFn(pobj, jobj) {
// var pobj = $(this).closest('td').parent(); // var pobj = $(this).closest('td').parent();
console.log(pobj); console.log(pobj);
// console.log(pobj.find('input[name=optionID]').val()); // console.log(pobj.find('input[name=optionID]').val());
// console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html())); // console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html()));
console.log(pobj.find('td').eq(0).html()); console.log(pobj.find('td').eq(0).html());
let sepc = pobj.find('td').eq(2).html() + '<br />(' + pobj.find('td').eq(3).html() + ')'; let sepc = pobj.find('td').eq(2).html() + '<br />(' + pobj.find('td').eq(3).html() + ')';
sepc = sepc.replace("()", "") sepc = sepc.replace("()", "")
jobj.html(pobj.find('td').eq(1).html() + " " ); jobj.html(pobj.find('td').eq(1).html() + " ");
jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(6).html()); jobj.closest('td').parent().find('input[name=option_price_id]').val(pobj.find('td').eq(0).html());
jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(6).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, ""))); jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(6).html());
jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('td').eq(0).html()); jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(6).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, "")));
$("#optionModal").modal('hide'); jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('td').eq(0).html());
$("#optionModal").modal('hide');
} }
function checkSubmit() { function checkSubmit() {

51
wms/mkt/pricereview-edit.php

@ -68,6 +68,7 @@ foreach ($res as $data) {
$ex_arr[$row['item_no']]['item_qty'] = $row['item_qty']; $ex_arr[$row['item_no']]['item_qty'] = $row['item_qty'];
$ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; $ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp'];
$ex_arr[$row['item_no']]['note'] = $row['note']; // 詢價單號 $ex_arr[$row['item_no']]['note'] = $row['note']; // 詢價單號
$ex_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec'];
} }
} }
mysqli_free_result($res_i); mysqli_free_result($res_i);
@ -653,6 +654,8 @@ foreach ($res as $data) {
$('#btnadd3').click(function() { $('#btnadd3').click(function() {
$('#tb3 tr:last').prev().after($("tr[name='except_templ']").last().clone().find('input').val('').end()); $('#tb3 tr:last').prev().after($("tr[name='except_templ']").last().clone().find('input').val('').end());
$("tr[name='except_templ']").last().find('input[name=except_act]').val('I'); $("tr[name='except_templ']").last().find('input[name=except_act]').val('I');
$('#tb3 tr:last').prev().find('td[name=ex_relate_facil]').html('');
//$('#tb3 tr:last').prev().find('td').first().html($("tr[name='except_templ']").length); //$('#tb3 tr:last').prev().find('td').first().html($("tr[name='except_templ']").length);
//$('#tb3 tr:last').prev().find('td').eq(1).find('a').attr('id', $("tr[name='except_templ']").length); //$('#tb3 tr:last').prev().find('td').eq(1).find('a').attr('id', $("tr[name='except_templ']").length);
}); });
@ -681,6 +684,7 @@ foreach ($res as $data) {
$("#optionModal .modal-body td").unbind().click(function() { $("#optionModal .modal-body td").unbind().click(function() {
var pobj = $(this).closest('td').parent(); var pobj = $(this).closest('td').parent();
jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html()); jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html());
jobj.closest('td').parent().find('input[name=option_price_id]').val(pobj.find('input[name=option_id]').val());
jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(5).html()); jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(5).html());
jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(5).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, ""))); jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(5).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, "")));
jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('input[name=option_id]').val()); jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('input[name=option_id]').val());
@ -1020,12 +1024,14 @@ foreach ($res as $data) {
mnKindArr.push($(this).val()); mnKindArr.push($(this).val());
}) })
$('#mn_kind_all').val(mnKindArr); $('#mn_kind_all').val(mnKindArr);
var mnSeatArr = []; var nmExclusions = [];
$("td[name='Exclusions']").each(function() { $("td[name='Exclusions']").each(function() {
exRelateFacilArr.push($(this).html()); nmExclusions.push($(this).val());
}) })
$('#Exclusions_all').val(exRelateFacilArr); $('#Exclusions_all').val(nmExclusions);
var exSpecArr = [];
var mnSeatArr = [];
$("select[name='mn_seat']").each(function() { $("select[name='mn_seat']").each(function() {
mnSeatArr.push($(this).val()); mnSeatArr.push($(this).val());
}) })
@ -1061,10 +1067,17 @@ foreach ($res as $data) {
}) })
$('#mn_memo_all').val(mnMemoArr); $('#mn_memo_all').val(mnMemoArr);
var mnRelateFacilArr = []; var mnRelateFacilArr = [];
$("td[name='mn_relate_facil']").each(function() { $("td[name='mn_relate_facil']").each(function() {
mnRelateFacilArr.push($(this).html().trim()); mnRelateFacilArr.push($(this).html().trim());
}) })
$('#mn_relate_facil_all').val(mnRelateFacilArr); $('#mn_relate_facil_all').val(mnRelateFacilArr);
var exRelateFacilArr = [];
$("td[name='ex_relate_facil']").each(function() {
exRelateFacilArr.push($(this).html().trim());
})
$('#ex_relate_facil_all').val(exRelateFacilArr);
var exNoteArr = []; var exNoteArr = [];
$("input[name='except_note']").each(function() { $("input[name='except_note']").each(function() {
exNoteArr.push($(this).val()); exNoteArr.push($(this).val());
@ -1144,6 +1157,13 @@ foreach ($res as $data) {
}); });
if ((rv === false)) return rv; if ((rv === false)) return rv;
$("td[name='ex_relate_facil']").each(function() {
if ($(this).closest('td').parent().find('select[name=except_qty').val() != '0' && $(this).html() == "") {
alert("【所屬電梯】資料空白!\n請至 保固延長區 點選紅色按鈕「電梯」並勾選項目。");
location.href = '#btnadd3';
return rv2 = false;
}
})
var rv2 = true; var rv2 = true;
$("td[name='mn_relate_facil']").each(function() { $("td[name='mn_relate_facil']").each(function() {
if ($(this).closest('td').parent().find('select[name=mn_kind').val() != '' && $(this).html() == "") { if ($(this).closest('td').parent().find('select[name=mn_kind').val() != '' && $(this).html() == "") {
@ -1380,6 +1400,7 @@ foreach ($res as $data) {
</tr> </tr>
<tr> <tr>
<th>選配規格</th> <th>選配規格</th>
<th>OPTION ID</th>
<th>單價</th> <th>單價</th>
<th>數量</th> <th>數量</th>
<th>複價</th> <th>複價</th>
@ -1404,6 +1425,7 @@ foreach ($res as $data) {
<td name="option_seat"> <td name="option_seat">
<a href="" name="option_href" data-toggle="modal"><?php echo $v["item_spec"]; ?></a> <a href="" name="option_href" data-toggle="modal"><?php echo $v["item_spec"]; ?></a>
</td> </td>
<td><input type="text" name="option_price_id" class="form-control dollar-right" size="8" value="<?php echo $v['op_id']; ?>" readonly></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_unit_price"]); ?>" readonly></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_unit_price"]); ?>" readonly></td>
<td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo $v["item_qty"]; ?>"></td> <td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2" value="<?php echo $v["item_qty"]; ?>"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_price_bp"]); ?>" readonly> <td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?php echo number_format($v["item_price_bp"]); ?>" readonly>
@ -1437,6 +1459,7 @@ foreach ($res as $data) {
<td name="option_seat"> <td name="option_seat">
<a href="" name="option_href" data-toggle="modal">點選</a> <a href="" name="option_href" data-toggle="modal">點選</a>
</td> </td>
<td><input type="text" name="option_price_id" class="form-control dollar-right" size="8" readonly></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" readonly></td> <td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" readonly></td>
<td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2"></td> <td><input type="text" name="option_qty" class="form-control" size="2" maxlength="2"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" readonly> <td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" readonly>
@ -1455,7 +1478,7 @@ foreach ($res as $data) {
} }
?> ?>
<tr> <tr>
<td colspan="3">小計</td> <td colspan="4">小計</td>
<td colspan="4"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" readonly></td> <td colspan="4"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" readonly></td>
</tr> </tr>
</tbody> </tbody>
@ -1501,8 +1524,19 @@ foreach ($res as $data) {
<!-- <a href="javascript:void(0);" name="btndel3" class="btn btn-danger btn-sm">X</a> --> <!-- <a href="javascript:void(0);" name="btndel3" class="btn btn-danger btn-sm">X</a> -->
</td> </td>
<td name='Exclusions'></td> <td name='Exclusions'>
<td name="mn_relate_facil" nowrap> <?php
if (!empty($v['option_relate_spec'])) {
$tmp_arr = explode(",", $v['option_relate_spec']);
foreach ($tmp_arr as $val) {
if (!empty($item_arr[$val]['item_spec'])) {
echo $val . "." . $item_arr[$val]['item_spec'] . "<br>";
}
}
}
?>
</td>
<td name="ex_relate_facil" nowrap>
<input type="hidden" name="item_group" value="E"> <input type="hidden" name="item_group" value="E">
<a href="javascript:void(0);" name="btnfaci" class="btn btn-danger btn-sm">電梯</a> <a href="javascript:void(0);" name="btnfaci" class="btn btn-danger btn-sm">電梯</a>
@ -1524,7 +1558,7 @@ foreach ($res as $data) {
<!-- <a href="javascript:void(0);" name="btndel3" class="btn btn-danger btn-sm">X</a> --> <!-- <a href="javascript:void(0);" name="btndel3" class="btn btn-danger btn-sm">X</a> -->
</td> </td>
<td name='Exclusions'></td> <td name='Exclusions'></td>
<td name="mn_relate_facil"> <td name="ex_relate_facil">
<a href="javascript:void(0);" name="btnfaci" class="btn btn-danger btn-sm">電梯</a> <a href="javascript:void(0);" name="btnfaci" class="btn btn-danger btn-sm">電梯</a>
<a href="javascript:void(0);" name="btndel3" class="btn btn-danger btn-sm">X</a> <a href="javascript:void(0);" name="btndel3" class="btn btn-danger btn-sm">X</a>
</td> </td>
@ -2006,6 +2040,7 @@ foreach ($res as $data) {
<input type="hidden" name="mn_price_bp_all" id="mn_price_bp_all"> <input type="hidden" name="mn_price_bp_all" id="mn_price_bp_all">
<input type="hidden" name="mn_memo_all" id="mn_memo_all"> <input type="hidden" name="mn_memo_all" id="mn_memo_all">
<input type="hidden" name="mn_relate_facil_all" id="mn_relate_facil_all"> <input type="hidden" name="mn_relate_facil_all" id="mn_relate_facil_all">
<!-- <input type="hidden" name="ex_relate_facil_all" id="ex_relate_facil_all"> -->
<input type="hidden" name="except_note_all" id="except_note_all"> <input type="hidden" name="except_note_all" id="except_note_all">
<input type="hidden" name="except_spec_all" id="except_spec_all"> <input type="hidden" name="except_spec_all" id="except_spec_all">
<input type="hidden" name="except_unit_price_all" id="except_unit_price_all"> <input type="hidden" name="except_unit_price_all" id="except_unit_price_all">

22
wms/mkt/pricereview-index.php

@ -498,7 +498,7 @@ if ($data) :
} }
} }
?> ?>
<a href="pricereview-check.php?id=<?php echo $data['id'] . "&" . $para; ?>" target="_blank" class="btn btn-warning btn-sm">檢視</a> <a href="pricereviewCheck.php?id=<?php echo $data['id'] . "&" . $para; ?>" target="_blank" class="btn btn-warning btn-sm">檢視</a>
<?php <?php
if ($user_id == "M0023") { if ($user_id == "M0023") {
?> ?>
@ -520,14 +520,14 @@ if ($data) :
if ($ss_arr["sign_st"] == 1 && in_array($user_id, $ss_arr["sign_nt"]) && $data["status"] == "YS" || $user_id == 'TEST04') { if ($ss_arr["sign_st"] == 1 && in_array($user_id, $ss_arr["sign_nt"]) && $data["status"] == "YS" || $user_id == 'TEST04') {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核"; $str = "待簽核";
$str = "<a href=\"pricereview-check.php?st=1&id=" . $data["id"] . "&" . $para . "\" target=\"_blank\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; $str = "<a href=\"pricereviewCheck.php?st=1&id=" . $data["id"] . "&" . $para . "\" target=\"_blank\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
} else $str = "--"; } else $str = "--";
} }
echo $str; echo $str;
/* /*
if ($sign_st==1 && $sign_nt==$user_id) { if ($sign_st==1 && $sign_nt==$user_id) {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "<a href=\"pricereview-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; $str = "<a href=\"pricereviewCheck.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>";
} else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程 } else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程
list($uperson, $ustatus, $udtte) = explode(",", $sign1); list($uperson, $ustatus, $udtte) = explode(",", $sign1);
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>";
@ -545,7 +545,7 @@ if ($data) :
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
} }
if (!$oneself) { if (!$oneself) {
$str = "<a href=\"pricereview-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; $str = "<a href=\"pricereviewCheck.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>";
$str .= "<br>".$data["checker_1"]."<br>".$data["checker_1_dt"]; $str .= "<br>".$data["checker_1"]."<br>".$data["checker_1_dt"];
} else { } else {
if ($data["checker_1_result"]) { if ($data["checker_1_result"]) {
@ -577,7 +577,7 @@ if ($data) :
if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 2) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST02') { if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 2) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST02') {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核"; $str = "待簽核";
$str = "<a href=\"pricereview-check.php?st=2&id=" . $data["id"] . "&" . $para . "\" target=\"_blank\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; $str = "<a href=\"pricereviewCheck.php?st=2&id=" . $data["id"] . "&" . $para . "\" target=\"_blank\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
} else $str = "--"; } else $str = "--";
} }
echo $str; echo $str;
@ -585,7 +585,7 @@ if ($data) :
/* /*
if ($sign_st==2 && $sign_nt==$user_id) { if ($sign_st==2 && $sign_nt==$user_id) {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "<a href=\"pricereview-check.php?st=2&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; $str = "<a href=\"pricereviewCheck.php?st=2&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>";
} else if ($sign_st > 2 || $data['last_check_result']) { } else if ($sign_st > 2 || $data['last_check_result']) {
list($uperson, $ustatus, $udtte) = explode(",", $sign2); list($uperson, $ustatus, $udtte) = explode(",", $sign2);
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>";
@ -603,7 +603,7 @@ if ($data) :
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
} }
if (!$oneself) { if (!$oneself) {
$str = "<a href=\"pricereview-check.php?st=2&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; $str = "<a href=\"pricereviewCheck.php?st=2&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>";
$str .= "<br>".$data["checker_2"]."<br>".$data["checker_2_dt"]; $str .= "<br>".$data["checker_2"]."<br>".$data["checker_2_dt"];
} else { } else {
if ($data["checker_2_result"]) { if ($data["checker_2_result"]) {
@ -631,7 +631,7 @@ if ($data) :
if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 3) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST03') { if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 3) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST03') {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核"; $str = "待簽核";
$str = "<a href=\"pricereview-check.php?st=3&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; $str = "<a href=\"pricereviewCheck.php?st=3&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
} else $str = "--"; } else $str = "--";
} }
echo $str; echo $str;
@ -639,7 +639,7 @@ if ($data) :
$str = ""; $str = "";
if ($sign_st==3 && $sign_nt==$user_id) { if ($sign_st==3 && $sign_nt==$user_id) {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "<a href=\"pricereview-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; $str = "<a href=\"pricereviewCheck.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>";
} else $str = "--"; } else $str = "--";
*/ */
@ -652,7 +652,7 @@ if ($data) :
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
} }
if (!$oneself) { if (!$oneself) {
$str = "<a href=\"pricereview-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; $str = "<a href=\"pricereviewCheck.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>";
$str .= "<br>".$data["checker_3"]."<br>".$data["checker_3_dt"]; $str .= "<br>".$data["checker_3"]."<br>".$data["checker_3_dt"];
} else { } else {
if ($data["checker_3_result"]) { if ($data["checker_3_result"]) {
@ -677,7 +677,7 @@ if ($data) :
if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 4) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST05') { if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 4) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST05') {
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; $str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核"; $str = "待簽核";
$str = "<a href=\"pricereview-check.php?st=4&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; $str = "<a href=\"pricereviewCheck.php?st=4&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
} else $str = "--"; } else $str = "--";
} }
echo $str; echo $str;

12
wms/mkt/pricereview-record-submit.php

@ -1,19 +1,21 @@
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
// exit;
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
// $except_relate_facil_arr = explode(",", htmlspecialchars_decode($Exclusions_all));
// echo '<pre>';
// print_r($except_relate_facil_arr);
// echo '</pre>';
// exit;
// 同客戶同電梯不能重覆價審 // 同客戶同電梯不能重覆價審
/* /*
$warr = []; $warr = [];
$fp_id_str = ""; $fp_id_str = "";
$fp_id_arr = explode(",", $fp_id_all); $fp_id_arr = explode(",", $fp_id_all);
foreach ($fp_id_arr as $val) { // foreach ($fp_id_arr as $val) {
if ($val && $val>0) $fp_id_str .= $val.","; if ($val && $val>0) $fp_id_str .= $val.",";
} }
$fp_id_str = rtrim($fp_id_str, ","); $fp_id_str = rtrim($fp_id_str, ",");

715
wms/mkt/pricereviewCheck.php

@ -1,5 +1,120 @@
<?php <?php
include_once('../header.php'); include_once('../header.php');
require_once('./conn.php');
$id = $_GET['id'];
$sql_str = "SELECT pricereview_main.*, account.name as person_name FROM pricereview_main LEFT JOIN account ON pricereview_main.person = account.accountid WHERE pricereview_main.id = :id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id', $id);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
// print_r($contract);
$sql_str = "SELECT * FROM pricereview_pay WHERE mid = :mid ORDER BY pay_kind ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$pays = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT pricereview_item.*, option_mi.price AS option_mi FROM pricereview_item LEFT JOIN option_mi ON option_mi.option_price_id = pricereview_item.price_id WHERE pricereview_item.mid = :mid AND option_mi.open_kind = 'CO' ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid ORDER BY item_group, item_no ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT * FROM pricereview_sign WHERE mid = :mid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$sign = $stmt->fetch(PDO::FETCH_ASSOC);
$currentSigner = '';
$currentSign = 0;
// Y:已同意 N:不同意 W:待簽
// sign1 => 處長, sign2 => 業務承辦人, sign3 => 協理, sign4 => 總經理
if($sign['sign1'] == NULL || $sign['sign1'] ==''){
$sign1 = NULL;
}else{
if( explode(",", $sign['sign1'])[1] != ''){
$sign1 = explode(",", $sign['sign1'])[1] == 'Y' ? 'Y' : 'N';
}else{
$sign1 = 'W';
}
}
if($sign['sign2'] == NULL || $sign['sign2'] ==''){
$sign2 = NULL;
}else{
if( explode(",", $sign['sign2'])[1] != ''){
$sign2 = explode(",", $sign['sign2'])[1] == 'Y' ? 'Y' : 'N';
}else{
$sign2 = 'W';
}
}
if($sign['sign3'] == NULL || $sign['sign3'] ==''){
$sign3 = NULL;
}else{
if( explode(",", $sign['sign3'])[1] != ''){
// $sign3 = explode(",", $sign['sign3'])[1] == 'Y' ? 'Y' : 'N';
if(explode(",", $sign['sign3'])[1] == 'YY') $sign3 = 'YY';
if(explode(",", $sign['sign3'])[1] == 'Y') $sign3 = 'Y';
}else{
$sign3 = 'W';
}
}
if($sign['sign4'] == NULL || $sign['sign4'] ==''){
$sign4 = NULL;
}else{
if( explode(",", $sign['sign4'])[1] != ''){
// $sign4 = explode(",", $sign['sign4'])[1] == 'Y' ? 'Y' : 'N';
if(explode(",", $sign['sign4'])[1] == 'YY') $sign4 = 'YY';
if(explode(",", $sign['sign4'])[1] == 'Y') $sign4 = 'Y';
}else{
$sign4 = 'W';
}
}
if($sign1 == 'W'){
$currentSigner = explode(",", $sign['sign1'])[0];
$currentSign = 1;
}elseif($sign2 == 'W'){
$currentSigner = explode(",", $sign['sign2'])[0];
$currentSign = 2;
}elseif($sign3 == 'W'){
$currentSigner = explode(",", $sign['sign3'])[0];
$currentSign = 3;
}elseif($sign4 == 'W'){
$currentSigner = explode(",", $sign['sign4'])[0];
$currentSign = 4;
}
// $sql_str = "SELECT * FROM account WHERE accountid = :accountid";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':accountid', $sign['sign']);
// $stmt->execute();
// $account = $stmt->fetch(PDO::FETCH_ASSOC);
// $sql_str = "SELECT * FROM account WHERE accountid = :accountid";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':accountid', $account['manager']);
// $stmt->execute();
// $manager = $stmt->fetch(PDO::FETCH_ASSOC);
$permissions = false;
//開啟業務部權限
if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
$permissions = true;
}
?> ?>
<link rel="stylesheet" href="./css/pricereview.css"> <link rel="stylesheet" href="./css/pricereview.css">
@ -8,6 +123,604 @@ include_once('../header.php');
<script src="./assets/js/pricereviewAlpine.js"></script> <script src="./assets/js/pricereviewAlpine.js"></script>
<div id="pricereviewCheck" x-data=pricereviewCheck()> <div id="pricereviewCheck" x-data=pricereviewCheck()>
<div class="container">
<table class="table customerinfo-table" >
<tbody>
<tr>
<th>卷號</th>
<th>營業員</th>
<th>客戶名稱</th>
<th>牌價總額(A)</th>
<th>售價總額(B)</th>
<th >破價總額(B-A)</th>
</tr>
<tr>
<td><input type="text" class="form-control" x-model="contractno" disabled /></td>
<td><input type="text" class="form-control" x-model="person_name" disabled /></td>
<td><input type="text" class="form-control" x-model="company" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(price_lowest).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(price_total).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="(price_total - price_lowest).toLocaleString()" disabled /></td>
</tr>
</tbody>
</table>
<table class="table mi-table" border=1>
<thead>
<tr>
<th colspan=5>整機單價</th>
<?php if($permissions): ?>
<th colspan=4>業務部作業區</th>
<?php endif; ?>
</tr>
<tr>
<th>項次</th>
<th>規格</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<?php if($permissions): ?>
<th>業務部MI</th>
<th>售價</th>
<th>利潤</th>
<th>利潤率(%)</th>
<?php endif; ?>
</tr>
</thead>
<template x-for="elevator in elevators">
<tbody>
<tr>
<td x-html="'<b>' + elevator.item_no + '</b>'"></td>
<td > <a href="javascript:;" x-text="elevator.item_spec"></a></td>
<td><input type="text" class="form-control" x-model="Number(elevator.item_unit_price).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="elevator.item_qty" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(elevator.item_unit_price * elevator.item_qty).toLocaleString()" disabled /></td>
<?php if($permissions): ?>
<td>
<input x-show="isNotfoundMi" type="text" class="form-control" value="公司無此規格">
<input x-show="!isNotfoundMi" type="text" class="form-control" x-model="Math.round(Number(elevator.optionsTotalPrice) + Number(elevator.otherOptionsTotalPrice) + Number(elevator.maintainOptionsTotalPrice) + Number(elevator.totalMi * elevator.item_qty)).toLocaleString() " disabled />
</td>
<td><input type="text" class="form-control" x-model="Number(elevator.item_price_ct).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="(elevator.item_price_ct - Math.round(Number(elevator.optionsTotalPrice) + Number(elevator.otherOptionsTotalPrice) + Number(elevator.maintainOptionsTotalPrice) + Number(elevator.totalMi * elevator.item_qty))).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Math.round((elevator.item_price_ct - Math.round(Number(elevator.optionsTotalPrice) + Number(elevator.otherOptionsTotalPrice) + Number(elevator.maintainOptionsTotalPrice) + Number(elevator.totalMi * elevator.item_qty))) / elevator.item_price_ct *1000) /10 + '%'" disabled /></td>
<?php endif; ?>
</tr>
<?php if($permissions): ?>
<tr>
<td colspan=5></td>
<td colspan=4>
<div class="mi-info">
<span>電梯設備</span>
<ul>
<li x-html="'設備1.0:<b>' + (elevator.mi.equipment_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'報關+運輸費:<b>' + (elevator.mi.customs_shipping_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'工廠卸貨:<b>' + (elevator.mi.unloading_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'運輸至工地:<b>' + (elevator.mi.transport_site_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'安裝成本:<b>' + (elevator.mi.install_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'一年免保:<b>' + (elevator.mi.free1y_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'起吊+木箱+耗材:<b>' + (elevator.mi.other_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
</ul>
<p x-html="'以上合計:<b>' + (elevator.totalMi * elevator.item_qty).toLocaleString() + '</b>'"></p>
<div class="line"></div>
<span>OPTION</span>
<ul>
<template x-for="option in elevator.options">
<li x-html="option.item_spec + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
</template>
<template x-for="option in elevator.otherOptions">
<li x-html="option.item_spec + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
</template>
<template x-for="option in elevator.maintainOptions">
<li x-html="option.item_spec + '(' + option.item_qty + '月):<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
</template>
</ul>
<p x-html="'以上合計:<b>' + (Math.round(Number(elevator.optionsTotalPrice) + Number(elevator.otherOptionsTotalPrice) + Number(elevator.maintainOptionsTotalPrice))).toLocaleString() + '</b>'"></p>
</div>
</td>
</tr>
<?php endif ;?>
</tbody>
</template>
<tr>
<td colspan=4>小計</td>
<td><input type="text" class="form-control" x-model="elevators_total_price.toLocaleString()" disabled></td>
</tr>
</table>
<table class="table mi-table" border=1>
<thead>
<tr>
<th colspan=8>OPTION 加價</th>
</tr>
<tr>
<th>項次</th>
<th>OPTION ID</th>
<th>名稱</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<th>備註</th>
<th>所屬電梯項次</th>
</tr>
</thead>
<tbody>
<template x-for="option in options">
<tr>
<td x-html="'<b>' + option.item_no + '</b>'"></td>
<td x-text="option.price_id"></td>
<td><input type="text" class="form-control" x-model="option.item_spec" disabled /></td>
<td><input type="text" class="form-control" x-model="option.item_unit_price.toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="option.item_qty" disabled /></td>
<td><input type="text" class="form-control" x-model="(option.item_unit_price * option.item_qty).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="option.memo" disabled /></td>
<td x-text="option.option_relate_spec"></td>
</tr>
</template>
<tr>
<td colspan=5>小計</td>
<td >
<input type="text" x-model="optionsTotalPrice().toLocaleString()" disabled class="form-control">
</td>
<td colspan=3></td>
</tr>
</tbody>
</table>
<table class="table mi-table" border=1>
<thead>
<tr>
<th colspan=8>除外項目</th>
</tr>
<tr>
<th>項次</th>
<th>詢價單號</th>
<th>名稱</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<th>所屬電梯項次</th>
</tr>
</thead>
<tbody>
<template x-for="option in otherOptions">
<tr>
<td x-html="'<b>' + option.item_no + '</b>'"></td>
<td x-text="option.price_id"></td>
<td><input type="text" class="form-control" x-model="option.item_spec" disabled /></td>
<td><input type="text" class="form-control" x-model="option.item_unit_price.toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="option.item_qty" disabled /></td>
<td><input type="text" class="form-control" x-model="(option.item_unit_price * option.item_qty).toLocaleString()" disabled /></td>
<td x-text="option.option_relate_spec"></td>
</tr>
</template>
<tr>
<td colspan=5>小計</td>
<td >
<input type="text" x-model="otherOptionsTotalPrice().toLocaleString()" disabled class="form-control">
</td>
<td colspan=3></td>
</tr>
</tbody>
</table>
<table class="table mi-table" border=1>
<thead>
<tr>
<th colspan=8>保固延長</th>
</tr>
<tr>
<th>項次</th>
<th>規格</th>
<th>單價</th>
<th>數量(月)</th>
<th>複價</th>
<th>備註</th>
<th>所屬電梯項次</th>
</tr>
</thead>
<tbody>
<template x-for="option in maintainOptions">
<tr>
<td x-text="option.item_no"></td>
<td x-text="option.item_spec"></td>
<td x-text="option.item_unit_price.toLocaleString()"></td>
<td x-text="option.item_qty"></td>
<td x-text="(option.item_qty * option.item_unit_price).toLocaleString()"></td>
<td x-text="option.memo"></td>
<td x-text="option.option_relate_spec"></td>
</tr>
</template>
<tr>
<td colspan=4>小計</td>
<td >
<input type="text" x-model="maintainOptionsTotalPrice().toLocaleString()" disabled class="form-control">
</td>
<td colspan=2></td>
</tr>
</tbody>
</table>
<table class="table mi-table" border=1 style="width:800px">
<thead>
<tr>
<th>付款辦法</th>
<th>款別</th>
<th>比例(%)</th>
<th>金額</th>
<th>票期</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4">材料</td>
<td>1.訂金</td>
<td><input type="text" class="form-control" x-model="pays[0].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[0].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[0].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60</option>
<option value="90">90</option>
<option value="120">120</option>
<option value="150">150</option>
<option value="180">180</option>
</select>
</td>
</tr>
<tr>
<td>2.二次款</td>
<td><input type="text" class="form-control" x-model="pays[1].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[1].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[1].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60天</option>
<option value="90">90天</option>
<option value="120">120天</option>
<option value="150">150天</option>
<option value="180">180天</option>
</select>
</td>
</tr>
<tr>
<td>3.貨到工地款</td>
<td><input type="text" class="form-control" x-model="pays[2].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[2].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[2].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60天</option>
<option value="90">90天</option>
<option value="120">120天</option>
<option value="150">150天</option>
<option value="180">180天</option>
</select>
</td>
</tr>
<tr>
<td>4.其他</td>
<td><input type="text" class="form-control" x-model="pays[3].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[3].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[3].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60天</option>
<option value="90">90天</option>
<option value="120">120天</option>
<option value="150">150天</option>
<option value="180">180天</option>
</select>
</td>
</tr>
<tr>
<td rowspan=3>材料</td>
<td>5.安裝完畢款</td>
<td><input type="text" class="form-control" x-model="pays[4].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[4].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[4].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60天</option>
<option value="90">90天</option>
<option value="120">120天</option>
<option value="150">150天</option>
<option value="180">180天</option>
</select>
</td>
</tr>
<tr>
<td>6.驗收款</td>
<td><input type="text" class="form-control" x-model="pays[5].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[5].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[5].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60天</option>
<option value="90">90天</option>
<option value="120">120天</option>
<option value="150">150天</option>
<option value="180">180天</option>
</select>
</td>
</tr>
<tr>
<td>7.尾款</td>
<td><input type="text" class="form-control" x-model="pays[6].pay_scale" disabled /></td>
<td><input type="text" class="form-control" x-model="pays[6].pay_amount.toLocaleString()" disabled /></td>
<td>
<select class="form-control" name="" id="" disabled x-model="pays[6].pay_period">
<option value=""></option>
<option value="7">7天</option>
<option value="30" selected>30天</option>
<option value="60">60天</option>
<option value="90">90天</option>
<option value="120">120天</option>
<option value="150">150天</option>
<option value="180">180天</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">合計</td>
<td><input type="text" class="form-control" x-model="totalScale()" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(price_total).toLocaleString()" disabled /></td>
<td></td>
</tr>
<tr>
<td colspan="2">備註</td>
<td colspan="3"><textarea name="" id="" cols="30" rows="5" class="form-control" disabled></textarea></td>
</tr>
</tbody>
</table>
<table class="table customerinfo-table" >
<tbody>
<tr>
<th>卷號</th>
<th>營業員</th>
<th>客戶名稱</th>
<th>案件名稱</th>
<th colspan="2">地址</th>
</tr>
<tr>
<td><input type="text" class="form-control" x-model="contractno" disabled /></td>
<td><input type="text" class="form-control" x-model="person_name" disabled /></td>
<td><input type="text" class="form-control" x-model="company" disabled /></td>
<td><input type="text" class="form-control" x-model="case_name" disabled /></td>
<td colspan="2"><input type="text" class="form-control" x-model="address" disabled /></td>
</tr>
<tr>
<th>牌價總額(A)</th>
<th>售價總額(B)</th>
<th>破價總額(B-A)</th>
<th>總台數</th>
<th>服務費(介紹費)</th>
<th>價率%(B/A)</th>
</tr>
<tr>
<td><input type="text" class="form-control" x-model="Number(price_lowest).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(price_total).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="(price_total - price_lowest).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="qty" disabled /></td>
<td><input type="text" class="form-control" x-model="special_fee.toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Math.round(price_total/price_lowest * 1000)/10" disabled /></td>
</tr>
<tr>
<th>預定成交日</th>
<th>預訂出貨日</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<td><input type="date" disabled class="form-control" x-model="predeal_date" /></td>
<td><input type="date" disabled class="form-control" x-model="facilitok_date" /></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>罰則</th>
<th>訂金保證金(函)%</th>
<th>履約保證金(函)%</th>
<th>保固保證金(函)%</th>
<th></th>
<th></th>
</tr>
<tr>
<td><input type="text" disabled class="form-control" x-model="penalty"></td>
<td><input type="text" disabled class="form-control" x-model="deposit_rate"></td>
<td><input type="text" disabled class="form-control" x-model="keep_rate"></td>
<td><input type="text" disabled class="form-control" x-model="warranty_rate"></td>
<td></td>
<td></td>
</tr>
<tr>
<th colspan="6">特記事項</th>
</tr>
<tr>
<td colspan="6">
<textarea name="" id="" cols="30" rows="5" class="form-control" x-model="memo" disabled></textarea>
</td>
</tr>
</tbody>
</table>
<li>營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。</li>
<table class="table" style="width:700px">
<thead>
<tr>
<th>審核</th>
<th>審核人</th>
<th>結果</th>
<th>意見</th>
<th>時間</th>
</tr>
</thead>
<tbody>
<tr>
<td>區經理</td>
<td><?php echo explode(',', $sign['sign1'])[0] ?></td>
<td>
<?php
if($sign1 == 'Y'){
echo "同意";
}elseif($sign1 == 'N'){
echo "不同意";
}elseif($sign1 == 'W'){
echo "待簽核";
}else{
echo "---";
}
?>
</td>
<td><?php echo $sign['sign1_note'] ?></td>
<td><?php echo explode(',', $sign['sign1'])[2] ?></td>
</tr>
<tr>
<td>業務承辦人</td>
<td><?php echo $sign['sign2']!=NULL ? explode(',', $sign['sign2'])[0] : '---' ?></td>
<td>
<?php
if($sign2 == 'Y'){
echo "同意";
}elseif($sign2 == 'N'){
echo "不同意";
}elseif($sign2 == 'W'){
echo "待簽核";
}else{
echo "---";
}
?>
</td>
<td><?php echo $sign['sign2']!=NULL ? $sign['sign2_note'] : '---'?></td>
<td><?php echo $sign['sign2']!=NULL ? explode(',', $sign['sign2'])[2] : '---' ?></td>
</tr>
<tr>
<td>業務部協理</td>
<td><?php echo $sign['sign3']!=NULL ? explode(',', $sign['sign3'])[0] : '---' ?></td>
<td>
<?php
if($sign3 == 'Y'){
echo "同意";
}elseif($sign3 == 'YY'){
echo "結案同意";
}elseif($sign3 == 'N'){
echo "不同意";
}elseif($sign3 == 'W'){
echo "待簽核";
}else{
echo "---";
}
?>
</td>
<td><?php echo $sign['sign3']!=NULL ? $sign['sign3_note'] : '---'?></td>
<td><?php echo $sign['sign3']!=NULL ? explode(',', $sign['sign3'])[2] : '---' ?></td>
</tr>
<tr>
<td>總經理</td>
<td><?php echo $sign['sign4']!=NULL ? explode(',', $sign['sign4'])[0] : '---' ?></td>
<td>
<?php
if($contract['status'] == 'YY'){
if($sign3 == 'YY'){
echo "---";
}elseif($sign3 == 'Y' && $sign4 == 'YY'){
echo "結案同意";
}
}else{
if($sign4 == 'Y'){
echo "同意";
}elseif($sign4 == 'N'){
echo "不同意";
}elseif($sign4 == 'W'){
echo "待簽核";
}else{
echo "---";
}
}
?>
</td>
<td><?php echo $sign['sign4']!=NULL ? $sign['sign4_note'] : '---'?></td>
<td><?php echo $sign['sign4']!=NULL ? explode(',', $sign['sign4'])[2] : '---' ?></td>
</tr>
</tbody>
</table>
<table class="table" style="width:700px">
<thead>
<tr>
<th>審核意見</th>
<th>批示售價</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<textarea name="" class="form-control" id="" cols="40" rows="5"></textarea>
</td>
<td>
<input type="text" class="form-control" disabled />
</td>
</tr>
</tbody>
</table>
<div>
<button class="btn btn-primary" @click="window.history.go(-1)">回上頁</button>
<?php if($contract['status'] == "YS"){ ?>
<?php if($currentSigner == $user_id): ?>
<button class="btn btn-primary" @click="check(<?php echo $currentSign; ?>, 'YN')">不同意(退回)</button>
<?php if($sign4 =='W' && $sign3 == 'W'): ?>
<button class="btn btn-primary" @click="check(<?php echo $currentSign; ?>, 'YS')">同意(上呈)</button>
<?php endif ; ?>
<button class="btn btn-primary" @click="check(<?php echo $currentSign; ?>, 'YY')">同意(結案)</button>
<?php endif; ?>
<?php } ?>
<button class="btn btn-primary">下載報價單</button>
<button class="btn btn-primary">下載附表一</button>
</div>
</div>
</div>
<script>
const mid = <?php echo $contract['id']; ?>;
const contractno = '<?php echo $contract['contractno']; ?>';
const person_name = '<?php echo $contract['person_name']; ?>';
const company = '<?php echo $contract['company']; ?>';
const case_name = '<?php echo $contract['case_name']; ?>';
const address = '<?php echo $contract['address']; ?>';
const price_lowest = '<?php echo $contract['price_lowest']; ?>';
const price_total = '<?php echo $contract['price_total']; ?>';
const special_fee = '<?php echo $contract['special_fee']; ?>';
const predeal_date = '<?php echo $contract['predeal_date']; ?>';
const facilitok_date = '<?php echo $contract['facilitok_date']; ?>';
const penalty = '<?php echo $contract['penalty']; ?>';
const deposit_rate = '<?php echo $contract['deposit_rate']; ?>';
const keep_rate = '<?php echo $contract['keep_rate']; ?>';
const warranty_rate = '<?php echo $contract['warranty_rate']; ?>';
const memo = '<?php echo $contract['memo']; ?>';
const pays = [...<?php echo json_encode($pays); ?>];
const items = [...<?php echo json_encode($items); ?>];
const options = [...<?php echo json_encode($options); ?>];
const is_renovate = '<?php echo $contract['ekind']; ?>';
</div> const user_id = '<?php echo $user_id; ?>';
</script>

77
wms/mkt/pricereview_mi-api.php

@ -88,11 +88,10 @@ try {
$special_fee = $row[0]; $special_fee = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
$specarr[0] = "服務費"; $specarr[0] = "服務費";
if($elev_qty_all == 0 ){ if ($elev_qty_all == 0) {
$specarr[1] = 0; $specarr[1] = 0;
$specarr[1] = round($special_fee / 1, 0); $specarr[1] = round($special_fee / 1, 0);
} else {
}else{
$specarr[1] = round($special_fee / $elev_qty_all, 0); $specarr[1] = round($special_fee / $elev_qty_all, 0);
} }
@ -135,7 +134,7 @@ try {
$sql = "select id, item_spec, item_price_bp, option_relate_spec, item_qty from pricereview_item where mid = '$id' and item_group = 'D'"; $sql = "select id, item_spec, item_price_bp, option_relate_spec, item_qty from pricereview_item where mid = '$id' and item_group = 'D'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
if($row[4] == 0){ if ($row[4] == 0) {
continue; continue;
} }
$mn_elev_arr[$row[0]]["item_spec"] = $row[1]; $mn_elev_arr[$row[0]]["item_spec"] = $row[1];
@ -156,14 +155,14 @@ try {
$sql = "select id, item_spec, item_price_bp, item_qty from pricereview_item where mid = '$id' and item_group = 'E'"; $sql = "select id, item_spec, item_price_bp, item_qty from pricereview_item where mid = '$id' and item_group = 'E'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
if($row[3] == 0){ if ($row[3] == 0) {
continue; continue;
} }
$exarr[$j][0] = $row[1]; $exarr[$j][0] = $row[1];
if($elev_qty_all == 0 || false){ if ($elev_qty_all == 0 || false) {
$exarr[$j][1] = 0; $exarr[$j][1] = 0;
$specarr[1] = round($special_fee / 1, 0); $specarr[1] = round($special_fee / 1, 0);
}else{ } else {
$exarr[$j][1] = round($row[2] / $elev_qty_all, 0); $exarr[$j][1] = round($row[2] / $elev_qty_all, 0);
} }
$ex_fee += $exarr[$j][1]; $ex_fee += $exarr[$j][1];
@ -178,7 +177,7 @@ try {
$sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'"; $sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'";
$res_i = mysqli_query($link, $sql3); $res_i = mysqli_query($link, $sql3);
while ($row_i = mysqli_fetch_assoc($res_i)) { while ($row_i = mysqli_fetch_assoc($res_i)) {
if($row_i[1] == 0){ if ($row_i[1] == 0) {
continue; continue;
} }
$sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' "; $sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' ";
@ -193,10 +192,10 @@ try {
} }
mysqli_free_result($res_i); mysqli_free_result($res_i);
} }
if($elev_qty_all == 0 || false){ if ($elev_qty_all == 0 || false) {
$dismantle_fee = round($dismantle_amt / 1, 0); $dismantle_fee = round($dismantle_amt / 1, 0);
$polishing_fee = round($polishing_amt / 1, 0); $polishing_fee = round($polishing_amt / 1, 0);
}else{ } else {
$dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); $dismantle_fee = round($dismantle_amt / $elev_qty_all, 0);
$polishing_fee = round($polishing_amt / $elev_qty_all, 0); $polishing_fee = round($polishing_amt / $elev_qty_all, 0);
} }
@ -210,8 +209,8 @@ try {
// echo json_encode($elev_arr); // echo json_encode($elev_arr);
require_once("./conn.php"); require_once("./conn.php");
// echo json_encode($elev_arr); // echo json_encode($elev_arr);
foreach ((Array)$elev_arr as $item_no => $v) { foreach ((array)$elev_arr as $item_no => $v) {
if($item_no == ""){ if ($item_no == "") {
continue; continue;
} }
// 電梯MI // 電梯MI
@ -220,11 +219,13 @@ try {
$floor = $v['floors']; $floor = $v['floors'];
$speed = $v['speed']; $speed = $v['speed'];
$min_weight = $v['item_weight']; $min_weight = $v['item_weight'];
$sql_str = "SELECT elevator_mi_option.*,elevator_quotation_rule.* FROM elevator_mi_option $sql_str = "SELECT elevator_mi_option.*,elevator_quotation_rule.* FROM elevator_mi_option
JOIN elevator_quotation_rule ON elevator_mi_option.quotation_no = elevator_quotation_rule.quotation_no JOIN elevator_quotation_rule ON elevator_mi_option.quotation_no = elevator_quotation_rule.quotation_no
WHERE elevator_mi_option.elevator_type = :elevator_type AND WHERE elevator_mi_option.elevator_type = :elevator_type AND
elevator_mi_option.min_weight = :min_weight AND elevator_mi_option.min_speed = :speed elevator_mi_option.min_weight = :min_weight AND elevator_mi_option.min_speed = :speed
AND elevator_mi_option.quotation_no = :quotation_no"; AND elevator_mi_option.quotation_no = :quotation_no";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $elevator_type); $stmt->bindParam(':elevator_type', $elevator_type);
$stmt->bindParam(':speed', $speed); $stmt->bindParam(':speed', $speed);
@ -247,8 +248,7 @@ try {
if ($row_e) { if ($row_e) {
// 加價:先不納入 // 加價:先不納入
$row_e["option_price"] = 0; $row_e["option_price"] = 0;
if(!isset($row_e["purchase_cost"])){ if (!isset($row_e["purchase_cost"])) {
} }
// 基准采购成本+±1停材料费+设计费+出口费用 // 基准采购成本+±1停材料费+设计费+出口费用
$part1 = $row_e["purchase_cost"] + ($v["floors"] - $row_e["base_floor"]) * $row_e["material_plus"] + $row_e["design"] * $row_e["design_hour"] + $row_e["export_fee"]; $part1 = $row_e["purchase_cost"] + ($v["floors"] - $row_e["base_floor"]) * $row_e["material_plus"] + $row_e["design"] * $row_e["design_hour"] + $row_e["export_fee"];
@ -258,7 +258,9 @@ try {
// 設備 // 設備
$equipment_ntd = round(($part1 + $profit) * $row_e["equipment"], 0); $equipment_ntd = round(($part1 + $profit) * $row_e["equipment"], 0);
// 報關+運輸 // 報關+運輸
$customs = round($equipment_ntd * $row_e["shipping"], 0) + $row_e["customs_shipping"]; // $customs = round($equipment_ntd * $row_e["shipping"], 0) + $row_e["customs_shipping"];
$customs = round($equipment_ntd * $row_e["shipping"], 0);
// 安裝基價 // 安裝基價
$install_base = $row_e["install_price"] + $row_e["trial_price"] + $row_e["install_coef"] * $row_e["install_plus"] + $row_e["trial_coef"] * $row_e["trial_plus"]; $install_base = $row_e["install_price"] + $row_e["trial_price"] + $row_e["install_coef"] * $row_e["install_plus"] + $row_e["trial_coef"] * $row_e["trial_plus"];
// 安裝成本 // 安裝成本
@ -318,7 +320,7 @@ try {
$todo_opt_arr = $v["option"]; $todo_opt_arr = $v["option"];
if (empty($todo_opt_arr)) $todo_opt_arr = $opt_nosel_id_arr; if (empty($todo_opt_arr)) $todo_opt_arr = $opt_nosel_id_arr;
if (!empty($todo_opt_arr)) { if (!empty($todo_opt_arr)) {
foreach ($todo_opt_arr as $val) { foreach ($todo_opt_arr as $val) {
$sql4 = "select o.base_floor, o.base_floor_plus, o.price, r.equipment, p.price 'OP' "; $sql4 = "select o.base_floor, o.base_floor_plus, o.price, r.equipment, p.price 'OP' ";
$sql4 .= "from option_mi o, elevator_quotation_rule r, option_price p "; $sql4 .= "from option_mi o, elevator_quotation_rule r, option_price p ";
$sql4 .= "where o.quotation_no = r.quotation_no and o.option_price_id = p.id "; $sql4 .= "where o.quotation_no = r.quotation_no and o.option_price_id = p.id ";
@ -339,7 +341,7 @@ try {
AND option_mi.open_kind = '" . $v["item_op"] . "'"; AND option_mi.open_kind = '" . $v["item_op"] . "'";
$res_om = mysqli_query($link, $sql4); $res_om = mysqli_query($link, $sql4);
if ($row_om = mysqli_fetch_assoc($res_om)) { if ($row_om = mysqli_fetch_assoc($res_om)) {
$row_om['price'] = (int)ceil($row_om['price']); $row_om['price'] = (int)ceil($row_om['price']);
$plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"]) * $row_om["base_floor_plus"] : 0; $plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"]) * $row_om["base_floor_plus"] : 0;
@ -446,8 +448,8 @@ try {
$mi_arr[$i][19] = $specarr; $mi_arr[$i][19] = $specarr;
$i++; $i++;
} }
}else{ } else {
$rarr['err'] = "notfoundmi"; $rarr['err'] = "notfoundmi";
} }
// mysqli_free_result($res_e); // mysqli_free_result($res_e);
} }
@ -479,46 +481,46 @@ try {
$exceptArr = []; $exceptArr = [];
foreach($items as $item){ foreach ($items as $item) {
if($item['option_relate_spec'] != NULL){ if ($item['option_relate_spec'] != NULL) {
$exceptArr[] = [ $exceptArr[] = [
'option_relate_spec'=> $item['option_relate_spec'], 'option_relate_spec' => $item['option_relate_spec'],
'item_spec'=>$item['item_spec'], 'item_spec' => $item['item_spec'],
'item_unit_price'=>$item['item_unit_price'], 'item_unit_price' => $item['item_unit_price'],
'item_qty'=>$item['item_qty'], 'item_qty' => $item['item_qty'],
'item_price_bp'=> $item['item_price_bp'], 'item_price_bp' => $item['item_price_bp'],
]; ];
} }
} }
// $rarr["content"][] = $exceptArr; // $rarr["content"][] = $exceptArr;
// print_r($rarr["content"]);
foreach($rarr["content"] as $idx=>&$item){ // exit;
foreach ($rarr["content"] as $idx => &$item) {
$newTotal = 0; $newTotal = 0;
$item[16] = []; $item[16] = [];
$item[14] = []; $item[14] = [];
foreach($exceptArr as $except){ foreach ($exceptArr as $except) {
if($idx+1 == $except['option_relate_spec']){ if ($idx + 1 == $except['option_relate_spec']) {
$item[16][] = [ $item[16][] = [
$except['item_spec'], $except['item_spec'],
$except['item_unit_price']* $except['item_qty'] $except['item_unit_price'] * $except['item_qty']
]; ];
} }
} }
foreach($itemoptions as $itemoption){ foreach ($itemoptions as $itemoption) {
if($idx+1 == $itemoption['option_relate_spec']){ if ($idx + 1 == $itemoption['option_relate_spec']) {
$item[14][] = [ $item[14][] = [
$itemoption['item_spec'], $itemoption['item_spec'],
round($itemoption['option_mi'] * $itemoption['item_qty'], 0), round($itemoption['option_mi'] * $itemoption['item_qty'], 0),
]; ];
} }
}
}
foreach($item[14] as $option){ foreach ($item[14] as $option) {
$newTotal += $option[1]; $newTotal += $option[1];
} }
foreach($item[16] as $ex){ foreach ($item[16] as $ex) {
$newTotal += $ex[1]; $newTotal += $ex[1];
} }
$newTotal += $item[17]; $newTotal += $item[17];
@ -526,7 +528,6 @@ try {
$item[13] = $newTotal; $item[13] = $newTotal;
} }
} catch (\Exception $e) { } catch (\Exception $e) {
$rarr['st'] = 'err'; $rarr['st'] = 'err';
$rarr['err'] = $e->getMessage(); $rarr['err'] = $e->getMessage();

2
wms/mkt/pricereview_repair-check.php

@ -1,6 +1,6 @@
<?php <?php
include "../header.php"; include "../header.php";
require_once '../cont/wf_common.php'; require_once '../crm/wf_common.php';
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : ""; $form_key = isset($_GET['form_key']) ? $_GET['form_key'] : "";
if ($form_key == "") $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); if ($form_key == "") $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');

15
wms/mkt/pricereview_repair-create.php

@ -1,6 +1,6 @@
<?php <?php
include "../header.php"; include "../header.php";
require_once '../cont/wf_common.php'; require_once '../crm/wf_common.php';
// 報價單編號 // 報價單編號
$repair_no_a = date("Ymd"); $repair_no_a = date("Ymd");
@ -270,6 +270,15 @@ $assign_status = '<option value="FH">指派</option>'
$('#tb1 tr:last').prev().prev().prev().after($("tr[name='main_templ']").last().clone().find('input').val('').end()); $('#tb1 tr:last').prev().prev().prev().after($("tr[name='main_templ']").last().clone().find('input').val('').end());
$('#tb1 tr:last').prev().prev().prev().find('td a[name=item_href]').html('點選'); $('#tb1 tr:last').prev().prev().prev().find('td a[name=item_href]').html('點選');
}); });
$("a[name=filedel]").hide();
$("input[name=attatch1]").change(function() {
if ($(this).val() != "") $("a[name=filedel]").show();
});
$("a[name=filedel]").click(function() {
$("input[name=attatch1]").val("");
$(this).hide();
});
// 點擊服務費會出現 or 消失 input 框 // 點擊服務費會出現 or 消失 input 框
// $('#btnadd-sc').click(function() { // $('#btnadd-sc').click(function() {
// $('#service_charge_tr').toggle(); // $('#service_charge_tr').toggle();
@ -537,6 +546,10 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
</table> </table>
</div> </div>
<div class="nextline"></div>
<label for="attatch1">報價單</label>
<input type="file" name="attatch1" id="attatch1"><a href="javascript:void(0);" name="filedel" class="btn btn-danger btn-sm">X</a>
<div class="nextline"></div> <div class="nextline"></div>
<div class="table-responsive"> <div class="table-responsive">

27
wms/mkt/pricereview_repair-record-submit.php

@ -21,11 +21,34 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$new_repair_no = $repair_no_a . $serial; $new_repair_no = $repair_no_a . $serial;
if ($new_repair_no != $repair_no) $repair_no = $new_repair_no; if ($new_repair_no != $repair_no) $repair_no = $new_repair_no;
// 附件上傳
$target_dir = "pricereview-uploads/";
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$target_file1 = $target_dir . $vol_no . "-price-" . $tds . "." . $img_file_type;
$upload_ok = 1;
foreach (glob($target_dir . $repair_no . "-price-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
} else $target_file1 = "";
if (($target_file1 && !$upload_res_1)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建。');";
echo "history.go(-1);";
echo "</script>";
exit;
}
// 價審單-主文 pricereview_repair_main // 價審單-主文 pricereview_repair_main
$db_query = "INSERT INTO pricereview_repair_main(repair_no, contractno, masada_addr, company, taxid, invoice, facilityno, "; $db_query = "INSERT INTO pricereview_repair_main(repair_no, contractno, masada_addr, company, taxid, invoice, facilityno, ";
$db_query .= "address, sales_tax, service_charge, total_price, sign_date, memo, repairerid, pstatus, checker, creater, create_at) values ("; $db_query .= "address, sales_tax, service_charge, total_price, sign_date, memo, repairerid, pstatus, checker, creater, create_at,file) values (";
$db_query .= "'$repair_no', '$contractno', '$masada_addr', '$company', '$taxid', '$invoice', '$facilityno', "; $db_query .= "'$repair_no', '$contractno', '$masada_addr', '$company', '$taxid', '$invoice', '$facilityno', ";
$db_query .= "'$address', $sales_tax ,$service_charge ,$total_price, '$sign_date', '$memo', '$repairerid', 'A', '$next_users', '$user_id', '$create_at')"; $db_query .= "'$address', $sales_tax ,$service_charge ,$total_price, '$sign_date', '$memo', '$repairerid', 'A', '$next_users', '$user_id', '$create_at','$target_file1')";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
if ($rid = mysqli_insert_id($link)) { if ($rid = mysqli_insert_id($link)) {

3
wms/rib01-check.php

@ -358,7 +358,8 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($pay_data as $pay) : ?> <?php
foreach ($pay_data as $pay) : ?>
<tr> <tr>
<td><?= $pay['FeeDate'] ?></td> <td><?= $pay['FeeDate'] ?></td>
<td><?= round($pay['Quantity']) ?></td> <td><?= round($pay['Quantity']) ?></td>

22
wms/rib01-edit.php

@ -159,11 +159,13 @@ if ($pay_data) {
<select name="WriteOffId" id="WriteOffId" class="form-control" required> <select name="WriteOffId" id="WriteOffId" class="form-control" required>
<option value="" id="WriteOffOption">請選擇報銷人</option> <option value="" id="WriteOffOption">請選擇報銷人</option>
<?php <?php
foreach ($member as $key => $value) { ?> if (is_iterable($member)) {
<option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) { foreach ($member as $key => $value) { ?>
echo "selected"; <option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) {
} ?>> <?php echo $value[0]; ?> </option> echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php } <?php }
}
?> ?>
</select> </select>
</div> </div>
@ -187,12 +189,14 @@ if ($pay_data) {
echo "disabled"; echo "disabled";
} ?>> } ?>>
<?php <?php
foreach ($member as $key => $value) { if (is_iterable($member)) {
foreach ($member as $key => $value) {
?> ?>
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . $value[0] ?>" <?php if ($key == $data['GatheringPersonId']) { <option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . $value[0] ?>" <?php if ($key == $data['GatheringPersonId']) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php }; ?> <?php }
}; ?>
</select> </select>
</div> </div>

150
wms/rib01-index.php

@ -105,81 +105,87 @@ if ($data) :
</thead> </thead>
<tbody> <tbody>
<?php foreach ($data as $data) : ?> <?php
<tr> if (is_iterable($data)) {
<td><?php echo $data['BillNo']; ?></td> foreach ($data as $data) : ?>
<td><?php echo substr($data['BillDate'], 0, 10); ?></td> <tr>
<td><?php if ($data['pay_type'] == 0) { <td><?php echo $data['BillNo']; ?></td>
echo "現金"; <td><?php echo substr($data['BillDate'], 0, 10); ?></td>
} elseif ($data['pay_type'] == 1) { <td><?php if ($data['pay_type'] == 0) {
echo "銀行轉帳"; echo "現金";
}; ?></td> } elseif ($data['pay_type'] == 1) {
<td><?php echo accountidToName($data['TransactId']); ?></td> echo "銀行轉帳";
<td><?php foreach ($deptype as $dept) { }; ?></td>
if ($data["DeptId"] == $dept['department_id']) { <td><?php echo accountidToName($data['TransactId']); ?></td>
echo $dept['name']; <td><?php
break; if (is_iterable($deptype)) {
} foreach ($deptype as $dept) {
} ?></td> if ($data["DeptId"] == $dept['department_id']) {
<td><?php echo accountidToName($data['WriteOffId']); ?></td> echo $dept['name'];
<td><?php if ($data['CurrId'] == "USD") : echo "美金"; break;
elseif ($data['CurrId'] == "TWD") : echo "台幣"; }
elseif ($data['CurrId'] == "CNY") : echo "人民幣"; }
elseif ($data['CurrId'] == "HKD") : echo "港幣"; } ?></td>
elseif ($data['CurrId'] == "EUR") : echo "歐元"; <td><?php echo accountidToName($data['WriteOffId']); ?></td>
endif; ?> </td> <td><?php if ($data['CurrId'] == "USD") : echo "美金";
<?php elseif ($data['CurrId'] == "TWD") : echo "台幣";
if (($user_id == "M0056" || $user_id == "M0209")) { ?> elseif ($data['CurrId'] == "CNY") : echo "人民幣";
<td><?php echo $data['OAmountWithTax']; ?> </td> elseif ($data['CurrId'] == "HKD") : echo "港幣";
<?php } ?> elseif ($data['CurrId'] == "EUR") : echo "歐元";
<td><?php if ($data['CurrentState'] == 0) : echo "草稿"; endif; ?> </td>
elseif ($data['CurrentState'] == 1) : echo "審核中"; <?php
elseif ($data['CurrentState'] == 2) : echo "通過"; if (($user_id == "M0056" || $user_id == "M0209")) { ?>
elseif ($data['CurrentState'] == 3) : echo "作廢"; <td><?php echo $data['OAmountWithTax']; ?> </td>
elseif ($data['CurrentState'] == 5) : echo "退回"; <?php } ?>
else : echo "結案"; <td><?php if ($data['CurrentState'] == 0) : echo "草稿";
endif ?> elseif ($data['CurrentState'] == 1) : echo "審核中";
</td> elseif ($data['CurrentState'] == 2) : echo "通過";
<td> elseif ($data['CurrentState'] == 3) : echo "作廢";
<p> elseif ($data['CurrentState'] == 5) : echo "退回";
<?php if (($user_id == "M0056" || $user_id == "M0209") && $data['CurrentState'] == 1) { else : echo "結案";
?> endif ?>
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-success btn-sm"> </td>
<span class="glyphicon glyphicon-pawn"></span> <td>
</a> <p>
<?php <?php if (($user_id == "M0056" || $user_id == "M0209") && $data['CurrentState'] == 1) {
} else { ?> ?>
<?php if ($data['CurrentState'] == 0) : ?> <a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-success btn-sm">
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=0&<?= $token_link ?>" class="btn btn-warning btn-sm"> <span class="glyphicon glyphicon-pawn"></span>
<span class="glyphicon glyphicon-pencil"></span>
</a> </a>
<?php elseif ($data['CurrentState'] == 1) : ?> <?php
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-primary btn-sm"> } else { ?>
<span class=" glyphicon glyphicon-search"></span> <?php if ($data['CurrentState'] == 0) : ?>
</a> <a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=0&<?= $token_link ?>" class="btn btn-warning btn-sm">
<button type="button" onclick="download(<?= $data['rib_id'] ?>)" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-download-alt"></span></button> <span class="glyphicon glyphicon-pencil"></span>
<!-- <a href="rib03-download.php?id=<?php echo $data['rib_id'] ?>&<?= $token_link ?>" class="btn btn-info btn-sm"> </a>
<?php elseif ($data['CurrentState'] == 1) : ?>
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=1&<?= $token_link ?>" class="btn btn-primary btn-sm">
<span class=" glyphicon glyphicon-search"></span>
</a>
<button type="button" onclick="download(<?= $data['rib_id'] ?>)" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-download-alt"></span></button>
<!-- <a href="rib03-download.php?id=<?php echo $data['rib_id'] ?>&<?= $token_link ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-download-alt"></span> <span class="glyphicon glyphicon-download-alt"></span>
</a> --> </a> -->
<?php elseif ($data['CurrentState'] == 2) : ?> <?php elseif ($data['CurrentState'] == 2) : ?>
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-info btn-sm"> <a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-info btn-sm">
<span class=" glyphicon glyphicon-ok"></span> <span class=" glyphicon glyphicon-ok"></span>
</a> </a>
<?php elseif ($data['CurrentState'] == 3) : ?> <?php elseif ($data['CurrentState'] == 3) : ?>
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm"> <a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-search"></span> <span class="glyphicon glyphicon-search"></span>
</a> </a>
<?php elseif ($data['CurrentState'] == 5) : ?> <?php elseif ($data['CurrentState'] == 5) : ?>
<a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm"> <a href="rib01-check.php?id=<?php echo $data['rib_id'] ?>&state=2&<?= $token_link ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-search"></span> <span class="glyphicon glyphicon-search"></span>
</a> </a>
<?php endif; <?php endif;
} ?> } ?>
</p> </p>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach;
} ?>
</tbody> </tbody>
</table> </table>
</div> </div>

107
wms/rib02-edit.php

@ -17,10 +17,12 @@ $member = array();
$sql_mydept = "SELECT UserId, Username FROM capMembership"; $sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept); $deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) { if (is_iterable($deptmem)) {
$userid = $mem['UserId']; foreach ($deptmem as $mem) {
$username = $mem['Username']; $userid = $mem['UserId'];
$member["$userid"] = [$username]; $username = $mem['Username'];
$member["$userid"] = [$username];
}
}; };
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'"; $sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept); $allpeople = $conn->query($sql_dept);
@ -61,10 +63,11 @@ $rib_id = $ribsub['rib_id'];
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id !== $rib_id"; $sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id !== $rib_id";
$invoiceNo = mysqli_query($link, $sql_invoiceNo); $invoiceNo = mysqli_query($link, $sql_invoiceNo);
$invoiceNo_array = array(); $invoiceNo_array = array();
foreach ($invoiceNo as $invoice) { if (is_iterable($invoiceNo)) {
array_push($invoiceNo_array, $invoice['InvoiceNo']); foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
}
} }
$BizJSON = json_encode($BusinessPartner); $BizJSON = json_encode($BusinessPartner);
$InvoiceJSON = json_encode($invoiceNo_array); $InvoiceJSON = json_encode($invoiceNo_array);
$sql_Project = "SELECT * FROM comProject"; $sql_Project = "SELECT * FROM comProject";
@ -105,11 +108,13 @@ $materials = $conn->query($sql_Material);
<label for="FeeTypeId" style="color: red;">費用項目代碼</label> <label for="FeeTypeId" style="color: red;">費用項目代碼</label>
<select name="FeeTypeId" class="form-control" required> <select name="FeeTypeId" class="form-control" required>
<?php <?php
foreach ($feetype as $key => $value) { ?> if (is_iterable($feetype)) {
<option value="<?php echo $value['FeeTypeId']; ?>" <?php if ($value['FeeTypeId'] == $ribsub['FeeTypeId']) { foreach ($feetype as $key => $value) { ?>
echo "selected"; <option value="<?php echo $value['FeeTypeId']; ?>" <?php if ($value['FeeTypeId'] == $ribsub['FeeTypeId']) {
} ?>><?php echo $value['FeeTypeName']; ?></option> echo "selected";
<?php }; } ?>><?php echo $value['FeeTypeName']; ?></option>
<?php }
};
?> ?>
</select> </select>
</div> </div>
@ -171,11 +176,13 @@ $materials = $conn->query($sql_Material);
<label for="FeeTypeId" style="color: red;">費用項目代碼</label> <label for="FeeTypeId" style="color: red;">費用項目代碼</label>
<select name="FeeTypeId" id="FeeTypeId" class="form-control" required> <select name="FeeTypeId" id="FeeTypeId" class="form-control" required>
<?php <?php
foreach ($feetype as $key => $value) { ?> if (is_iterable($feetype)) {
<option value="<?php echo $value['FeeTypeId']; ?>" <?php if ($value['FeeTypeId'] == $ribsub['FeeTypeId']) { foreach ($feetype as $key => $value) { ?>
echo "selected"; <option value="<?php echo $value['FeeTypeId']; ?>" <?php if ($value['FeeTypeId'] == $ribsub['FeeTypeId']) {
} ?>><?php echo $value['FeeTypeName']; ?></option> echo "selected";
<?php }; } ?>><?php echo $value['FeeTypeName']; ?></option>
<?php }
};
?> ?>
</select> </select>
</div> </div>
@ -188,12 +195,14 @@ $materials = $conn->query($sql_Material);
<label for="FeeDeptId" style="color: red;">歸屬部門</label> <label for="FeeDeptId" style="color: red;">歸屬部門</label>
<select name="FeeDeptId" id="FeeDeptId" class="form-control" required> <select name="FeeDeptId" id="FeeDeptId" class="form-control" required>
<?php <?php
foreach ($deptype as $dept) { ?> if (is_iterable($deptype)) {
<option value="<?php echo $dept['DeptId']; ?>" <?php foreach ($deptype as $dept) { ?>
if ($dept['DeptId'] == $ribsub['FeeDeptId']) { <option value="<?php echo $dept['DeptId']; ?>" <?php
echo "selected"; if ($dept['DeptId'] == $ribsub['FeeDeptId']) {
} ?>><?php echo $dept['DeptName']; ?></option> echo "selected";
<?php }; } ?>><?php echo $dept['DeptName']; ?></option>
<?php }
};
?> ?>
</select> </select>
@ -207,11 +216,13 @@ $materials = $conn->query($sql_Material);
<select name="WriteOffId" id="WriteOffId" class="form-control"> <select name="WriteOffId" id="WriteOffId" class="form-control">
<option value="" id="WriteOddOption"> </option> <option value="" id="WriteOddOption"> </option>
<?php <?php
foreach ($member as $key => $value) { ?> if (is_iterable($member)) {
<option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . '-' . $value[0] ?>" <?php if ($key == $ribsub['WriteOffId']) { foreach ($member as $key => $value) { ?>
echo "selected"; <option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . '-' . $value[0] ?>" <?php if ($key == $ribsub['WriteOffId']) {
} ?>> <?php echo $value[0]; ?> </option> echo "selected";
<?php }; ?> } ?>> <?php echo $value[0]; ?> </option>
<?php }
}; ?>
</select> </select>
</div> </div>
@ -224,12 +235,14 @@ $materials = $conn->query($sql_Material);
<select name="ProjectId" id="ProjectId"> <select name="ProjectId" id="ProjectId">
<option value=""></option> <option value=""></option>
<?php <?php
foreach ($projects as $Project) { if (is_iterable($projects)) {
foreach ($projects as $Project) {
?> ?>
<option value="<?= $Project['ProjectId'] ?>" <?php if ($Project['ProjectId'] == $ribsub['ProjectId']) { <option value="<?= $Project['ProjectId'] ?>" <?php if ($Project['ProjectId'] == $ribsub['ProjectId']) {
echo "selected"; echo "selected";
} ?>><?= $Project['ProjectId'] . $Project['ProjectName'] ?></option> } ?>><?= $Project['ProjectId'] . $Project['ProjectName'] ?></option>
<?php <?php
}
} }
?> ?>
</select> </select>
@ -240,12 +253,14 @@ $materials = $conn->query($sql_Material);
<select name="CU_MaterialId" id="CU_MaterialId"> <select name="CU_MaterialId" id="CU_MaterialId">
<option value=""></option> <option value=""></option>
<?php <?php
foreach ($materials as $material) { if (is_iterable($materials)) {
foreach ($materials as $material) {
?> ?>
<option value="<?= $material['MaterialId'] ?>" <?php if ($material['MaterialId'] == $ribsub['CU_MaterialId']) { <option value="<?= $material['MaterialId'] ?>" <?php if ($material['MaterialId'] == $ribsub['CU_MaterialId']) {
echo "selected"; echo "selected";
} ?>><?= $material['MaterialId'] . $material['MaterialName'] ?></option> } ?>><?= $material['MaterialId'] . $material['MaterialName'] ?></option>
<?php <?php
}
} }
?> ?>
</select> </select>
@ -285,11 +300,13 @@ $materials = $conn->query($sql_Material);
<label for="UnitId" style="color: red;">計量單位</label> <label for="UnitId" style="color: red;">計量單位</label>
<select name="UnitId" class="form-control" required> <select name="UnitId" class="form-control" required>
<?php <?php
foreach ($unit as $key => $value) { ?> if (is_iterable($unit)) {
<option value="<?php echo $value['UnitId']; ?>" <?php if ($value['UnitId'] == $ribsub['UnitId']) { foreach ($unit as $key => $value) { ?>
echo "selected"; <option value="<?php echo $value['UnitId']; ?>" <?php if ($value['UnitId'] == $ribsub['UnitId']) {
} ?>><?php echo $value['UnitName']; ?></option> echo "selected";
<?php }; } ?>><?php echo $value['UnitName']; ?></option>
<?php }
};
?> ?>
</select> </select>
</div> </div>
@ -694,11 +711,13 @@ $materials = $conn->query($sql_Material);
window.open('rib02-invoice.php', '新視窗的名稱', config = 'height=600, width=600'); window.open('rib02-invoice.php', '新視窗的名稱', config = 'height=600, width=600');
} }
function checkInvoice(){
function checkInvoice() {
var invoiceArray = <?= $InvoiceJSON ?>; var invoiceArray = <?= $InvoiceJSON ?>;
if($.inArray($("#InvoiceNo").val().replace("-", ""),invoiceArray) !== -1) { if ($.inArray($("#InvoiceNo").val().replace("-", ""), invoiceArray) !== -1) {
alert("此發票已報銷過"); alert("此發票已報銷過");
$("#InvoiceNo").val('');} $("#InvoiceNo").val('');
}
} }
function changeWriteOffId(SelectedDept) { function changeWriteOffId(SelectedDept) {

18
wms/rib02-submit.php

@ -50,7 +50,7 @@ $OAmount = $CurrId == "TWD" ? round($_POST['OAmount']) : round($_POST['OAmount']
$TaxId = $_POST['TaxId']; $TaxId = $_POST['TaxId'];
$IsCounteract = $_POST['IsCounteract']; $IsCounteract = $_POST['IsCounteract'];
$InvoiceId = $_POST['InvoiceId']; $InvoiceId = $_POST['InvoiceId'];
$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount']; $VoucherCount = isset($_POST['VoucherCount']) ? $_POST['VoucherCount']:0;
$VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0; $VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0;
$InvoiceNo = empty($_POST['InvoiceNo']) ? " " : (in_array(str_replace("-", "", $_POST['InvoiceNo']), $invoiceNo_array) ? " " : str_replace("-", "", $_POST['InvoiceNo'])); $InvoiceNo = empty($_POST['InvoiceNo']) ? " " : (in_array(str_replace("-", "", $_POST['InvoiceNo']), $invoiceNo_array) ? " " : str_replace("-", "", $_POST['InvoiceNo']));
@ -106,12 +106,11 @@ if ($submit == "add") {
$SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`, $SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`,
`BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`, `BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`,
`Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`OTax`,`LTax`, `Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`OTax`,`LTax`,
`OAmountUnWithTax`,`LAmountUnWithTax`,`LAmount`"; `OAmountUnWithTax`,`LAmountUnWithTax`,`LAmount`,`VoucherCount`";
$SQL1 .= isset($CurrLAmount) ? ",`CurrentLAmount`" : ""; $SQL1 .= isset($CurrLAmount) ? ",`CurrentLAmount`" : "";
$SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`"; $SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`";
$SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : ""; $SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`"; $SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`";
$SQL1 .= empty($VoucherCount) ? "" : ",`VoucherCount`";
$SQL1 .= isset($VoucherType) ? ",`VoucherType`" : ""; $SQL1 .= isset($VoucherType) ? ",`VoucherType`" : "";
$SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`"; $SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`";
$SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`"; $SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`";
@ -120,12 +119,11 @@ if ($submit == "add") {
$SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2, $SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2,
'1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity, '1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity,
$Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$OTax,$LTax, $Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$OTax,$LTax,
$OAmountUnWithTax,$LAmountUnWithTax,$LAmount"; $OAmountUnWithTax,$LAmountUnWithTax,$LAmount,$VoucherCount";
$SQL2 .= isset($CurrLAmount) ? "," . $CurrLAmount : ""; $SQL2 .= isset($CurrLAmount) ? "," . $CurrLAmount : "";
$SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'"; $SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'";
$SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : ""; $SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : "";
$SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'"; $SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'";
$SQL2 .= empty($VoucherCount) ? "" : "," . $VoucherCount;
$SQL2 .= isset($VoucherType) ? "," . $VoucherType : ""; $SQL2 .= isset($VoucherType) ? "," . $VoucherType : "";
$SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'"; $SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'";
$SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'"; $SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'";
@ -134,11 +132,10 @@ if ($submit == "add") {
} else { } else {
$SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`, $SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`,
`BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`, `BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`,
`Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`"; `Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`VoucherCount`";
$SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`"; $SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`";
$SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : ""; $SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`"; $SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`";
$SQL1 .= empty($VoucherCount) ? "" : ",`VoucherCount`";
$SQL1 .= isset($VoucherType) ? ",`VoucherType`" : ""; $SQL1 .= isset($VoucherType) ? ",`VoucherType`" : "";
$SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`"; $SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`";
$SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`"; $SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`";
@ -146,11 +143,10 @@ if ($submit == "add") {
$SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2, $SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2,
'1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity, '1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity,
$Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo'"; $Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$VoucherCount";
$SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'"; $SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'";
$SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : ""; $SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : "";
$SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'"; $SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'";
$SQL2 .= empty($VoucherCount) ? "" : "," . $VoucherCount;
$SQL2 .= isset($VoucherType) ? "," . $VoucherType : ""; $SQL2 .= isset($VoucherType) ? "," . $VoucherType : "";
$SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'"; $SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'";
$SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'"; $SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'";
@ -177,11 +173,11 @@ if ($submit == "add") {
<?php <?php
} elseif ($submit == "edit") { } elseif ($submit == "edit") {
$SQL1 = "UPDATE rib_sub SET RowCode=$RowCode, RowNo=$RowCode,FeeDate=$FeeDate,FeeTypeId=$FeeTypeId,FeeDeptId=$FeeDeptId,WriteOffId='$WriteOffId',FeeNoteShow='$FeeNoteShow', $SQL1 = "UPDATE rib_sub SET RowCode=$RowCode, RowNo=$RowCode,FeeDate=$FeeDate,FeeTypeId=$FeeTypeId,FeeDeptId=$FeeDeptId,WriteOffId='$WriteOffId',FeeNoteShow='$FeeNoteShow',
UnitId='$UnitId', Price=$Price,Quantity=$Quantity, OAmount=$OAmount, TaxId='$TaxId', IsCounteract=$IsCounteract,InvoiceId= '$InvoiceId', TaxRate=$TaxRate,LastOperatorId='$user_id',TaxNo='$TaxNo',LastOperatorId='$user_id'"; UnitId='$UnitId', Price=$Price,Quantity=$Quantity, OAmount=$OAmount, TaxId='$TaxId', IsCounteract=$IsCounteract,InvoiceId= '$InvoiceId',
TaxRate=$TaxRate,LastOperatorId='$user_id',TaxNo='$TaxNo',LastOperatorId='$user_id',VoucherCount=$VoucherCount";
$SQL1 .= empty($ProjectId) ? "" : ",ProjectId='$ProjectId'"; $SQL1 .= empty($ProjectId) ? "" : ",ProjectId='$ProjectId'";
$SQL1 .= isset($FeeTypeGen) ? ",FeeTypeGen=$FeeTypeGen" : ""; $SQL1 .= isset($FeeTypeGen) ? ",FeeTypeGen=$FeeTypeGen" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",CU_MaterialId='$CU_MaterialId'"; $SQL1 .= empty($CU_MaterialId) ? "" : ",CU_MaterialId='$CU_MaterialId'";
$SQL1 .= empty($VoucherCount) ? "" : ",VoucherCount=$VoucherCount";
$SQL1 .= isset($VoucherType) ? ",VoucherType=$VoucherType" : ""; $SQL1 .= isset($VoucherType) ? ",VoucherType=$VoucherType" : "";
$SQL1 .= empty($InvoiceNo) ? " " : ",InvoiceNo='$InvoiceNo'"; $SQL1 .= empty($InvoiceNo) ? " " : ",InvoiceNo='$InvoiceNo'";
$SQL1 .= empty($comSupplierName) ? ",comSupplierName=' '" : ",comSupplierName='$comSupplierName'"; $SQL1 .= empty($comSupplierName) ? ",comSupplierName=' '" : ",comSupplierName='$comSupplierName'";

Loading…
Cancel
Save