10994015 1 year ago
parent
commit
916908b6cc
  1. 1
      .gitignore
  2. 26
      wms/account-receivable-check.php
  3. 258
      wms/account-receivable-contract.php
  4. 97
      wms/account-receivable-excel.php
  5. 759
      wms/account-receivable-index-ing.php
  6. 706
      wms/account-receivable-index.php
  7. 37
      wms/account-receivable-test.php
  8. BIN
      wms/account-receivable-test.xlsx
  9. 246
      wms/api/bpm/addContract.ini
  10. 169
      wms/api/bpm/addContract.php
  11. 242
      wms/api/bpm/addContract.txt
  12. 4
      wms/api/bpm/addContract_form.php
  13. 108
      wms/api/bpm/download.php
  14. 6
      wms/api/bpm/requests.ini
  15. 22
      wms/class/Cnotice.php
  16. 2811
      wms/estimated_shipping_date_report.php
  17. BIN
      wms/facility-price.xlsx
  18. 4
      wms/frame/api_getdata.php
  19. 24
      wms/fun_global.php
  20. 60
      wms/gary_psd.php
  21. 20
      wms/wipwhole-change-contractdate-function.php
  22. 611
      wms/wipwhole-change-contractdate-submit.php
  23. 8
      wms/wipwhole-change-contractdate.php
  24. 141
      wms/wipwhole-index-function.php
  25. 20
      wms/wipwhole-index.php
  26. 340
      wms/wipwhole-rec-invoice-edit-submit.php
  27. 57
      wms/wipwhole-rec-invoice-edit.php
  28. 1754
      wms/wipwhole-rec-invoice.php
  29. 1271
      wms/wipwhole-renovate-index-function.php
  30. 24
      wms/wipwhole-renovate-index.php
  31. 77
      wms/wipwhole-renovate-rec-invoice-edit-submit.php
  32. 48
      wms/wipwhole-renovate-rec-invoice-edit.php
  33. 1848
      wms/wipwhole-renovate-rec-invoice.php
  34. 593
      wms/wipwhole-wipinstallstatus-index.php
  35. 2300
      wms/wipwholeinstall-index-function.php
  36. 2344
      wms/wipwholeinstall-renovate-index-function.php

1
.gitignore

@ -25,3 +25,4 @@ wms/mkt/WriteOffRepair.xlsx
wms/contract/images/contracts
wms/test.php
app/account_log/
wms/gary2.php

26
wms/account-receivable-check.php

@ -1,18 +1,20 @@
<?php
include "./header.php";
$BillNo = $_GET['BillNo'];
echo $BillNo;
//企業名稱 統一編號 聯絡地址
$Bill = $_POST['Bill'];
$Bill = json_decode($Bill, true);
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
$pay_received = mysqli_query($link, $sql_received);
$had_received = 0;
if (mysqli_num_rows($pay_received) == 0) {
foreach ($pay_received as $received) {
$had_received += $received['received_amount'];
}
}
$unreceived = $Bill[12] - $had_received;
$data = json_encode($Bill);
// $Bill = $_POST['Bill'];
// $Bill = json_decode($Bill, true);
// $sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
// $pay_received = mysqli_query($link, $sql_received);
// $had_received = 0;
// if (mysqli_num_rows($pay_received) == 0) {
// foreach ($pay_received as $received) {
// $had_received += $received['received_amount'];
// }
// }
// $unreceived = $Bill[12] - $had_received;
// $data = json_encode($Bill);
?>
<style>
th {

258
wms/account-receivable-contract.php

@ -1,39 +1,245 @@
<?php
include "header.php";
$BillNo = $_GET['BillNo'];
if ($cont['BillNo'] == 'M231067') {
$BillNo = 'SO20230801002';
}
// 合約收款款別名稱
$arrayData = [];
echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>";
// echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>";
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName
FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4)";
WHERE s.BillNo = '$BillNo'";
// T8發票
//M220478
$sql_invoice = "SELECT DISTINCT
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState,
b.ProjectId
FROM arSellInvoice as a
LEFT JOIN arSellInvoiceMaterial as b
ON a.BillNo=b.BillNo
WHERE b.ProjectId='$BillNo'";
$contract = $conn->query($sql_contract);
foreach ($contract as $cont) {
if ($cont['BillNo'] == 'SO20230801002') {
$BillNo = 'M231067';
}else{
$BillNo = $cont['BillNo'];
};
$PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
if(isset($arrayData[$BillNo])){
array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount);
}else{
$arrayData[$BillNo][0] = $BillNo;
$arrayData[$BillNo][1] = $partnerName;
array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount);
$invoices = $conn->query($sql_invoice);
// foreach($contract as $con){
// print_r($con);
// echo "<br>";
// }
// foreach ($contract as $cont) {
// if ($cont['BillNo'] == 'SO20230801002') {
// $BillNo = 'M231067';
// }else{
// $BillNo = $cont['BillNo'];
// };
// $PayStage = $cont['PayStage'];
// $PayAmount = $cont['PlanPayAmt'];
// $partnerName = $cont['BizPartnerName'];
// if(isset($arrayData[$BillNo])){
// array_push($arrayData[$BillNo], $PayStage);
// array_push($arrayData[$BillNo], $PayAmount);
// }else{
// $arrayData[$BillNo][0] = $BillNo;
// $arrayData[$BillNo][1] = $partnerName;
// array_push($arrayData[$BillNo], $PayStage);
// array_push($arrayData[$BillNo], $PayAmount);
// }
// };
// foreach($arrayData as $data){
// foreach($data as $value){
// echo $value.";";
// }
// echo "</br>";
// }
?>
<style>
th {
text-align: center;
}
td {
text-align: right;
}
};
foreach($arrayData as $data){
foreach($data as $value){
echo $value.";";
</style>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong><?= $Bill[4] ?></strong></h3>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptId">部門</label>
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="Manager">經理</label>
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled>
</div>
</div>
<div>
<label for="detail">狀態</label>
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea>
</div>
</form>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>目前應收</th>
<th>已開發票金額</th>
<th>未開發票金額</th>
<th>已收金額</th>
<th>未收金額</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[12])) ?></td>
<td><?= number_format(round($Bill[19])) ?></td>
<td><?= number_format(round($Bill[21])) ?></td>
<td><?= number_format(round($Bill[20])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td>
</tr>
</tbody>
</table>
</div>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>簽約款</th>
<th>二次款</th>
<th>貨抵工地款</th>
<th>安裝款</th>
<th>試車款</th>
<th>官檢款</th>
<th>交車款</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[5])) ?></td>
<td><?= number_format(round($Bill[6])) ?></td>
<td><?= number_format(round($Bill[7])) ?></td>
<td><?= number_format(round($Bill[8])) ?></td>
<td><?= number_format(round($Bill[9])) ?></td>
<td><?= number_format(round($Bill[10])) ?></td>
<td><?= number_format(round($Bill[11])) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
include "./footer.php";
?>
<?php
if ($user_id == "M0122") {
?>
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button>
<?php
}
?>
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>發票號碼</th>
<th>發票日期</th>
<th>發票金額</th>
<th>收款日期</th>
<th>收款金額</th>
<th>說明</th>
<th style="width: 10%;">功能</th>
</tr>
</thead>
<tbody>
<?php if (!empty($invoices)) {
foreach ($invoices as $invoice) { ?>
<tr>
<td><?= $invoice['InvoiceNo'] ?></td>
<td><?= date('Y-m-d', strtotime(strval($invoice['InvoiceTime']))) ?></td>
<td><?= number_format($invoice['OAmountWithTax']) ?></td>
<td><?= number_format($received['received_amount']) ?></td>
<td><?= $received['remark'] ?></td>
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?>
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
<span class="glyphicon glyphicon-pencil"></span></button>
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<span class=" glyphicon glyphicon-trash"></span>
</a>
<?php } ?>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
<script>
function create(type, pay_id) {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
if (type === 'create') {
form.action = "account-receivable-received-create.php?<?= $token_link ?>";
} else {
form.action = "account-receivable-received-edit.php?pay_id=" + pay_id + "&<?= $token_link ?>";
}
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(BillData);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
echo "</br>";
}
</script>

97
wms/account-receivable-excel.php

@ -6,92 +6,46 @@ require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
header('Content-Type: application/json');
// $Bill = file_get_contents('php://input');
// $Bill = $_POST['Bill'];
$array_data = array();
$Bill = json_decode(file_get_contents("php://input"), true);
// $Bill = json_decode($Bill, true);
// 檢查是否有 POST 資料
// if ($_SERVER["REQUEST_METHOD"] == "POST") {
// // 獲取 POST 資料
// // $postData = $_POST['Bill'];
// // 指定儲存資料的檔案路徑
// $filePath = 'Bill.txt';
// // 寫入檔案
// // 使用 FILE_APPEND 選項,以便將資料附加到檔案的末尾而不是覆寫檔案
// file_put_contents($filePath, $Bill . PHP_EOL, FILE_APPEND);
// echo '資料已成功寫入檔案。';
// } else {
// echo '請透過正確的方式訪問此頁面。';
// }
// exit();
// print_r($Bill);
// foreach ($Bill as $key => $value) {
// $value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
// $value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
// $value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0;
// $value['install'][3] = (isset($value['install'][3])) ? $value['install'][3] : 0;
// $value['tryrun'][3] = (isset($value['tryrun'][3])) ? $value['tryrun'][3] : 0;
// $value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0;
// $value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0;
// $value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0;
// $array_data[$key] = [
// $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
// $value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
// $value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
// $value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
// $value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
// $value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
// $value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
// $value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
// $value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
// $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
// ];
// $array_data[$key] = [
// $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
// $value['sign'][1], $value['second'][1], $value['arrive'][1], $value['install'][1], $value['tryrun'][1], $value['check'][1], $value['delivery'][1], $value['final'][1],
// $value['sign'][3], $value['second'][3], $value['arrive'][3], $value['install'][3], $value['tryrun'][3], $value['check'][3], $value['delivery'][3], $value['final'][3],
// $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
// ];
// }
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colomnHeader = [
'合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'簽約款', '簽約款目前應收', '簽約最小催收次數', '簽約最大應收次數',
'二次款', '二次款目前應收', '二次最小催收次數', '二次最大應收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地最小催收次數', '貨抵工地最大應收次數',
'安裝款', '安裝款目前應收', '安裝最小催收次數', '安裝最大應收次數',
'試車款', '試車款目前應收', '試車最小催收次數', '試車最大應收次數',
'官檢款', '官檢款目前應收', '官檢最小催收次數', '官檢最大應收次數',
'交車款', '交車款目前應收', '交車最小催收次數', '交車最大應收次數',
'尾款', '尾款目前應收', '尾款最小催收次數', '尾款最大應收次數',
'合約總金額', '目前應收', '已開發票金額', '已收金額', '作番狀態'
'合約號','作番號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金', '訂金目前應收', '訂金已收','訂金催收','訂金符合收款條件日期','訂金催收次數',
'二次款', '二次款目前應收', '二次款已收', '二次款催收','二次款符合收款條件日期','二次款催收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已收', '貨抵工地款催收','貨抵工地款符合收款條件日期','貨抵工地款催收次數',
'安裝款', '安裝款目前應收', '安裝款已收', '安裝款催收','安裝款符合收款條件日期','安裝款催收次數',
'試車款', '試車款目前應收', '試車款已收', '試車款催收','試車款符合收款條件日期','試車款催收次數',
'官檢款', '官檢款目前應收', '官檢款已收', '官檢款催收','官檢款符合收款條件日期','官檢款催收次數',
'交車款', '交車款目前應收', '交車款已收', '交車款催收','交車款符合收款條件日期','交車款催收次數',
'尾款', '尾款目前應收', '尾款已收', '尾款催收','尾款符合收款條件日期','尾款催收次數',
'合約總金額', '目前應收', '已開發票金額', '已收金額'
];
// $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', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS'
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS','AT'
];
foreach ($column as $col) {
if ($col == 'AS') {
$sheet->getStyle('AS' . $rowIndex)->getAlignment()->setWrapText(true);
if ($col == 'AT') {
$sheet->getStyle('AT' . $rowIndex)->getAlignment()->setWrapText(true);
} else {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
@ -103,7 +57,4 @@ $writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-test.xlsx';
$writer->save($excelFileName);
echo $excelFileName;
?>
<!-- <script>
window.location.href = "account-receivable-index.php?<?= $token_link ?>";
</script> -->
?>

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

@ -91,6 +91,7 @@ foreach ($contract as $cont) {
$ContactAddress = $cont['ContactAddress'];
//['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 通訊地址
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
@ -106,9 +107,9 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['sign']['min'] = $arrayData[$BillNo]['second']['min'] = $arrayData[$BillNo]['arrive']['min'] = $arrayData[$BillNo]['install']['min'] = $arrayData[$BillNo]['tryrun']['min'] = $arrayData[$BillNo]['check']['min'] = $arrayData[$BillNo]['delivery']['min'] = $arrayData[$BillNo]['final']['min'] = array();
$arrayData[$BillNo]['sign']['max'] = $arrayData[$BillNo]['second']['max'] = $arrayData[$BillNo]['arrive']['max'] = $arrayData[$BillNo]['install']['max'] = $arrayData[$BillNo]['tryrun']['max'] = $arrayData[$BillNo]['check']['max'] = $arrayData[$BillNo]['delivery']['max'] = $arrayData[$BillNo]['final']['max'] = array();
$arrayData[$BillNo]['facilities'] = "";
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['sign_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
}
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
if (stristr($PayStage, '二次款') || (stristr($PayStage, '出貨前') && $PayStage != "寶佳出貨前30天") || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) {
$arrayData[$BillNo]['second'][0] = $PayStage;
$arrayData[$BillNo]['second'][1] = $PayAmount;
$arrayData[$BillNo]['second'][2] = $PlanPayDate;
@ -133,14 +134,14 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['second'][2] = strval($secondtime);
}
}
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工')) {
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工') || $PayStage == '寶佳出貨前30天') {
$arrayData[$BillNo]['sign'][0] = $PayStage;
$arrayData[$BillNo]['sign'][1] = $PayAmount;
$arrayData[$BillNo]['sign'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
$arrayData[$BillNo]['receivable_budget'] += $PayAmount;
if (isset($PlanPayDate) && !empty($PlanPayDate)) {
array_push($arrayData[$BillNo]['sign']['min'], strval($PlanPayDate));
if (isset($PlanPayDate) && !empty($PlanPayDate) && $PayStage != "寶佳出貨前30天") {
array_push($arrayData[$BillNo]['sign']['min'], strtotime(strval($PlanPayDate)));
array_push($arrayData[$BillNo]['sign']['max'], strtotime(strval($PlanPayDate)));
}
} elseif (stristr($PayStage, '試車')) {
@ -179,8 +180,9 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['total_budget'] += $PayAmount;
}
}
//取作番大日程作番與時程
// real_contract_arrival_date 預計出貨日
// real_arrival_date 實際出貨日
$sql = "SELECT
tmp2.*,
d.name AS depart_name
@ -218,6 +220,8 @@ FROM department
ON d.department_id = tmp2.department_id ORDER BY contractno";
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
$today = strtotime(date('Ymd'));
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if (isset($arrayData[$wip['contractno']])) {
// 整理合約資料
$arrayData[$wip['contractno']][0] = $wip['department_id'];;
@ -226,14 +230,16 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']][3] = $wip['salesid'];
$arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno'];
// [合約號][作番號]['no']
$arrayData[$wip['contractno']][$wip['facilityno']]['no'] = $wip['facilityno'];
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
// [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno'];
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期]
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
$arrayData[$wip['contractno']][$wip['facilityno']][$i] = ['', 0, '', 0, 0, 0, 0];
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['date'] = "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0;
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = "";
@ -241,6 +247,26 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['date'] = (isset($arrayData[$wip['contractno']][$i][2])) ? $arrayData[$wip['contractno']][$i][2] : "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['budget'] = 0;
}
// 補上寶佳 (出貨前) 收款時間
if (isset($arrayData[$wip['contractno']]['sign'][0]) && $arrayData[$wip['contractno']]['sign'][0] == '寶佳出貨前30天') {
if ($wip['real_arrival_date'] != NULL) {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$signtime = $estimate_delivery_time - (30 * 86400);
$signtime = date('Ymd', $signtime);
$arrayData[$wip['contractno']]['sign'][2] = strval($signtime);
array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime)));
array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime)));
} elseif ($wip['real_contract_arrival_date'] != NULL) {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$signtime = $estimate_delivery_time - (30 * 86400);
$signtime = date('Ymd', $signtime);
$arrayData[$wip['contractno']]['sign'][2] = strval($signtime);
array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime)));
array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime)));
}
}
// 補上二次款 (出貨前) 收款時間,條件不是"出貨前"就pass
if (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前30天')) {
if (empty($wip['real_contract_arrival_date'])) {
@ -249,8 +275,8 @@ foreach ($wipwhole_array as $wip) {
$secondtime = $estimate_delivery_time - (30 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['second']['min'], strval($wip['real_contract_arrival_date']));
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前90天')) {
if (empty($wip['real_contract_arrival_date'])) {
@ -259,121 +285,432 @@ foreach ($wipwhole_array as $wip) {
$secondtime = $estimate_delivery_time - (90 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['second']['min'], strval($wip['real_contract_arrival_date']));
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
}
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前120天')) {
if (empty($wip['real_contract_arrival_date'])) {
} else {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time - (120 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && $arrayData[$wip['contractno']]['second'][0] == '寶佳出貨後10天') {
if ($wip['real_arrival_date'] != NULL) {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$secondtime = $estimate_delivery_time + (10 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
} else {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time + (10 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime($secondtime));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
}
//根據作番狀態填入facilities,計算各階段數量、一個合約有幾個作番,增加作番資料
if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
if (!empty($wip['delivery_date']) && $wip['delivery_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['delivery']['min'], strval($wip['delivery_date']));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($wip['delivery_date'])));
// real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地
// real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地
//----------------------------------------寶佳的另外處理---------------------------------------------------
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = "";
// if ($arrayData[$wip['contractno']]['sign'][2])
$today = strtotime(date('Ymd'));
$contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = $arrayData[$wip['contractno']]['sign'][2];
if ($today > $contractday) {
$arrayData[$wip['contractno']]['sign_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>";
//二次款
$contractday = strtotime($arrayData[$wip['contractno']]['second'][2]);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = $arrayData[$wip['contractno']]['second'][2];
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>";
//貨抵工地款
if ($wip['real_arrival_date'] != NULL) {
$estimate_time = strtotime($wip['real_arrival_date']);
$contractday = $estimate_time + (90 * 86400);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>";
//試車款
if ($wip['tryrun_end_date'] != NULL) {
$estimate_time = strtotime($wip['tryrun_end_date']);
$contractday = $estimate_time + (90 * 86400);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>";
//交車款
if ($wip['delivery_date'] != NULL) {
$estimate_time = strtotime($wip['delivery_date']);
$contractday = $estimate_time + (270 * 86400);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>";
}
}
}
}
}
}
}
} else {
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "未到) <br>";
}
$arrayData[$wip['contractno']]['facilities'] .= $facility_status;
} else {
$signtime = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($signtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = strval(date('Ymd', $signtime));
if (isset($arrayData[$wip['contractno']]['second'][2]) && ($arrayData[$wip['contractno']]['second'][2] !== NULL)) {
$secondtime = strtotime($arrayData[$wip['contractno']]['second'][2]);
$month = collect_month($secondtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime));
}
if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
if ($today > $arrivetime) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
}
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['delivery'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']);
$deliverytime = strtotime($wip['delivery_date']);
$month = collect_month($deliverytime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $deliverytime));
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($wip['delivery_date'])));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($wip['delivery_date'])));
}
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strval($wip['official_check_date']));
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
$checktime = strtotime($wip['official_check_date']);
$month = collect_month($checktime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][2] = strval(date('Ymd', $checktime));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strval($wip['tryrun_end_date']));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$tryruntime = $estimate_delivery_time + (90 * 86400);
$tryruntime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($tryruntime)));
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
} else {
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
$tryruntime = strtotime($wip['tryrun_end_date']);
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
}
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date']));
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], strval($wip['real_arrival_date']));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
}
} elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strval($wip['official_check_date']));
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
$checktime = strtotime($wip['official_check_date']);
$month = collect_month($checktime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][2] = strval(date('Ymd', $checktime));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strval($wip['tryrun_end_date']));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$tryruntime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($tryruntime);
$tryruntime = date('Ymd', $tryruntime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($tryruntime)));
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval($tryruntime);
} else {
$tryruntime = strtotime($wip['tryrun_end_date']);
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
}
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date']));
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], strval($wip['real_arrival_date']));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strval($wip['tryrun_end_date']));
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
$tryruntime = strtotime($wip['tryrun_end_date']);
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date']));
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], strval($wip['real_arrival_date']));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['install_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date']));
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date']))));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], strval($wip['real_arrival_date']));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['real_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], strval($wip['real_arrival_date']));
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) {
$secondtime = strtotime($arrayData[$wip['contractno']]['second'][2]);
$month = collect_month($secondtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime));
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
} else {
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
} elseif ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
} else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
}
}
}
@ -381,13 +718,14 @@ foreach ($wipwhole_array as $wip) {
}
// 計算每個合約的應收款、作番總數
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d')))));
foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) {
$value['receivable_budget'] += ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
$value['receivable_budget'] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']) + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
($value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num'])) + ($value['install'][1] * ($value['install_num'] / $value['total_facility_num'])) +
($value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num'])) + ($value['check'][1] * ($value['check_num'] / $value['total_facility_num'])) +
(($value['delivery'][1] + $value['final'][1]) * ($value['delivery_num'] / $value['total_facility_num']));
$value['sign'][3] = $value['sign'][1];
$value['sign'][3] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']);
$value['second'][3] = $value['second'][1] * ($value['second_num'] / $value['total_facility_num']);
$value['arrive'][3] = $value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num']);
$value['install'][3] = $value['install'][1] * ($value['install_num'] / $value['total_facility_num']);
@ -396,50 +734,41 @@ foreach ($arrayData as &$value) {
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']);
$value['final'][3] = $value['final'][1] * ($value['delivery_num'] / $value['total_facility_num']);
}
$stagearray = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
$today = date('Ym01', strtotime('-1 month',strtotime(date('Ym01'))));
// $today = strtotime($today,);
// echo "today: " . $today . "<br>";
// exit();
// foreach ($stagearray as $stage) {
// // 計算月份差距
// if (empty($value[$stage]['min'])==0) {
// print_r($value[$stage]['min']);
// echo "<br>";
// // $maxtime = array_map('strtotime', $value[$stage]['min']);
// $earliestDate = min($value[$stage]['min']);
// $earliestMonth = date('Ym01', $earliestDate);
// echo "earliestDate: " . $earliestDate . "<br>";
// // $earliestMonth = date('n', strtotime($earliestDate));
// // 計算月份差距
// $maxDifference = $today -$earliestMonth;
// echo "difference = ".$maxDifference."<br>";
// $value[$stage]['max'] = $maxDifference;
// } else {
// $value[$stage]['max'] = 0;
// }
// echo $value[$stage]['max'];
// echo "<br>--------------------<br>";
// exit();
// if(!empty($value[$stage]['max']) && $value[$stage]['max'] !==10 && $value[$stage]['max'] !==1){
// echo "max: " . $value[$stage]['max'] . "<br>";
// if (!empty($value[$stage]['max'])) {
// $mintime = array_map('strtotime', $value[$stage]['max']);
// $latestDate = max($mintime);
// $latestMonth = date('n', strtotime($latestDate));
// $minDifference = abs($latestMonth - $today);
// $value[$stage]['min'] = $minDifference;
// } else {
// $value[$stage]['min'] = 0;
// }
// }else{
// $value[$stage]['min'] = 0;
// }
// }
// 計算最大催收次數與最小催收次數
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) {
$latest_timestamp = max($value[$i]['min']);
$latest_date = new DateTime();
$latest_date->setTimestamp($latest_timestamp);
if ($latest_date < $today_date) {
$interval = $latest_date->diff($today_date);
$month = $interval->format('%m');
$value[$i]['min'] = $month;
} else {
$value[$i]['min'] = 0;
}
} else {
$value[$i]['min'] = 0;
};
if (!empty($value[$i]['max']) && count($value[$i]['max']) > 0) {
$latest_timestamp = min($value[$i]['max']);
$latest_date = new DateTime();
$latest_date->setTimestamp($latest_timestamp);
if ($latest_date < $today_date) {
$interval = $latest_date->diff($today_date);
$month = $interval->format('%m');
$value[$i]['max'] = $month;
} else {
$value[$i]['max'] = 0;
}
} else {
$value[$i]['max'] = 0;
};
}
}
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期]
@ -451,7 +780,6 @@ foreach ($wipwhole_array as $wip) {
}
}
}
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號]
foreach ($invoice_data as $invoice) {
if (isset($arrayData[$invoice['ProjectId']])) {
@ -476,12 +804,74 @@ foreach ($received_array as $received) {
}
}
}
foreach($arrayData as $key => $value){
print_r($value);
echo "<br>";
//產生excel的array
$excel_aray = array();
$boga_array = array();
$exclude_boga_array = array();
foreach ($arrayData as $key => $value) {
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
$value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0;
$value['install'][3] = (isset($value['install'][3])) ? $value['install'][3] : 0;
$value['tryrun'][3] = (isset($value['tryrun'][3])) ? $value['tryrun'][3] : 0;
$value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0;
$value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0;
$value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0;
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
$value[$i]['max'] = (empty($value[$i]['max']) || is_null($value[$i]['max'])) ? 0 : $value[$i]['max'];
$value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min'];
};
if ($value['sign'][0] == "寶佳出貨前30天") {
$boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
$value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
$value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
$value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
$value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
} else {
$exclude_boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
$value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
$value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
$value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
$value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
}
$excel_aray[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
$value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
$value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
$value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
$value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
}
$data = json_encode($arrayData);
$data = json_encode($excel_aray);
$boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_boga_array);
?>
<style>
@ -521,7 +911,16 @@ $data = json_encode($arrayData);
}
</style>
<button type="button" onclick="downloadData()" class="btn btn-warning btn-lg pull-right"><span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="downloadData()" class="btn btn-success btn-lg pull-right">全部<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="exclude_bogaData()" class="btn btn-info btn-lg pull-right">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="bogaData()" class="btn btn-warning btn-lg pull-right">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<?php
if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id == 'M0060') {
?>
<a href="facility-price.php?<?= $token_link ?>" class="btn btn-primary btn-lg pull-right">合約作番明細</span></a>
<?php
}
?>
<div style="width:98%;margin:1% ;overflow-x: auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead>
@ -530,45 +929,45 @@ $data = json_encode($arrayData);
<th style="width: 120px;">部門</th>
<th style="width: 120px;">經理</th>
<th style="width: 120px;">營業員</th>
<th style="width: 180px;">客戶名稱</th>
<th style="width: 150px;">簽約款</th>
<th style="width: 150px;">應收簽約金額</th>
<th style="width: 150px;">簽約最大催收次數</th>
<th style="width: 150px;">簽約最小催收次數</th>
<th style="width: 150px;">二次款</th>
<th style="width: 150px;">應收二次金額</th>
<th style="width: 150px;">二次最大催收次數</th>
<th style="width: 150px;">二次最小催收次數</th>
<th style="width: 150px;">貨抵工地款</th>
<th style="width: 150px;">應收貨抵工地金額</th>
<th style="width: 150px;">貨抵工地最大催收次數</th>
<th style="width: 150px;">貨抵工地最小催收次數</th>
<th style="width: 150px;">安裝款</th>
<th style="width: 150px;">應收安裝金額</th>
<th style="width: 150px;">安裝最大催收次數</th>
<th style="width: 150px;">安裝最小催收次數</th>
<th style="width: 150px;">試車款</th>
<th style="width: 150px;">應收試車金額</th>
<th style="width: 150px;">試車最大催收次數</th>
<th style="width: 150px;">試車最小催收次數</th>
<th style="width: 150px;">官檢款</th>
<th style="width: 150px;">應收官檢金額</th>
<th style="width: 150px;">官檢最大催收次數</th>
<th style="width: 150px;">官檢最小催收次數</th>
<th style="width: 150px;">移交款</th>
<th style="width: 150px;">應收移交金額</th>
<th style="width: 150px;">移交最大催收次數</th>
<th style="width: 150px;">移交最小催收次數</th>
<th style="width: 150px;">尾款</th>
<th style="width: 150px;">應收尾款金額</th>
<th style="width: 150px;">尾款最大催收次數</th>
<th style="width: 150px;">尾款最小催收次數</th>
<th style="width: 150px;">合約總金額</th>
<th style="width: 150px;" style="width: 120px;">目前應收</th>
<th style="width: 150px;" style="width: 120px;">已開發票金額</th>
<th style="width: 150px;">已收金額</th>
<th style="width: 120px;">客戶名稱</th>
<th style="width: 120px;">簽約款</th>
<th style="width: 120px;">應收簽約金額</th>
<th style="width: 120px;">簽約最小催收次數</th>
<th style="width: 120px;">簽約最大催收次數</th>
<th style="width: 120px;">二次款</th>
<th style="width: 120px;">應收二次金額</th>
<th style="width: 120px;">二次最小催收次數</th>
<th style="width: 120px;">二次最大催收次數</th>
<th style="width: 120px;">貨抵工地款</th>
<th style="width: 120px;">應收貨抵工地金額</th>
<th style="width: 120px;">貨抵工地最小催收次數</th>
<th style="width: 120px;">貨抵工地最大催收次數</th>
<th style="width: 120px;">安裝款</th>
<th style="width: 120px;">應收安裝金額</th>
<th style="width: 120px;">安裝最小催收次數</th>
<th style="width: 120px;">安裝最大催收次數</th>
<th style="width: 120px;">試車款</th>
<th style="width: 120px;">應收試車金額</th>
<th style="width: 120px;">試車最小催收次數</th>
<th style="width: 120px;">試車最大催收次數</th>
<th style="width: 120px;">官檢款</th>
<th style="width: 120px;">應收官檢金額</th>
<th style="width: 120px;">官檢最小催收次數</th>
<th style="width: 120px;">官檢最大催收次數</th>
<th style="width: 120px;">移交款</th>
<th style="width: 120px;">應收移交金額</th>
<th style="width: 120px;">移交最小催收次數</th>
<th style="width: 120px;">移交最大催收次數</th>
<th style="width: 120px;">尾款</th>
<th style="width: 120px;">應收尾款金額</th>
<th style="width: 120px;">尾款最小催收次數</th>
<th style="width: 120px;">尾款最大催收次數</th>
<th style="width: 120px;">合約總金額</th>
<th style="width: 120px;" style="width: 120px;">目前應收</th>
<th style="width: 120px;" style="width: 120px;">已開發票金額</th>
<th style="width: 120px;">已收金額</th>
<!-- <th>作番狀態</th> -->
<!-- <th style="width: 100px;">收款狀態</th> -->
<th style="width: 350px;">收款狀態</th>
</tr>
</thead>
@ -577,7 +976,7 @@ $data = json_encode($arrayData);
foreach ($arrayData as $key => $value) {
?>
<tr>
<th><?= $key ?></th>
<th><a onclick="showContract('<?= $key ?>')"><?= $key ?> </a></th>
<td><?= $value[1] ?></td>
<td><?= $value[2] ?></td>
<td><?= $value[4] ?></td>
@ -618,8 +1017,8 @@ $data = json_encode($arrayData);
<td style="text-align: end;"><?= isset($value['receivable_budget']) ? number_format(round($value['receivable_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['invoice_budget']) ? number_format(round($value['invoice_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['received_budget']) ? number_format(round($value['received_budget'])) : '--' ?></td>
<!-- <td style="text-align: start;"><?= $value['facilities'] ?></td>
<td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
<td style="text-align: start;"><?= $value['facilities'] ?></td>
<!-- <td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
</td> -->
</tr>
<?php
@ -629,6 +1028,11 @@ $data = json_encode($arrayData);
</table>
</div>
<script>
function showContract(BillNo) {
window.open('account-receivable-contract.php?BillNo=' + BillNo + '&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200');
console.log(BillNo);
}
function test() {
var BillData = <?= $data ?>;
var form = document.createElement("form");
@ -653,8 +1057,8 @@ $data = json_encode($arrayData);
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.xlsx");
var name = "全部應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
@ -662,11 +1066,68 @@ $data = json_encode($arrayData);
document.body.removeChild(link);
}
}
// xhr.send(JSON.stringify({
// Bill: <?= $data ?>
// })
// );
xhr.send(JSON.stringify({
Bill: <?= $data ?>
}));
}
function bogaData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $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-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $boga_data ?>
}));
}
function exclude_bogaData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $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-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $exclude_boga_data ?>
}));
}
function sendData(BillNo) {
var BillData = <?= $data ?>;
var Bill = BillData[BillNo];

706
wms/account-receivable-index.php

@ -32,6 +32,7 @@ LEFT JOIN
ON a.BillNo=c.BillNo
WHERE DATALENGTH(c.OrderBillNo) >0";
//T8 銷售訂單 階段收款計畫
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId,
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
@ -66,6 +67,7 @@ $received_array = $conn->query($sql_received);
$opening_data = mysqli_query($link, $sql_opening);
$invoice_data = $conn->query($sql_invoice);
// 合約收款階段內容分類
$sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天');
$sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天');
@ -89,6 +91,7 @@ foreach ($contract as $cont) {
$ContactAddress = $cont['ContactAddress'];
//['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 通訊地址
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
@ -104,9 +107,9 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['sign']['min'] = $arrayData[$BillNo]['second']['min'] = $arrayData[$BillNo]['arrive']['min'] = $arrayData[$BillNo]['install']['min'] = $arrayData[$BillNo]['tryrun']['min'] = $arrayData[$BillNo]['check']['min'] = $arrayData[$BillNo]['delivery']['min'] = $arrayData[$BillNo]['final']['min'] = array();
$arrayData[$BillNo]['sign']['max'] = $arrayData[$BillNo]['second']['max'] = $arrayData[$BillNo]['arrive']['max'] = $arrayData[$BillNo]['install']['max'] = $arrayData[$BillNo]['tryrun']['max'] = $arrayData[$BillNo]['check']['max'] = $arrayData[$BillNo]['delivery']['max'] = $arrayData[$BillNo]['final']['max'] = array();
$arrayData[$BillNo]['facilities'] = "";
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['sign_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
}
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後')) {
if (stristr($PayStage, '二次款') || (stristr($PayStage, '出貨前') && $PayStage != "寶佳出貨前30天") || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) {
$arrayData[$BillNo]['second'][0] = $PayStage;
$arrayData[$BillNo]['second'][1] = $PayAmount;
$arrayData[$BillNo]['second'][2] = $PlanPayDate;
@ -116,28 +119,31 @@ foreach ($contract as $cont) {
if (in_array($PayStage, $sign60)) {
$secondtime = $signtime + (60 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
$arrayData[$BillNo]['second'][2] = strval($secondtime);
} elseif (in_array($PayStage, $sign90)) {
$secondtime = $signtime + (90 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
$arrayData[$BillNo]['second'][2] = strval($secondtime);
} elseif (in_array($PayStage, $sign120)) {
$secondtime = $signtime + (120 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
$arrayData[$BillNo]['second'][2] = strval($secondtime);
} elseif (stristr($PayStage, '簽訂後30天')) {
$secondtime = $signtime + (30 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
$arrayData[$BillNo]['second'][2] = strval($secondtime);
}
}
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工') || stristr($PayStage, '寶佳出貨前')) {
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工') || $PayStage == '寶佳出貨前30天') {
$arrayData[$BillNo]['sign'][0] = $PayStage;
$arrayData[$BillNo]['sign'][1] = $PayAmount;
$arrayData[$BillNo]['sign'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
array_push($arrayData[$BillNo]['sign']['min'], intval(substr($PlanPayDate, 4, 2)));
array_push($arrayData[$BillNo]['sign']['max'], intval(substr($PlanPayDate, 4, 2)));
$arrayData[$BillNo]['receivable_budget'] += $PayAmount;
if (isset($PlanPayDate) && !empty($PlanPayDate) && $PayStage != "寶佳出貨前30天") {
array_push($arrayData[$BillNo]['sign']['min'], strtotime(strval($PlanPayDate)));
array_push($arrayData[$BillNo]['sign']['max'], strtotime(strval($PlanPayDate)));
}
} elseif (stristr($PayStage, '試車')) {
$arrayData[$BillNo]['tryrun'][0] = $PayStage;
$arrayData[$BillNo]['tryrun'][1] = $PayAmount;
@ -174,6 +180,9 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['total_budget'] += $PayAmount;
}
}
//取作番大日程作番與時程
// real_contract_arrival_date 預計出貨日
// real_arrival_date 實際出貨日
$sql = "SELECT
tmp2.*,
d.name AS depart_name
@ -187,6 +196,7 @@ SELECT
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,
@ -207,155 +217,406 @@ SELECT DISTINCT
FROM department
) AS d
ON d.department_id = tmp2.department_id";
ON d.department_id = tmp2.department_id ORDER BY contractno";
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
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']]['total_facility_num'] += 1;
// [合約號][作番號]['no']
$arrayData[$wip['contractno']][$wip['facilityno']]['no'] = $wip['facilityno'];
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期]
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['date'] = "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0;
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['budget'] = 0;
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['date'] = (isset($arrayData[$wip['contractno']][$i][2])) ? $arrayData[$wip['contractno']][$i][2] : "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['budget'] = 0;
}
// 補上寶佳 (出貨前) 收款時間
if (isset($arrayData[$wip['contractno']]['sign'][0]) && $arrayData[$wip['contractno']]['sign'][0] == '寶佳出貨前30天') {
if ($wip['real_arrival_date'] != NULL) {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$signtime = $estimate_delivery_time - (30 * 86400);
$signtime = date('Ymd', $signtime);
$arrayData[$wip['contractno']]['sign'][2] = strval($signtime);
array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime)));
array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime)));
} elseif ($wip['real_contract_arrival_date'] != NULL) {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$signtime = $estimate_delivery_time - (30 * 86400);
$signtime = date('Ymd', $signtime);
$arrayData[$wip['contractno']]['sign'][2] = strval($signtime);
array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime)));
array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime)));
}
}
// 補上二次款 (出貨前) 收款時間,條件不是"出貨前"就pass
if (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前30天')) {
$estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$secondtime = $estimate_delivery_time - (30 * 86400);
$secondtime = date('Ymd', $secondtime);
if (empty($wip['estimated_shipping_date'])) {
$arrayData[$wip['contractno']]['second']['min'] = 0;
if (empty($wip['real_contract_arrival_date'])) {
} else {
array_push($arrayData[$wip['contractno']]['second']['max'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['second']['min'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time - (30 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
$arrayData[$wip['contractno']]['second'][2] = intval($secondtime);
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前90天')) {
$estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$secondtime = $estimate_delivery_time - (90 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = intval($secondtime);
if (empty($wip['estimated_shipping_date'])) {
$arrayData[$wip['contractno']]['second']['min'] = 0;
if (empty($wip['real_contract_arrival_date'])) {
} else {
array_push($arrayData[$wip['contractno']]['second']['max'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['second']['min'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
}
}
if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['delivery']['min'], intval(substr($wip['delivery_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['delivery']['max'], intval(substr($wip['delivery_date'], 5, 2)));
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], intval(substr($wip['official_check_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['check']['max'], intval(substr($wip['official_check_date'], 5, 2)));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], intval(substr($wip['tryrun_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], intval(substr($wip['tryrun_end_date'], 5, 2)));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['check']['min'], intval(substr($wip['official_check_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['check']['max'], intval(substr($wip['official_check_date'], 5, 2)));
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], intval(substr($wip['tryrun_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], intval(substr($wip['tryrun_end_date'], 5, 2)));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], intval(substr($wip['tryrun_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], intval(substr($wip['tryrun_end_date'], 5, 2)));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time - (90 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
} elseif ($wip['install_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前120天')) {
if (empty($wip['real_contract_arrival_date'])) {
} else {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time - (120 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && $arrayData[$wip['contractno']]['second'][0] == '寶佳出貨後10天') {
if ($wip['real_arrival_date'] != NULL) {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$secondtime = $estimate_delivery_time + (10 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
} else {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time + (10 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime($secondtime));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
} elseif ($wip['real_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
//根據作番狀態填入facilities,計算各階段數量、一個合約有幾個作番,增加作番資料
// real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地
// real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地
//----------------------------------------寶佳的另外處理---------------------------------------------------
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = "";
// if ($arrayData[$wip['contractno']]['sign'][2])
$today = strtotime(date('Ymd'));
$contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($contractday);
if ($today > $contractday) {
$arrayData[$wip['contractno']]['sign_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>";
$contractday = strtotime($arrayData[$wip['contractno']]['second'][2]);
if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>";
if ($wip['real_arrival_date'] != NULL) {
$estimate_time = strtotime($wip['real_arrival_date']);
$contractday = $estimate_time + (90 * 86400);
if ($today > $contractday) {
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>";
if ($wip['tryrun_end_date'] != NULL) {
$estimate_time = strtotime($wip['tryrun_end_date']);
$contractday = $estimate_time + (90 * 86400);
if ($today > $contractday) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>";
if ($wip['delivery_date'] != NULL) {
$estimate_time = strtotime($wip['delivery_date']);
$contractday = $estimate_time + (270 * 86400);
if ($today > $contractday) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>";
}
}
}
}
}
}
}
} else {
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "未到) <br>";
}
} elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['facilities'] .= $facility_status;
} else {
if ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['delivery'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']);
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($wip['delivery_date'])));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($wip['delivery_date'])));
}
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
}
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
}
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['install_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date']))));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['real_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
} else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計到港日待確認) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>";
} elseif ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>";
} else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>";
}
}
}
}
}
// 計算每個合約的應收款、作番總數
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d')))));
foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) {
$month = 11;
$value['receivable_budget'] = $value['sign'][1] + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
$value['receivable_budget'] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']) + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
($value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num'])) + ($value['install'][1] * ($value['install_num'] / $value['total_facility_num'])) +
($value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num'])) + ($value['check'][1] * ($value['check_num'] / $value['total_facility_num'])) +
(($value['delivery'][1] + $value['final'][1]) * ($value['delivery_num'] / $value['total_facility_num']));
$value['sign'][3] = $value['sign'][1];
$value['sign'][3] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']);
$value['second'][3] = $value['second'][1] * ($value['second_num'] / $value['total_facility_num']);
$value['arrive'][3] = $value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num']);
$value['install'][3] = $value['install'][1] * ($value['install_num'] / $value['total_facility_num']);
@ -364,22 +625,51 @@ foreach ($arrayData as &$value) {
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']);
$value['final'][3] = $value['final'][1] * ($value['delivery_num'] / $value['total_facility_num']);
}
$value['sign']['max'] = empty($value['sign']['max']) ? 0 : (($month - max($value['sign']['max'])) < 0 ? 0 : ($month - max($value['sign']['max'])));
$value['sign']['min'] = empty($value['sign']['min']) ? 0 : (($month - min($value['sign']['min'])) < 0 ? 0 : ($month - min($value['sign']['min'])));
$value['second']['max'] = empty($value['second']['max']) ? 0 : (($month - max($value['second']['max'])) < 0 ? 0 : ($month - max($value['second']['max'])));
$value['second']['min'] = empty($value['second']['min']) ? 0 : (($month - min($value['second']['min'])) < 0 ? 0 : ($month - min($value['second']['min'])));
$value['arrive']['max'] = empty($value['arrive']['max']) ? 0 : (($month - max($value['arrive']['max'])) < 0 ? 0 : ($month - max($value['arrive']['max'])));
$value['arrive']['min'] = empty($value['arrive']['min']) ? 0 : (($month - min($value['arrive']['min'])) < 0 ? 0 : ($month - min($value['arrive']['min'])));
$value['install']['max'] = empty($value['install']['max']) ? 0 : (($month - max($value['install']['max'])) < 0 ? 0 : ($month - max($value['install']['max'])));
$value['install']['min'] = empty($value['install']['min']) ? 0 : (($month - min($value['install']['min'])) < 0 ? 0 : ($month - min($value['install']['min'])));
$value['tryrun']['max'] = empty($value['tryrun']['max']) ? 0 : (($month - max($value['tryrun']['max'])) < 0 ? 0 : ($month - max($value['tryrun']['max'])));
$value['tryrun']['min'] = empty($value['tryrun']['min']) ? 0 : (($month - min($value['tryrun']['min'])) < 0 ? 0 : ($month - min($value['tryrun']['min'])));
$value['check']['max'] = empty($value['check']['max']) ? 0 : (($month - max($value['check']['max'])) < 0 ? 0 : ($month - max($value['check']['max'])));
$value['check']['min'] = empty($value['check']['min']) ? 0 : (($month - min($value['check']['min'])) < 0 ? 0 : ($month - min($value['check']['min'])));
$value['delivery']['max'] = empty($value['delivery']['max']) ? 0 : (($month - max($value['delivery']['max'])) < 0 ? 0 : ($month - max($value['delivery']['max'])));
$value['delivery']['min'] = empty($value['delivery']['min']) ? 0 : (($month - min($value['delivery']['min'])) < 0 ? 0 : ($month - min($value['delivery']['min'])));
$value['final']['max'] = empty($value['final']['max']) ? 0 : (($month - max($value['final']['max'])) < 0 ? 0 : ($month - max($value['final']['max'])));
$value['final']['min'] = empty($value['final']['min']) ? 0 : (($month - min($value['final']['min'])) < 0 ? 0 : ($month - min($value['final']['min'])));
// 計算最大催收次數與最小催收次數
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) {
$latest_timestamp = max($value[$i]['min']);
$latest_date = new DateTime();
$latest_date->setTimestamp($latest_timestamp);
if ($latest_date < $today_date) {
$interval = $latest_date->diff($today_date);
$month = $interval->format('%m');
$value[$i]['min'] = $month;
} else {
$value[$i]['min'] = 0;
}
} else {
$value[$i]['min'] = 0;
};
if (!empty($value[$i]['max']) && count($value[$i]['max']) > 0) {
$latest_timestamp = min($value[$i]['max']);
$latest_date = new DateTime();
$latest_date->setTimestamp($latest_timestamp);
if ($latest_date < $today_date) {
$interval = $latest_date->diff($today_date);
$month = $interval->format('%m');
$value[$i]['max'] = $month;
} else {
$value[$i]['max'] = 0;
}
} else {
$value[$i]['max'] = 0;
};
}
}
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期]
foreach ($wipwhole_array as $wip) {
if (isset($arrayData[$wip['contractno']]) && isset($arrayData[$wip['contractno']][$wip['facilityno']]) && !empty($arrayData[$wip['contractno']]['total_facility_num'])) {
$stagearray = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($stagearray as $stage) {
$arrayData[$wip['contractno']][$wip['facilityno']][$stage]['con'] = $arrayData[$wip['contractno']][$stage][1] / $arrayData[$wip['contractno']]['total_facility_num'];
}
}
}
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號]
foreach ($invoice_data as $invoice) {
@ -409,6 +699,8 @@ foreach ($received_array as $received) {
//產生excel的array
$excel_aray = array();
$boga_array = array();
$exclude_boga_array = array();
foreach ($arrayData as $key => $value) {
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
@ -418,6 +710,42 @@ foreach ($arrayData as $key => $value) {
$value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0;
$value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0;
$value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0;
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
$value[$i]['max'] = (empty($value[$i]['max']) || is_null($value[$i]['max'])) ? 0 : $value[$i]['max'];
$value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min'];
};
if ($value['sign'][0] == "寶佳出貨前30天") {
$boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
$value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
$value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
$value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
$value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
} else {
$exclude_boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
$value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
$value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
$value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
$value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
}
$excel_aray[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
@ -428,11 +756,13 @@ foreach ($arrayData as $key => $value) {
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
}
$data = json_encode($excel_aray);
$boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_boga_array);
?>
<style>
@ -472,7 +802,9 @@ $data = json_encode($excel_aray);
}
</style>
<button type="button" onclick="downloadData()" class="btn btn-warning btn-lg pull-right"><span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="downloadData()" class="btn btn-success btn-lg pull-right">全部<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="exclude_bogaData()" class="btn btn-info btn-lg pull-right">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="bogaData()" class="btn btn-warning btn-lg pull-right">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<?php
if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id == 'M0060') {
?>
@ -491,42 +823,42 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
<th style="width: 120px;">客戶名稱</th>
<th style="width: 120px;">簽約款</th>
<th style="width: 120px;">應收簽約金額</th>
<th style="width: 120px;">簽約最大催收次數</th>
<th style="width: 120px;">簽約最小催收次數</th>
<th style="width: 120px;">簽約最大催收次數</th>
<th style="width: 120px;">二次款</th>
<th style="width: 120px;">應收二次金額</th>
<th style="width: 120px;">二次最大催收次數</th>
<th style="width: 120px;">二次最小催收次數</th>
<th style="width: 120px;">二次最大催收次數</th>
<th style="width: 120px;">貨抵工地款</th>
<th style="width: 120px;">應收貨抵工地金額</th>
<th style="width: 120px;">貨抵工地最大催收次數</th>
<th style="width: 120px;">貨抵工地最小催收次數</th>
<th style="width: 120px;">貨抵工地最大催收次數</th>
<th style="width: 120px;">安裝款</th>
<th style="width: 120px;">應收安裝金額</th>
<th style="width: 120px;">安裝最大催收次數</th>
<th style="width: 120px;">安裝最小催收次數</th>
<th style="width: 120px;">安裝最大催收次數</th>
<th style="width: 120px;">試車款</th>
<th style="width: 120px;">應收試車金額</th>
<th style="width: 120px;">試車最大催收次數</th>
<th style="width: 120px;">試車最小催收次數</th>
<th style="width: 120px;">試車最大催收次數</th>
<th style="width: 120px;">官檢款</th>
<th style="width: 120px;">應收官檢金額</th>
<th style="width: 120px;">官檢最大催收次數</th>
<th style="width: 120px;">官檢最小催收次數</th>
<th style="width: 120px;">官檢最大催收次數</th>
<th style="width: 120px;">移交款</th>
<th style="width: 120px;">應收移交金額</th>
<th style="width: 120px;">移交最大催收次數</th>
<th style="width: 120px;">移交最小催收次數</th>
<th style="width: 120px;">移交最大催收次數</th>
<th style="width: 120px;">尾款</th>
<th style="width: 120px;">應收尾款金額</th>
<th style="width: 120px;">尾款最大催收次數</th>
<th style="width: 120px;">尾款最小催收次數</th>
<th style="width: 120px;">尾款最大催收次數</th>
<th style="width: 120px;">合約總金額</th>
<th style="width: 120px;" style="width: 120px;">目前應收</th>
<th style="width: 120px;" style="width: 120px;">已開發票金額</th>
<th style="width: 120px;">已收金額</th>
<!-- <th>作番狀態</th> -->
<!-- <th style="width: 100px;">收款狀態</th> -->
<th style="width: 350px;">收款狀態</th>
</tr>
</thead>
@ -535,7 +867,7 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
foreach ($arrayData as $key => $value) {
?>
<tr>
<th><?= $key ?></th>
<th><a onclick="showContract('<?= $key ?>')"><?= $key ?> </a></th>
<td><?= $value[1] ?></td>
<td><?= $value[2] ?></td>
<td><?= $value[4] ?></td>
@ -576,8 +908,8 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
<td style="text-align: end;"><?= isset($value['receivable_budget']) ? number_format(round($value['receivable_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['invoice_budget']) ? number_format(round($value['invoice_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['received_budget']) ? number_format(round($value['received_budget'])) : '--' ?></td>
<!-- <td style="text-align: start;"><?= $value['facilities'] ?></td>
<td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
<td style="text-align: start;"><?= $value['facilities'] ?></td>
<!-- <td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
</td> -->
</tr>
<?php
@ -587,6 +919,11 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
</table>
</div>
<script>
function showContract(BillNo) {
window.open('account-receivable-contract.php?BillNo=' + BillNo + '&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200');
console.log(BillNo);
}
function test() {
var BillData = <?= $data ?>;
var form = document.createElement("form");
@ -611,7 +948,7 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
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";
var name = "全部應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
@ -631,6 +968,57 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
}
function bogaData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $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-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $boga_data ?>
}));
}
function exclude_bogaData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $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-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $exclude_boga_data ?>
}));
}
function sendData(BillNo) {
var BillData = <?= $data ?>;
var Bill = BillData[BillNo];

37
wms/account-receivable-test.php

@ -1,9 +1,32 @@
<?php
$today = date('Ym01', strtotime('-1 month',strtotime(date('Ym01'))));
$yesterday = date("Ym01", strtotime('-1 month',strtotime(date('2023-11-17'))));
echo "today: " . $today . "<br>";
echo "yesterday: " . $yesterday . "<br>";
echo $today-$yesterday;
// $today = date('Ym01', strtotime('-1 month',strtotime(date('Ym01'))));
// $yesterday = date("Ym01", strtotime('-1 month',strtotime(date('2023-11-17'))));
// echo "today: " . $today . "<br>";
// echo "yesterday: " . $yesterday . "<br>";
// echo $today-$yesterday;
// echo "<br>";
// $test = date('Ymd', $today-$yesterday);
// echo $test;
include './header.php';
$sql = "SELECT
salOrderStagePay.BillNo,
salOrderStagePay.PayStage
FROM salOrderStagePay
LEFT JOIN salSalesOrder
ON salSalesOrder.BillNo = salOrderStagePay.BillNo WHERE salSalesOrder.ModeId = 'M' AND (salSalesOrder.CurrentState=2 OR salSalesOrder.CurrentState=4) ";
$query = $conn->query($sql);
$contracts = array();
foreach ($query as $row) {
if (!array_key_exists($row['BillNo'], $contracts)) {
$contracts[$row['BillNo']] = [$row['BillNo'], $row['PayStage']];
}else{
array_push($contracts[$row['BillNo']], $row['PayStage']);
}
}
foreach($contracts as $contract){
foreach($contract as $con){
echo $con.";";
}
echo "<br>";
$test = date('Ymd', $today-$yesterday);
echo $test;
}

BIN
wms/account-receivable-test.xlsx

Binary file not shown.

246
wms/api/bpm/addContract.ini

@ -0,0 +1,246 @@
[1702986324]
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:D23070085"
fd_3c7af41f068350 = "劉世華"
fd_3c7b8fdee03432 = "Fri Dec 15 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0074"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號"
fd_3c7bd36b993eac = "204000"
fd_3c7bd7adce7f3e = "Thu Dec 21 00:00:00 CST 2023"
fd_3c7b96c1b5523c = ""
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0018"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "桃園市"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "1703433600100"
fd_3c7bd7aac30e4c = "Tue Dec 19 00:00:00 CST 2023"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = "需要 QC + 官檢"
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0960-625735"
fd_3c7b9892c08350 = "A079-大地國際開發-大園10戶313住宅"
fd_3c7b8ffee177ae = "2"
fd_3c7c7ca07fa8ea = "3"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "桃園市"
fd_3c7af41b3bc014 = "吳嬖如"
fd_3c7d2bac66cb4a = "MAH100-6*5-2S45;轎廂 MA019;扶手 MC002;操縱盤 ME017"
fd_3c7b96cbd9a332 = ""
fdNumber = "20231219002"
fd_3c7af4170a31b4 = "D23070085"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "510001"
fd_3c7c931495463e = "1020002"
fd_3c7c7e4d52426a = "QO"
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219002"
fd_3c7bd7aecd1bf2 = "Sat Dec 23 00:00:00 CST 2023"
fd_3c7bd3704d1772 = "204001"
fd_3c7c7daa12b3a6_text = "月保養"
fd_3c7af41d5f0c0e = "13010305 "
docStatus = "20"
docCreateTime = "2023-12-19 19:44:00.0"
fdId = "18c81e3e6fbfd27dc603c3948d6af18e"
fd_3c7d207688e4c0 = "2"
fd_3c7af41a3391d8 = "永融營造工程有限公司"
fd_3c7b9787f379c4_text = "M0018_范育偉"
fd_3c7bd7ae2619e2 = "Fri Dec 22 00:00:00 CST 2023"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7bd7af873bb8 = "Mon Dec 25 00:00:00 CST 2023"
fd_3c7b96ec571486 = "定期保養"
fd_3c7bd7af250b76 = "Sun Dec 24 00:00:00 CST 2023"
fd_3c7c7ca07fa8ea_text = "全包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "永融營造工程有限公司"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7bd7ac5bca84 = "Wed Dec 20 00:00:00 CST 2023"
fd_3c7af6af1c2232_text = "章又仁"
fd_3c7bd37147ce12 = "102000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "hm"
[1702987657]
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:D23070085"
fd_3c7af41f068350 = "劉世華"
fd_3c7b8fdee03432 = "Fri Dec 15 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0074"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號123"
fd_3c7bd36b993eac = "204000"
fd_3c7bd7adce7f3e = "Tue Dec 19 00:00:00 CST 2023"
fd_3c7b96c1b5523c = ""
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0045"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "桃園市"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "1703260800100"
fd_3c7bd7aac30e4c = "Sun Dec 17 00:00:00 CST 2023"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = ""
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0960-625735"
fd_3c7b9892c08350 = "A079-大地國際開發-大園10戶313住宅"
fd_3c7b8ffee177ae = "2"
fd_3c7c7ca07fa8ea = "2"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "桃園市"
fd_3c7af41b3bc014 = "吳嬖如"
fd_3c7d2bac66cb4a = "MAH100-6*5-2S45;轎廂 MA019;扶手 MC002;操縱盤 ME017"
fd_3c7b96cbd9a332 = ""
fdNumber = "20231219003"
fd_3c7af4170a31b4 = "D23070085"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "510001"
fd_3c7c931495463e = "1020002"
fd_3c7c7e4d52426a = ""
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219003"
fd_3c7bd7aecd1bf2 = "Thu Dec 21 00:00:00 CST 2023"
fd_3c7bd3704d1772 = "204001"
fd_3c7c7daa12b3a6_text = "雙週保養"
fd_3c7af41d5f0c0e = "13010305 "
docStatus = "20"
docCreateTime = "2023-12-19 20:05:00.0"
fdId = "18c81f7e09080da42588ce5471faea8d"
fd_3c7d207688e4c0 = "2"
fd_3c7af41a3391d8 = "永融營造工程有限公司"
fd_3c7b9787f379c4_text = "M0045_徐振淞"
fd_3c7bd7ae2619e2 = "Wed Dec 20 00:00:00 CST 2023"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7bd7af873bb8 = "Sat Dec 23 00:00:00 CST 2023"
fd_3c7b96ec571486 = "定期保養"
fd_3c7bd7af250b76 = "Fri Dec 22 00:00:00 CST 2023"
fd_3c7c7ca07fa8ea_text = "半包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "永融營造工程有限公司"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7bd7ac5bca84 = "Mon Dec 18 00:00:00 CST 2023"
fd_3c7af6af1c2232_text = "章又仁"
fd_3c7bd37147ce12 = "102000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "bw"
[1702988835]
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:D23070085"
fd_3c7af41f068350 = "劉世華"
fd_3c7b8fdee03432 = "Sun Dec 31 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0074"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號"
fd_3c7bd36b993eac = "204000"
fd_3c7b96c1b5523c = ""
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0059"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "嘉義縣"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "100"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = "只需官檢"
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0960-625735"
fd_3c7b9892c08350 = "A079-大地國際開發-大園10戶313住宅"
fd_3c7b8ffee177ae = "2"
fd_3c7c7ca07fa8ea = "2"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "嘉義縣"
fd_3c7af41b3bc014 = "吳嬖如"
fd_3c7d2bac66cb4a = "MAH100-6*5-2S45;轎廂 MA019;扶手 MC002;操縱盤 ME017"
fd_3c7b96cbd9a332 = "328桃園市觀音區崙坪村8鄰140號"
fdNumber = "20231219004"
fd_3c7af4170a31b4 = "D23070085"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "510001"
fd_3c7c931495463e = "1020002"
fd_3c7c7e4d52426a = "O"
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219004"
fd_3c7bd3704d1772 = "204001"
fd_3c7c7daa12b3a6_text = "雙週保養"
fd_3c7af41d5f0c0e = "13010305 "
docStatus = "20"
docCreateTime = "2023-12-19 20:26:00.0"
fdId = "18c820a7decaf6dfbcf4b2d4da199d27"
fd_3c7d207688e4c0 = "2"
fd_3c7af41a3391d8 = "永融營造工程有限公司"
fd_3c7b9787f379c4_text = "M0059_林永鴻"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7b96ec571486 = "定期保養"
fd_3c7c7ca07fa8ea_text = "半包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "永融營造工程有限公司"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7af6af1c2232_text = "章又仁"
fd_3c7bd37147ce12 = "102000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "bw"
[1702989437]
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:M230609"
fd_3c7af41f068350 = "曾永霖"
fd_3c7b8fdee03432 = "Sun Nov 26 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0035"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號"
fd_3c7bd36b993eac = "636000"
fd_3c7b96c1b5523c = "0930005720"
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0089"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "南投縣"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "100"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = ""
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0930005720"
fd_3c7b9892c08350 = "祥發開發(青砂街)"
fd_3c7b8ffee177ae = "6"
fd_3c7c7ca07fa8ea = "2"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "南投縣"
fd_3c7af41b3bc014 = "楊雅惠"
fd_3c7d2bac66cb4a = "MAH100-6*4-2S45;轎廂 MA018;扶手 MC005;清安費用;其他配合費用"
fd_3c7b96cbd9a332 = "328桃園市觀音區崙坪村8鄰140號"
fdNumber = "20231219005"
fd_3c7af4170a31b4 = "M230609"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "1590000"
fd_3c7c931495463e = "3180000"
fd_3c7c7e4d52426a = ""
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219005"
fd_3c7bd3704d1772 = "636000"
fd_3c7c7daa12b3a6_text = "雙週保養"
fd_3c7af41d5f0c0e = ""
docStatus = "20"
docCreateTime = "2023-12-19 20:33:00.0"
fdId = "18c82117c73aafc593e492142d28b88b"
fd_3c7d207688e4c0 = "6"
fd_3c7af41a3391d8 = "祥發開發(青砂街)"
fd_3c7b9787f379c4_text = "M0089_郭玠德"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7b96ec571486 = "定期保養"
fd_3c7c7ca07fa8ea_text = "半包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "祥發開發(青砂街)"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7af6af1c2232_text = "林易增"
fd_3c7bd37147ce12 = "318000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "bw"

169
wms/api/bpm/addContract.php

@ -0,0 +1,169 @@
<?php
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
show405Error();
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$request_data_json = file_get_contents('php://input');
$request_data = json_decode(file_get_contents('php://input'), true);
if (empty($request_data)) {
show400Error();
exit;
}
writePostIni($request_data);
writePostIniJson($request_data);
$dsn = 'mysql:host=localhost;dbname=appwms_test';
$username = 'masadaroot';
$password = 'x6h5E5p#u8y';
// fdSignEnable = ""
// fd_3c7b956a747f5e = ""
// docSubject = "合約入力(新梯)_合約號:D23070085"
// fd_3c7af41f068350 = "劉世華"
// fd_3c7b8fdee03432 = "Fri Dec 15 00:00:00 CST 2023"
// fd_3c7af6af1c2232 = "M0074"
// fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號123"
// fd_3c7bd36b993eac = "204000"
// fd_3c7bd7adce7f3e = "Tue Dec 19 00:00:00 CST 2023"
// fd_3c7b96c1b5523c = ""
// fd_3c7b96b95bb932 = "test@gmail.com"
// fd_3c7b9787f379c4 = "M0045"
// fd_3c7bb84b1e63c4 = "12"
// fd_3c7d1ee50bc354_text = "桃園市"
// fd_3c7bd6cac53216 = "0"
// fd_3c7c93e2e39832 = "1703260800100"
// fd_3c7bd7aac30e4c = "Sun Dec 17 00:00:00 CST 2023"
// fdCanCircularize = ""
// fd_3c7c7e4d52426a_text = ""
// fd_3c7bd6cc6292b6 = "20"
// fd_3c7af41fffd500 = "0960-625735"
// fd_3c7b9892c08350 = "A079-大地國際開發-大園10戶313住宅"
// fd_3c7b8ffee177ae = "2"
// fd_3c7c7ca07fa8ea = "2"
// fd_3c7bd36cc1ac98 = "0"
// fd_3c7d1ee50bc354 = "桃園市"
// fd_3c7af41b3bc014 = "吳嬖如"
// fd_3c7d2bac66cb4a = "MAH100-6*5-2S45;轎廂 MA019;扶手 MC002;操縱盤 ME017"
// fd_3c7b96cbd9a332 = ""
// fdNumber = "20231219003"
// fd_3c7af4170a31b4 = "D23070085"
// fd_3c7bd6cb481c76 = "50"
// fd_3c7bd36dbd6424 = "510001"
// fd_3c7c931495463e = "1020002"
// fd_3c7c7e4d52426a = ""
// fd_3c7bd6ccccad9e = "10"
// fd_3c7c88160cf576 = "20231219003"
// fd_3c7bd7aecd1bf2 = "Thu Dec 21 00:00:00 CST 2023"
// fd_3c7bd3704d1772 = "204001"
// fd_3c7c7daa12b3a6_text = "雙週保養"
// fd_3c7af41d5f0c0e = "13010305 "
// docStatus = "20"
// docCreateTime = "2023-12-19 20:05:00.0"
// fdId = "18c81f7e09080da42588ce5471faea8d"
// fd_3c7d207688e4c0 = "2"
// fd_3c7af41a3391d8 = "永融營造工程有限公司"
// fd_3c7b9787f379c4_text = "M0045_徐振淞"
// fd_3c7bd7ae2619e2 = "Wed Dec 20 00:00:00 CST 2023"
// fd_3c7bd69fa6ac52 = "20"
// fd_3c7bd36f203800 = "0"
// fd_3c7bd7af873bb8 = "Sat Dec 23 00:00:00 CST 2023"
// fd_3c7b96ec571486 = "定期保養"
// fd_3c7bd7af250b76 = "Fri Dec 22 00:00:00 CST 2023"
// fd_3c7c7ca07fa8ea_text = "半包"
// fd_3c7bd6cc026d8e = "0"
// fd_3c7b8fbca98fbc = "永融營造工程有限公司"
// fdIsFiling = ""
// fd_3c7bd372804cae = "0"
// fd_3c7bd7ac5bca84 = "Mon Dec 18 00:00:00 CST 2023"
// fd_3c7af6af1c2232_text = "章又仁"
// fd_3c7bd37147ce12 = "102000"
// fd_3c7bd6cd30113a = "0"
// fd_3c7c7daa12b3a6 = "bw"
try {
$pdo = new PDO($dsn, $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET CHARACTER SET utf8mb4');
$pdo->beginTransaction();
$sth = $pdo->prepare("INSERT INTO account (accounttype , accountid) VALUES (?, ?)");
$sth->bindValue(1, 'mf_vol_no');
$sth->execute();
$pdo->commit();
showSuccessMessage();
} catch (PDOException $e) {
$pdo->rollBack();
echo "Transaction failed: " . $e->getMessage();
}
}
function showSuccessMessage()
{
$response = array('status' => 'success', 'message' => 'Data received and stored successfully');
header('Content-Type: application/json');
echo json_encode($response);
}
function showErrorMessage()
{
$response = array('status' => 'error', 'message' => 'Data received and stored error');
header('Content-Type: application/json');
echo json_encode($response);
}
function show400Error()
{
http_response_code(400);
echo 'Invalid request data';
}
function show405Error()
{
http_response_code(405);
echo 'Method Not Allowed';
}
function writePostIni($request_data)
{
// 讀取現有 ini 檔案的資料
$ini_file = 'addContract.ini';
$existing_data = parse_ini_file($ini_file, true);
// 將接收到的資料加入現有資料
$timestamp = time();
$existing_data[$timestamp] = $request_data;
// 將資料寫入 ini 檔
$ini_content = '';
foreach ($existing_data as $key => $value) {
$ini_content .= "[$key]\n";
foreach ($value as $k => $v) {
$ini_content .= "$k = \"$v\"\n";
}
$ini_content .= "\n";
}
file_put_contents($ini_file, $ini_content);
}
function writePostIniJson($request_data)
{
$txt_file = 'addContract.txt';
$txt = "";
$file = fopen($txt_file, 'a');
foreach($request_data as $k => $v){
$txt .= "$k = \"$v\"\n";
}
fwrite($file, $txt . PHP_EOL);
fclose($file);
}

242
wms/api/bpm/addContract.txt

@ -0,0 +1,242 @@
Array
{
"統一編號/身分證":"13010305 ",
"客戶電話":"",
"主旨":"合約入力(新梯)_合約號:D23070085",
"QC和官檢(顯示值)":"",
"保養期限":0.0,
"保養員":"",
"合計":1020002.0,
"營業員":"M0074",
"是否歸檔":false,
"負責人":"吳嬖如",
"启用电子签章":false,
"是否允許傳閱":false,
"區域":"南投縣",
"QC和官檢":"",
"維修型態":"",
"地址":"328桃園市觀音區崙坪村8鄰140號",
"ID":"18c6ca8d4a5fafcece62472441cb1fe5",
"創建時間":"2023-12-15 16:47:00.0",
"規格":"MAH100-6*5-2S45;
轎廂 MA019;
扶手 MC002;
操縱盤 ME017",
"立約人":"永融營造工程有限公司",
"2、二次款":0.0,
"7、其它":0.0,
"合約號碼":"D23070085",
"3占百分比":50.0,
"1、訂金":204000.0,
"保養頻率":"",
"電梯台數":2.0,
"3、貨到工地款":510001.0,
"2占百分比":0.0,
"營業員(顯示值)":"章又仁",
"保養員(顯示值)":"",
"5、安裝完畢款":204001.0,
"業務聯繫人電話":"0960-625735",
"客戶名稱":"永融營造工程有限公司",
"1占百分比":20.0,
"6占百分比":10.0,
"保養別":"",
"合約簽訂時間":"Fri Dec 15 00:00:00 CST 2023",
"明細表總台數":2.0,
"保養頻率(顯示值)":"",
"表單號":"20231215018",
"7占百分比":0.0,
"申請單編號":"20231215018",
"加總趴數":100.0,
"email":"",
"案件名稱":"A079-大地國際開發-大園10戶313住宅",
"4占百分比":0.0,
"業務聯繫人地址":"",
"業務聯繫人":"劉世華",
"6、驗收款":102000.0,
"保養別(顯示值)":"",
"5占百分比":20.0,
"區域(顯示值)":"南投縣",
"4、其他":0.0,
"文檔狀態":"20",
"業務聯繫人Email":""
}
Array
Array
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:D23070085"
fd_3c7af41f068350 = "劉世華"
fd_3c7b8fdee03432 = "Fri Dec 15 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0074"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號123"
fd_3c7bd36b993eac = "204000"
fd_3c7bd7adce7f3e = "Tue Dec 19 00:00:00 CST 2023"
fd_3c7b96c1b5523c = ""
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0045"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "桃園市"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "1703260800100"
fd_3c7bd7aac30e4c = "Sun Dec 17 00:00:00 CST 2023"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = ""
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0960-625735"
fd_3c7b9892c08350 = "A079-大地國際開發-大園10戶313住宅"
fd_3c7b8ffee177ae = "2"
fd_3c7c7ca07fa8ea = "2"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "桃園市"
fd_3c7af41b3bc014 = "吳嬖如"
fd_3c7d2bac66cb4a = "MAH100-6*5-2S45;轎廂 MA019;扶手 MC002;操縱盤 ME017"
fd_3c7b96cbd9a332 = ""
fdNumber = "20231219003"
fd_3c7af4170a31b4 = "D23070085"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "510001"
fd_3c7c931495463e = "1020002"
fd_3c7c7e4d52426a = ""
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219003"
fd_3c7bd7aecd1bf2 = "Thu Dec 21 00:00:00 CST 2023"
fd_3c7bd3704d1772 = "204001"
fd_3c7c7daa12b3a6_text = "雙週保養"
fd_3c7af41d5f0c0e = "13010305 "
docStatus = "20"
docCreateTime = "2023-12-19 20:05:00.0"
fdId = "18c81f7e09080da42588ce5471faea8d"
fd_3c7d207688e4c0 = "2"
fd_3c7af41a3391d8 = "永融營造工程有限公司"
fd_3c7b9787f379c4_text = "M0045_徐振淞"
fd_3c7bd7ae2619e2 = "Wed Dec 20 00:00:00 CST 2023"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7bd7af873bb8 = "Sat Dec 23 00:00:00 CST 2023"
fd_3c7b96ec571486 = "定期保養"
fd_3c7bd7af250b76 = "Fri Dec 22 00:00:00 CST 2023"
fd_3c7c7ca07fa8ea_text = "半包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "永融營造工程有限公司"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7bd7ac5bca84 = "Mon Dec 18 00:00:00 CST 2023"
fd_3c7af6af1c2232_text = "章又仁"
fd_3c7bd37147ce12 = "102000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "bw"
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:D23070085"
fd_3c7af41f068350 = "劉世華"
fd_3c7b8fdee03432 = "Sun Dec 31 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0074"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號"
fd_3c7bd36b993eac = "204000"
fd_3c7b96c1b5523c = ""
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0059"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "嘉義縣"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "100"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = "只需官檢"
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0960-625735"
fd_3c7b9892c08350 = "A079-大地國際開發-大園10戶313住宅"
fd_3c7b8ffee177ae = "2"
fd_3c7c7ca07fa8ea = "2"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "嘉義縣"
fd_3c7af41b3bc014 = "吳嬖如"
fd_3c7d2bac66cb4a = "MAH100-6*5-2S45;轎廂 MA019;扶手 MC002;操縱盤 ME017"
fd_3c7b96cbd9a332 = "328桃園市觀音區崙坪村8鄰140號"
fdNumber = "20231219004"
fd_3c7af4170a31b4 = "D23070085"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "510001"
fd_3c7c931495463e = "1020002"
fd_3c7c7e4d52426a = "O"
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219004"
fd_3c7bd3704d1772 = "204001"
fd_3c7c7daa12b3a6_text = "雙週保養"
fd_3c7af41d5f0c0e = "13010305 "
docStatus = "20"
docCreateTime = "2023-12-19 20:26:00.0"
fdId = "18c820a7decaf6dfbcf4b2d4da199d27"
fd_3c7d207688e4c0 = "2"
fd_3c7af41a3391d8 = "永融營造工程有限公司"
fd_3c7b9787f379c4_text = "M0059_林永鴻"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7b96ec571486 = "定期保養"
fd_3c7c7ca07fa8ea_text = "半包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "永融營造工程有限公司"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7af6af1c2232_text = "章又仁"
fd_3c7bd37147ce12 = "102000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "bw"
fdSignEnable = ""
fd_3c7b956a747f5e = ""
docSubject = "合約入力(新梯)_合約號:M230609"
fd_3c7af41f068350 = "曾永霖"
fd_3c7b8fdee03432 = "Sun Nov 26 00:00:00 CST 2023"
fd_3c7af6af1c2232 = "M0035"
fd_3c7af42a237960 = "328桃園市觀音區崙坪村8鄰140號"
fd_3c7bd36b993eac = "636000"
fd_3c7b96c1b5523c = "0930005720"
fd_3c7b96b95bb932 = "test@gmail.com"
fd_3c7b9787f379c4 = "M0089"
fd_3c7bb84b1e63c4 = "12"
fd_3c7d1ee50bc354_text = "南投縣"
fd_3c7bd6cac53216 = "0"
fd_3c7c93e2e39832 = "100"
fdCanCircularize = ""
fd_3c7c7e4d52426a_text = ""
fd_3c7bd6cc6292b6 = "20"
fd_3c7af41fffd500 = "0930005720"
fd_3c7b9892c08350 = "祥發開發(青砂街)"
fd_3c7b8ffee177ae = "6"
fd_3c7c7ca07fa8ea = "2"
fd_3c7bd36cc1ac98 = "0"
fd_3c7d1ee50bc354 = "南投縣"
fd_3c7af41b3bc014 = "楊雅惠"
fd_3c7d2bac66cb4a = "MAH100-6*4-2S45;轎廂 MA018;扶手 MC005;清安費用;其他配合費用"
fd_3c7b96cbd9a332 = "328桃園市觀音區崙坪村8鄰140號"
fdNumber = "20231219005"
fd_3c7af4170a31b4 = "M230609"
fd_3c7bd6cb481c76 = "50"
fd_3c7bd36dbd6424 = "1590000"
fd_3c7c931495463e = "3180000"
fd_3c7c7e4d52426a = ""
fd_3c7bd6ccccad9e = "10"
fd_3c7c88160cf576 = "20231219005"
fd_3c7bd3704d1772 = "636000"
fd_3c7c7daa12b3a6_text = "雙週保養"
fd_3c7af41d5f0c0e = ""
docStatus = "20"
docCreateTime = "2023-12-19 20:33:00.0"
fdId = "18c82117c73aafc593e492142d28b88b"
fd_3c7d207688e4c0 = "6"
fd_3c7af41a3391d8 = "祥發開發(青砂街)"
fd_3c7b9787f379c4_text = "M0089_郭玠德"
fd_3c7bd69fa6ac52 = "20"
fd_3c7bd36f203800 = "0"
fd_3c7b96ec571486 = "定期保養"
fd_3c7c7ca07fa8ea_text = "半包"
fd_3c7bd6cc026d8e = "0"
fd_3c7b8fbca98fbc = "祥發開發(青砂街)"
fdIsFiling = ""
fd_3c7bd372804cae = "0"
fd_3c7af6af1c2232_text = "林易增"
fd_3c7bd37147ce12 = "318000"
fd_3c7bd6cd30113a = "0"
fd_3c7c7daa12b3a6 = "bw"

4
wms/api/bpm/addContract_form.php

@ -0,0 +1,4 @@
<form action="addContract.php" method="post">
<input type='text' name='id' value='123' />
<input type='submit' />
</form>

108
wms/api/bpm/download.php

@ -0,0 +1,108 @@
<?php
ini_set('display_errors', 'on');
class Bpm_Download_files
{
/**
* 連接資料庫
*/
function connectionDB()
{
$envFile = __DIR__ . '/../../../.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
putenv("$key=$value");
}
}
}
date_default_timezone_set("Asia/Taipei");
$host = getenv('DB_BPM_HOST');
$dbport = getenv('DB_BPM_PORT');
$dbuser = getenv('DB_BPM_USERNAME');
$dbpassword = getenv('DB_BPM_PASSWORD');
$dbname = getenv('DB_BPM_DATABASE');
try {
$options = [
PDO::ATTR_PERSISTENT => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
];
$pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options);
$pdo->exec('SET CHARACTER SET utf8mb4');
return $pdo;
} catch (PDOException $e) {
die("Something wrong: {$e->getMessage()}");
}
}
/**
* 結束資料庫連線
*/
function endConnectionDB($pdo)
{
unset($pdo);
}
// /**
// * 取得下一個新的作番
// * @param string $facility_type : M:新梯 T:汰改 B:保養
// * @return array $new_facility_arr
// */
function downloadBPMFilesByFormNo($tablename, $form_column_name, $form_no)
{
$fd_id = $this->getFd_id($tablename, $form_column_name, $form_no);
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$sql = "
SELECT * FROM sys_att_main AS b
LEFT JOIN sys_att_file AS c
ON b.fd_file_id = c.fd_id
WHERE b.fd_model_id = :fd_id
";
$sth = $pdo->prepare($sql);
$sth->bindParam(':fd_id', $fd_id);
$sth->execute();
$result = $sth->fetchAll();
foreach ($result as $row) {
$fd_file_name = $row['fd_file_name'];
$fd_file_path = "/public/bpm/" . $row['fd_file_path'];
// $filePath = $_SERVER['DOCUMENT_ROOT'] . $fd_file_path;
$str = "";
$str .= '<a href="' . $fd_file_path . '" download="' . $fd_file_name . '">' . $fd_file_name . '</a>';
$str .= "<br/>";
echo $str;
}
return $result;
}
function getFd_id($tablename, $form_column_name, $form_no)
{
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$sth = $pdo->prepare('SELECT fd_id FROM ' . $tablename . ' WHERE ' . $form_column_name . ' = ? ');
$sth->bindValue(1, $form_no);
$sth->execute();
$result = $sth->fetch();
return $result['fd_id'];
}
}
$bdf = new Bpm_Download_files;
// 映射的 table name
$tablename = "ekp_test";
// 映射的 表單表單編號欄位名稱
$form_column_name = "fd_shen1";
// 映射的 表單編號
$form_no = "20231221001";
$bdf->downloadBPMFilesByFormNo($tablename, $form_column_name, $form_no);

6
wms/api/bpm/requests.ini

@ -0,0 +1,6 @@
[1702622618]
id = "123"
[1702622646]
id = "123"

22
wms/class/Cnotice.php

@ -96,14 +96,14 @@ class Cnotice
}
}
$cn = new Cnotice();
$data = array(
'kind' => 1,
'related_id' => 1,
'title' => "標題",
'content' => "內容",
'permission' => "M0117",
'creater' => "M0117",
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
// $cn = new Cnotice();
// $data = array(
// 'kind' => 1,
// 'related_id' => 1,
// 'title' => "標題",
// 'content' => "內容",
// 'permission' => "M0117",
// 'creater' => "M0117",
// 'create_at' => date("Y-m-d H:i:s")
// );
// $cn->sendx($data);

2811
wms/estimated_shipping_date_report.php

File diff suppressed because it is too large

BIN
wms/facility-price.xlsx

Binary file not shown.

4
wms/frame/api_getdata.php

@ -124,7 +124,9 @@ function get_pending($token)
flow f,
flow_main m,
system_main y
WHERE EXISTS (
WHERE 1=1
AND m.flow_id NOT IN ('wws04')
AND EXISTS (
SELECT form_key,
MAX(seq)
FROM subflow

24
wms/fun_global.php

@ -600,3 +600,27 @@ function getAccounttype($link, $user_id)
$row = mysqli_fetch_array($data, MYSQLI_ASSOC);
return $row['accounttype'];
}
/**
* 算催收月份
* @param int $contractday
* @return int $month
*/
function collect_month($contractday)
{
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d')))));
$latest_timestamp = $contractday;
$latest_date = new DateTime();
$latest_date->setTimestamp($latest_timestamp);
if($latest_timestamp < $today_date->getTimestamp()) {
$interval = $latest_date->diff($today_date);
$interval2 = $latest_date->diff($today_date);
$year = $interval2->format('%y');
$month = $interval->format('%m');
$total_month = $year * 12 + $month;
return $total_month;
}else{
return 0;
}
}

60
wms/gary_psd.php

@ -0,0 +1,60 @@
<?php
function encrypt($data, $key)
{
$encrypted = '';
for ($i = 0; $i < strlen($data); $i++) {
$encrypted .= $data[$i] ^ $key[$i % strlen($key)];
}
return base64_encode($encrypted);
}
function decrypt($data, $key)
{
$data = base64_decode($data);
$decrypted = '';
for ($i = 0; $i < strlen($data); $i++) {
$decrypted .= $data[$i] ^ $key[$i % strlen($key)];
}
return $decrypted;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = $_POST['data'] ?? '';
$key = $_POST['key'] ?? '';
if (!empty($data) && !empty($key)) {
if (isset($_POST['encrypt'])) {
$encrypted_data = encrypt($data, $key);
echo "加密後的資料:" . $encrypted_data . "<br>";
} elseif (isset($_POST['decrypt'])) {
$decrypted_data = decrypt($data, $key);
echo "解密後的資料:" . $decrypted_data . "<br>";
}
} else {
echo "請輸入資料和金鑰。";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>加密解密表單</title>
</head>
<body>
<form method="post" action="">
<label for="data">請輸入要加密或解密的資料:</label><br>
<input type="text" id="data" name="data"><br><br>
<label for="key">請輸入金鑰:</label><br>
<input type="text" id="key" name="key" value="masada@<?php echo date("Y"); ?>"><br><br>
<input type="submit" name="encrypt" value="加密資料">
<input type="submit" name="decrypt" value="解密資料">
</form>
</body>
</html>

20
wms/wipwhole-change-contractdate-function.php

@ -674,3 +674,23 @@ function checkStatus($link, $cid, $user_id)
$res = mysqli_query($link, $sql);
return $res->num_rows > 0 ? false : true;
}
/**
* 取台灣縣市select
* @param object $link:資料庫連線
* @return object 回傳 mysqli_fetch_all
*/
function getCity($link)
{
$sql = "
SELECT
content,
code_name
FROM code
WHERE field_name = 'taiwan_city'
";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_free_result($result);
return $data;
}

611
wms/wipwhole-change-contractdate-submit.php

@ -1,303 +1,308 @@
<?php
// echo $_POST['assign_status'];exit;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$checkStatus = checkStatus($link, $id, $user_id);
if (!empty($_POST['contract_arrival_date']) || !empty($_POST['real_address'])) {
if ($checkStatus) {
$all_contractno_change = empty($_POST['all_contractno_change']) ? null : $_POST['all_contractno_change'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$contract_arrival_date = $_POST['contract_arrival_date'];
$real_address = $_POST['real_address'];
$old_real_address = $_POST['old_real_address'];
$estimated_shipping_schedule_date = $_POST['estimated_shipping_schedule_date'];
$contractno = $_POST['contractno'];
$next_users = $_POST['next_users'];
$tds = date("Y-m-d H:i:s");
// 檢查日期是否正確
if ($_POST['assign_status'] !== 'C' && empty($real_address)) {
if (strtotime($contract_arrival_date) < strtotime($estimated_shipping_schedule_date)) {
return;
}
}
// 單次申請
if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && empty($all_contractno_change)) {
$data_arr = array(
'id' => $id,
'all_contractno_change' => $all_contractno_change,
'real_contract_arrival_date' => $real_contract_arrival_date,
'contract_arrival_date' => $contract_arrival_date,
'real_address' => $real_address,
'old_real_address' => $old_real_address,
'contractno' => $contractno,
'tds' => $tds,
'form_key' => getFomkeySeq($link),
'user_id' => $user_id,
'change_status' => $_POST['assign_status']
);
// 寫入表單主檔
addWipwholeChangeContractdateDetails($link, $data_arr);
// 取得寫入後表單seq
$data_arr['last_id'] = $link->insert_id;
// 寫入待簽
addFlow($link, $data_arr);
$data_arr['seq'] = '0';
$data_arr['current_assigner'] = $user_id;
addSubflow($link, $data_arr);
$data_arr['seq'] = '1';
$data_arr['current_assigner'] = $next_users;
addSubflow($link, $data_arr);
}
// 批次申請
if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && !empty($all_contractno_change)) {
$wipwholestatus_id_arr = getWipwholestatusIdByConstractNo($link, $contractno);
$assign_status = $_POST['assign_status'];
foreach ($wipwholestatus_id_arr as $wipwholestatus_id) {
$data_arr = array(
'id' => $wipwholestatus_id[0],
'all_contractno_change' => $all_contractno_change,
'real_contract_arrival_date' => $real_contract_arrival_date,
'contract_arrival_date' => $contract_arrival_date,
'real_address' => $real_address,
'old_real_address' => $old_real_address,
'contractno' => $contractno,
'tds' => $tds,
'form_key' => getFomkeySeq($link),
'user_id' => $user_id,
'change_status' => $assign_status
);
// 寫入表單主檔
addWipwholeChangeContractdateDetails($link, $data_arr);
// 取得寫入後表單seq
$data_arr['last_id'] = $link->insert_id;
// 寫入待簽
addFlow($link, $data_arr);
$data_arr['seq'] = '0';
$data_arr['current_assigner'] = $user_id;
addSubflow($link, $data_arr);
$data_arr['seq'] = '1';
$data_arr['current_assigner'] = $next_users;
addSubflow($link, $data_arr);
}
}
}
}
// 單次申請 營業
if ($_POST['assign_status'] == 'D') {
$tds = date("Y-m-d H:i:s");
$next_users = $_POST['next_users'];
$seq = $_POST['seq'];
$sql = "
UPDATE wipwhole_change_contractdate_details
SET change_status = 'D'
WHERE id = '$cid'
";
mysqli_query($link, $sql);
$sql = "
UPDATE flow
SET flow_code = 'D'
WHERE form_key = '$form_key'
";
mysqli_query($link, $sql);
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'2',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
}
// 取消
if ($_POST['assign_status'] == 'C') {
$tds = date("Y-m-d H:i:s");
$next_users = "00000";
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
if (getChangeStatus($link, $cid) == 'D' || getChangeStatus($link, $cid) == 'A') {
$seq = $_POST['seq'];
}
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'$seq',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
} else if (accountidToDepartId($user_id) == "521" || accountidToDepartId($user_id) == "531") {
if (getChangeStatus($link, $cid) == 'D') {
$sql = "
UPDATE subflow
SET current_assigner = '$next_users',
create_date = '$tds'
WHERE form_key = '$form_key'
AND seq = '$seq'
";
mysqli_query($link, $sql);
} else if (getChangeStatus($link, $cid) == 'A') {
$seq = $_POST['seq'];
$sql = "
UPDATE subflow
SET current_assigner = '$next_users',
create_date = '$tds'
WHERE form_key = '$form_key'
AND seq = '$seq'
";
mysqli_query($link, $sql);
} else {
$seq = $_POST['seq'];
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'$seq',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
}
} else {
$seq = $_POST['seq'];
$sql = "
UPDATE subflow
SET current_assigner = '$next_users',
create_date = '$tds'
WHERE form_key = '$form_key'
AND seq = '$seq'
";
mysqli_query($link, $sql);
}
$sql = "
UPDATE wipwhole_change_contractdate_details
SET change_status = 'C'
WHERE id = '$cid'
";
mysqli_query($link, $sql);
$sql = "
UPDATE flow
SET flow_code = 'Z'
WHERE form_key = '$form_key'
";
mysqli_query($link, $sql);
}
// 通過
if ($_POST['assign_status'] == 'Z') {
$contract_arrival_date_tmp = empty($contract_arrival_date) ? $real_contract_arrival_date : $contract_arrival_date;
$real_address_tmp = empty($real_address) ? $old_real_address : $real_address;
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
$tds = date("Y-m-d H:i:s");
$next_users = $_POST['next_users'];
$seq = $_POST['seq'] + 1;
$sql = "
UPDATE wipwhole_change_contractdate_details
SET change_status = 'Z'
WHERE id = '$cid'
";
mysqli_query($link, $sql);
$sql = "
UPDATE flow
SET flow_code = 'Z'
WHERE form_key = '$form_key'
";
mysqli_query($link, $sql);
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'$seq',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
$sql = "
UPDATE wipwholestatus
SET real_contract_arrival_date = '$contract_arrival_date_tmp',
real_address = '$real_address_tmp'
WHERE id = '$id'
";
mysqli_query($link, $sql);
// 發送系統通知
$contractno = $_POST['contractno'];
$facilityno = $_POST['facilityno'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$salesid = $_POST['salesid'];
$gongWuokid = $_POST['gongWuokid'];
$old_real_address = $_POST['old_real_address'];
$real_address = $_POST['real_address'];
$content = "合約號 : $contractno
作番號 : $facilityno
出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . "
工地地址微調: " . $old_real_address . " => " . $real_address_tmp;
// 大日程出貨日調整 通知營業人員
$noticeData = array(
'related_id' => $cid,
'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno,
'content' => $content,
'permission' => $salesid,
);
addNotice($link, $noticeData);
// 大日程出貨日調整 通知工務人員
$noticeData = array(
'related_id' => $cid,
'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno,
'content' => $content,
'permission' => $gongWuokid,
);
addNotice($link, $noticeData);
$shengguano_arr = getShengguanokOptions($link);
foreach ($shengguano_arr as $row) :
$contractno = $_POST['contractno'];
$facilityno = $_POST['facilityno'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$gongWuokid = $_POST['gongWuokid'];
$old_real_address = $_POST['old_real_address'];
$real_address = $_POST['real_address'];
$content = "合約號 : $contractno
作番號 : $facilityno
出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . "
工地地址微調: " . $old_real_address . " => " . $real_address_tmp;
// 大日程出貨日調整 通知營業人員
$noticeData = array(
'related_id' => $cid,
'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno,
'content' => $content,
'permission' => $row['val'],
);
addNotice($link, $noticeData);
endforeach;
}
}
}
<?php
// echo $_POST['assign_status'];exit;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$checkStatus = checkStatus($link, $id, $user_id);
if (!empty($_POST['contract_arrival_date']) || !empty($_POST['real_address'])) {
if ($checkStatus) {
$all_contractno_change = empty($_POST['all_contractno_change']) ? null : $_POST['all_contractno_change'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$contract_arrival_date = $_POST['contract_arrival_date'];
$city = $_POST['city'];
if (!empty($_POST['real_address'])) {
$real_address = $city . $_POST['real_address'];
} else {
$real_address = $_POST['real_address'];
}
$old_real_address = $_POST['old_real_address'];
$estimated_shipping_schedule_date = $_POST['estimated_shipping_schedule_date'];
$contractno = $_POST['contractno'];
$next_users = $_POST['next_users'];
$tds = date("Y-m-d H:i:s");
// 檢查日期是否正確
if ($_POST['assign_status'] !== 'C' && empty($real_address)) {
if (strtotime($contract_arrival_date) < strtotime($estimated_shipping_schedule_date)) {
return;
}
}
// 單次申請
if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && empty($all_contractno_change)) {
$data_arr = array(
'id' => $id,
'all_contractno_change' => $all_contractno_change,
'real_contract_arrival_date' => $real_contract_arrival_date,
'contract_arrival_date' => $contract_arrival_date,
'real_address' => $real_address,
'old_real_address' => $old_real_address,
'contractno' => $contractno,
'tds' => $tds,
'form_key' => getFomkeySeq($link),
'user_id' => $user_id,
'change_status' => $_POST['assign_status']
);
// 寫入表單主檔
addWipwholeChangeContractdateDetails($link, $data_arr);
// 取得寫入後表單seq
$data_arr['last_id'] = $link->insert_id;
// 寫入待簽
addFlow($link, $data_arr);
$data_arr['seq'] = '0';
$data_arr['current_assigner'] = $user_id;
addSubflow($link, $data_arr);
$data_arr['seq'] = '1';
$data_arr['current_assigner'] = $next_users;
addSubflow($link, $data_arr);
}
// 批次申請
if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && !empty($all_contractno_change)) {
$wipwholestatus_id_arr = getWipwholestatusIdByConstractNo($link, $contractno);
$assign_status = $_POST['assign_status'];
foreach ($wipwholestatus_id_arr as $wipwholestatus_id) {
$data_arr = array(
'id' => $wipwholestatus_id[0],
'all_contractno_change' => $all_contractno_change,
'real_contract_arrival_date' => $real_contract_arrival_date,
'contract_arrival_date' => $contract_arrival_date,
'real_address' => $real_address,
'old_real_address' => $old_real_address,
'contractno' => $contractno,
'tds' => $tds,
'form_key' => getFomkeySeq($link),
'user_id' => $user_id,
'change_status' => $assign_status
);
// 寫入表單主檔
addWipwholeChangeContractdateDetails($link, $data_arr);
// 取得寫入後表單seq
$data_arr['last_id'] = $link->insert_id;
// 寫入待簽
addFlow($link, $data_arr);
$data_arr['seq'] = '0';
$data_arr['current_assigner'] = $user_id;
addSubflow($link, $data_arr);
$data_arr['seq'] = '1';
$data_arr['current_assigner'] = $next_users;
addSubflow($link, $data_arr);
}
}
}
}
// 單次申請 營業
if ($_POST['assign_status'] == 'D') {
$tds = date("Y-m-d H:i:s");
$next_users = $_POST['next_users'];
$seq = $_POST['seq'];
$sql = "
UPDATE wipwhole_change_contractdate_details
SET change_status = 'D'
WHERE id = '$cid'
";
mysqli_query($link, $sql);
$sql = "
UPDATE flow
SET flow_code = 'D'
WHERE form_key = '$form_key'
";
mysqli_query($link, $sql);
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'2',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
}
// 取消
if ($_POST['assign_status'] == 'C') {
$tds = date("Y-m-d H:i:s");
$next_users = "00000";
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
if (getChangeStatus($link, $cid) == 'D' || getChangeStatus($link, $cid) == 'A') {
$seq = $_POST['seq'];
}
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'$seq',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
} else if (accountidToDepartId($user_id) == "521" || accountidToDepartId($user_id) == "531") {
if (getChangeStatus($link, $cid) == 'D') {
$sql = "
UPDATE subflow
SET current_assigner = '$next_users',
create_date = '$tds'
WHERE form_key = '$form_key'
AND seq = '$seq'
";
mysqli_query($link, $sql);
} else if (getChangeStatus($link, $cid) == 'A') {
$seq = $_POST['seq'];
$sql = "
UPDATE subflow
SET current_assigner = '$next_users',
create_date = '$tds'
WHERE form_key = '$form_key'
AND seq = '$seq'
";
mysqli_query($link, $sql);
} else {
$seq = $_POST['seq'];
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'$seq',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
}
} else {
$seq = $_POST['seq'];
$sql = "
UPDATE subflow
SET current_assigner = '$next_users',
create_date = '$tds'
WHERE form_key = '$form_key'
AND seq = '$seq'
";
mysqli_query($link, $sql);
}
$sql = "
UPDATE wipwhole_change_contractdate_details
SET change_status = 'C'
WHERE id = '$cid'
";
mysqli_query($link, $sql);
$sql = "
UPDATE flow
SET flow_code = 'Z'
WHERE form_key = '$form_key'
";
mysqli_query($link, $sql);
}
// 通過
if ($_POST['assign_status'] == 'Z') {
$contract_arrival_date_tmp = empty($contract_arrival_date) ? $real_contract_arrival_date : $contract_arrival_date;
$real_address_tmp = empty($real_address) ? $old_real_address : $real_address;
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
$tds = date("Y-m-d H:i:s");
$next_users = $_POST['next_users'];
$seq = $_POST['seq'] + 1;
$sql = "
UPDATE wipwhole_change_contractdate_details
SET change_status = 'Z'
WHERE id = '$cid'
";
mysqli_query($link, $sql);
$sql = "
UPDATE flow
SET flow_code = 'Z'
WHERE form_key = '$form_key'
";
mysqli_query($link, $sql);
$sql = "
INSERT into subflow (
form_key,
seq,
current_assigner,
create_date
) VALUES (
'$form_key',
'$seq',
'$next_users',
'$tds'
)
";
mysqli_query($link, $sql);
$sql = "
UPDATE wipwholestatus
SET real_contract_arrival_date = '$contract_arrival_date_tmp',
real_address = '$real_address_tmp'
WHERE id = '$id'
";
mysqli_query($link, $sql);
// 發送系統通知
$contractno = $_POST['contractno'];
$facilityno = $_POST['facilityno'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$salesid = $_POST['salesid'];
$gongWuokid = $_POST['gongWuokid'];
$old_real_address = $_POST['old_real_address'];
$real_address = $_POST['real_address'];
$content = "合約號 : $contractno
作番號 : $facilityno
出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . "
工地地址微調: " . $old_real_address . " => " . $real_address_tmp;
// 大日程出貨日調整 通知營業人員
$noticeData = array(
'related_id' => $cid,
'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno,
'content' => $content,
'permission' => $salesid,
);
addNotice($link, $noticeData);
// 大日程出貨日調整 通知工務人員
$noticeData = array(
'related_id' => $cid,
'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno,
'content' => $content,
'permission' => $gongWuokid,
);
addNotice($link, $noticeData);
$shengguano_arr = getShengguanokOptions($link);
foreach ($shengguano_arr as $row) :
$contractno = $_POST['contractno'];
$facilityno = $_POST['facilityno'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$gongWuokid = $_POST['gongWuokid'];
$old_real_address = $_POST['old_real_address'];
$real_address = $_POST['real_address'];
$content = "合約號 : $contractno
作番號 : $facilityno
出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . "
工地地址微調: " . $old_real_address . " => " . $real_address_tmp;
// 大日程出貨日調整 通知營業人員
$noticeData = array(
'related_id' => $cid,
'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno,
'content' => $content,
'permission' => $row['val'],
);
addNotice($link, $noticeData);
endforeach;
}
}
}

8
wms/wipwhole-change-contractdate.php

@ -283,7 +283,13 @@ if (!empty(checkNowFormStatus($link)))
<td colspan="3">
<?php
if (empty(checkNowFormStatus($link))) {
echo "<input type='text' name='real_address' />";
echo "<select id='city' name='city' required>";
$citys = getCity($link);
echo "<option value=''>請選擇</option>";
foreach ($citys as $city)
echo "<option value='" . $city['content'] . "'>" . $city['content'] . "</option>";
echo "</select>";
echo "<input type='text' id='real_address' name='real_address' />";
} else {
echo $row2["real_address"];
echo "<input type='hidden' name='real_address' value='" . $row2["real_address"] . "' />";

141
wms/wipwhole-index-function.php

@ -9,8 +9,8 @@
function getWipwholestatusDetail($link, $id)
{
$db_query = "
SELECT * FROM
wipwholestatus WHERE id = '$id'
SELECT * FROM wipwholestatus
WHERE id = '$id'
AND status = '1'
";
$receivabledata = mysqli_query($link, $db_query);
@ -117,8 +117,11 @@ function getEditFlag($department_id, $role_id, $user_id)
if ($user_id == 'M0113' || $user_id == 'M0158')
return 4;
// 南區工務組長
if ($user_id == 'M0039' || $user_id == 'M0078')
if ($user_id == 'M0078')
return 4;
if ($user_id == 'M0188') {
return 4;
}
// 工務部門
if (in_array($department_id, [521, 531, 541, 542, 543, 544, 545]))
return 4;
@ -147,10 +150,25 @@ function getDataSql($department_id, $role_id, $user_id)
if (in_array($user_id, ['M0166', 'M0091'])) {
$user_id = 'M0086';
}
// 補丁 許馨文 權限 = 李烘銘
if (in_array($user_id, ['M0115'])) {
$user_id = 'M0086';
}
// 補丁 孫仲凱 = 林瑋隆
if (in_array($user_id, ['M0159'])) {
$user_id = 'M0113';
}
// 補丁 林修賢 = 鄭存邑
if (in_array($user_id, ['M0188'])) {
$user_id = 'M0102';
$department_id = '545';
$role_id = '6';
}
// 補丁 林靜雯 權限 = 劉永德 新梯 北區+桃竹
if (in_array($user_id, ['M0189'])) {
$user_id = 'M0137';
}
$sql_cmd = sql_myself($user_id, "salesid");
$sql = "
@ -164,10 +182,23 @@ function getDataSql($department_id, $role_id, $user_id)
// 北區營銷部 營銷專案經理 311 1
// 新梯營銷經理 311 3
// 桃竹營銷部 銷售專案經理 312 1
// 桃竹契約部 經理 512 3
// 中區營銷部 新梯營銷經理 313 1
// 南區營銷部 銷售專案經理 314 2
// 花東區營銷部 銷售專案經理 315 1
if ($department_id == '512' && (in_array($role_id, ['3']))) {
$sql = "
SELECT * FROM wipwholestatus
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
return $sql;
}
if ($department_id == '311' && (in_array($role_id, ['1', '3']))) {
$sql = "
SELECT * FROM wipwholestatus
@ -285,7 +316,7 @@ function getDataSql($department_id, $role_id, $user_id)
return $sql;
}
// 南區工務組長
if ($user_id == 'M0039' || $user_id == 'M0078') {
if ($user_id == 'M0078') {
$sql = "
SELECT * FROM wipwholestatus
WHERE 1=1
@ -319,30 +350,73 @@ function getDataSqlByFlowCode($department_id, $role_id, $user_id, $flow_code)
if (in_array($user_id, ['M0166', 'M0091'])) {
$user_id = 'M0086';
}
// 補丁 許馨文 權限 = 李烘銘
if (in_array($user_id, ['M0115'])) {
$user_id = 'M0086';
}
// 補丁 孫仲凱 = 林瑋隆
if (in_array($user_id, ['M0159'])) {
$user_id = 'M0113';
}
// 補丁 林靜雯 權限 = 劉永德 新梯 北區+桃竹
if (in_array($user_id, ['M0189'])) {
$user_id = 'M0137';
}
// 補丁 林修賢 = 鄭存邑
if (in_array($user_id, ['M0188'])) {
$user_id = 'M0102';
$department_id = '545';
$role_id = '6';
}
$flow_code_tmp = explode(',', $flow_code);
$flow_code = implode("','", $flow_code_tmp);
// 合約類型
$contract_type = 'A';
// 營業員主管或營業員
$department_arr = ['310', '311', '312', '313', '314', '315'];
$department_arr = ['310', '311', '312', '313', '314', '315', '512'];
if (in_array($department_id, $department_arr)) {
// 北區營銷部 營銷專案經理 311 1
// 新梯營銷經理 311 3
// 桃竹營銷部 銷售專案經理 312 1
// 桃竹契約部 經理 512 3
// 中區營銷部 新梯營銷經理 313 1
// 南區營銷部 銷售專案經理 314 2
// 花東區營銷部 銷售專案經理 315 1
if ($department_id == '512' && (in_array($role_id, ['3']))) {
$sql = "
SELECT * FROM wipwholestatus
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
AND id IN (
SELECT
form_id AS id
FROM flow
WHERE system_id = 'wws'
AND flow_id = 'wws01'
AND flow_code IN ('$flow_code')
)
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
return $sql;
}
if ($department_id == '311' && (in_array($role_id, ['1', '3']))) {
$sql = "
SELECT * FROM wipwholestatus
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
AND id IN (
SELECT
form_id AS id
FROM flow
WHERE system_id = 'wws'
AND flow_id = 'wws01'
AND flow_code IN ('$flow_code')
)
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
@ -354,6 +428,14 @@ function getDataSqlByFlowCode($department_id, $role_id, $user_id, $flow_code)
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
AND id IN (
SELECT
form_id AS id
FROM flow
WHERE system_id = 'wws'
AND flow_id = 'wws01'
AND flow_code IN ('$flow_code')
)
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
@ -365,6 +447,14 @@ function getDataSqlByFlowCode($department_id, $role_id, $user_id, $flow_code)
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
AND id IN (
SELECT
form_id AS id
FROM flow
WHERE system_id = 'wws'
AND flow_id = 'wws01'
AND flow_code IN ('$flow_code')
)
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
@ -376,6 +466,14 @@ function getDataSqlByFlowCode($department_id, $role_id, $user_id, $flow_code)
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
AND id IN (
SELECT
form_id AS id
FROM flow
WHERE system_id = 'wws'
AND flow_id = 'wws01'
AND flow_code IN ('$flow_code')
)
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
@ -387,6 +485,14 @@ function getDataSqlByFlowCode($department_id, $role_id, $user_id, $flow_code)
WHERE 1=1
AND status = '1'
AND contract_type = '$contract_type'
AND id IN (
SELECT
form_id AS id
FROM flow
WHERE system_id = 'wws'
AND flow_id = 'wws01'
AND flow_code IN ('$flow_code')
)
" . getWipwholeSearchSql() . "
ORDER BY real_contract_arrival_date ASC
";
@ -845,8 +951,8 @@ function getYewuStatus($link, $user_department_id, $role_id)
// 取得工務的欄位權限
function getWarehouseStatus($link, $user_department_id, $role_id, $status)
{
// if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 50, 501, 311, 313, 314, 521, 315, 912])) {
if (getSaveEstimateInstallData($user_department_id, $role_id)) {
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 50, 501, 311, 313, 314, 521, 315, 912])) {
// if (getSaveEstimateInstallData($user_department_id, $role_id)) {
if ($status == 1) {
return checkNowFormGStatus($link) == 'G' ? "" : "disabled";
} else {
@ -1221,3 +1327,24 @@ function getAllCustomerPlanningVerify($link, $id)
";
return mysqli_query($link, $sql);
}
// 各區營銷(契約)經理判斷程式
function checkUseridIsManager($user_id)
{
// 北區 劉永德
if (in_array($user_id, ['M0137']))
return true;
// 中區 李烘銘
if (in_array($user_id, ['M0086']))
return true;
// 桃竹 張莉凱
if (in_array($user_id, ['M0026']))
return true;
// 宜花東 陳志文
if (in_array($user_id, ['M0054']))
return true;
// 南區 吳育宗
if (in_array($user_id, ['M0033']))
return true;
return false;
}

20
wms/wipwhole-index.php

@ -67,7 +67,8 @@ $tableArr = array(
"B" => "B",
"G" => "G",
"CH" => "C,H",
"Z" => "Z"
"Z" => "Z",
"I" => "I",
);
if (empty($sheetNum) || $sheetNum == "All") {
@ -212,6 +213,9 @@ $data = mysqli_query($link, $sql);
<li>
<a href="#" onclick="showATable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showITable()">營業主管確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">設計確認中</a>
</li>
@ -433,14 +437,20 @@ mysqli_close($link);
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showITable() {
sheetNum = "I";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showTable(code) {
var tmp_arr = {
"All": "1",
"A": "2",
"B": "3",
"G": "4",
"CH": "5",
"Z": "6",
"I": "3",
"B": "4",
"G": "5",
"CH": "6",
"Z": "7",
}
$("nav.navbar.navbar-tabs div > ul > li").attr("class", "");
$("nav.navbar.navbar-tabs div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");

340
wms/wipwhole-rec-invoice-edit-submit.php

@ -1,149 +1,104 @@
<?php
ini_set('display_errors', 'on');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'main_form') {
include("class/Cnotice.php");
$cn = new Cnotice();
if ($_POST['form_name'] == 'main_form') {
foreach ($_POST as $k => $v) {
if ($k !== 'desin_taiwan_items_no' && $k !== 'desin_taiwan_items_name')
$$k = htmlspecialchars(stripslashes(trim($v)));
}
// 時間戳記
$datetime = date("Y-m-d H:i:s");
// 合約號
$contractno = $_POST['contractno'];
// 號機
$facility_temp_no = $_POST['facility_temp_no'];
// 作番號
$facilityno = $_POST['facilityno'];
// 客戶名稱
$custom = $_POST['custom'];
// 工地負責人
$site_manager = $_POST['site_manager'];
// 緯度
$latitude = $_POST['latitude'];
// 經度
$longitude = $_POST['longitude'];
$weight = $_POST['weight'];
// 人乘
$numberofpassenger = $_POST['numberofpassenger'];
// 樓停
$numberofstop = $_POST['numberofstop'];
// 樓層
$numberoffloor = $_POST['numberoffloor'];
// 開門方式
$opentype = $_POST['opentype'];
// 速度
$speed = $_POST['speed'];
// 機型
$facility_kind = $_POST['facility_kind'];
// 地址
$address = $_POST['address'];
// 工地地址
$real_address = $_POST['real_address'];
//合約到貨日
$contract_arrival_date = $_POST['contract_arrival_date'];
//合約到貨日
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
//营业规格确认
$sales_spec_verify = $_POST['sales_spec_verify'];
$sales_spec_verify_at = $_POST['sales_spec_verify_at'] ?: $row['sales_spec_verify_at'];
$sales_spec_verify_owner = $_POST['sales_spec_verify_owner'] ?: $row['sales_spec_verify_owner'];
//客户计划图确认
$real_custom_name = $_POST['real_custom_name'] ?: $row['real_custom_name'];
$customer_planning_verify = $_POST['customer_planning_verify'];
$customer_planning_verify_at = $_POST['customer_planning_verify_at'] ?: $row['customer_planning_verify_at'];
$customer_planning_verify_owner = $_POST['customer_planning_verify_owner'] ?: $row['customer_planning_verify_owner'];
//客户颜色确认
$customer_color_verify = $_POST['customer_color_verify'];
$customer_color_verify_at = $_POST['customer_color_verify_at'] ?: $row['customer_color_verify_at'];
$customer_color_verify_owner = $_POST['customer_color_verify_owner'] ?: $row['customer_color_verify_owner'];
//客户颜色确认
$customer_style_verify = $_POST['customer_style_verify'];
$customer_style_verify_at = $_POST['customer_style_verify_at'] ?: $row['customer_style_verify_at'];
$customer_style_verify_owner = $_POST['customer_style_verify_owner'] ?: $row['customer_style_verify_owner'];
//工勘聯絡表
$site_survey_contact_form_verify = $_POST['site_survey_contact_form_verify'];
$site_survey_contact_form_verify_at = $_POST['site_survey_contact_form_verify_at'] ?: $row['site_survey_contact_form_verify_at'];
$site_survey_contact_form_verify_owner = $_POST['site_survey_contact_form_verify_owner'] ?: $row['site_survey_contact_form_verify_owner'];
//设计规格确认
$desin_spec_verify = $_POST['desin_spec_verify'];
$desin_spec_verify_at = $_POST['desin_spec_verify_at'] ?: $row['desin_spec_verify_at'];
$desin_spec_verify_owner = $_POST['desin_spec_verify_owner'] ?: $row['desin_spec_verify_owner'];
//设计计划图确认
$desin_planning_verify = $_POST['desin_planning_verify'];
$desin_planning_verify_at = $_POST['desin_planning_verify_at'] ?: $row['desin_planning_verify_at'];
$desin_planning_verify_owner = $_POST['desin_planning_verify_owner'] ?: $row['desin_planning_verify_owner'];
//设计颜色确认
$desin_color_verify = $_POST['desin_color_verify'];
$desin_color_verify_at = $_POST['desin_color_verify_at'] ?: $row['desin_color_verify_at'];
$desin_color_verify_owner = $_POST['desin_color_verify_owner'] ?: $row['desin_color_verify_owner'];
//设计仕样确认
$desin_style_verify = $_POST['desin_style_verify'];
$desin_style_verify_at = $_POST['desin_style_verify_at'] ?: $row['desin_style_verify_at'];
$desin_style_verify_owner = $_POST['desin_style_verify_owner'] ?: $row['desin_style_verify_owner'];
//设计主管確認
$desin_leader_verify = $_POST['desin_leader_verify'];
$desin_leader_verify_at = $_POST['desin_leader_verify_at'] ?: $row['desin_leader_verify_at'];
$desin_leader_verify_owner = $_POST['desin_leader_verify_owner'] ?: $row['desin_leader_verify_owner'];
//楼高通报
$building_heigh_verify = $_POST['building_heigh_verify'];
$building_heigh_verify_at = $_POST['building_heigh_verify_at'] ?: $row['building_heigh_verify_at'];
$building_heigh_verify_owner = $_POST['building_heigh_verify_owner'] ?: $row['building_heigh_verify_owner'];
//工勘
$site_survey_contact_verify = $_POST['site_survey_contact_verify'];
$site_survey_contact_verify_at = $_POST['site_survey_contact_verify_at'] ?: $row['site_survey_contact_verify_at'];
$site_survey_contact_verify_owner = $_POST['site_survey_contact_verify_owner'] ?: $row['site_survey_contact_verify_owner'];
$old_site_survey_contact_verify = $_POST['old_site_survey_contact_verify'];
//是否齊備
$shengguanok_status = $_POST['shengguanok_status'];
$shengguanok_status_at = $_POST['shengguanok_status_at'];
$shengguanok_status_owner = $_POST['shengguanok_status_owner'] ?: $row['shengguanok_status_owner'];
//下單日(普萊特富)
$prattford_order_date_verify = $_POST['prattford_order_date_verify'];
$prattford_order_date = $_POST['prattford_order_date'];
$prattford_order_date_owner = $_POST['prattford_order_date_owner'] ?: $row['prattford_order_date_owner'];
// 預計發貨日(到港日)
$estimated_shipping_date_verify = $_POST['estimated_shipping_date_verify'];
$estimated_shipping_date = $_POST['estimated_shipping_date'];
$estimated_shipping_date_owner = $_POST['estimated_shipping_date_owner'] ?: $row['estimated_shipping_date_owner'];
// 預計船期(改成預計到廠日)
$estimated_shipping_schedule_date_verify = $_POST['estimated_shipping_schedule_date_verify'];
$estimated_shipping_schedule_date = $_POST['estimated_shipping_schedule_date'];
$estimated_shipping_schedule_date_owner = $_POST['estimated_shipping_schedule_date_owner'] ?: $row['estimated_shipping_schedule_date_owner'];
// 普來特富發貨類別
$goods_type = $_POST['goods_type'] ?: $row['goods_type'];
$goods_type_date = $_POST['goods_type_date'] ?: $row['goods_type_date'];
$goods_type_owner = $_POST['goods_type_owner'] ?: $row['goods_type_owner'];
// 台灣自理發貨類別
$taiwan_goods_type = $_POST['taiwan_goods_type'] ?: $row['taiwan_goods_type'];
$taiwan_goods_type_date = $_POST['taiwan_goods_type_date'];
$taiwan_goods_type_owner = $_POST['taiwan_goods_type_owner'] ?: $row['taiwan_goods_type_owner'];
// 實際到貨日
$arrival_date_verify = $_POST['arrival_date_verify'] ?: $row['arrival_date_verify'];
$actual_tofactory_date = $_POST['actual_tofactory_date'];
$arrival_date_owner = $_POST['arrival_date_owner'] ?: $row['arrival_da
te_owner'];
// 各部門備註
$marketing_remark = $_POST['marketing_remark'] ?: $row['marketing_remark'];
$desin_remark = $_POST['desin_remark'] ?: $row['desin_remark'];
$desin_leader_remark = $_POST['desin_leader_remark'] ?: $row['desin_leader_remark'];
$warehouse_remark = $_POST['warehouse_remark'] ?: $row['warehouse_remark'];
$yewu_remark = $_POST['yewu_remark'] ?: $row['yewu_remark'];
$shengguan_remark = $_POST['shengguan_remark'] ?: $row['shengguan_remark'];
// 台製件
$desin_taiwan_items_no = json_encode($_POST['desin_taiwan_items_no'], JSON_UNESCAPED_UNICODE);
$desin_taiwan_items_name = json_encode($_POST['desin_taiwan_items_name'], JSON_UNESCAPED_UNICODE);
$desin_taiwan_items_no = $desin_taiwan_items_no == 'null' ? null : $desin_taiwan_items_no;
$desin_taiwan_items_name = $desin_taiwan_items_name == 'null' ? null : $desin_taiwan_items_name;
// 品証部
$qc_date = $_POST['qc_date'] ?: $row['qc_date'];
$qc_date_owner = $_POST['qc_date_owner'] ?: $row['qc_date_owner'];
$end_qc_date = $_POST['end_qc_date'] ?: $row['end_qc_date'];
@ -154,8 +109,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$delivery_date = $_POST['delivery_date'] ?: $row['delivery_date'];
$delivery_date_owner = $_POST['delivery_date_owner'] ?: $row['delivery_date_owner'];
$qc_official_type = $_POST['qc_official_type'] ?: $row['qc_official_type'];
// 工務助理
$outsourcer_type = $_POST['outsourcer_type'];
$install_outsourcer = $_POST['install_outsourcer'];
$install_outsourcer_owner = $_POST['install_outsourcer_owner'];
@ -175,8 +128,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$estimate_tryrun_end_date_owner = $_POST['estimate_tryrun_end_date_owner'];
$warehouse_assistant_remark = $_POST['warehouse_assistant_remark'];
$creater = $_POST['creater'];
$create_at = date("Y-m-fd H:i:s");
// $creater = $_POST['creater'];
$creater = $user_id;
$create_at = date("Y-m-d H:i:s");
// 上傳附件
include "wipwhole-rec-invoice-edit-fileupload.php";
@ -197,29 +151,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$content = "客戶:$custom
作番:$facilityno
官檢日 $old_official_check_date => $official_check_date";
$sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'$title',
'$content',
null,
'$permission',
'$creater',
'" . date("Y-m-d H:i:s") . "'
);
";
mysqli_query($link, $sql);
$data = array(
'kind' => 1,
'related_id' => $id,
'title' => $title,
'content' => $content,
'permission' => $permission,
'creater' => $creater,
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
}
}
}
@ -265,62 +206,44 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
作番:$facilityno
工勘狀態 $site_survey_status[$old_site_survey_contact_verify] => $site_survey_status[$site_survey_contact_verify]";
$sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'$title',
'$content',
null,
'$permission',
'$creater',
'$create_at'
);
";
mysqli_query($link, $sql);
$data = array(
'kind' => 1,
'related_id' => $id,
'title' => $title,
'content' => $content,
'permission' => $permission,
'creater' => $creater,
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
}
}
if (!empty($desin_documents_verify_file)) {
echo $sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件',
'合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件',
null,
'M0168',
'$creater',
'$create_at'
);
";
mysqli_query($link, $sql);
$title = "合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件";
$content = "合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件";
$data = array(
'kind' => 1,
'related_id' => $id,
'title' => $title,
'content' => $content,
'permission' => "M0168",
'creater' => $creater,
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
}
$updatesql = "
UPDATE wipwholestatus
SET
";
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545])) {
// 工務更新;
if (
in_array($user_id, ['M0164', 'M0165', 'M0127', 'M0193', 'M0170', 'M0188', 'M0117', 'M0054'])
|| in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545])
) {
// 工務助理 工務更新
$updatesql .= "
building_heigh_verify = '$building_heigh_verify',
building_heigh_verify_at = '$building_heigh_verify_at',
@ -339,7 +262,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$updatesql .= "building_heigh_verify_file = '$building_heigh_verify_file', ";
if (!empty($site_survey_contact_verify_file))
$updatesql .= "site_survey_contact_verify_file = '$site_survey_contact_verify_file', ";
} else if ($user_department_id == 311 || $user_department_id == 312 || $user_department_id == 313 || $user_department_id == 314 || $user_department_id == 315) {
} else if (in_array($user_department_id, [311, 312, 313, 314, 315])) {
// 營業更新;
$updatesql .= "
sales_spec_verify = '$sales_spec_verify',
@ -430,26 +353,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$updatesql .= "desin_documents_verify_file = '$desin_documents_verify_file', ";
}
} else if ($user_department_id == 321) {
// 共用更新
// $updatesql .= "
// contractno = '$contractno',
// facility_temp_no = '$facility_temp_no',
// facilityno = '$facilityno',
// custom='$custom' ,
// latitude = '$latitude',
// longitude = '$longitude',
// weight = '$weight',
// numberofpassenger = '$numberofpassenger',
// numberofstop = '$numberofstop',
// numberoffloor = '$numberoffloor',
// opentype = '$opentype',
// speed = '$speed',
// site_manager = '$site_manager',
// address = '$address',
// real_address = '$real_address',
// contract_arrival_date = '$contract_arrival_date',
// facility_kind = '$facility_kind',
// ";
// 業務更新
$updatesql .= "
prattford_order_date_verify = '$prattford_order_date_verify' ,
@ -540,9 +443,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 工務助理
if (
in_array($user_id, ['M0164', 'M0165', 'M0127', 'M0193', 'M0170', 'M0188', 'M0117'])
in_array($user_id, ['M0164', 'M0165', 'M0127', 'M0193', 'M0170', 'M0188', 'M0117', 'M0054'])
|| in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545])
|| $user_id == 'M0054'
) {
$qc_official_type = $_POST['qc_official_type2'] ?: $row['qc_official_type'];
@ -566,9 +468,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$tryrun_end_date_owner = $_POST['tryrun_end_date2_owner'] ?: $row['tryrun_end_date_owner'];
$updatesql .= "
qc_official_type = '$qc_official_type',
install_start_date = '$install_start_date',
install_start_date_owner = '$install_start_date_owner',
install_end_date = '$install_end_date',
@ -577,7 +477,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
tryrun_start_date_owner = '$tryrun_start_date_owner',
tryrun_end_date = '$tryrun_end_date',
tryrun_end_date_owner = '$tryrun_end_date_owner',
delivery_date = '$delivery_date',
delivery_date_owner = '$delivery_date_owner',
qc_date = '$qc_date',
@ -586,7 +485,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
end_qc_date_owner = '$end_qc_date_owner',
official_check_date = '$official_check_date',
official_check_date_owner = '$official_check_date_owner',
outsourcer_type = '$outsourcer_type',
install_outsourcer = '$install_outsourcer',
install_outsourcer_owner = '$install_outsourcer_owner',
@ -739,6 +637,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'update_contract_date_form') {
foreach ($_POST as $k => $v)
$$k = htmlspecialchars(stripslashes(trim($v)));
@ -746,8 +645,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$contractno = $_POST['contractno'];
$facilityno = $_POST['facilityno'];
$custom = $_POST['custom'];
$creater = $_POST['creater'];
$create_at = $_POST['create_at'];
// $creater = $_POST['creater'];
$creater = $user_id;
// $create_at = $_POST['create_at'];
$create_at = date("Y-m-d H:i:s");
$old_real_contract_arrival_date = $_POST['old_real_contract_arrival_date'];
$real_contract_arrival_date = $_POST['real_contract_arrival_date'];
$salesid = $_POST['salesid'];
@ -762,54 +663,33 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
";
mysqli_query($link, $updatesql);
$title = "作番大日程(新梯)出貨日調整通知 > " . $facilityno;
$content = "合約號 : $contractno
作番號 : $facilityno
出貨日期微調: " . substr($old_real_contract_arrival_date, 0, 10) . " => " . substr($real_contract_arrival_date, 0, 10);
$sql = "
INSERT INTO notice (
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
) VALUES(
'1',
'$id',
'作番大日程(新梯)出貨日調整通知 > " . $facilityno . "',
'$content',
NULL,
'$salesid',
'system',
'" . date("Y-m-d H:i:s") . "'
)
";
mysqli_query($link, $sql);
$sql = "
INSERT INTO notice (
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
) VALUES(
'1',
'$id',
'作番大日程(新梯)出貨日調整通知 > " . $facilityno . "',
'$content',
NULL,
'$gongWuokid',
'system',
'" . date("Y-m-d H:i:s") . "'
)
";
mysqli_query($link, $sql);
$data = array(
'kind' => 1,
'related_id' => $id,
'title' => $title,
'content' => $content,
'permission' => $salesid,
'creater' => 'system',
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
$data = array(
'kind' => 1,
'related_id' => $id,
'title' => $title,
'content' => $content,
'permission' => $gongWuokid,
'creater' => 'system',
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
$sql = "
INSERT INTO wipwhole_change_contractdate_details (
@ -839,6 +719,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'update_date_form') {
$creater = $user_id;
@ -874,28 +755,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
作番:$facilityno
實際出貨日(到工地):$real_arrival_date";
$sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'$title',
'$content',
null,
'$permission',
'$creater',
'" . date("Y-m-d H:i:s") . "'
);
";
mysqli_query($link, $sql);
$data = array(
'kind' => 1,
'related_id' => $id,
'title' => $title,
'content' => $content,
'permission' => $permission,
'creater' => $creater,
'create_at' => date("Y-m-d H:i:s")
);
$cn->sendx($data);
}
echo "<script type ='text/JavaScript'>";
@ -954,7 +823,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($_POST as $k => $v)
$$k = htmlspecialchars(stripslashes(trim($v)));
$creater = $_POST['creater'];
// $creater = $_POST['creater'];
$creater = $user_id;
$datetime = date("Y-m-d H:i:s");
$shengguan_remark = $_POST['shengguan_remark'];
$updatesql = "
@ -995,40 +865,6 @@ function write_note($link, $id, $user_id, $content)
mysqli_query($link, $updatesql);
}
// function getWipwholestatusDetail($link, $id)
// {
// $sql = "
// SELECT *
// FROM wipwholestatus
// WHERE 1=1
// AND id = '$id'
// AND status = '1'
// ";
// $result = mysqli_query($link, $sql);
// $row = mysqli_fetch_assoc($result);
// return $row;
// }
// 各區營銷(契約)經理判斷程式
function checkUseridIsManager($user_id)
{
// 北區 劉永德
if (in_array($user_id, ['M0137']))
return true;
// 中區 李烘銘
if (in_array($user_id, ['M0086']))
return true;
// 桃竹 張莉凱
if (in_array($user_id, ['M0026']))
return true;
// 宜花東 陳志文
if (in_array($user_id, ['M0054']))
return true;
// 南區 吳育宗
if (in_array($user_id, ['M0033']))
return true;
return false;
}
// 表單簽核狀態檢查主程式
function checkWwsAssianStatus($link, $user_id, $id = null)

57
wms/wipwhole-rec-invoice-edit.php

@ -158,8 +158,9 @@ include "wipwhole-rec-invoice-edit-submit.php";
521, 531, 220, 250,
541, 542, 543, 544, 545
];
if (in_array($user_department_id, $show_tmp_arr))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>工地地址調整</a>";
if ($user_id !== 'M0115')
if (in_array($user_department_id, $show_tmp_arr))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>工地地址調整</a>";
?>
</td>
<td>
@ -227,8 +228,9 @@ include "wipwhole-rec-invoice-edit-submit.php";
521, 531, 220, 250,
541, 542, 543, 544, 545
];
if (in_array($user_department_id, $show_tmp_arr))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>出貨日調整</a>";
if ($user_id !== 'M0115')
if (in_array($user_department_id, $show_tmp_arr))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>出貨日調整</a>";
?>
</td>
<td style="vertical-align: middle">
@ -298,6 +300,17 @@ include "wipwhole-rec-invoice-edit-submit.php";
<tbody style="font-weight: bolder;margin-bottom: 20px">
<tr>
<td>營業人員確認項</td>
<td>
<?php
echo "營業擔當:" . $row['salesid'] . accountid2name()[$row['salesid']];
?>
<br />
<?php
if (!checkUseridIsManager($row['salesid'])) {
echo "營業擔當主管:" . manage_class($row['salesid'])[0] . accountid2name(manage_class($row['salesid'])[0])[manage_class($row['salesid'])[0]];
}
?>
</td>
</tr>
<tr>
<td style="vertical-align: middle;width:auto;">營業/契約確認規格</td>
@ -507,25 +520,29 @@ include "wipwhole-rec-invoice-edit-submit.php";
<input class="form-control " type="hidden" name="creater" value="<?= $user_id; ?>">
<input class="form-control " type="hidden" name="create_at" value="<?= $row["create_at"]; ?>">
<?php
if (checkNowFormYDStatus($link) == 'A' && in_array($user_department_id, [220, 311, 312, 313, 314, 315])) {
if ($user_id !== 'M0115') {
if (checkNowFormYDStatus($link) == 'A' && in_array($user_department_id, [220, 311, 312, 313, 314, 315])) {
?>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至<?php echo checkUseridIsManager($user_id) ? "設計部門" : "營業主管"; ?>
</button>
<?php
} else if (checkNowFormYDStatus($link) == 'I' && checkUseridIsManager($user_id)) {
?>
<button onclick="doBackMarketingAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">
退回營業
</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至設計部門
</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至<?php echo checkUseridIsManager($user_id) ? "設計部門" : "營業主管"; ?>
</button>
<?php
} else if (checkNowFormYDStatus($link) == 'I' && checkUseridIsManager($user_id)) {
?>
<button onclick="doBackMarketingAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">
退回營業
</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至設計部門
</button>
<?php
}
?>
<button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $marketing2; ?>>存檔</button>
<span class="text-danger pull-right">若無工勘資料請勿移交至設計階段!</span>
<?php
}
?>
<button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $marketing2; ?>>存檔</button>
<span class="text-danger pull-right">若無工勘資料請勿移交至設計階段!</span>
</td>
</tr>
</tbody>
@ -877,7 +894,7 @@ include "wipwhole-rec-invoice-edit-submit.php";
<input class="form-control " type="hidden" name="creater" value="<?= $user_id; ?>" readonly>
<input class="form-control " type="hidden" name="create_at" value="<?= $row["create_at"]; ?>" readonly>
<?php
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 220])) {
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 220]) || in_array($user_id, ['M0188'])) {
echo "<button onclick='savedata()' class='btn btn-primary btn-lg pull-right' style='margin-left:3px;'>存檔</button>";
if (checkNowFormGStatus($link) == 'G')
echo "<button onclick='doWarhouseAssign()' type='button' class='btn btn-primary btn-lg pull-right' style='margin-left:3px;'>提交至生管</button>";

1754
wms/wipwhole-rec-invoice.php

File diff suppressed because it is too large

1271
wms/wipwhole-renovate-index-function.php

File diff suppressed because it is too large

24
wms/wipwhole-renovate-index.php

@ -65,7 +65,8 @@ $tableArr = array(
"B" => "B",
"C" => "C",
"D" => "D",
"Z" => "Z"
"Z" => "Z",
"F" => "F",
);
if (empty($sheetNum) || $sheetNum == "All") {
@ -210,6 +211,9 @@ $data = mysqli_query($link, $sql);
<li>
<a href="#" onclick="showBTable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showFTable()">營業主管確認中</a>
</li>
<li>
<a href="#" onclick="showCTable()">設計確認中</a>
</li>
@ -296,9 +300,9 @@ $data = mysqli_query($link, $sql);
</div>
<?php
echo "<div id='data_detail_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
echo "<div id='data_detail_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
#結束連線
@ -444,6 +448,11 @@ mysqli_close($link);
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showFTable() {
sheetNum = "F";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showBTable() {
sheetNum = "B";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
@ -469,9 +478,10 @@ mysqli_close($link);
"All": "1",
"A": "2",
"B": "3",
"C": "4",
"D": "5",
"Z": "6",
"F": "4",
"C": "5",
"D": "6",
"Z": "7",
}
$("nav.navbar.navbar-tabs div > ul > li").attr("class", "");
$("nav.navbar.navbar-tabs div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");

77
wms/wipwhole-renovate-rec-invoice-edit-submit.php

@ -1,4 +1,5 @@
<?php
// ini_set('display_errors', 'on');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'main_form') {
@ -9,6 +10,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 時間戳記
$datetime = date("Y-m-d H:i:s");
$create_at = date("Y-m-d H:i:s");
// 合約號
$contractno = $_POST['contractno'];
@ -234,7 +236,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$delivery_date_owner = $_POST['delivery_date_owner'] ?: $row['delivery_date_owner'];
$creater = $_POST['creater'];
$create_at = $_POST['create_at'];
$create_at = date("Y-m-d H:i:s");
// 上傳附件
include "wipwhole-rec-invoice-edit-fileupload.php";
@ -282,7 +284,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$updatesql = "update wipwholestatus set ";
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545])) {
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545]) || $user_id == 'M0054') {
// 工務更新;
$updatesql .= "
building_heigh_verify = '$building_heigh_verify',
@ -935,6 +937,23 @@ function checkWwsAssianStatus($link, $user_id)
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : getForm_key($link, $id);
}
include "./class/Cmail.php";
$cmail = new Cmail();
$data = getWipwholestatusDetail($link, $id);
$data['salesname'] = accountid2name($data['salesid'])[$data['salesid']];
$data['salesmail'] = accountid2email([$data['salesid']])[$data['salesid']];
$data['salesmanagername'] = accountid2name(manage_class($data['salesid'])[0])[manage_class($data['salesid'])[0]];
$data['salesmanagermail'] = accountid2email([manage_class($data['salesid'])[0]])[manage_class($data['salesid'])[0]];
$data['designname'] = accountid2name("M0023")["M0023"];
$data['designmail'] = accountid2email(["M0023"])["M0023"];
$data['designleadername'] = accountid2name(getSheJiokLeaderNo($link))[getSheJiokLeaderNo($link)];
$data['designleadermail'] = accountid2email([getSheJiokLeaderNo($link)])[getSheJiokLeaderNo($link)];
$data['gongwokname'] = accountid2name(getGongWuokNo($link))[getGongWuokNo($link)];
$data['gongwokmail'] = accountid2email([getGongWuokNo($link)])[getGongWuokNo($link)];
$data['shengguanname'] = accountid2name(getShengGuanokLeaderNo($link))[getShengGuanokLeaderNo($link)];
$data['shengguanmail'] = accountid2email([getShengGuanokLeaderNo($link)])[getShengGuanokLeaderNo($link)];
// 確認工務階段 進入營業階段
if (checkNowFormStatus($link) == 'A' && checkGongWuok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>工務提交至營業階段</em>");
@ -944,10 +963,58 @@ function checkWwsAssianStatus($link, $user_id)
// 確認營業階段 進入設計人員(汰改:林坤翰 M0052 改 林昭翰 M0173)階段
if (checkNowFormStatus($link) == 'B' && checkYingYeok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>營業提交至設計階段</em>");
do_wws_next_assign("M0173", $form_key, 'C');
return;
if (checkUseridIsManager($user_id)) {
write_note($link, $id, $user_id, "<em>營業提交至設計階段</em>");
$mail_title = "作番大日程(汰改)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業提交至設計階段";
$mail_content = "作番大日程(汰改)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業提交至設計階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
[$data['designname'], $data['designmail']]
],
"永佳捷科技"
);
do_wws_next_assign("M0173", $form_key, 'C');
return;
} else {
write_note($link, $id, $user_id, "<em>營業提交至營業經理階段</em>");
$mail_title = "作番大日程(汰改)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業提交至營業經理階段";
$mail_content = "作番大日程(汰改)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業提交至營業經理階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
[$data['salesmanagername'], $data['salesmanagermail']]
],
"永佳捷科技"
);
do_wws_next_assign(manage_class($data['salesid'])[0], $form_key, 'F');
}
}
// 確認營業主管階段 進入設計人員(汰改:林昭翰 M0173)階段
if (checkNowFormStatus($link) == 'F' && checkYingYeok($link, $id) == '0') {
if (checkUseridIsManager($user_id)) {
write_note($link, $id, $user_id, "<em>營業經理提交至設計階段</em>");
$mail_title = "作番大日程(汰改)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業經理提交至設計階段";
$mail_content = "作番大日程(汰改)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業經理提交至設計階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
[$data['designname'], $data['designmail']]
],
"永佳捷科技"
);
do_wws_next_assign("M0173", $form_YD_key, 'C');
return true;
}
}
// 確認設計人員(汰改:林坤翰 M0052 改 林昭翰 M0173)階段 進入設計主管階段
if (checkNowFormStatus($link) == 'C' && checkSheJiok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>設計提交至設計主管階段</em>");

48
wms/wipwhole-renovate-rec-invoice-edit.php

@ -153,8 +153,9 @@ include "wipwhole-renovate-rec-invoice-edit-submit.php";
<td style="vertical-align: middle">預計交期(到工地)
<br />
<?php
if (getWipwholeChangeButtonStatus($user_department_id))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>出貨日調整</a>";
if ($user_id !== 'M0115')
if (getWipwholeChangeButtonStatus($user_department_id))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>出貨日調整</a>";
?>
</td>
<td style="vertical-align: middle">
@ -176,8 +177,9 @@ include "wipwhole-renovate-rec-invoice-edit-submit.php";
</td>
<td style="vertical-align: middle">工地地址<br />
<?php
if (getWipwholeChangeButtonStatus($user_department_id))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>工地地址調整</a>";
if ($user_id !== 'M0115')
if (getWipwholeChangeButtonStatus($user_department_id))
echo "<a target='_blank' href='wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id'>工地地址調整</a>";
?>
</td>
<td>
@ -458,12 +460,12 @@ include "wipwhole-renovate-rec-invoice-edit-submit.php";
<td colspan="8">
<input class="form-control " type="hidden" name="creater" value="<?= $user_id; ?>" readonly>
<input class="form-control " type="hidden" name="create_at" value="<?= $row["create_at"]; ?>" readonly>
<button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $warehouse2; ?>>存檔</button>
<?php
if (checkNowFormStatus($link) == 'A' && in_array($user_department_id, [220, 521, 531, 541, 542, 543, 544, 545])) {
?>
<button onclick="doWarhouseAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">提交至營業</button>
<!-- <button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $warehouse2; ?>>存檔</button> -->
<?php
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 220]) || in_array($user_id, ['M0188'])) {
echo "<button onclick='savedata()' class='btn btn-primary btn-lg pull-right' style='margin-left:3px;'>存檔</button>";
if (checkNowFormStatus($link) == 'A')
echo "<button onclick='doWarhouseAssign()' type='button' class='btn btn-primary btn-lg pull-right' style='margin-left:3px;'>提交至營業</button>";
}
?>
</td>
@ -711,14 +713,28 @@ include "wipwhole-renovate-rec-invoice-edit-submit.php";
<input class="form-control " type="hidden" name="creater" value="<?= $user_id; ?>">
<input class="form-control " type="hidden" name="create_at" value="<?= $row["create_at"]; ?>">
<?php
if (checkNowFormStatus($link) == 'B' && in_array($user_department_id, [220, 311, 312, 313, 314, 315, 511, 512, 513, 514])) {
if ($user_id !== 'M0115') {
if (checkNowFormStatus($link) == 'B' && in_array($user_department_id, [220, 311, 312, 313, 314, 315, 511, 512, 513, 514])) {
?>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">提交至設計部門</button>
<button onclick="doBackWarhouseAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">退回工務部門</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至<?php echo checkUseridIsManager($user_id) ? "設計部門" : "營業主管"; ?>
</button>
<button onclick="doBackWarhouseAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">退回工務部門</button>
<?php
} else if (checkNowFormStatus($link) == 'F' && checkUseridIsManager($user_id)) {
?>
<button onclick="doBackMarketingAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;" <?= $marketing2; ?>>退回營業</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至設計部門
</button>
<?php
}
?>
<button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $marketing2; ?>>存檔</button>
<span class="text-danger pull-right">若無工勘資料請勿移交至設計階段!</span>
<?php
}
?>
<button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $marketing2; ?>>存檔</button>
</td>
</tr>
</tbody>
@ -1146,12 +1162,12 @@ include "wipwhole-renovate-rec-invoice-edit-submit.php";
if (checkNowFormStatus($link) == 'Z' && ($user_department_id == '220' || ($user_department_id == '321' && $role_id !== '5'))) {
?>
<button class="btn btn-primary btn-lg pull-right" type="button" style="margin-left:3px;" disabled>日程已結案</button>
<?php
<?php
} else {
// 生管 小雯 預計到貨日(到觀音廠日)權限
// if ($user_id == 'M0168') {
?>
<!-- <button onclick="savedata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">存檔</button> -->
?>
<!-- <button onclick="savedata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">存檔</button> -->
<?php
// }

1848
wms/wipwhole-renovate-rec-invoice.php

File diff suppressed because it is too large

593
wms/wipwhole-wipinstallstatus-index.php

@ -1,22 +1,6 @@
<?php
// ini_set('display_errors', 'on');
// 新梯
// $Adata
// 出貨台數 = 有實際出貨日期
// $Adata2
// 在裝台數 = 已出貨且官檢日跟移交日都沒填日期
// $Adata3
// 工收台數 = 已出貨且官檢日或移交日其中一個有日期
// 合計
// $data
// 出貨台數 = 有實際出貨日期
// $data2
// 在裝台數 = 已出貨且官檢日跟移交日都沒填日期
// $data3
// 工收台數 = 已出貨且官檢日或移交日其中一個有日期
$real_arrival_date_start = empty($_REQUEST['real_arrival_date_start']) ? date("Y") . '-01' : $_REQUEST['real_arrival_date_start'];
$real_arrival_date_end = empty($_REQUEST['real_arrival_date_end']) ? date("Y-m") : $_REQUEST['real_arrival_date_end'];
$radsY = SUBSTR($real_arrival_date_start, 0, 4);
@ -26,287 +10,117 @@ $radeM = SUBSTR($real_arrival_date_end, 5, 2);
include "header.php";
// 新梯-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'A'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Adata = $result->fetch_all(MYSQLI_ASSOC);
// 新梯-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'A'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Adata2 = $result->fetch_all(MYSQLI_ASSOC);
// 新梯-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'A'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Adata3 = $result->fetch_all(MYSQLI_ASSOC);
// M1-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%M1%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$M1data = $result->fetch_all(MYSQLI_ASSOC);
// M1-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%M1%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$M1data2 = $result->fetch_all(MYSQLI_ASSOC);
// M1-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%M1%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$M1data3 = $result->fetch_all(MYSQLI_ASSOC);
// MA-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%MA%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Madata = $result->fetch_all(MYSQLI_ASSOC);
// MA-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%MA%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Madata2 = $result->fetch_all(MYSQLI_ASSOC);
// MA-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%MA%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Madata3 = $result->fetch_all(MYSQLI_ASSOC);
// 合計-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$data = $result->fetch_all(MYSQLI_ASSOC);
// 合計-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$data2 = $result->fetch_all(MYSQLI_ASSOC);
// 合計-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$data3 = $result->fetch_all(MYSQLI_ASSOC);
// 出貨台數
function getShipping($type, $mtype, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(*) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
";
$sql .= !empty($type) ? " AND contract_type = '$type'" : "";
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : "";
// echo $sql . "<br/>";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_array($result, MYSQLI_ASSOC);
return $data['all_count'];
}
// 試車完台數
function getInstalling($type, $mtype, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(*) AS all_count
-- real_arrival_date,
-- tryrun_end_date
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
AND tryrun_end_date <= '$year-$month-31'
AND tryrun_end_date != ''
AND tryrun_end_date IS NOT NULL
";
$sql .= !empty($type) ? " AND contract_type = '$type'" : "";
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : "";
// echo $sql."<br/>";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_array($result, MYSQLI_ASSOC);
return $data['all_count'];
}
// 工收台數
function getEnding($type, $mtype, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(
*
) AS all_count
-- real_arrival_date,
-- delivery_date,
-- official_check_date
FROM wipwholestatus
WHERE status = '1'
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
AND (delivery_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
OR
official_check_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
)
";
$sql .= !empty($type) ? " AND contract_type = '$type'" : "";
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : "";
// echo $sql . "<br/>";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_array($result, MYSQLI_ASSOC);
return $data['all_count'];
}
// 在裝中台數
function getInstalling2($type, $mtype, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(*) AS all_count
-- delivery_date,
-- official_check_date
FROM wipwholestatus
WHERE status = '1'
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
AND (
delivery_date IS NULL
OR delivery_date = ''
OR delivery_date >= '$year-$month-31'
)
AND(
official_check_date IS NULL
OR official_check_date = ''
OR official_check_date >= '$year-$month-31'
)
";
$sql .= !empty($type) ? " AND contract_type = '$type'" : "";
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : "";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_array($result, MYSQLI_ASSOC);
return $data['all_count'];
}
?>
<form id='myForm' method='post' action='wipwhole-wipinstallstatus-index.php?<?= $token_link ?>'>
@ -371,11 +185,11 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
$end_month = $radeM;
}
?>
<th style='text-align:center;' colspan="<?php echo $end_month * 3 ?>"><?php echo $radsYi . '年'; ?></th>
<th style='text-align:center;' colspan="<?php echo $end_month * 4 ?>"><?php echo $radsYi . '年'; ?></th>
<?php
}
?>
<th style='width:200px' colspan="3" rowspan="2">總計(全部)</th>
<!-- <th style='width:200px' colspan="3" rowspan="2">總計(全部)</th> -->
</tr>
<tr>
<!-- <th style="width:150px;"></th> -->
@ -398,7 +212,7 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
for ($start_month; $start_month <= $end_month; $start_month++) {
?>
<th style='width:200px' colspan="3"><?php echo (int)$start_month . '月'; ?></th>
<th style='width:200px;text-align:center;' colspan="4"><?php echo (int)$start_month . '月'; ?></th>
<?php
}
?>
@ -430,16 +244,17 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
?>
<th style="background-color:#CECECE;">出貨</th>
<th style="background-color:#DEDEDE;">工收</th>
<th>在裝</th>
<th style="background-color:#EEEEEE;">試車完</th>
<th style="background-color:#FFFFFF;">在裝中</th>
<?php
}
?>
<?php
}
?>
<th style="background-color:#FF8040;">出貨</th>
<!-- <th style="background-color:#FF8040;">出貨</th>
<th style="background-color:#FFAF60;">工收</th>
<th style="background-color:#9D9D9D;">在裝</th>
<th style="background-color:#9D9D9D;">試車完</th> -->
</tr>
</thead>
<tbody>
@ -465,40 +280,33 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// 新梯出貨
$all_count = 0;
foreach ($Adata as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
$all_count = getShipping("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#CECECE;'>$all_count</td>";
// 新梯工收
$all_count = 0;
foreach ($Adata3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
$all_count = getEnding("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
// 新梯試車完
$all_count = 0;
foreach ($Adata2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
$all_count = getInstalling("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#EEEEEE;'>$all_count</td>";
// 新梯在裝中
$all_count = 0;
$all_count = getInstalling2("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#FFFFFF;'>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
// echo "<td style='background-color:#FF8040;'>$a_count</td>";
// echo "<td style='background-color:#FFAF60;'>$b_count</td>";
// echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
<tr>
@ -523,40 +331,33 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// M1出貨
$all_count = 0;
foreach ($M1data as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
$all_count = getShipping("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#CECECE;'>$all_count</td>";
// M1工收
$all_count = 0;
foreach ($M1data3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
$all_count = getEnding("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
// M1試車完
$all_count = 0;
foreach ($M1data2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
$all_count = getInstalling("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#EEEEEE;'>$all_count</td>";
// M1在裝中
$all_count = 0;
$all_count = getInstalling2("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#FFFFFF;'>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
// echo "<td style='background-color:#FF8040;'>$a_count</td>";
// echo "<td style='background-color:#FFAF60;'>$b_count</td>";
// echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
<tr>
@ -581,40 +382,33 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// MA出貨
$all_count = 0;
foreach ($Madata as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
$all_count = getShipping("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#CECECE;'>$all_count</td>";
// MA工收
$all_count = 0;
foreach ($Madata3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
$all_count = getEnding("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
// MA試車完
$all_count = 0;
foreach ($Madata2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
$all_count = getInstalling("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#EEEEEE;'>$all_count</td>";
// MA在裝中
$all_count = 0;
$all_count = getInstalling2("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#FFFFFF;'>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
// echo "<td style='background-color:#FF8040;'>$a_count</td>";
// echo "<td style='background-color:#FFAF60;'>$b_count</td>";
// echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
<tr>
@ -639,40 +433,33 @@ if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// 出貨
$all_count = 0;
foreach ($data as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
$all_count = getShipping("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#CECECE;'>$all_count</td>";
// 工收
$all_count = 0;
foreach ($data3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
$all_count = getEnding("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
// 試車完
$all_count = 0;
foreach ($data2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
$all_count = getInstalling("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#EEEEEE;'>$all_count</td>";
// 在裝中
$all_count = 0;
$all_count = getInstalling2("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
echo "<td style='background-color:#FFFFFF;'>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
// echo "<td style='background-color:#FF8040;'>$a_count</td>";
// echo "<td style='background-color:#FFAF60;'>$b_count</td>";
// echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
</tbody>

2300
wms/wipwholeinstall-index-function.php

File diff suppressed because it is too large

2344
wms/wipwholeinstall-renovate-index-function.php

File diff suppressed because it is too large
Loading…
Cancel
Save