Browse Source

應收帳款 增加期初

gary
Ellin 1 year ago
parent
commit
7957324851
  1. BIN
      wms/account-receivable-contract.xlsx
  2. 25
      wms/account-receivable-excel.php
  3. 371
      wms/account-receivable-new-index.php
  4. 42
      wms/account-receivable-renovate-index.php
  5. BIN
      wms/account-receivable-renovate.xlsx
  6. 44
      wms/account-receivable-repair-index.php
  7. BIN
      wms/account-receivable-repair.xlsx
  8. 2
      wms/account-receivable.txt

BIN
wms/account-receivable-contract.xlsx

Binary file not shown.

25
wms/account-receivable-excel.php

@ -14,7 +14,6 @@ $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
if ($type == 'newContract') {
$excel_array = array();
$colomnHeader = [
'合約號', '客戶名稱', '營業員', '合約金額', '台數', '作番狀態', '催收金額', '催收次數', '訂金催收金額', '訂金催收次數', '二次款催收金額', '二次款催收次數',
'貨抵工地款催收金額', '貨抵工地款催收次數',
@ -24,32 +23,24 @@ if ($type == 'newContract') {
'交車款催收金額', '交車款催收次數',
'尾款催收金額', '尾款催收次數'
];
foreach ($Bill as $key => $value) {
$excel_array[$key] = [
$value[0], $value[3], $value[8], $value[11], $value[19], $value[20], $value[17], $value[18], $value[26], $value[27], $value[33], $value[34],
$value[40], $value[41],
$value[47], $value[48],
$value[54], $value[55],
$value[61], $value[62],
$value[68], $value[69],
$value[75], $value[76]
];
}
file_put_contents('account-receivable.txt', json_encode($excel_array, JSON_UNESCAPED_UNICODE));
file_put_contents('account-receivable.txt', json_encode($Bill, JSON_UNESCAPED_UNICODE));
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($excel_array as $item) {
$sheet->fromArray($item, NULL, 'A' . $rowIndex);
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'
'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'
];
foreach ($column as $col) {
if ($col == 'F') {
$sheet->getColumnDimension('F')->setWidth(35);
$sheet->getStyle('F')->getAlignment()->setWrapText(true);
} else {
$sheet->getColumnDimension($col)->setAutoSize(true);
// $sheet->getColumnDimension($col)->setAutoSize(true);
$sheet->getColumnDimension($col)->setWidth(10);
$sheet->getStyle($col)->getAlignment()->setWrapText(true);
}
}
$rowIndex++;

371
wms/account-receivable-new-index.php

@ -613,7 +613,7 @@ foreach ($query_invoice as $invoice) {
//未在T8的收款資料
$sql_wms = "SELECT * FROM account_received WHERE type='M' AND BillNo IN $str_numbers";
$query_wms = mysqli_query($link, $sql_wms);
foreach($query_wms as $wms){
foreach ($query_wms as $wms) {
if (isset($arrayData[$wms['BillNo']]) && isset($arrayData[$wms['BillNo']]['invoice_budget'])) {
$arrayData[$wms['BillNo']]['invoice_budget'] += $wms['invoice_budget'];
}
@ -756,6 +756,7 @@ $average_contract_facility = $sum_facility / $sum_contract;
// 21 訂金名稱; 22 訂金金額; 23 應收金額; 24 已開發票金額; 25 已收金額; 26 催收金額; 27 催收次數;
// 28 二次款名稱; 29 二次款金額; 30 應收金額; 31 已開發票金額; 32 已收金額; 33 催收金額; 34 催收次數;
$excel_contract_array = array();
$excel_contract_all_array = array();
$excel_contract_boga_array = array();
$excel_contract_noboga_array = array();
@ -786,59 +787,38 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--';
$excel_contract_array[$key][14] = number_format(round($excel_contract_array[$key][14]));
$excel_contract_array[$key][16] = number_format(round($excel_contract_array[$key][16]));
if (isset($value['PayStage']) && is_iterable($value['PayStage'])) {
if ($excel_contract_array[$key][17] > 1 && isset($value['PayStage']) && is_iterable($value['PayStage'])) {
$excel_contract_all_array[$key] = array_fill(0, 24, 0);
$excel_contract_all_array[$key][0] = $excel_contract_array[$key][0];
$excel_contract_all_array[$key][1] = $excel_contract_array[$key][3];
$excel_contract_all_array[$key][2] = $excel_contract_array[$key][8];
$excel_contract_all_array[$key][3] = $excel_contract_array[$key][11];
$excel_contract_all_array[$key][4] = $excel_contract_array[$key][19];
$excel_contract_all_array[$key][5] = $excel_contract_array[$key][20];
$excel_contract_all_array[$key][6] = $excel_contract_array[$key][17];
$excel_contract_all_array[$key][7] = $excel_contract_array[$key][18];
$isBoga = 0;
if (stristr($value['PayStage'][1]['PayStage'], '寶佳')) {
$isBoga = 1;
$excel_contract_boga_array[$key] = array_fill(0, 76, '');
$excel_contract_boga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : '';
$excel_contract_boga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : '';
$excel_contract_boga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
$excel_contract_boga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : '';
$excel_contract_boga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : '';
$excel_contract_boga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : '';
$excel_contract_boga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : '';
$excel_contract_boga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : '';
$excel_contract_boga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
$excel_contract_boga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
$excel_contract_boga_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_boga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? number_format(round($value['OAmountWithTax'])) : '0';
$excel_contract_boga_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? number_format(round($value['A40001'])) : '0';
$excel_contract_boga_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? number_format(round($value['A40008'])) : '0';
$excel_contract_boga_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0;
$excel_contract_boga_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? number_format(round($value['invoice_budget'])) : '0';
$excel_contract_boga_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_boga_array[$key][17] = number_format(round($excel_contract_boga_array[$key][14] - $excel_contract_boga_array[$key][16]));
$excel_contract_boga_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? number_format(round($value['collect_month'])) : '0';
$excel_contract_boga_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? number_format(round($value['facility_num'])) : '0';
$excel_contract_boga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--';
$excel_contract_boga_array[$key][14] = number_format(round($excel_contract_boga_array[$key][14]));
$excel_contract_boga_array[$key][16] = number_format(round($excel_contract_boga_array[$key][16]));
$excel_contract_boga_array[$key] = array_fill(0, 24, '');
$excel_contract_boga_array[$key][0] = $excel_contract_array[$key][0];
$excel_contract_boga_array[$key][1] = $excel_contract_array[$key][3];
$excel_contract_boga_array[$key][2] = $excel_contract_array[$key][8];
$excel_contract_boga_array[$key][3] = $excel_contract_array[$key][11];
$excel_contract_boga_array[$key][4] = $excel_contract_array[$key][19];
$excel_contract_boga_array[$key][5] = $excel_contract_array[$key][20];
$excel_contract_boga_array[$key][6] = $excel_contract_array[$key][17];
$excel_contract_boga_array[$key][7] = $excel_contract_array[$key][18];
} else {
$excel_contract_noboga_array[$key] = array_fill(0, 76, '');
$excel_contract_noboga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : '';
$excel_contract_noboga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : '';
$excel_contract_noboga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
$excel_contract_noboga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : '';
$excel_contract_noboga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : '';
$excel_contract_noboga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : '';
$excel_contract_noboga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : '';
$excel_contract_noboga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : '';
$excel_contract_noboga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
$excel_contract_noboga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
$excel_contract_noboga_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_noboga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? number_format(round($value['OAmountWithTax'])) : '0';
$excel_contract_noboga_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? number_format(round($value['A40001'])) : '0';
$excel_contract_noboga_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? number_format(round($value['A40008'])) : '0';
$excel_contract_noboga_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? number_format(round($value['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_noboga_array[$key][17] = number_format(round($excel_contract_noboga_array[$key][14] - $excel_contract_noboga_array[$key][16]));
$excel_contract_noboga_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? number_format(round($value['collect_month'])) : '0';
$excel_contract_noboga_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? number_format(round($value['facility_num'])) : '0';
$excel_contract_noboga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--';
$excel_contract_noboga_array[$key][14] = number_format(round($excel_contract_noboga_array[$key][14]));
$excel_contract_noboga_array[$key][16] = number_format(round($excel_contract_noboga_array[$key][16]));
$excel_contract_noboga_array[$key] = array_fill(0, 24, '');
$excel_contract_noboga_array[$key][0] = $excel_contract_array[$key][0];
$excel_contract_noboga_array[$key][1] = $excel_contract_array[$key][3];
$excel_contract_noboga_array[$key][2] = $excel_contract_array[$key][8];
$excel_contract_noboga_array[$key][3] = $excel_contract_array[$key][11];
$excel_contract_noboga_array[$key][4] = $excel_contract_array[$key][19];
$excel_contract_noboga_array[$key][5] = $excel_contract_array[$key][20];
$excel_contract_noboga_array[$key][6] = $excel_contract_array[$key][17];
$excel_contract_noboga_array[$key][7] = $excel_contract_array[$key][18];
}
foreach ($value['PayStage'] as $paykey => $payvalue) {
switch ($payvalue['stage']) {
@ -850,29 +830,21 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][26] = number_format(round($excel_contract_array[$key][23] - $excel_contract_array[$key][25]));
$excel_contract_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][8] = number_format(round($excel_contract_array[$key][23] - $excel_contract_array[$key][25]));
$excel_contract_all_array[$key][9] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if ($isBoga == 1) {
$excel_contract_boga_array[$key][8] = $excel_contract_all_array[$key][8];
$excel_contract_boga_array[$key][9] = $excel_contract_all_array[$key][9];
} else {
$excel_contract_noboga_array[$key][8] = $excel_contract_all_array[$key][8];
$excel_contract_noboga_array[$key][9] = $excel_contract_all_array[$key][9];
}
}
$excel_contract_array[$key][23] = number_format(round($excel_contract_array[$key][23]));
$excel_contract_array[$key][25] = number_format(round($excel_contract_array[$key][25]));
if ($isBoga == 1) {
$excel_contract_boga_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_boga_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_boga_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][26] = number_format(round($excel_contract_boga_array[$key][23] - $excel_contract_boga_array[$key][25]));
$excel_contract_boga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_boga_array[$key][23] = number_format(round($excel_contract_boga_array[$key][23]));
$excel_contract_boga_array[$key][25] = number_format(round($excel_contract_boga_array[$key][25]));
} else {
$excel_contract_noboga_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][26] = number_format(round($excel_contract_noboga_array[$key][23] - $excel_contract_noboga_array[$key][25]));
$excel_contract_noboga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][23] = number_format(round($excel_contract_noboga_array[$key][23]));
$excel_contract_noboga_array[$key][25] = number_format(round($excel_contract_noboga_array[$key][25]));
}
break;
case "二次款":
$excel_contract_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -882,30 +854,22 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][33] = number_format(round($excel_contract_array[$key][30] - $excel_contract_array[$key][32]));
$excel_contract_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][10] = number_format(round($excel_contract_array[$key][30] - $excel_contract_array[$key][32]));
$excel_contract_all_array[$key][11] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if ($isBoga == 1) {
$excel_contract_boga_array[$key][10] = $excel_contract_all_array[$key][10];
$excel_contract_boga_array[$key][11] = $excel_contract_all_array[$key][11];
} else {
$excel_contract_noboga_array[$key][10] = $excel_contract_all_array[$key][10];
$excel_contract_noboga_array[$key][11] = $excel_contract_all_array[$key][11];
}
}
$excel_contract_array[$key][30] = number_format(round($excel_contract_array[$key][30]));
$excel_contract_array[$key][32] = number_format(round($excel_contract_array[$key][32]));
if ($isBoga == 1) {
$excel_contract_boga_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_boga_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_boga_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][33] = number_format(round($excel_contract_boga_array[$key][30] - $excel_contract_boga_array[$key][32]));
$excel_contract_boga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_boga_array[$key][30] = number_format(round($excel_contract_boga_array[$key][30]));
$excel_contract_boga_array[$key][32] = number_format(round($excel_contract_boga_array[$key][32]));
} else {
$excel_contract_noboga_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][33] = number_format(round($excel_contract_noboga_array[$key][30] - $excel_contract_noboga_array[$key][32]));
$excel_contract_noboga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][30] = number_format(round($excel_contract_noboga_array[$key][30]));
$excel_contract_noboga_array[$key][32] = number_format(round($excel_contract_noboga_array[$key][32]));
}
break;
case "貨抵工地款":
$excel_contract_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -915,29 +879,20 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][40] = number_format(round($excel_contract_array[$key][37] - $excel_contract_array[$key][39]));
$excel_contract_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][12] = number_format(round($excel_contract_array[$key][37] - $excel_contract_array[$key][39]));
$excel_contract_all_array[$key][13] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if ($isBoga == 1) {
$excel_contract_boga_array[$key][12] = $excel_contract_all_array[$key][12];
$excel_contract_boga_array[$key][13] = $excel_contract_all_array[$key][13];
} else {
$excel_contract_noboga_array[$key][12] = $excel_contract_all_array[$key][12];
$excel_contract_noboga_array[$key][13] = $excel_contract_all_array[$key][13];
}
}
$excel_contract_array[$key][37] = number_format(round($excel_contract_array[$key][37]));
$excel_contract_array[$key][39] = number_format(round($excel_contract_array[$key][39]));
if ($isBoga == 1) {
$excel_contract_boga_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_boga_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_boga_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][40] = number_format(round($excel_contract_boga_array[$key][37] - $excel_contract_boga_array[$key][39]));
$excel_contract_boga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_boga_array[$key][37] = number_format(round($excel_contract_boga_array[$key][37]));
$excel_contract_boga_array[$key][39] = number_format(round($excel_contract_boga_array[$key][39]));
} else {
$excel_contract_noboga_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][40] = number_format(round($excel_contract_noboga_array[$key][37] - $excel_contract_noboga_array[$key][39]));
$excel_contract_noboga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][37] = number_format(round($excel_contract_noboga_array[$key][37]));
$excel_contract_noboga_array[$key][39] = number_format(round($excel_contract_noboga_array[$key][39]));
}
break;
case "安裝款":
$excel_contract_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -947,18 +902,14 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][47] = number_format(round($excel_contract_array[$key][44] - $excel_contract_array[$key][46]));
$excel_contract_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][14] = number_format(round($excel_contract_array[$key][44] - $excel_contract_array[$key][46]));
$excel_contract_all_array[$key][15] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][14] = $excel_contract_all_array[$key][14];
$excel_contract_noboga_array[$key][15] = $excel_contract_all_array[$key][15];
}
$excel_contract_array[$key][44] = number_format(round($excel_contract_array[$key][44]));
$excel_contract_array[$key][46] = number_format(round($excel_contract_array[$key][46]));
$excel_contract_noboga_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][44] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][45] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][47] = number_format(round($excel_contract_noboga_array[$key][44] - $excel_contract_noboga_array[$key][46]));
$excel_contract_noboga_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][44] = number_format(round($excel_contract_noboga_array[$key][44]));
$excel_contract_noboga_array[$key][46] = number_format(round($excel_contract_noboga_array[$key][46]));
break;
case "試車款":
$excel_contract_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -968,29 +919,20 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][54] = number_format(round($excel_contract_array[$key][51] - $excel_contract_array[$key][53]));
$excel_contract_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][16] = number_format(round($excel_contract_array[$key][51] - $excel_contract_array[$key][53]));
$excel_contract_all_array[$key][17] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if ($isBoga == 1) {
$excel_contract_boga_array[$key][16] = $excel_contract_all_array[$key][16];
$excel_contract_boga_array[$key][17] = $excel_contract_all_array[$key][17];
} else {
$excel_contract_noboga_array[$key][16] = $excel_contract_all_array[$key][16];
$excel_contract_noboga_array[$key][17] = $excel_contract_all_array[$key][17];
}
}
$excel_contract_array[$key][51] = number_format(round($excel_contract_array[$key][51]));
$excel_contract_array[$key][53] = number_format(round($excel_contract_array[$key][53]));
if ($isBoga == 1) {
$excel_contract_boga_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_boga_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_boga_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][54] = number_format(round($excel_contract_boga_array[$key][51] - $excel_contract_boga_array[$key][53]));
$excel_contract_boga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_boga_array[$key][51] = number_format(round($excel_contract_boga_array[$key][51]));
$excel_contract_boga_array[$key][53] = number_format(round($excel_contract_boga_array[$key][53]));
} else {
$excel_contract_noboga_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][54] = number_format(round($excel_contract_noboga_array[$key][51] - $excel_contract_noboga_array[$key][53]));
$excel_contract_noboga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][51] = number_format(round($excel_contract_noboga_array[$key][51]));
$excel_contract_noboga_array[$key][53] = number_format(round($excel_contract_noboga_array[$key][53]));
}
break;
case "官檢驗收款":
$excel_contract_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -1000,18 +942,16 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][61] = number_format(round($excel_contract_array[$key][58] - $excel_contract_array[$key][60]));
$excel_contract_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][18] = number_format(round($excel_contract_array[$key][58] - $excel_contract_array[$key][60]));
$excel_contract_all_array[$key][19] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][18] = $excel_contract_all_array[$key][18];
$excel_contract_noboga_array[$key][19] = $excel_contract_all_array[$key][19];
}
$excel_contract_array[$key][58] = number_format(round($excel_contract_array[$key][58]));
$excel_contract_array[$key][60] = number_format(round($excel_contract_array[$key][60]));
$excel_contract_noboga_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][58] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][59] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][61] = number_format(round($excel_contract_noboga_array[$key][58] - $excel_contract_noboga_array[$key][60]));
$excel_contract_noboga_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][58] = number_format(round($excel_contract_noboga_array[$key][58]));
$excel_contract_noboga_array[$key][60] = number_format(round($excel_contract_noboga_array[$key][60]));
break;
case "交車款":
$excel_contract_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -1021,18 +961,15 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][68] = number_format(round($excel_contract_array[$key][65] - $excel_contract_array[$key][67]));
$excel_contract_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][20] = number_format(round($excel_contract_array[$key][65] - $excel_contract_array[$key][67]));
$excel_contract_all_array[$key][21] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][20] = $excel_contract_all_array[$key][20];
$excel_contract_noboga_array[$key][21] = $excel_contract_all_array[$key][21];
}
$excel_contract_array[$key][65] = number_format(round($excel_contract_array[$key][65]));
$excel_contract_array[$key][67] = number_format(round($excel_contract_array[$key][67]));
$excel_contract_noboga_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][65] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][66] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][68] = number_format(round($excel_contract_noboga_array[$key][65] - $excel_contract_noboga_array[$key][67]));
$excel_contract_noboga_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][65] = number_format(round($excel_contract_noboga_array[$key][65]));
$excel_contract_noboga_array[$key][67] = number_format(round($excel_contract_noboga_array[$key][67]));
break;
case "尾款":
$excel_contract_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
@ -1042,29 +979,20 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][75] = number_format(round($excel_contract_array[$key][72] - $excel_contract_array[$key][74]));
$excel_contract_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][22] = number_format(round($excel_contract_array[$key][72] - $excel_contract_array[$key][74]));
$excel_contract_all_array[$key][23] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if ($isBoga == 1) {
$excel_contract_boga_array[$key][22] = $excel_contract_all_array[$key][22];
$excel_contract_boga_array[$key][23] = $excel_contract_all_array[$key][23];
} else {
$excel_contract_noboga_array[$key][22] = $excel_contract_all_array[$key][22];
$excel_contract_noboga_array[$key][23] = $excel_contract_all_array[$key][23];
}
}
$excel_contract_array[$key][72] = number_format(round($excel_contract_array[$key][72]));
$excel_contract_array[$key][74] = number_format(round($excel_contract_array[$key][74]));
if ($isBoga == 1) {
$excel_contract_boga_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_boga_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_boga_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][75] = number_format(round($excel_contract_boga_array[$key][72] - $excel_contract_boga_array[$key][74]));
$excel_contract_boga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_boga_array[$key][72] = number_format(round($excel_contract_boga_array[$key][72]));
$excel_contract_boga_array[$key][74] = number_format(round($excel_contract_boga_array[$key][74]));
} else {
$excel_contract_noboga_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_noboga_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_noboga_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][75] = number_format(round($excel_contract_noboga_array[$key][72] - $excel_contract_noboga_array[$key][74]));
$excel_contract_noboga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_noboga_array[$key][72] = number_format(round($excel_contract_noboga_array[$key][72]));
$excel_contract_noboga_array[$key][74] = number_format(round($excel_contract_noboga_array[$key][74]));
}
break;
}
}
@ -1085,36 +1013,8 @@ foreach ($arrayData as $key => $value) {
}
}
}
// $excel_contract_noboga_array[$key] = array_fill(0, 76, '');
// $excel_contract_noboga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : '';
// $excel_contract_noboga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : '';
// $excel_contract_noboga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
// $excel_contract_noboga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : '';
// $excel_contract_noboga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : '';
// $excel_contract_noboga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : '';
// $excel_contract_noboga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : '';
// $excel_contract_noboga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : '';
// $excel_contract_noboga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
// $excel_contract_noboga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
// $excel_contract_noboga_array[$key][10] = (isset($value['ManagerName']) && !is
// foreach ($arrayData as $key => $value) {
// echo $key . "<br>";
// foreach ($value as $k => $v) {
// if ($k == 'facility') {
// foreach ($v as $fkey => $fvalue) {
// echo $fkey . "<br>";
// print_r($fvalue);
// echo "<br><br>";
// }
// }
// // echo $k . "<br>";
// // print_r($v);
// // echo "<br><br>";
// }
// exit();
// }
$total_data = json_encode($excel_contract_array);
$total_data = json_encode($excel_contract_all_array);
$boga_data = json_encode($excel_contract_boga_array);
$noboga_data = json_encode($excel_contract_noboga_array);
?>
@ -1210,6 +1110,31 @@ $noboga_data = json_encode($excel_contract_noboga_array);
</div>
</div>
</form>
<form class="form-horizontal" id='myForm' method='post' action='account-receivable-new-index.php?<?= $token_link ?>'>
<table class="table table-striped table-bordered" style='width:98%;text-align:center;margin:0 auto'>
<tbody>
<tr>
<th class="text-center" style="vertical-align: middle;">合約日期</th>
<td colspan="2">
<input type="date" class='form-control' id='date_start' name='date_start' style='width:40%;display:inline;'>
<input type="date" class='form-control' id='date_end' name='date_end' style='width:40%;display:inline;'>
<button type="submit" class="btn btn-primary btn-sm">搜尋</button>
</td>
</tr>
<tr>
<th class="text-center" style="vertical-align: middle;">合約催收次數</th>
<td colspan="2">
<input type="text" class='form-control' id='collect_time_start' name='collect_time_start' style='width:10%;display:inline;' oninput="searchFront('collect_time_start')">
≤ 催收次數 ≤
<input type="text" class='form-control' id='collect_time_end' name='collect_time_end' style='width:10%;display:inline;'>
<!-- <button type="submit" class="btn btn-primary btn-sm">搜尋</button> -->
</td>
</tr>
</tbody>
</table>
</form>
</div>
<?php
@ -1223,7 +1148,7 @@ include "./footer.php";
<tr>
<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: 180px;">客戶</th>
@ -1235,8 +1160,8 @@ include "./footer.php";
<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: 100px;">催收次數</th>
<th style="width: 100px;">作番數量</th>
<th style="width: 120px;">訂金 <br>名稱</th>
<th style="width: 120px;">訂金<br>合約金額</th>
@ -1244,7 +1169,7 @@ include "./footer.php";
<th style="width: 120px;">訂金<br>已開金額</th>
<th style="width: 120px;">訂金<br>已收金額</th>
<th style="width: 120px;">訂金<br>催收金額</th>
<th style="width: 120px;">訂金<br>催收次數</th>
<th style="width: 100px;">訂金<br>催收次數</th>
<th style="width: 120px;">二次款 <br>名稱</th>
<th style="width: 120px;">二次款<br>合約金額</th>
@ -1252,7 +1177,7 @@ include "./footer.php";
<th style="width: 120px;">二次款<br>已開金額</th>
<th style="width: 120px;">二次款<br>已收金額</th>
<th style="width: 120px;">二次款<br>催收金額</th>
<th style="width: 120px;">二次款<br>催收次數</th>
<th style="width: 100px;">二次款<br>催收次數</th>
<th style="width: 120px;">貨抵工地款 <br>名稱</th>
<th style="width: 120px;">貨抵工地款<br>合約金額</th>
@ -1260,7 +1185,7 @@ include "./footer.php";
<th style="width: 120px;">貨抵工地款<br>已開金額</th>
<th style="width: 120px;">貨抵工地款<br>已收金額</th>
<th style="width: 120px;">貨抵工地款<br>催收金額</th>
<th style="width: 120px;">貨抵工地款<br>催收次數</th>
<th style="width: 100px;">貨抵工地款<br>催收次數</th>
<th style="width: 120px;">安裝款 <br>名稱</th>
<th style="width: 120px;">安裝款<br>合約金額</th>
@ -1268,7 +1193,7 @@ include "./footer.php";
<th style="width: 120px;">安裝款<br>已開金額</th>
<th style="width: 120px;">安裝款<br>已收金額</th>
<th style="width: 120px;">安裝款<br>催收金額</th>
<th style="width: 120px;">安裝款<br>催收次數</th>
<th style="width: 100px;">安裝款<br>催收次數</th>
<th style="width: 120px;">試車款 <br>名稱</th>
<th style="width: 120px;">試車款<br>合約金額</th>
@ -1276,7 +1201,7 @@ include "./footer.php";
<th style="width: 120px;">試車款<br>已開金額</th>
<th style="width: 120px;">試車款<br>已收金額</th>
<th style="width: 120px;">試車款<br>催收金額</th>
<th style="width: 120px;">試車款<br>催收次數</th>
<th style="width: 100px;">試車款<br>催收次數</th>
<th style="width: 120px;">官檢驗收款 <br>名稱</th>
<th style="width: 120px;">官檢驗收款<br>合約金額</th>
@ -1284,7 +1209,7 @@ include "./footer.php";
<th style="width: 120px;">官檢驗收款<br>已開金額</th>
<th style="width: 120px;">官檢驗收款<br>已收金額</th>
<th style="width: 120px;">官檢驗收款<br>催收金額</th>
<th style="width: 120px;">官檢驗收款<br>催收次數</th>
<th style="width: 100px;">官檢驗收款<br>催收次數</th>
<th style="width: 120px;">交車款 <br>名稱</th>
<th style="width: 120px;">交車款<br>合約金額</th>
@ -1292,7 +1217,7 @@ include "./footer.php";
<th style="width: 120px;">交車款<br>已開金額</th>
<th style="width: 120px;">交車款<br>已收金額</th>
<th style="width: 120px;">交車款<br>催收金額</th>
<th style="width: 120px;">交車款<br>催收次數</th>
<th style="width: 100px;">交車款<br>催收次數</th>
<th style="width: 120px;">尾款 <br>名稱</th>
<th style="width: 120px;">尾款<br>合約金額</th>
@ -1300,7 +1225,7 @@ include "./footer.php";
<th style="width: 120px;">尾款<br>已開金額</th>
<th style="width: 120px;">尾款<br>已收金額</th>
<th style="width: 120px;">尾款<br>催收金額</th>
<th style="width: 120px;">尾款<br>催收次數</th>
<th style="width: 100px;">尾款<br>催收次數</th>

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

@ -119,11 +119,6 @@ FROM arWriteOffBillDetail
WHERE CheckDetail.ModeId = 'T'";
// 期初收款資訊
$sql_opening = "
SELECT * FROM account_received ";
$contractNumbers = array();
$query_contract_number = $conn->query($sql_contractNumber);
foreach ($query_contract_number as $contract_numbers) {
@ -261,7 +256,7 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['invoice'] = array();
$arrayData[$BillNo]['received_budget'] = 0;
$arrayData[$BillNo]['invoice_budget'] = 0;
$arrayData[$BillNo]['A40002'] = $arrayData[$BillNo]['A40009'] = $arrayData[$BillNo]['A40010'] =$arrayData[$BillNo]['A40019'] = 0;
$arrayData[$BillNo]['A40002'] = $arrayData[$BillNo]['A40009'] = $arrayData[$BillNo]['A40010'] = $arrayData[$BillNo]['A40019'] = 0;
$arrayData[$BillNo]['total_facility_num'] = 0;
}
$arrayData[$BillNo]['PayStage'][$RowNo]['type'] = 0;
@ -283,7 +278,6 @@ foreach ($contract as $cont) {
}
}
$received_array = $conn->query($sql_received);
$opening_data = mysqli_query($link, $sql_opening);
$invoice_data = $conn->query($sql_invoice);
$contract_budget_data = $conn->query($sql_contract_budget);
@ -596,11 +590,23 @@ foreach ($received_array as $received) {
$BillNo = $received['OrderBillNo'];
if (isset($arrayData[$BillNo])) {
// if (isset($received['InvoiceNo']) && isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) {
$arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount'];
$arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount'];
// array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']);
// }
}
}
//未在T8的收款資料
$sql_wms = "SELECT * FROM account_received WHERE type='T' ";
$query_wms = mysqli_query($link, $sql_wms);
foreach ($query_wms as $wms) {
if (isset($arrayData[$wms['BillNo']]) && isset($arrayData[$wms['BillNo']]['invoice_budget'])) {
$arrayData[$wms['BillNo']]['invoice_budget'] += $wms['invoice_budget'];
$arrayData[$wms['BillNo']]['invoice'][$wms['invoice_no']] = [date("Y-m-d", strtotime($wms['invoice_date'])), $wms['invoice_budget'], 1];
}
if (isset($arrayData[$wms['BillNo']]) && isset($arrayData[$wms['BillNo']]['received_budget'])) {
$arrayData[$wms['BillNo']]['received_budget'] += $wms['received_budget'];
}
}
// $final_paystage ['type'] ['PlanPayDate'] ['PayAmount'] ['facilityno'] ['sequenceNumber'] ['name'] ['InvoiceAmount'] ['receivedAmount']
foreach ($final_paystage as $key => &$payStage) {
if (isset($arrayData[$key]['invoice_budget']) && isset($arrayData[$key]['received_budget'])) {
@ -640,6 +646,7 @@ foreach ($final_paystage as $key => &$payStage) {
// 0 合約號 1 作番號 2 部門id 3 部門名稱 4 經理名稱 5 營業員id 6 營業員名稱 7 客戶名稱 8 抬頭 9 統編 10 通訊地址
// 11 收款階段名稱 12 應收日期 13 收款金額 14 已開金額 15 已收金額 16 催收次數
$excel_aray = array();
$print_array = array();
$today = strtotime(date('Ymt'));
foreach ($arrayData as $key => $value) {
if (isset($final_paystage[$key])) {
@ -664,6 +671,17 @@ foreach ($arrayData as $key => $value) {
$unReceivedAmount = 0;
break;
}
if ($havetopay == "V" && $unReceivedAmount > 1) {
$print_array[$keyname] = [
$value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8],
$thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay,
number_format(round($final_paystage[$key][$sequence]['PayAmount'])),
number_format(round($final_paystage[$key][$sequence]['InvoiceAmount'])), number_format(round($unInvoiceAmount)),
number_format(round($final_paystage[$key][$sequence]['receivedAmount'])), number_format(round($unReceivedAmount)),
number_format(round($final_paystage[$key][$sequence]['collect_month']))
];
}
$excel_aray[$keyname] = [
$value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8],
$thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay,
@ -676,7 +694,7 @@ foreach ($arrayData as $key => $value) {
}
}
}
$total_data = json_encode($excel_aray);
$total_data = json_encode($print_array);
?>
<style>
@ -777,7 +795,11 @@ include "./footer.php";
<td><?= $row[13]; ?></td>
<td><?= $row[14]; ?></td>
<td><?= $row[15]; ?></td>
<td><?php if($row[14] == 'V' && $row[19]>0){echo $row[15];}else{echo '0';} ?></td>
<td><?php if ($row[14] == 'V' && $row[19] > 0) {
echo $row[15];
} else {
echo '0';
} ?></td>
<td><?= $row[16]; ?></td>
<td><?= $row[17]; ?></td>
<td><?= $row[18]; ?></td>

BIN
wms/account-receivable-renovate.xlsx

Binary file not shown.

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

@ -203,6 +203,21 @@ foreach ($received_array as $received) {
$arrayData[$received['OrderBillNo']]['received_budget'] += $received['CurrStandOffOAmount'];
}
}
//未在T8的收款資料
$sql_wms = "SELECT * FROM account_received WHERE type='Z' ";
$query_wms = mysqli_query($link, $sql_wms);
foreach ($query_wms as $wms) {
if (isset($arrayData[$wms['BillNo']]) && isset($wms['invoice_budget']) && isset($wms['invoice_no']) && isset($arrayData[$wms['BillNo']]['invoice_budget'])) {
$arrayData[$wms['BillNo']]['invoice_budget'] += $wms['invoice_budget'];
if (isset($arrayData[$wms['BillNo']]['invoice'][$wms['invoice_no']])) {
$arrayData[$wms['BillNo']]['invoice'][$wms['invoice_no']] += $wms['invoice_budget'];
}
}
if (isset($arrayData[$wms['BillNo']]) && isset($wms['received_budget']) && isset($arrayData[$wms['BillNo']]['received_budget'])) {
$arrayData[$wms['BillNo']]['received_budget'] += $wms['received_budget'];
}
}
foreach ($arrayData as $key => &$value) {
@ -239,10 +254,12 @@ foreach ($arrayData as $key => &$value) {
}
$excel_aray = array();
$print_array = array();
foreach ($arrayData as $key => $value) {
$uninvoice_budget = $value['OAmountWithTax'] - $value['invoice_budget'];
$unreceive_budget = $value['receivable_budget'] - $value['received_budget'];
$collect_month = $value['month']==0? '0':$value['month'];
$excel_aray[$key] = [
$value['BillNo'], date('Y-m-d', strtotime($value['BillDate'])), $value['CustomerId'], $value['CustomerName'],
@ -250,11 +267,22 @@ foreach ($arrayData as $key => $value) {
$value['ManagerId'], $value['ManagerName'],
number_format(round($value['OAmountWithTax'])), number_format(round($value['receivable_budget'])),
number_format(round($value['invoice_budget'])), number_format(round($uninvoice_budget)),
number_format(round($value['received_budget'])), $unreceive_budget, $value['month']
number_format(round($value['received_budget'])), $unreceive_budget, $collect_month
];
if ($excel_aray[$key][14] > 1) {
$print_array[$key] = [
$value['BillNo'], date('Y-m-d', strtotime($value['BillDate'])), $value['CustomerId'], $value['CustomerName'],
$value['DeptName'], $value['PersonId'], $value['PersonName'],
$value['ManagerId'], $value['ManagerName'],
number_format(round($value['OAmountWithTax'])), number_format(round($value['receivable_budget'])),
number_format(round($value['invoice_budget'])), number_format(round($uninvoice_budget)),
number_format(round($value['received_budget'])), $unreceive_budget, $collect_month
];
}
}
$total_data = json_encode($excel_aray);
$total_data = json_encode($print_array);
?>
<style>
@ -385,11 +413,12 @@ include "./footer.php";
<tr>
<th style='text-align:center;vertical-align: middle;width:140px'>合約號</th>
<th style='text-align:center;vertical-align: middle;width:100px'>合約日期</th>
<th style='text-align:center;vertical-align: middle;'>客戶編號</th>
<th style='text-align:center;vertical-align: middle;width:140px'>客戶名稱</th>
<th style='text-align:center;vertical-align: middle;width:110px'>部門</th>
<th style='text-align:center;vertical-align: middle;'>主管</th>
<th style='text-align:center;vertical-align: middle;'>契約員</th>
<th style='text-align:center;vertical-align: middle;'>保養員</th>
<th style='text-align:center;vertical-align: middle;'>客戶編號</th>
<th style='text-align:center;vertical-align: middle;width:140px'>客戶名稱</th>
<th style='text-align:center;vertical-align: middle;'>合約總金額</th>
<th style='text-align:center;vertical-align: middle;'>應收金額</th>
<th style='text-align:center;vertical-align: middle;'>已開金額</th>
@ -405,11 +434,12 @@ include "./footer.php";
<tr class="data-row" style="display: '';" id="<?= $key; ?>">
<td style='text-align:center;vertical-align: middle;' class="contract"><?= $row[0]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="contractdate"><?= $row[1]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="customerid"><?= $row[2] ?></td>
<td style='text-align:center;vertical-align: middle;' class="customername"><?= $row[3] ?></td>
<td style='text-align:center;vertical-align: middle;' class="department"><?= $row[4] ?></td>
<td style='text-align:center;vertical-align: middle;' class="manager"><?= $row[7] . "<br>" . $row[8]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="personId"><?= $row[5] . "<br>" . $row[6]; ?></td>
<td style='text-align:center;vertical-align: middle;' class="customerid"><?= $row[2] ?></td>
<td style='text-align:center;vertical-align: middle;' class="customername"><?= $row[3] ?></td>
<td style='text-align:end;vertical-align: middle;' class="total_budget"><?= $row[9]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="receivable_budget"><?= $row[10]; ?></td>
<td style='text-align:end;vertical-align: middle;' class="invoice_budget"><?= $row[11]; ?></td>

BIN
wms/account-receivable-repair.xlsx

Binary file not shown.

2
wms/account-receivable.txt

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save