Browse Source

Merge branch 'main' into gary

gary
gary_chen\gary_chen 1 year ago
parent
commit
ccb7aa36e9
  1. 0
      wms/T8-purReceive-submit.php
  2. 0
      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. 174
      wms/account-receivable-index-ing.php
  7. 24
      wms/account-receivable-index.php
  8. 42
      wms/account-receivable-renovate-excel.php
  9. 773
      wms/account-receivable-renovate-index-ing.php
  10. 2107
      wms/account-receivable-renovate-index.php
  11. BIN
      wms/account-receivable-renovate.xlsx
  12. 18
      wms/account-receivable-test.php
  13. 75
      wms/bons/api/get.php
  14. 135
      wms/bons/bons_index.php
  15. 125
      wms/bons/elevator_new/elevator_new_deal_bonus_v1_0.php
  16. 72
      wms/bons/elevator_new/elevator_new_deal_bonus_v1_0_examination.php
  17. 164
      wms/bons/elevator_new/elevator_new_deal_bonus_v2_0.php
  18. 116
      wms/bons/elevator_new/elevator_new_deal_bonus_v2_0_examination.php
  19. 399
      wms/bons/maintainance_contract_payment_status.php
  20. 248
      wms/bons/maintance/maintenance_contract_bonus_v2_0.php
  21. 156
      wms/bons/maintance/maintenance_contract_bonus_v2_0_examination.php
  22. 3
      wms/contract-repair/contract-repair-input.php
  23. 2
      wms/contract-repair/insertFacility.php
  24. 82
      wms/contract-repair/js/alpine.js
  25. 2
      wms/contract-repair/prviewPdf.php
  26. 2
      wms/contract/api/T8salIncomeApply.php
  27. 24
      wms/contract/api/postContractData.php
  28. 23
      wms/contract/api/testT8API.php
  29. 2
      wms/contract/connt8.php
  30. 15
      wms/contract/connt8_test.php
  31. 8
      wms/contract/contract-download.php
  32. 114
      wms/contract/contract-maintainance-management.php
  33. 16
      wms/contract/contract-new-apply.php
  34. 5
      wms/contract/js/alpine.js
  35. BIN
      wms/contract/mi/mi7.xlsx
  36. BIN
      wms/contract/option/facility.xlsx
  37. 7
      wms/contract/prviewPdf.php
  38. 2
      wms/contract/restoremi.php
  39. 20
      wms/database.php
  40. 8
      wms/fun_global.php
  41. 7
      wms/mkt/assets/js/alpine.js
  42. 5
      wms/mkt/assets/js/alpinejs/cdn.min.js
  43. 7
      wms/mkt/assets/js/pricereviewAlpine.js
  44. 10
      wms/mkt/conn.php
  45. 90
      wms/mkt/css/pricereview.css
  46. 1
      wms/mkt/css/pricereview.css.map
  47. 98
      wms/mkt/css/pricereview.scss
  48. 4
      wms/mkt/price_option-index.php
  49. 4
      wms/mkt/price_option-select.php
  50. 3
      wms/mkt/pricereview-check.php
  51. 14
      wms/mkt/pricereview-create.php
  52. 3346
      wms/mkt/pricereview-edit.php
  53. 57
      wms/mkt/pricereview-index.php
  54. 516
      wms/mkt/pricereviewCreate.php
  55. 95
      wms/mkt/pricereview_mi-api.php
  56. 3
      wms/rib01-check.php
  57. 22
      wms/rib01-edit.php
  58. 150
      wms/rib01-index.php
  59. 2
      wms/rib02-create.php
  60. 109
      wms/rib02-edit.php
  61. 18
      wms/rib02-submit.php
  62. 44
      wms/schedule-index.php

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

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

8
wms/T8_Authorization.php

@ -14,12 +14,13 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
var validation = "";
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
// 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 = {
UserId: 'M0000',
Pwd: 'M012290493119',
TimestampUTC: <?= $now ?>,
Sign: '<?= $sign ?>'
Sign: '<?= $sign ?>',
GroupId: 'TEST',
};
obj = {
type: 'get',
@ -30,7 +31,7 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
success: function(res) {
validation = res.Data['CHI_Authorization'];
console.log(validation);
// console.log(res);
console.log(res);
// console.log()
// window.parent.postMessage(validation,'http://localhost:3000');
// window.parent.postMessage(validation,'https://masada.com.tw');
@ -40,4 +41,5 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
jQuery.ajax(obj);
// return jQuery.ajax(obj);
}
get_Auth();
</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 = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
//GroupId : TEST測試區 ; MASADA正式區
$headerParam = [
"UserId: $user_id",
"Pwd: $user_password",
"TimestampUTC: $now",
"Sign: $sign"
"Sign: $sign",
"GroupId: TEST"
];
$ch = curl_init();
@ -51,4 +53,4 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
curl_close($ch);
}
// $data = [];
// get_Auth();
get_Auth();

BIN
wms/WriteOff.xlsx

Binary file not shown.

174
wms/account-receivable-index-ing.php

@ -2158,9 +2158,14 @@ include "./footer.php";
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
?>
<div>
<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>
<div style="width:98%;margin:1% ;overflow-x: auto;">
<table class="table table-striped table-bordered" style="width:100%;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th style="width: 120px;">合約號</th>
@ -2180,7 +2185,7 @@ include "./footer.php";
<?php
foreach ($arrayData as $key => $value) {
?>
<tr>
<tr class="data-row" style="display: '';">
<td onclick="toggleContent(this)"><?= $key ?> </td>
<td><?= $value[1] ?></td>
<td><?= $value[4] ?></td>
@ -2246,6 +2251,21 @@ include "./footer.php";
</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 toggleContent(element) {
var parentRow = element.parentNode;
var contentRow = parentRow.nextElementSibling;
@ -2391,80 +2411,80 @@ $table = "";
// [合約號]['facility'][作番號]['no']
//['receivable_budget'] / ['total_facility_num'] / ['total_budget']
//('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($arrayData as $key => $value) {
if (isset($value['facility']) && !empty($value['facility'])) {
foreach ($value['facility'] as $fakey => $facility) {
foreach ($contractstage as $stage) {
switch ($stage) {
case 'sign':
$stageno = 0;
break;
case 'second':
$stageno = 1;
break;
case 'arrive':
$stageno = 2;
break;
case 'install':
$stageno = 3;
break;
case 'tryrun':
$stageno = 4;
break;
case 'check':
$stageno = 5;
break;
case 'delivery':
$stageno = 6;
break;
case 'final':
$stageno = 7;
break;
}
if (isset($value[$stage]) && isset($value[$stage][0]) && !empty($value[$stage][0])) {
if ($value[$stage][3] > 0) {
$stage3 = 1;
} else {
$stage3 = 0;
}
if ($value[$stage][7] > 0) {
$stage7 = 1;
} else {
$stage7 = 0;
}
$invoice_budget = $value[$stage][7];
$received_budget = $value[$stage][4];
$budget = $value[$stage][1];
$receivable_date = $value[$stage][2];
$table .= "INSERT INTO account_receivable (
`contract_no`,
`facility_no`,
`stage`,
`budget`,
`receivable_date`,
`receivable`,
`invoice`,
`invoice_budget`,
`received_budget`";
if ($value[$stage][7] > 0) {
$table .= ",`invoice_state`";
}
$table .= ") VALUES ('$key','$fakey',$stageno,$budget,$receivable_date,$stage3,$stage7,$invoice_budget,$received_budget ";
if ($value[$stage][7] > 0) {
$table .= ",0";
}
$table .= "); \n";
}
}
}
}
}
// foreach ($arrayData as $key => $value) {
// if (isset($value['facility']) && !empty($value['facility'])) {
// foreach ($value['facility'] as $fakey => $facility) {
// foreach ($contractstage as $stage) {
// switch ($stage) {
// case 'sign':
// $stageno = 0;
// break;
// case 'second':
// $stageno = 1;
// break;
// case 'arrive':
// $stageno = 2;
// break;
// case 'install':
// $stageno = 3;
// break;
// case 'tryrun':
// $stageno = 4;
// break;
// case 'check':
// $stageno = 5;
// break;
// case 'delivery':
// $stageno = 6;
// break;
// case 'final':
// $stageno = 7;
// break;
// }
// if (isset($value[$stage]) && isset($value[$stage][0]) && !empty($value[$stage][0])) {
// if ($value[$stage][3] > 0) {
// $stage3 = 1;
// } else {
// $stage3 = 0;
// }
// if ($value[$stage][7] > 0) {
// $stage7 = 1;
// } else {
// $stage7 = 0;
// }
// $invoice_budget = $value[$stage][7];
// $received_budget = $value[$stage][4];
// $budget = $value[$stage][1];
// $receivable_date = $value[$stage][2];
// $table .= "INSERT INTO account_receivable (
// `contract_no`,
// `facility_no`,
// `stage`,
// `budget`,
// `receivable_date`,
// `receivable`,
// `invoice`,
// `invoice_budget`,
// `received_budget`";
// if ($value[$stage][7] > 0) {
// $table .= ",`invoice_state`";
// }
// $table .= ") VALUES ('$key','$fakey',$stageno,$budget,$receivable_date,$stage3,$stage7,$invoice_budget,$received_budget ";
// if ($value[$stage][7] > 0) {
// $table .= ",0";
// }
// $table .= "); \n";
// }
// }
// }
// }
// }
$file_path = 'account_receivable_sql_file.sql';
// $file_path = 'account_receivable_sql_file.sql';
if (file_put_contents($file_path, $table) !== false) {
echo "SQL文件已成功生成:{$file_path}";
} else {
echo "生成SQL文件时出现错误。";
}
// if (file_put_contents($file_path, $table) !== false) {
// echo "SQL文件已成功生成:{$file_path}";
// } else {
// echo "生成SQL文件时出现错误。";
// }
// echo $table;

24
wms/account-receivable-index.php

@ -2401,6 +2401,12 @@ include "./footer.php";
<th style="width: 120px;">營業員</th>
<th style="width: 180px;">客戶名稱</th>
<th style="width: 300px;">作番狀態</th>
<th style="width: 150px;">合約-設備金額</th>
<th style="width: 150px;">合約-安裝金額</th>
<th style="width: 150px;">作番總金額</th>
<th style="width: 150px;">作番目前應收</th>
<th style="width: 120px;">訂金 <br>名稱</th>
<th style="width: 120px;">訂金<br>合約金額</th>
<th style="width: 120px;">訂金<br>應收日期</th>
@ -2481,11 +2487,7 @@ include "./footer.php";
<th style="width: 120px;">尾款<br>催收金額</th>
<th style="width: 120px;">尾款<br>催收次數</th>
<th style="width: 300px;">作番狀態</th>
<th style="width: 150px;">合約-設備金額</th>
<th style="width: 150px;">合約-安裝金額</th>
<th style="width: 150px;">作番總金額</th>
<th style="width: 150px;">作番目前應收</th>
</tr>
</thead>
@ -2501,6 +2503,12 @@ include "./footer.php";
<td style="text-align: center;"><?= $value[5] ?></td>
<td style="text-align: center;"><?= $value[6] ?></td>
<td style="text-align: end;"><?= $value[82] ?></td>
<td style="text-align: end;"><?= $value[83] ?></td>
<td style="text-align: end;"><?= $value[84] ?></td>
<td style="text-align: end;"><?= $value[85] ?></td>
<td style="text-align: end;"><?= $value[86] ?></td>
<td style="text-align: end;"><?= $value[10] ?></td>
<td style="text-align: end;"><?= $value[11] ?></td>
<td style="text-align: end;"><?= $value[12] ?></td>
@ -2585,12 +2593,6 @@ include "./footer.php";
<td style="text-align: end;"><?= $value[80] ?></td>
<td style="text-align: end;"><?= $value[81] ?></td>
<td style="text-align: end;"><?= $value[82] ?></td>
<td style="text-align: end;"><?= $value[83] ?></td>
<td style="text-align: end;"><?= $value[84] ?></td>
<td style="text-align: end;"><?= $value[85] ?></td>
<td style="text-align: end;"><?= $value[86] ?></td>
</tr>
<?php
}

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

@ -0,0 +1,42 @@
<?php
include "./header.php";
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
header('Content-Type: application/json');
$type = $_GET['type'];
$array_data = array();
$Bill = json_decode(file_get_contents("php://input"), true);
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// file_put_contents('account-receivable.txt', json_encode($Bill));
$colomnHeader = [
'合約號', '作番號', '部門編號', '部門名稱', '主管工號','主管名稱', '營業員工號', '營業員名稱', '客戶名稱', '抬頭', '統編', '通訊地址',
'收款階段名稱', '應收日期','是否應收', '應收金額', '已開金額','未開金額', '已收金額','催收金額', '催收次數'
];
$sheet->fromArray($colomnHeader, NULL, 'A1');
$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++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-renovate.xlsx';
$writer->save($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>

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

File diff suppressed because it is too large

BIN
wms/account-receivable-renovate.xlsx

Binary file not shown.

18
wms/account-receivable-test.php

@ -374,9 +374,17 @@ $P_all = "
// echo $value['facilityno']. ";" . $value['actual_tofactory_date'] . "<br>";
// }
$sql_paystage = "SELECT A.PayStage, A.BillNo FROM salOrderStagePay AS A
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo WHERE s.ModeId = 'T' AND (s.CurrentState=2 OR s.CurrentState=4)";
$query_paystage = $conn->query($sql_paystage);
foreach($query_paystage as $key => $value) {
echo $value['PayStage'] .";".$value['BillNo']. "<br>";
// $sql_paystage = "SELECT A.PayStage, A.BillNo FROM salOrderStagePay AS A
// LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo WHERE s.ModeId = 'T' AND (s.CurrentState=2 OR s.CurrentState=4)";
// $query_paystage = $conn->query($sql_paystage);
// foreach($query_paystage as $key => $value) {
// echo $value['PayStage'] .";".$value['BillNo']. "<br>";
// }
$sql = "SELECT A.BillNo,B.CU_MaterialId, B.ProjectId FROM salSalesOrder AS A
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";
$query = $conn->query($sql);
foreach($query as $key => $value) {
echo $value['BillNo'] .";".$value['CU_MaterialId'].";".$value['ProjectId']. "<br>";
}

75
wms/bons/api/get.php

@ -0,0 +1,75 @@
<?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;
}
// }

135
wms/bons/bons_index.php

@ -0,0 +1,135 @@
<?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="bons_index" x-data="bonsIndex">
<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="5">
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="contract_no" x-model="data.contract_no">
</td>
<td colspan="2" style="vertical-align:middle"></td>
</tr>
</tbody>
</template>
<template x-if="step==2">
<tbody style="font-weight: bolder;margin-bottom:20px">
<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>
<input type="text" x-model="data.contract_no" disabled="disabled">
</td>
<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>
</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.bons_verson" disabled="disabled">
</td>
</tr>
<tr>
<td style="vertical-align:middle">獎金發放人員</td>
<td>
<input type="text" x-model="data.receiver" disabled="disabled">
</td>
<td style="vertical-align:middle">保養月份</td>
<td>
<input type="text" x-model="data.maintain_month" disabled="disabled">
</td>
<td style="vertical-align:middle">保養總額</td>
<td>
<input type="text" x-model="data.maintain_price_toal" disabled="disabled">
</td>
</tr>
</tbody>
</template>
<!-- 獎金計算頁面 -->
<template x-if="step == 3">
<tbody style="font-weight: bolder;margin-bottom:20px">
<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>
</tr>
</tbody>
</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>

125
wms/bons/elevator_new/elevator_new_deal_bonus_v1_0.php

@ -0,0 +1,125 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
營業員獎金($sales_bonus)
區域經理獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、貨到工地款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_price, $sales_id, $region_manger_id){
$bonus_array = [];
if ($ver == "1.0"){
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type){
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_knockdown_price * 0.007;
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_knockdown_price * 0.015;
#區域經理獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
};
#營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20%
array_push($bonus_array,[
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.2), #金額
"payment_schedul_due" => "deposit", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定
]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%
array_push($bonus_array,[
"bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.5), #金額
"payment_schedul_due" => "shipping", #訂金已收款20%
"payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定
]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%
array_push($bonus_array,[
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.3), #金額
"payment_schedul_due" => "acceptance", #訂金已收款20%
"payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定
]);
#區域經理獎金水庫-----訂金已收款100%,發放總獎金50%
array_push($bonus_array,[
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
]);
#區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50%
array_push($bonus_array,[
"bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
"payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
];
}else{
array_push($bonus_array,[
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"payment_schedul_due" => "9999-1-1", #預計發放時間
"payment_schedul_regulation" => "error" #發放規定
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"error", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
];
};
return $result_array;
};
?>

72
wms/bons/elevator_new/elevator_new_deal_bonus_v1_0_examination.php

@ -0,0 +1,72 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
營業員獎金($sales_bonus)
區域經理獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、貨到工地款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
require_once("elevator_new_deal_bonus_v1_0.php");
#$ver, $contract_type, $elevator_knockdown_price, $sales_id, $region_manger_id
#獎金測試
$examination_array = [
#錯誤版本
["2.0","strategy_customer",1000000,"M0001", "M0003"],
#戰略客戶(strategy_customer)
["1.0","strategy_customer",1000000,"M0001", "M0003"], #戰略客戶
#一般客戶(general_customer)
["1.0","general_customer",1000000,"M0001", "M0003"] #一般客戶
];
for($i = 0; $i<count($examination_array); $i++){
$result = elevator_new_deal_bonus_v1_0(
$examination_array[$i][0],
$examination_array[$i][1],
$examination_array[$i][2],
$examination_array[$i][3],
$examination_array[$i][4]
);
echo "獎金版本:" . $result["ver"] . "<br>";
echo "計算結果:" . $result["result_status"] . "<br>";
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . "<br>";
for($j = 0; $j<count($result["bonus_array"]); $j++){
echo "輸出結果:" . $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>";
};
?>

164
wms/bons/elevator_new/elevator_new_deal_bonus_v2_0.php

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

116
wms/bons/elevator_new/elevator_new_deal_bonus_v2_0_examination.php

@ -0,0 +1,116 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番機種($elevator_type):客梯(passenger)、貨梯(cargo)、小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
作番表價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price)
營業員獎金($sales_bonus)
區域經理獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
require_once("elevator_new_deal_bonus_v2_0.php");
#$ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id
#獎金測試
$examination_array = [
#錯誤版本
["1.0","strategy_customer","passenger",1000000,1000000,"M0001", "M0003"],
#戰略客戶(strategy_customer)
["2.0","strategy_customer","passenger",1000000,1000000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數100%
["2.0","strategy_customer","passenger",1000000,900000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數90%
["2.0","strategy_customer","passenger",1000000,750000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數75%
["2.0","strategy_customer","passenger",1000000,600000,"M0001", "M0003"], #戰略客戶、客梯、銷售點數60%
["2.0","strategy_customer","cargo",1000000,1000000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數100%
["2.0","strategy_customer","cargo",1000000,900000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數90%
["2.0","strategy_customer","cargo",1000000,750000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數75%
["2.0","strategy_customer","cargo",1000000,600000,"M0001", "M0003"], #戰略客戶、貨梯、銷售點數60%
["2.0","strategy_customer","dumbwaiter",1000000,1000000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數100%
["2.0","strategy_customer","dumbwaiter",1000000,900000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數90%
["2.0","strategy_customer","dumbwaiter",1000000,720000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數75%
["2.0","strategy_customer","dumbwaiter",1000000,600000,"M0001", "M0003"], #戰略客戶、小電梯、銷售點數60%
["2.0","strategy_customer","flatbase",1000000,1000000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數100%
["2.0","strategy_customer","flatbase",1000000,900000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數90%
["2.0","strategy_customer","flatbase",1000000,720000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數75%
["2.0","strategy_customer","flatbase",1000000,600000,"M0001", "M0003"], #戰略客戶、平台梯、銷售點數60%
["2.0","strategy_customer","positive_drive",1000000,1000000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數100%
["2.0","strategy_customer","positive_drive",1000000,900000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數90%
["2.0","strategy_customer","positive_drive",1000000,720000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數75%
["2.0","strategy_customer","positive_drive",1000000,600000,"M0001", "M0003"], #戰略客戶、強驅、銷售點數60%
#一般客戶(general_customer)
["2.0","general_customer","passenger",1000000,1000000,"M0001", "M0003"], #一般客戶、客梯、銷售點數100%
["2.0","general_customer","passenger",1000000,900000,"M0001", "M0003"], #一般客戶、客梯、銷售點數90%
["2.0","general_customer","passenger",1000000,750000,"M0001", "M0003"], #一般客戶、客梯、銷售點數75%
["2.0","general_customer","passenger",1000000,600000,"M0001", "M0003"], #一般客戶、客梯、銷售點數60%
["2.0","general_customer","cargo",1000000,1000000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數100%
["2.0","general_customer","cargo",1000000,900000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數90%
["2.0","general_customer","cargo",1000000,750000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數75%
["2.0","general_customer","cargo",1000000,600000,"M0001", "M0003"], #一般客戶、貨梯、銷售點數60%
["2.0","general_customer","dumbwaiter",1000000,1000000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數100%
["2.0","general_customer","dumbwaiter",1000000,900000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數90%
["2.0","general_customer","dumbwaiter",1000000,720000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數75%
["2.0","general_customer","dumbwaiter",1000000,600000,"M0001", "M0003"], #一般客戶、小電梯、銷售點數60%
["2.0","general_customer","flatbase",1000000,1000000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數100%
["2.0","general_customer","flatbase",1000000,900000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數90%
["2.0","general_customer","flatbase",1000000,720000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數75%
["2.0","general_customer","flatbase",1000000,600000,"M0001", "M0003"], #一般客戶、平台梯、銷售點數60%
["2.0","general_customer","positive_drive",1000000,1000000,"M0001", "M0003"], #一般客戶、強驅、銷售點數100%
["2.0","general_customer","positive_drive",1000000,900000,"M0001", "M0003"], #一般客戶、強驅、銷售點數90%
["2.0","general_customer","positive_drive",1000000,720000,"M0001", "M0003"], #一般客戶、強驅、銷售點數75%
["2.0","general_customer","positive_drive",1000000,600000,"M0001", "M0003"] #一般客戶、強驅、銷售點數60%
];
for($i = 0; $i<count($examination_array); $i++){
$result = elevator_new_deal_bonus_v2_0(
$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>";
};
?>

399
wms/bons/maintainance_contract_payment_status.php

@ -0,0 +1,399 @@
<?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";
?>

248
wms/bons/maintance/maintenance_contract_bonus_v2_0.php

@ -0,0 +1,248 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.0
契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上
該作番所佔的服務費金額($commission_fee)
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
簽約年數($contract_years):1年(one),超過1年(above_two)
第一筆保養款項應收回日($receivable_date_due, array)
契約員員工號($sales_id)
地區經理經理員工號($region_manger_id)
專任契約經理員工號($regular_contract_manger_id)
【2.函數中的變數說明】
契約員獎金($sales_bonus)
地區經理經理獎金($region_manager_bonus)
專任契約經理獎金($regular_contract_manger_bonus)
獎金預計發放日($payday_due)
獎金預計發放規定($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_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id){
$bonus_array = [];
if ($ver == "2.0"){
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type){
case "new":
#契約員獎金($sales_bonus)
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.6;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$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;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_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.5;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 100;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 100;
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_manager_bonus)
$region_manager_bonus = 100;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 100;
break;
};
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount < 0.6):
$sales_bonus = $sales_bonus * 0.7;
break;
case ($discount >= 0.6 and $discount < 0.8):
$sales_bonus = $sales_bonus * 0.8;
break;
case ($discount >= 0.8):
$sales_bonus = $sales_bonus * 1.0;
break;
};
#簽約年數($contract_years):1年(1),超過1年(above)
switch ($contract_years){
case $contract_years == "one":
#契約員獎金
array_push($bonus_array,[
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array,[
"bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_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" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
];
break;
case $contract_years == "above_two":
/*** 以下第1年獎金 ***/
#契約員獎金
array_push($bonus_array,[
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array,[
"bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_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" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
/*** 以上第1年獎金 ***/
/*** 以下第2年獎金 ***/
#第2年契約員獎金
array_push($bonus_array,[
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年地區經理經理獎金
array_push($bonus_array,[
"bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年專任契約經理獎金
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 +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
/*** 以上第2年獎金 ***/
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
];
break;
}
}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;
};
?>

156
wms/bons/maintance/maintenance_contract_bonus_v2_0_examination.php

@ -0,0 +1,156 @@
<?php
/* 函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.0
契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上
該作番所佔的服務費金額($commission_fee)
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
簽約年數($contract_years):1年(one),超過1年(above_two)
第一筆保養款項應收回日($receivable_date_due, array)
契約員員工號($sales_id)
地區經理經理員工號($region_manger_id)
專任契約經理員工號($regular_contract_manger_id)
【2.函數中的變數說明】
契約員獎金($sales_bonus)
地區經理經理獎金($region_manger_bonus)
專任契約經理獎金($regular_contract_manger_bonus)
獎金預計發放日($payday_due)
獎金預計發放規定($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_0.php");
#獎金測試
$examination_array = [
#錯誤版本
["1.0","new","one",0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"],
#新簽約
["2.0","new","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","new","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","new","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","new","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","new","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","new","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","new","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","new","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","new","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","new","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","new","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","new","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","new","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","new","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","new","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","new","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","new","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","new","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","new","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","new","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","new","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","new","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","new","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","new","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
#免保轉有費(free_to_charge)
["2.0","free_to_charge","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","free_to_charge","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","free_to_charge","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","free_to_charge","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","free_to_charge","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","free_to_charge","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","free_to_charge","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","free_to_charge","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","free_to_charge","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","free_to_charge","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","free_to_charge","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","free_to_charge","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","free_to_charge","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","free_to_charge","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","free_to_charge","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","free_to_charge","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","free_to_charge","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","free_to_charge","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","free_to_charge","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","free_to_charge","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","free_to_charge","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","free_to_charge","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","free_to_charge","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","free_to_charge","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
#續簽約(原價或僅契約金額異動)(renew_priceissue)
["2.0","renew_priceissue","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","renew_priceissue","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","renew_priceissue","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","renew_priceissue","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","renew_priceissue","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","renew_priceissue","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","renew_priceissue","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","renew_priceissue","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","renew_priceissue","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","renew_priceissue","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","renew_priceissue","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","renew_priceissue","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","renew_priceissue","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","renew_priceissue","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","renew_priceissue","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","renew_priceissue","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","renew_priceissue","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","renew_priceissue","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","renew_priceissue","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","renew_priceissue","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","renew_priceissue","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","renew_priceissue","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","renew_priceissue","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","renew_priceissue","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"] #新簽約、2年以上、折扣率0.6、4000元
];
for($i = 0; $i<count($examination_array); $i++){
$result = maintenance_contract_bonus_v2_0(
$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] . "<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>";
};
?>

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

@ -48,7 +48,6 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修
<td style="vertical-align: middle">報價單編號</td>
<td colspan="5">
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="repair_no" x-model="data.repair_no">
</td>
<td colspan="2" style="vertical-align: middle">
<label for="customize">
@ -68,7 +67,7 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修
<h4>業務確認項</h4>
</td>
<td class="text-right" style='border-left:0px;'>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button>
<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>

2
wms/contract-repair/insertFacility.php

@ -5,7 +5,7 @@ ini_set('data.timezone', 'Asia/Taipei');
use PhpOffice\PhpSpreadsheet\IOFactory;
$filePath = './facility/facility.xlsx';
// $filePath = './facility/facility.xlsx';
try {
$spreadsheet = IOFactory::load($filePath);

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

@ -873,3 +873,85 @@ const contract_edit = () => {
}
}
const bonsIndex = () => {
return {
data: {
contract_no: 'Q23080067',
client_type: '',
facility_no: '',
bons_verson: '',
receiver: '',
maintain_month: '',
maintain_price_toal: ''
},
step: 1,
isLoading: false,
fail_arr: [],
nextStepFn() {
if (this.step == 1) {
if (this.data.contract_no == '') return alert('請輸入合約號');
this.isLoading = true;
this.getContractData();
} else if (this.step == 2) {
if (!this.data.disabled) {
this.calBons();
}
}
this.step = 3;
},
nextStepKeyupFn(e) {
if (e.keyCode !== 13) return;
if (this.step == 1) {
if (this.data.contract_no == '') return alert('請輸入合約號');
this.isLoading = true;
this.getContractData();
} else if (this.step == 2) {
this.step = 3; s
}
},
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.bons_verson = res.data.bons_verson;
this.data.receiver = res.data.personId;
this.data.maintain_price_toal = res.data.amount;
this.data.bons_verson = 2;
this.data.maintain_month = res.data.maintain_month;
}
this.step = 2;
this.isLoading = false;
}).catch(err => {
})
},
preStepFn() {
this.step = 1
if (this.step == 2) {
}
},
save() {
},
calBons() {
console.log('123');
},
errorFn() {
let msg = '';
for (let i = 0; i < this.fail_arr.length; i++) {
msg += this.fail_arr[i] + '、';
}
alert(msg);
},
}
}

2
wms/contract-repair/prviewPdf.php

@ -509,7 +509,7 @@ if ($_POST['list']) {
</tr>
</table>
</td>
<td style="border:none">&nbsp;臺北市中山區敬業一路128巷39號3樓之1</td>
<td style="border:none">&nbsp;桃園市觀音區崙坪村8鄰140號</td>
</tr>
</table>
<p>&nbsp;</p>

2
wms/contract/api/T8salIncomeApply.php

@ -29,9 +29,7 @@ function T8API($data)
echo 'API傳入失敗,' . $result['ErrorMsg'];
return $result;
} else {
// echo '<pre>';
// print_r($result);
// echo '</pre>';
return $result;
}
}

24
wms/contract/api/postContractData.php

@ -459,12 +459,12 @@ function T8insert($data, $facilityno)
// print_r($elevators['maintainance']);
// echo '</pre>';
foreach ($elevators as $index => $elevator) {
$type[] = $elevator['maintainance'];
if ($type[$index] == 'A') {
$maintainance_type = $elevator['maintainance'];
if ($maintainance_type == 'A') {
$type = 'C3';
} else if ($type[$index] == 'B') {
} else if ($maintainance_type == 'B') {
$type = 'C4';
} else if ($type[$index] == 'C') {
} else if ($maintainance_type == 'C') {
$type = 'C5';
}
}
@ -487,7 +487,7 @@ function T8insert($data, $facilityno)
$stmt->bindParam(':CreatorId', $user_id);
$stmt->execute();
}
$row = 0;
// // 新增電梯數
foreach ($elevators as $index => $elevator) {
// echo '<pre>';
@ -535,23 +535,24 @@ function T8insert($data, $facilityno)
// 依每台電梯去加入各個的付款項
for ($i = 0; $i < $IncomeId[$payType]; $i++) {
$row++;
// 計算分期款的收款月份
$paymonth = $i * $SQuantity;
$payday = date('Y-m-d', strtotime("$date_1 + $paymonth months"));
$countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months"));
$payDay = str_replace('-', '', $countDay);
$rows_data = [
"BillNo" => "$contractno",
"IncomeId" => "$payType",
"TaxId" => "ST005",
"RowCode" => $i + 1,
"RowNo" => $i + 1,
"RowCode" => $row,
"RowNo" => $row,
"ItemType" => 1,
"SPrice" => $elevator['sold_price'],
"SQuantity" => $SQuantity,
"ProjectId" => "$contractno",
"FromSourceTag" => 0,
"CU_MaterialId" => "$facilityno[$index]",
"CU_EstPayDate" => "$payday"
"CU_EstPayDate" => "$payDay"
];
$salIncomeApplyDetail_rows[] = $rows_data;
}
@ -594,7 +595,8 @@ function T8insert($data, $facilityno)
// 呼叫 API
$result = T8API($API_body);
if ($result['Status'] == 'Error') {
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') {
http_response_code(404);
die('Error!:' . $result['ErrorMsg']);
}

23
wms/contract/api/testT8API.php

@ -2,13 +2,18 @@
$date = Date('Y-m-d');
$date1 = Date('Y-m-d', strtotime("$date +1 months"));
$a = 1;
$b = 12 / $a;
for ($i = 0; $i < $b; $i++) {
$c = $i * $a;
$date1 = Date('Y-m-d', strtotime("$date + $c months"));
echo '<pre>';
print_r($date1);
echo '</pre>';
// $countDay = date('Ymd', strtotime("$date1 + 1 months"));
// echo '<pre>';
// print_r($countDay);
// echo '</pre>';
// exit();
$a = 0;
// $b = 24 / $a;
for ($i = 0; $i < 2; $i++) {
for ($j = 0; $j < 12; $j++) {
$a++;
echo '<pre>';
print_r($a);
echo '</pre>';
}
}

2
wms/contract/connt8.php

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

15
wms/contract/connt8_test.php

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

8
wms/contract/contract-download.php

@ -24,6 +24,7 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
$stmt->bindParam(':id', $id);
$stmt->execute();
$contracts = $stmt->fetchAll(PDO::FETCH_ASSOC);
$contract = $contracts[0];
$contract_apply_id = $contract['id'];
if (($contract['status'] !== "YY" && $user_id != 'M0107' && $user_id != "TEST02" && $user_id == "TEST01") && $user_id != 'M0174' && $user_id != 'M0225') {
@ -52,7 +53,8 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
$install_total_price = 0;
// $noteArr = explode(",", $contracts[0]['note']);
$noteArr = array(1, 1, 1, 1, 1);
$qty = $contracts[0]['total_items'];
// $qty = $contracts[0]['total_items'];
$qty = 1;
foreach ($contracts as $idx => $amount) {
$isset = false;
if ($amount['pay_kind'] == 5 || $amount['pay_kind'] == 6) {
@ -413,8 +415,8 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
<input type="hidden" name="buystandard" x-model="toggleBuyStandard" />
<input type="hidden" name="installstandard" x-model="toggleInstallStandard" />
<input type="hidden" name="total_price" x-model="total_price" id="total_price" />
<input type="hidden" name="person" id="person" value="<?php echo $contract['accountname']; ?>" />
<input type="hidden" name="personid" id="personid" value="<?php echo $contract['accountid']; ?>" />
<input type="hidden" name="person" id="person" value="<?php echo $contract['personname']; ?>" />
<input type="hidden" name="personid" id="personid" value="<?php echo $contract['person']; ?>" />
<input type="hidden" name="delivery_term" id="delivery_term" x-model="buyfill1" />
<input type="hidden" name="install_period" id="install_period" x-model="installfill1" />
<input type="hidden" name="free_maintainance" id="free_maintainance" x-model="installfill2" />

114
wms/contract/contract-maintainance-management.php

@ -0,0 +1,114 @@
<?php
include("../header.php");
require_once("./conn.php");
$sql_str = "SELECT * FROM contract_b_signed_back ";
$stmt = $conn->prepare($sql_str);
$stmt->execute();
$contracts= $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<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 defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script>
<div style="overflow-x:auto;margin-top:12px">
<a href="contract-newelevator-input.php?function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</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>
</tr>
</thead>
<tbody>
<?php foreach($contracts as $contract): ?>
<tr>
<td><?php echo $contract['id']; ?></td>
<td><?php echo $contract['contract_no'] ?></td>
<td><?php echo $contract['company'] ?></td>
<td><?php echo $contract['customer_no'] ?></td>
<td><?php echo $contract['salesperson'] ?></td>
<td><?php echo $contract['contract_start_date'] ?></td>
<td><?php echo $contract['contract_end_date'] ?></td>
<td>
<?php
$endDate = new DateTime($contract['contract_end_date']);
$now = new DateTime();
$interval = $now->diff($endDate);
if ($interval->days <= 60) {
echo "60天以內。";
} else {
echo "指定日期與當前日期相差超過60天。";
}
?>
</td>
<td><?php echo $contract['created_by'] ?></td>
<td><?php echo $contract['created_at'] ?></td>
<td style="width:30px">
<p>
<a href="contract-newelevator-edit.php?contractid=<?php echo $contract['id']; ?>&function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a href="javascript:;" class="btn btn-info btn-sm" style="margin-left:10px;" @click="deleteFn(<?php echo $contract['id']; ?>)">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
<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>

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

@ -97,13 +97,14 @@ if (empty($contract_new_apply)) {
$stmt->bindParam(':contract_id', $id);
$stmt->execute();
$files = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($files);
// print_r($files);
}
$secondPayDeadline = $contract['secondPayDeadline'] ?? 0;
$status = isset($contract['status']) ? $contract['status'] : -1;
$progress = isset($contract['progress']) ? $contract['progress'] : 0;
$person = $contract['person'];
$para = "function_name=pricereview&" . $token_link;
?>
<link rel="stylesheet" href="./styles/style.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" />
@ -129,7 +130,8 @@ $person = $contract['person'];
</td>
<td class="text-right" style='border-left:0px;'>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button>
<button type="button" id="btn_close" class="btn btn-success" onclick="donwloadDraft()">下載草搞</button>
<!-- <a class="applybtn" href="./contract-download.php?id=<?php echo $id . '&' . $para ?>">下載草稿</a> -->
</td>
</tr>
<tr>
@ -703,3 +705,13 @@ $person = $contract['person'];
</script>
<?php endif; ?>
<script>
const donwloadDraft = () => {
if('<?php echo $status ?>' >=0 ){
window.location.href='./contract-download.php?id=<?php echo $id . '&' . $para ?>'
}else{
alert("請先暫存或送審文件!")
}
}
</script>

5
wms/contract/js/alpine.js

@ -734,7 +734,7 @@ const contractDownload = () => {
this.standardData.list.plaintext[10].text = '電梯保養:<br>一、乙方完工交車後,期後&nbsp;' + this.installfill2 + '&nbsp;個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。<br>二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。<br>三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。'
this.onstandardViewData.list.plaintext[10].text = '電梯保養:<br>一、乙方完工交車後,期後&nbsp;' + this.installfill2 + '&nbsp;個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。<br>二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。<br>三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。'
},
errorFn(){
errorFn() {
alert("資料有誤,請先填完整資料進行保存")
},
sendBuyInputFn() {
@ -948,7 +948,7 @@ const contractInput = () => {
},
cities: [],
data: {
contractno: 'B23100060',
contractno: 'B24010030',
total_price: '', //合約總價
vat: '', //統一編號
mtype: 'A', //維修型態
@ -1381,6 +1381,7 @@ const contractNewApply = () => {
form.append('status', 1);
form.append('review_comment', this.data.review_comment);
form.append('description', this.data.description);
form.append('progress', 0);
for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]);
}

BIN
wms/contract/mi/mi7.xlsx

Binary file not shown.

BIN
wms/contract/option/facility.xlsx

Binary file not shown.

7
wms/contract/prviewPdf.php

@ -19,6 +19,7 @@ if($_POST['list']){
$total_price = $_POST['total_price'];
$person = $_POST['person'];
$personid = $_POST['personid'];
echo "----->" . $personid;
$delivery_term = $_POST['delivery_term'];
$install_period = $_POST['install_period'];
$free_maintainance = $_POST['free_maintainance'];
@ -45,6 +46,10 @@ if($_POST['list']){
$stmt->bindParam(':vol_no', $partyAcontractno);
$stmt->execute();
$customer = $stmt->fetch(PDO::FETCH_ASSOC);
if(empty($customer)){
echo "有望客戶資料有誤!";
exit;
}
if(count($customer) <= 0 ){
echo "<script>
alert('資料不齊或合約書已生成過。');
@ -490,7 +495,7 @@ if($_POST['list']){
</tr>
</table>
</td>
<td style="border:none">&nbsp;臺北市中山區敬業一路128巷39號3樓之1</td>
<td style="border:none">&nbsp;桃園市觀音區崙坪村8鄰140號</td>
</tr>
</table>
<p>&nbsp;</p>

2
wms/contract/restoremi.php

@ -9,7 +9,7 @@ $id = $_GET['id'];
use PhpOffice\PhpSpreadsheet\IOFactory;
if($id == 999){
$filePath = './option/f1.xlsx';
$filePath = './option/facility.xlsx';
try {
$spreadsheet = IOFactory::load($filePath);
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {

20
wms/database.php

@ -19,21 +19,21 @@ $host = getenv('DB_HOST');
$dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE');
$link = mysqli_connect($host, $dbuser, $dbpassword, $dbname);
// $link = mysqli_connect($host, $dbuser, $dbpassword, $dbname);
$sqlsrv = getenv('sqlsrv');
$Database = getenv('Database');
$Account = getenv('Account');
$Password = getenv('Password');
try {
$conn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", "$Account", "$Password");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
}
// try {
// $conn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", "$Account", "$Password");
// if ($conn) {
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// }
// } catch (PDOException $e) {
// echo "fail";
// echo $e->getMessage();
// }
if ($link) {
mysqli_query($link, 'SET NAMES utf8');
// echo "正確連接資料庫";

8
wms/fun_global.php

@ -102,7 +102,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0)
// 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。
if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) {
$ret[1] = $user_id . ",,";
$ret[2] = "M0175,,<##>M0107,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
// $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理
@ -123,7 +123,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0)
}
} else {
$ret[2] = "M0175,,<##>M0107,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
// $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理
@ -158,7 +158,7 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
}
}
// $ret[1] = "M0029";
mysqli_free_result($res);
$ret[2] = 'M0012';
if ($renovate_flag == "REN") {
// $ret[2] = 'M0012';
@ -169,7 +169,7 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
if ($rate <= 100) $ret[3] = "M0008"; // 詹總
if ($rate < 80) $ret[4] = "M0006"; // 總經理
}
mysqli_free_result($res);
return $ret;
}

7
wms/mkt/assets/js/alpine.js

@ -84,7 +84,7 @@ const priceOptionIndex = () => {
if (item.spec == null) item.spec = ''
if (item.memo == null) item.memo = ''
if (item.price == null) item.price = 0
return (item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase()));
return (item.id.includes(text.toLowerCase()) ||item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase()));
}
}).slice((Number(this.currentpage) - 1) * Number(this.pageLength), (Number(this.currentpage) - 1) * Number(this.pageLength) + Number(this.pageLength))
this.dataLangth = this.options.length
@ -165,7 +165,7 @@ const priceOptionSelect = () => {
if (item.spec == null) item.spec = ''
if (item.memo == null) item.memo = ''
if (item.price == null) item.price = 0
return (item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase()));
return (item.id.includes(text.toLowerCase()) || item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase()));
}).slice((Number(this.currentpage) - 1) * Number(this.pageLength), (Number(this.currentpage) - 1) * Number(this.pageLength) + Number(this.pageLength))
this.dataLangth = this.options.length
} else {
@ -297,13 +297,14 @@ const pricereviewOptionSelect = () => {
this.options = this.orioptions
this.reloadOptions();
let val = (e== null) ? this.searchtext.toLowerCase() : e.target.value.toLowerCase()
console.log(val);
this.options.forEach(option=>{
if(option.group_name == null) option.group_name = ''
if(option.spec == null) option.spec = ''
if(option.memo == null) option.memo = ''
if(option.price == null) option.price = 0
if(option.unit == null) option.unit = ''
if(option.group_name.includes(val) || option.memo.toLowerCase().includes(val) || option.spec.toLowerCase().includes(val) || option.unit.includes(val) || String(option.price).includes(val)){
if(option.id.includes(val) || option.group_name.includes(val) || option.memo.toLowerCase().includes(val) || option.spec.toLowerCase().includes(val) || option.unit.includes(val) || String(option.price).includes(val)){
option.status = "Y"
}else{
option.status = "N"

5
wms/mkt/assets/js/alpinejs/cdn.min.js

File diff suppressed because one or more lines are too long

7
wms/mkt/assets/js/pricereviewAlpine.js

@ -0,0 +1,7 @@
const pricereviewCreate = ()=>{
return {
init(){
console.log(123)
}
}
}

10
wms/mkt/conn.php

@ -20,11 +20,11 @@ $db_name = getenv('DB_DATABASE'); //使用的資料庫
$db_charset = 'utf8'; //設定字元編碼
// $db_hostname = 'localhost'; //資料庫主機名稱
// $db_username = 'masadaroot'; //登入資料庫的管理者的帳號
// $db_password = 'x6h5E5p#u8y'; //登入密碼
// $db_name = 'appwms'; //使用的資料庫
// $db_charset = 'utf8'; //設定字元編碼
$db_hostname = 'localhost'; //資料庫主機名稱
$db_username = 'root'; //登入資料庫的管理者的帳號
$db_password = ''; //登入密碼
$db_name = 'appwms'; //使用的資料庫
$db_charset = 'utf8'; //設定字元編碼
//建立PDO的指定工作
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset";

90
wms/mkt/css/pricereview.css

@ -0,0 +1,90 @@
#pricereviewCreate table, #pricereviewCreate th, #pricereviewCreate td {
border: 1px #ccc solid;
padding: 15px;
}
#pricereviewCreate table thead th {
background-color: #6D9EEB;
}
#pricereviewCreate table tbody td input {
font-size: 14px;
}
#pricereviewCreate table tbody th {
background-color: #CCE4F8;
font-size: 14px;
padding: 15px 2px;
min-width: 100px;
text-align: center;
}
#pricereviewCreate table input {
font-size: 13px;
}
#pricereviewCreate .pricreviewmain {
background-color: #F2F2F2;
padding: 20px;
border-radius: 6px;
}
#pricereviewCreate .pricreviewmain button {
color: #fff;
width: 55px;
height: 30px;
padding: 0;
margin-left: 10px;
font-size: 13px;
}
#pricereviewCreate .pricreviewmain button.addbtn {
background-color: #337AB7;
width: 30px;
}
#pricereviewCreate .pricreviewmain button.deleteBtn {
background-color: #D9534F;
color: #fff;
font-size: 12px;
width: 30px;
}
#pricereviewCreate .pricreviewmain button.selectElevator {
background-color: #D9534F;
color: #fff;
}
#pricereviewCreate .pricreviewmain > .divitem {
border: 1px #ccc solid;
padding: 10px;
border-radius: 4px;
}
#pricereviewCreate .pricreviewmain > .divitem .title {
display: flex;
align-items: center;
border-bottom: 1px #ccc solid;
padding: 10px 0;
margin-bottom: 10px;
}
#pricereviewCreate .pricreviewmain > .divitem .title h6 {
font-weight: 600;
}
#pricereviewCreate .pricreviewmain > .divitem table, #pricereviewCreate .pricreviewmain > .divitem th, #pricereviewCreate .pricreviewmain > .divitem td {
font-size: 14px;
background-color: transparent;
}
#pricereviewCreate .pricreviewmain > .divitem table input, #pricereviewCreate .pricreviewmain > .divitem table select, #pricereviewCreate .pricreviewmain > .divitem table textarea, #pricereviewCreate .pricreviewmain > .divitem th input, #pricereviewCreate .pricreviewmain > .divitem th select, #pricereviewCreate .pricreviewmain > .divitem th textarea, #pricereviewCreate .pricreviewmain > .divitem td input, #pricereviewCreate .pricreviewmain > .divitem td select, #pricereviewCreate .pricreviewmain > .divitem td textarea {
font-size: 13px;
}
#pricereviewCreate .pricreviewmain > .divitem table input[type=number]::-webkit-outer-spin-button,
#pricereviewCreate .pricreviewmain > .divitem table input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .pricreviewmain > .divitem th input[type=number]::-webkit-outer-spin-button,
#pricereviewCreate .pricreviewmain > .divitem th input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .pricreviewmain > .divitem td input[type=number]::-webkit-outer-spin-button,
#pricereviewCreate .pricreviewmain > .divitem td input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
#pricereviewCreate .pricreviewmain > .divitem table tr:hover .deleteBtn {
opacity: 1;
}
#pricereviewCreate .pricreviewmain > .divitem table .saletd {
position: relative;
}
#pricereviewCreate .pricreviewmain > .divitem table .saletd > .deleteBtn {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 2px;
opacity: 0;
transition: 0.3s;
}/*# sourceMappingURL=pricereview.css.map */

1
wms/mkt/css/pricereview.css.map

@ -0,0 +1 @@
{"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,sBAAA;EACA,aAAA;ACAR;ADGQ;EACI,yBAAA;ACDZ;ADIY;EACI,eAAA;ACFhB;ADIY;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACFhB;ADKQ;EACI,eAAA;ACHZ;ADMI;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;ACJR;ADKQ;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,iBAAA;EACA,eAAA;ACHZ;ADIY;EACI,yBAAA;EACA,WAAA;ACFhB;ADIY;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACFhB;ADIY;EACI,yBAAA;EACA,WAAA;ACFhB;ADMQ;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACJZ;ADKY;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACHhB;ADIgB;EACI,gBAAA;ACFpB;ADMY;EACI,eAAA;EACA,6BAAA;ACJhB;ADKgB;EACI,eAAA;ACHpB;ADKgB;;;;EAEA,wBAAA;EACA,SAAA;ACDhB;ADKgB;EACI,UAAA;ACHpB;ADKgB;EACI,kBAAA;ACHpB;ADIoB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACFxB","file":"pricereview.css"}

98
wms/mkt/css/pricereview.scss

@ -0,0 +1,98 @@
#pricereviewCreate{
table, th, td{
border:1px #ccc solid;
padding: 15px;
}
table{
thead th{
background-color: #6D9EEB;
}
tbody {
td input{
font-size: 14px;
}
th{
background-color: #CCE4F8;
font-size: 14px;
padding: 15px 2px;
min-width: 100px;
text-align: center;
}
}
input{
font-size: 13px;
}
}
.pricreviewmain{
background-color: #F2F2F2;
padding: 20px;
border-radius: 6px ;
button{
color:#fff;
width: 55px;
height: 30px;
padding: 0;
margin-left: 10px;
font-size: 13px;
&.addbtn{
background-color: #337AB7;
width: 30px;
}
&.deleteBtn{
background-color: #D9534F;
color:#fff;
font-size: 12px;
width: 30px;
}
&.selectElevator{
background-color: #D9534F;
color:#fff;
}
}
>.divitem{
border:1px #ccc solid;
padding: 10px;
border-radius: 4px ;
.title{
display: flex;
align-items: center;
border-bottom: 1px #ccc solid;
padding: 10px 0;
margin-bottom: 10px;
h6{
font-weight: 600;
}
}
table, th, td{
font-size: 14px;
background-color: transparent;
input, select, textarea{
font-size: 13px;
}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
}
table {
tr:hover .deleteBtn{
opacity: 1;
}
.saletd{
position: relative;
>.deleteBtn{
position: absolute;
top: 50%;
transform: translateY(-50%);
right:2px;
opacity: 0;
transition: .3s;
}
}
}
}
}
}

4
wms/mkt/price_option-index.php

@ -74,7 +74,7 @@ $optional_arr = [1 => '標', 2 => '選'];
<th scope="col" nowrap>配置</th>
<th scope="col" nowrap>單位</th>
<th scope="col" nowrap>定價</th>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225") : ?>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225" || $user_id =="M0060" || $user_id =="M0061") : ?>
<th scope="col" nowrap>MI</th>
<?php endif; ?>
</tr>
@ -96,7 +96,7 @@ $optional_arr = [1 => '標', 2 => '選'];
<td x-text="options_arr[option.optional]"></td>
<td x-text="option.unit"></td>
<td x-html="option.price!=null ? '$'+Number(option.price).toLocaleString() : '$0'"></td>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225") : ?>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225" || $user_id =="M0060" || $user_id =="M0061") : ?>
<td x-html="option.mi!=null ? '$'+Number(option.mi).toLocaleString() : ''"></td>
<?php endif; ?>
</tr>

4
wms/mkt/price_option-select.php

@ -58,7 +58,7 @@ $optional_arr = [1 => '標配', 2 => '選配',3=>'加價'];
<th scope="col" nowrap>配置</th>
<th scope="col" nowrap>單位</th>
<th scope="col" nowrap>定價</th>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225") : ?>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225" || $user_id =="M0061" || $user_id == "M0060") : ?>
<th scope="col" nowrap>MI</th>
<?php endif; ?>
</tr>
@ -80,7 +80,7 @@ $optional_arr = [1 => '標配', 2 => '選配',3=>'加價'];
<td x-text="options_arr[option.optional]"></td>
<td x-text="option.unit"></td>
<td x-html="option.price!=null ? '$'+Number(option.price).toLocaleString() : '$0'"></td>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225") : ?>
<?php if ($user_id == 'M0174' || $user_id == 'M0107' || $user_id == "M0225" || $user_id =="M0060" || $user_id =="M0061") : ?>
<td x-html="option.mi!=null ? '$'+Number(option.mi).toLocaleString() : '$0'"></td>
<?php endif; ?>
</tr>

3
wms/mkt/pricereview-check.php

@ -52,6 +52,7 @@ $res = mysqli_query($link, $db_query);
foreach ($res as $data) {
// 上層主管
$sql = "select manager from account where accountid = '" . $data["person"] . "'";
echo $sql;
$res_a = mysqli_query($link, $sql);
$row_a = mysqli_fetch_row($res_a);
$manager = $row_a[0];
@ -662,7 +663,7 @@ foreach ($res as $data) {
?>
<tr>
<td><?php echo $idx; ?></td>
<td><input type="text" name="option_seat" class="form-control" size="30" value="<?= $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_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?= number_format($val["item_price_bp"]); ?>"></td>

14
wms/mkt/pricereview-create.php

@ -754,7 +754,7 @@ $option_str .= "</tbody></table>";
$("#optionModal").modal('show');
var jobj = $(this); // 父視窗
$("#optionModal .modal-body td").unbind().click(function(){
$("#optionModal .modal-body td").unbind().click(function() {
var pobj = $(this).closest('td').parent();
selectOptionFn(pobj, jobj)
});
@ -832,7 +832,7 @@ $option_str .= "</tbody></table>";
jobj.closest('td').parent().find('td[name=Exclusions]').html(str);
});
} else {
alert("請先新增OPTION");
alert("請先新增除外項目");
return false;
}
});
@ -2486,7 +2486,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<input type="file" name="attatch2" id="attatch2"><a href="javascript:void(0);" name="filedel2" class="btn btn-danger btn-sm">X</a>
<div class="nextline"></div><br>
<button type="submit" name="save" id="save" value="save">保存</button>&nbsp;
<button type="submit" name="submit" id="submit" value="tosign" >提交</button>
<button type="submit" name="submit" id="submit" value="tosign">提交</button>
<input type="hidden" name="fp_id_all" id="fp_id_all">
<input type="hidden" name="fp_kind_all" id="fp_kind_all">
@ -2556,14 +2556,16 @@ include "../footer.php";
// 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(pobj.find('td').eq(0).html());
jobj.html(pobj.find('td').eq(1).html() + " " + 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("()", "")
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_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=op_id]').val(pobj.find('td').eq(0).html());
$("#optionModal").modal('hide');
}
function checkSubmit(){
function checkSubmit() {
const price_total = document.getElementById('price_total')
if (Number(price_total.value.replace(",", "")) > 0) {

3346
wms/mkt/pricereview-edit.php

File diff suppressed because it is too large

57
wms/mkt/pricereview-index.php

@ -125,6 +125,14 @@ if (!empty($res_get) || (!empty($_GET['check']) && $_GET['check'] == 1)) {
// echo $sql;
}
if ($user_id === "M0137") {
$sql = "SELECT pricereview_main.*,contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress
FROM pricereview_main
left join contract_new_apply on contract_new_apply.mid = pricereview_main.id
JOIN account ON account.accountid = pricereview_main.creater
WHERE (account.manager = 'M0029' OR account.manager='M0137') AND pricereview_main.status <> 'D' AND pricereview_main.ekind = '新梯' order by pricereview_main.id";
}
$data = mysqli_query($link, $sql);
// 若結案不同意
@ -323,9 +331,11 @@ function get_pending($token)
}
$result = get_pending($token);
print_r($result);
$result[1]['sid'] = !empty($result) ? $result[1]['sid'] : 'prm';
$result[1]['fid'] = !empty($result) ? $result[1]['fid'] : 'prm01';
// print_r($result);
if (count($result) > 0) {
$result[1]['sid'] = !empty($result) ? $result[1]['sid'] : 'prm';
$result[1]['fid'] = !empty($result) ? $result[1]['fid'] : 'prm01';
}
if ($data) :
/*
@ -338,23 +348,27 @@ if ($data) :
}
*/
?>
<style>
.categoryBtn{
width:120px;
height: 32px;
padding: 0;
line-height: 30px;
}
</style>
<style>
.categoryBtn {
width: 120px;
height: 32px;
padding: 0;
line-height: 30px;
}
</style>
<link rel="stylesheet" href="common.css">
<div style="overflow-x:auto; white-space:nowrap;">
<?php if($user_id=== "M0060" || $user_id==="M0107" || $user_id==="M0175" || $user_id==="M0174" || $user_id==="M0225"){ ?>
<a href="/wms/mkt/pricereview-index.php?&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['system_id']) && !isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有價審</a>
<a href="/wms/mkt/pricereview-index.php?system_id=<?= $result[1]['sid'] ?>&flow_id=<?= $result[1]['fid'] ?>&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['system_id'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 待我簽核</a>
<a href="/wms/mkt/pricereview-index.php?check=1&function_name=pricereview&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/mkt/pricereview-index.php?check=2&function_name=pricereview&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/mkt/pricereview-index.php?check=3&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 結案不同意</a>
<?php } ?>
<?php if (($user_id === "M0060" || $user_id === "M0107" || $user_id === "M0175" || $user_id === "M0174" || $user_id === "M0225")) { ?> <a href="/wms/mkt/pricereview-index.php?&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['system_id']) && !isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有價審</a>
<?php if (count($result) > 0) : ?>
<a href="/wms/mkt/pricereview-index.php?system_id=<?= $result[1]['sid'] ?>&flow_id=<?= $result[1]['fid'] ?>&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['system_id'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 待我簽核</a>
<?php else : ?>
<a href="javascript:;" onclick="alert('無待簽資料')" class=" btn <?php echo (isset($_GET['system_id'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 待我簽核</a>
<?php endif; ?>
<a href="/wms/mkt/pricereview-index.php?check=1&function_name=pricereview&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/mkt/pricereview-index.php?check=2&function_name=pricereview&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/mkt/pricereview-index.php?check=3&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 結案不同意</a>
<?php } ?>
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
@ -698,13 +712,15 @@ if ($data) :
<?php if (($user_id === "M0107" || $user_id === "M0060") && $data['applystatus'] < 3) : ?>
<span style="font-size:13px;font-weight:600">待申請</span>
<?php elseif ($data['applystatus'] < 3) : ?>
<a class="applybtn" target="_blank" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">
<?php if ($data['applystatus'] < 1) {
echo "申請";
} else {
echo "檢視";
} ?>
</a><br>
<?php else : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">審請已通過</a><br>
<?php endif; ?>
<?php else : ?>
@ -720,9 +736,6 @@ if ($data) :
<?php if (false && ($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175" || $user_id === "TEST02")) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載</a>
<?php endif; ?>
<?php if ($data['status'] === 'YY') : ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載草稿</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>

516
wms/mkt/pricereviewCreate.php

@ -0,0 +1,516 @@
<?php
// include "../header.php";
require_once("./conn.php");
?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="./css/pricereview.css">
<script src="./assets/js/alpinejs/cdn.min.js"></script>
<script src="./assets/js/pricereviewAlpine.js"></script>
<div id="pricereviewCreate" x-data="pricereviewCreate()">
<div class="container">
<table class="table" border="1">
<thead >
<tr class="" >
<th scope="col" class="text-center " colspan="8">有望客戶基本資料</th>
</tr>
</thead>
<tbody>
<tr>
<th >卷號</th>
<td><input class="form-control" type="text" disabled value="B123456789" /></td>
<th>客戶名稱</th>
<td><input class="form-control" type="text" disabled value="中華民國" /></td>
<th>負責人</th>
<td><input class="form-control" type="text" disabled value="馬英九" /></td>
<th>客戶來源</th>
<td><input class="form-control" type="text" disabled value="朋友介紹" /></td>
</tr>
<tr>
<th>地址</th>
<td><input class="form-control" type="text" disabled value="嘉義市東區日新街55巷13號" /></td>
<th>案件名稱</th>
<td><input class="form-control" type="text" disabled value="川勝開發營造(興美七街)" /></td>
<th>統編/身份證</th>
<td><input class="form-control" type="text" disabled value="83557587" /></td>
<th>業主方聯係人</th>
<td><input class="form-control" type="text" disabled value="曾祈達" /></td>
</tr>
<tr>
<th>市話/手機</th>
<td><input class="form-control" type="text" disabled value="0921361700" /></td>
<th>營業員</th>
<td><input class="form-control" type="text" disabled value="林易增" /></td>
<th>台數</th>
<td><input class="form-control" type="number" disabled value="1" /></td>
<th>預定成交日</th>
<td><input class="form-control" type="text" disabled value="2024/02/01" /></td>
</tr>
<tr>
<th>有望客戶狀態</th>
<td><input class="form-control" type="text" disabled value="有望簽約(已報價)" /></td>
<th>汰改</th>
<td><input class="form-control" type="text" disabled value="否" /></td>
</tr>
</tbody>
</table>
<table class="table" border="1">
<thead >
<tr class="" >
<th scope="col" class="text-center " colspan="8">洽商進度</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan=8>
<textarea class="form-control" name="progress" id="progress" cols="20" rows="5" disabled ></textarea>
</td>
</tr>
</tbody>
</table>
<table class="table" border="1">
<thead >
<tr class="" >
<th scope="col" class="text-center " colspan="8">電梯規格訊息</th>
</tr>
</thead>
<tbody>
<tr>
<th >序號</th>
<th >規格</th>
<th >人乘/載重</th>
<th >停數</th>
<th >開門方式</th>
<th >速度(m/min)</th>
<th >數量</th>
<th >單價</th>
</tr>
<tr>
<td ><input type="text" disabled class="form-control disabled" value="1"></td>
<td ><input type="text" disabled class="form-control disabled" value="MAH100(家庭梯)"></td>
<td ><input type="text" disabled class="form-control disabled" value="6人"></td>
<td ><input type="text" disabled class="form-control disabled" value="4人"></td>
<td ><input type="text" disabled class="form-control disabled" value="2S"></td>
<td ><input type="text" disabled class="form-control disabled" value="45"></td>
<td ><input type="text" disabled class="form-control disabled" value="1"></td>
<td ><input type="text" disabled class="form-control disabled" value="100000"></td>
</tr>
</tbody>
</table>
<div class="pricreviewmain container">
<div class="divitem">
<div class="title">
<h6>整機單價</h6>
<button class="addbtn btn" x-ref="addElevatorBtn">+</button>
</div>
<table class="table" border=1>
<thead>
<tr>
<td>電梯</td>
<td>人乘/載重</td>
<td>停數</td>
<td>速度(m/min)</td>
<td>開門方式</td>
<td>規格</td>
<td>單價</td>
<td>數量</td>
<td>複價</td>
<td>售價 </td>
</tr>
</thead>
<tbody>
<tr>
<td>
<select name="" id="" class="form-control">
<option value="">請選擇</option>
<option value="MAE100">MAE100有機房</option>
<option value="MAM200">MAM200無機房</option>
<option value="MAH100">MAH100小電梯</option>
<option value="MAF100">MAE100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option>
</select>
</td>
<td>
<select name="" id="" class="form-control">
<option value="">請選擇</option>
<option value="6">6</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="15">15</option>
<option value="17">17</option>
<option value="20">20</option>
<option value="24">24</option>
</select>
</td>
<td>
<input class="form-control" type="number" style="width:50px;padding-left:5px" />
</td>
<td>
<select name="" id="" class="form-control" style="width:80px">
<option value="">請選擇</option>
<option value="9">9</option>
<option value="24">24</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="60">60</option>
<option value="90">90</option>
<option value="105">105</option>
<option value="120">120</option>
<option value="150">150</option>
</select>
</td>
<td>
<select name="" id="" class="form-control" style="width:80px">
<option value="CO">CO</option>
<option value="2S">2S</option>
<option value="2U">CO</option>
<option value="4PCO">4PCO</option>
<option value="6PCO">6PCO</option>
</select>
</td>
<td>
<input type="text" class="form-control" disabled value="MAE100-6*7-CO45">
</td>
<td><input type="text" class="form-control" disabled value="750000" style="width:100px"></td>
<td><input type="number" class="form-control " disabled value="1" style="width:40px;padding-left:5px"></td>
<td><input type="number" class="form-control " disabled value="750000" style="width:100px"></td>
<td class="saletd">
<input type="number" class="form-control " disabled value="690000" style="width:100px">
<button class="deleteBtn btn btn-danger">X</button>
</td>
</tr>
<tr>
<td colspan=7>小計</td>
<td><input type="number" class="form-control" disabled value="1" style="width:40px;padding-left:5px"></td>
<td><input type="text" class="form-control" disabled value="750000" style="width:100px"></td>
<td><input type="text" class="form-control" disabled value="690000" style="width:100px"></td>
</tr>
</tbody>
</table>
</div>
<div class="divitem">
<div class="title">
<h6>Option加價</h6>
<button class="addbtn btn" x-ref="addElevatorBtn">+</button>
</div>
<table class="table" border=1>
<thead>
<tr>
<td>選配規格</td>
<td>單價</td>
<td>數量</td>
<td>複價</td>
<td>備註</td>
<td>所屬電梯</td>
<td>功能</td>
</tr>
</thead>
<tbody>
<tr>
<td><button class="btn btn-success">選擇</button></td>
<td><input type="text" class="form-control" value="35000"></td>
<td><input type="number" class="form-control" value="1"></td>
<td><input type="text" class="form-control" disabled value="35000"></td>
<td><input type="text" class="form-control"></td>
<td>MAE100-6*7-CO45</td>
<td>
<div class="d-flex">
<button class="selectElevator btn btn-danger">電梯</button>
<button class="deleteBtn btn btn-danger">X</button>
</div>
</td>
</tr>
<tr>
<td colspan=3>小計</td>
<td colspan=1 ><input type="number" class="form-control" disabled value="350000" ></td>
<td colspan=4 ></td>
</tr>
</tbody>
</table>
</div>
<div class="divitem">
<div class="title">
<h6>除外項目</h6>
<button class="addbtn btn" x-ref="addElevatorBtn">+</button>
</div>
<table class="table" border=1>
<thead>
<tr>
<td>詢價單號</td>
<td>名稱</td>
<td>單價</td>
<td>數量</td>
<td>複價</td>
<td>所屬電梯</td>
<td>功能</td>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" class="form-control" value=""></td>
<td><input type="text" class="form-control" value=""></td>
<td><input type="text" class="form-control" value=""></td>
<td><input type="number" class="form-control" value=""></td>
<td><input type="text" class="form-control" disabled></td>
<td>MAE100-6*7-CO45</td>
<td>
<div class="d-flex">
<button class="selectElevator btn btn-danger">電梯</button>
<button class="deleteBtn btn btn-danger">X</button>
</div>
</td>
</tr>
<tr>
<td colspan=3>小計</td>
<td colspan=1 ><input type="number" class="form-control" disabled value="0" ></td>
<td colspan=1 ><input type="number" class="form-control" disabled value="0" ></td>
<td colspan=3 ></td>
</tr>
</tbody>
</table>
</div>
<div class="divitem">
<div class="title">
<h6>保固延長</h6>
<button class="addbtn btn" x-ref="addElevatorBtn">+</button>
</div>
<table class="table" border=1>
<thead>
<tr>
<td>電梯</td>
<td>人乘/載重</td>
<td>停數</td>
<td>速度</td>
<td>單價</td>
<td>數量(月)</td>
<td>複價</td>
<td>備註</td>
<td>所屬電梯</td>
<td>功能</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<select name="" id="" class="form-control">
<option value="">請選擇</option>
<option value="MAE100">MAE100有機房</option>
<option value="MAM200">MAM200無機房</option>
<option value="MAH100">MAH100小電梯</option>
<option value="MAF100">MAE100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option>
</select>
</td>
<td>
<select name="" id="" class="form-control">
<option value="">請選擇</option>
<option value="6">6</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="15">15</option>
<option value="17">17</option>
<option value="20">20</option>
<option value="24">24</option>
</select>
</td>
<td>
<input class="form-control" type="number" style="width:50px;padding-left:5px" />
</td>
<td>
<select name="" id="" class="form-control" style="width:80px">
<option value="">請選擇</option>
<option value="9">9</option>
<option value="24">24</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="60">60</option>
<option value="90">90</option>
<option value="105">105</option>
<option value="120">120</option>
<option value="150">150</option>
</select>
</td>
<td><input type="text" class="form-control"></td>
<td><input type="number" class="form-control " value="1" style="width:40px;padding-left:5px"></td>
<td><input type="number" class="form-control " disabled value="750000" style="width:100px"></td>
<td><input type="text" class="form-control"></td>
<td>MAE100-6*7-CO45</td>
<td>
<div class="d-flex">
<button class="selectElevator btn btn-danger">電梯</button>
<button class="deleteBtn btn btn-danger">X</button>
</div>
</td>
</tr>
<tr>
<td colspan=5>小計</td>
<td colspan=1 ><input type="number" class="form-control" disabled value="0" ></td>
<td colspan=1 ><input type="number" class="form-control" disabled value="0" ></td>
<td colspan=3 ></td>
</tr>
</tbody>
</table>
</div>
<div class="divitem">
<table style="width:800px" class="table" border=1>
<thead>
<tr>
<td>付款辦法</td>
<td>款別</td>
<td >比例(%)</td>
<td>金額</td>
<td>票期</td>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4">材料</td>
<td >1.訂金</td>
<td ><input type="number" class="form-control" value="20"></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td >2.二次款</td>
<td ><input type="number" class="form-control" ></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td >3.貨到工地款</td>
<td ><input type="number" class="form-control" value="50"></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td >4.其他</td>
<td ><input type="number" class="form-control"></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td rowspan="3">安裝</td>
<td >5.安裝完畢款</td>
<td ><input type="number" class="form-control" value="20"></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td >6.驗收款</td>
<td ><input type="number" class="form-control" value="10"></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td >7.其他</td>
<td ><input type="number" class="form-control"></td>
<td><input type="number" class="form-control" disabled></td>
<td>
<select name="" id="" class="form-control">
<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="180">180天</option>
<option value="">其他</option>
</select>
</td>
</tr>
<tr>
<td colspan=2>合計</td>
<td colspan=1 ><input type="number" class="form-control" disabled value="0" ></td>
<td colspan=1 ><input type="number" class="form-control" disabled value="0" ></td>
<td colspan=3 ></td>
</tr>
<tr>
<td colspan=2>備註</td>
<td colspan=4 >
<textarea name="" class="form-control" id="" cols="30" rows="5"></textarea>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

95
wms/mkt/pricereview_mi-api.php

@ -106,6 +106,7 @@ try {
$opt_elev_arr[$row[0]]["item_qty"] = $row[3];
$tmp_arr = explode(",", $row[4]);
$opt_elev_arr[$row[0]]["elev_no"] = $tmp_arr;
if (!empty($opt_elev_arr[$row[0]]["elev_no"][0])) {
foreach ($tmp_arr as $v) {
$elev_arr[$v]["option"][] = $row[0];
@ -125,6 +126,7 @@ try {
}
*/
}
mysqli_free_result($res);
$opt_nosel_id_arr = array_diff(array_keys($opt_elev_arr), $opt_sel_id_arr);
@ -167,6 +169,7 @@ try {
$ex_fee += $exarr[$j][1];
$j++;
}
// print_r($exarr);
mysqli_free_result($res);
// 拆梯&美容平均分到每台電梯
@ -326,16 +329,17 @@ try {
LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id
LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no
WHERE option_price.status = 'Y' ";
$sql4 = "SELECT option_price.id, elevator_quotation_rule.equipment, option_mi.base_floor, option_mi.quotation_no, option_mi.base_floor_plus, option_mi.price, option_price.price as OP
FROM option_price
LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id
LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no
WHERE option_mi.option_price_id = " . $opt_elev_arr[$val]["price_id"] . "
AND (" . $v["item_weight"] . " BETWEEN option_mi.min_weight AND option_mi.max_weight)
AND option_mi.open_kind = '" . $v["item_op"] . "'";
//新的SQL
$sql4 = "SELECT option_price.id, elevator_quotation_rule.equipment, option_mi.base_floor, option_mi.quotation_no, option_mi.base_floor_plus, option_mi.price, option_price.price as OP
FROM option_price
LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id
LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no
WHERE option_mi.option_price_id = " . $opt_elev_arr[$val]["price_id"] . "
AND (" . $v["item_weight"] . " BETWEEN option_mi.min_weight AND option_mi.max_weight)
AND option_mi.open_kind = '" . $v["item_op"] . "'";
$res_om = mysqli_query($link, $sql4);
if ($row_om = mysqli_fetch_assoc($res_om)) {
$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;
@ -449,6 +453,81 @@ AND option_mi.open_kind = '" . $v["item_op"] . "'";
}
$rarr["content"] = $mi_arr;
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'E'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT pricereview_item.*,option_mi.price as option_mi FROM pricereview_item LEFT JOIN option_mi ON pricereview_item.price_id = option_mi.option_price_id WHERE pricereview_item.mid = :mid AND pricereview_item.item_group = 'B'";
$sql_str = "SELECT
pricereview_item.*,
(SELECT option_mi.price
FROM option_mi
WHERE pricereview_item.price_id = option_mi.option_price_id
ORDER BY option_mi.id ASC LIMIT 1) AS option_mi
FROM
pricereview_item
WHERE
pricereview_item.mid = :mid
AND pricereview_item.item_group = 'B'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$itemoptions = $stmt->fetchAll(PDO::FETCH_ASSOC);
$exceptArr = [];
foreach($items as $item){
if($item['option_relate_spec'] != NULL){
$exceptArr[] = [
'option_relate_spec'=> $item['option_relate_spec'],
'item_spec'=>$item['item_spec'],
'item_unit_price'=>$item['item_unit_price'],
'item_qty'=>$item['item_qty'],
'item_price_bp'=> $item['item_price_bp'],
];
}
}
// $rarr["content"][] = $exceptArr;
print_r($rarr["content"]);
exit;
foreach($rarr["content"] as $idx=>&$item){
$newTotal = 0;
$item[16] = [];
$item[14] = [];
foreach($exceptArr as $except){
if($idx+1 == $except['option_relate_spec']){
$item[16][] = [
$except['item_spec'],
$except['item_unit_price']* $except['item_qty']
];
}
}
foreach($itemoptions as $itemoption){
if($idx+1 == $itemoption['option_relate_spec']){
$item[14][] = [
$itemoption['item_spec'],
round($itemoption['option_mi'] * $itemoption['item_qty'], 0),
];
}
}
foreach($item[14] as $option){
$newTotal += $option[1];
}
foreach($item[16] as $ex){
$newTotal += $ex[1];
}
$newTotal += $item[17];
$newTotal += $item[19][1];
$item[13] = $newTotal;
}
} catch (\Exception $e) {
$rarr['st'] = 'err';
$rarr['err'] = $e->getMessage();

3
wms/rib01-check.php

@ -358,7 +358,8 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
</tr>
</thead>
<tbody>
<?php foreach ($pay_data as $pay) : ?>
<?php
foreach ($pay_data as $pay) : ?>
<tr>
<td><?= $pay['FeeDate'] ?></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>
<option value="" id="WriteOffOption">請選擇報銷人</option>
<?php
foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
if (is_iterable($member)) {
foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php }
}
?>
</select>
</div>
@ -187,12 +189,14 @@ if ($pay_data) {
echo "disabled";
} ?>>
<?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']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php }; ?>
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . $value[0] ?>" <?php if ($key == $data['GatheringPersonId']) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
<?php }
}; ?>
</select>
</div>

150
wms/rib01-index.php

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

2
wms/rib02-create.php

@ -157,7 +157,7 @@ $materials = $conn->query($sql_Material);
</div>
<div class="col-md-3">
<label for="FeeDate" style="color: red;">發票日期</label>
<label for="FeeDate" style="color: red;">費用日期</label>
<input class="form-control" type="int" name="FeeDate" id="FeeDate" placeholder="西元年(4碼)+月(2碼)+日(2碼)" required>
</div>

109
wms/rib02-edit.php

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

18
wms/rib02-submit.php

@ -50,7 +50,7 @@ $OAmount = $CurrId == "TWD" ? round($_POST['OAmount']) : round($_POST['OAmount']
$TaxId = $_POST['TaxId'];
$IsCounteract = $_POST['IsCounteract'];
$InvoiceId = $_POST['InvoiceId'];
$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount'];
$VoucherCount = isset($_POST['VoucherCount']) ? $_POST['VoucherCount']:0;
$VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0;
$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`,
`BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`,
`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 .= empty($ProjectId) ? "" : ",`ProjectId`";
$SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`";
$SQL1 .= empty($VoucherCount) ? "" : ",`VoucherCount`";
$SQL1 .= isset($VoucherType) ? ",`VoucherType`" : "";
$SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`";
$SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`";
@ -120,12 +119,11 @@ if ($submit == "add") {
$SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2,
'1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity,
$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 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'";
$SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : "";
$SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'";
$SQL2 .= empty($VoucherCount) ? "" : "," . $VoucherCount;
$SQL2 .= isset($VoucherType) ? "," . $VoucherType : "";
$SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'";
$SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'";
@ -134,11 +132,10 @@ if ($submit == "add") {
} else {
$SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`,
`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 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`";
$SQL1 .= empty($VoucherCount) ? "" : ",`VoucherCount`";
$SQL1 .= isset($VoucherType) ? ",`VoucherType`" : "";
$SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`";
$SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`";
@ -146,11 +143,10 @@ if ($submit == "add") {
$SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2,
'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 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : "";
$SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'";
$SQL2 .= empty($VoucherCount) ? "" : "," . $VoucherCount;
$SQL2 .= isset($VoucherType) ? "," . $VoucherType : "";
$SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'";
$SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'";
@ -177,11 +173,11 @@ if ($submit == "add") {
<?php
} elseif ($submit == "edit") {
$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 .= isset($FeeTypeGen) ? ",FeeTypeGen=$FeeTypeGen" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",CU_MaterialId='$CU_MaterialId'";
$SQL1 .= empty($VoucherCount) ? "" : ",VoucherCount=$VoucherCount";
$SQL1 .= isset($VoucherType) ? ",VoucherType=$VoucherType" : "";
$SQL1 .= empty($InvoiceNo) ? " " : ",InvoiceNo='$InvoiceNo'";
$SQL1 .= empty($comSupplierName) ? ",comSupplierName=' '" : ",comSupplierName='$comSupplierName'";

44
wms/schedule-index.php

@ -24,7 +24,7 @@ $data = array();
// sql語法存在變數中
$page_close = 0;
$sql_cmd2 = "";
$sql_cmd = sql_myself($user_id, "repairedid");
$sql_cmd = sql_myself($user_id, "repairerid");
if ($user_department_id == "501" || $user_department_id == "322" || $user_id == "M0012" || $user_id == "M0105") $sql_cmd = "";
if (in_array($user_department_id . $user_role_id, $dr_arr)) $sql_cmd = "";
//if (empty($sql_cmd)) $sql_cmd = "where ";
@ -177,17 +177,17 @@ if ($data) :
<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>
<th>評價/服務態度</th>
<th>內容</th>
<th>簽名檔</th>
<!-- <th>評價/保養品質</th>
<th>評價/服務態度</th> -->
<!-- <th>內容</th>
<th>簽名檔</th> -->
<th>建檔人</th>
<th>建檔時間</th>
<?php if ($user_auth & 2) { ?>
@ -208,16 +208,22 @@ if ($data) :
<td><?php echo $data['repairername']; ?></td>
<td><?php echo $data['duedate']; ?></td>
<td><?php echo $data['actualdate']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item_detail']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['result']; ?></td>
<td><?php if ($data['evidences']) {
echo "<a href=\"/app/" . $data['evidences'] . "\">瀏覽</a>";
<!-- <td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item_detail']; ?></td> -->
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;">
<?php //echo $data['result']; ?>
<a href="/app/app-maintenance-uploadsuccess-survey.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>">查看明細</a>
</td>
<td>
<a href="/app/app-maintenance-uploadsuccess-photo-review_v2.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>">瀏覽</a>
<?php if ($data['evidences']) {
// echo "<a href=\"/app/" . $data['evidences'] . "\">瀏覽</a>";
} ?></td>
<td><?php echo $data['descriptons']; ?></td>
<td><?php echo $data['customer_login_id']; ?></td>
<!-- <td><?php echo $data['customer_login_id']; ?></td> -->
<td><?php echo $data['customer_login_name']; ?></td>
<td>
<!-- <td>
<?php
$stars_1 = ($data['stars_c1']) ? $data['stars_c1'] : $data['stars'];
echo $stars_1;
@ -228,9 +234,9 @@ if ($data) :
$stars_2 = ($data['stars_c2']) ? $data['stars_c2'] : $data['stars_b2'];
echo $stars_2;
?>
</td>
<td><?php echo $data['details']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['customer_signature']; ?></td>
</td> -->
<!-- <td><?php echo $data['details']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['customer_signature']; ?></td> -->
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth & 2) { ?>

Loading…
Cancel
Save