Browse Source

應收帳款(新梯) debug&合約列印OK

gary
Ellin 1 year ago
parent
commit
0889f21533
  1. BIN
      wms/account-receivable-contract.xlsx
  2. 85
      wms/account-receivable-excel.php
  3. 638
      wms/account-receivable-new-index.php

BIN
wms/account-receivable-contract.xlsx

Binary file not shown.

85
wms/account-receivable-excel.php

@ -13,18 +13,57 @@ $Bill = json_decode(file_get_contents("php://input"), true);
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet(); $sheet = $spreadsheet->getActiveSheet();
// file_put_contents('account-receivable.txt', json_encode($Bill)); // file_put_contents('account-receivable.txt', json_encode($Bill));
if ($type == 'facility') { if ($type == 'newContract') {
$colomnHeader = [ $colomnHeader = [
'T8單據日期','作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', '合約號', '單據日期', '客戶編號', '客戶名稱', '客戶地址', '部門代碼', '部門名稱', '營業員工號', '營業員名稱', '部門主管工號', '部門主管名稱',
'訂金名稱', '訂金合約金額', '訂金應收日期', '訂金目前應收金額','訂金已開金額','訂金未開金額', '訂金已收金額', '訂金催收金額', '訂金催收次數', '合約總金額', '設備金額', '安裝金額', '目前應收金額', '已開發票金額', '已收金額', '催收金額', '催收次數', '作番總數 ', '作番狀態',
'二次款名稱', '二次款合約金額', '二次款應收日期', '二次款目前應收金額','二次款已開金額','二次款未開金額', '二次款已收金額', '二次款催收金額', '二次款催收次數', '訂金名稱', '訂金金額', '訂金應收金額', '訂金已開發票金額', '訂金已收金額', '訂金催收金額', '訂金催收次數',
'貨抵工地款名稱', '貨抵工地款合約金額', '貨抵工地款應收日期', '貨抵工地款目前應收金額','貨抵工地款已開金額','貨抵工地款未開金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數', '二次款名稱', '二次款金額', '二次款應收金額', '二次款已開發票金額', '二次款已收金額', '二次款催收金額', '二次款催收次數',
'安裝款名稱', '安裝款合約金額', '安裝款應收日期', '安裝款目前應收金額','安裝款已開金額','安裝款未開金額', '安裝款已收金額', '安裝款催收金額', '安裝款催收次數', '貨抵工地款名稱', '貨抵工地款金額', '貨抵工地款應收金額', '貨抵工地款已開發票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數',
'試車款名稱', '試車款合約金額', '試車款應收日期', '試車款目前應收金額','試車款已開金額','試車款未開金額', '試車款已收金額', '試車款催收金額', '試車款催收次數', '安裝款名稱', '安裝款金額', '安裝款應收金額', '安裝款已開發票金額', '安裝款已收金額', '安裝款催收金額', '安裝款催收次數',
'官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額','官檢款已開金額','官檢款未開金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數', '試車款名稱', '試車款金額', '試車款應收金額', '試車款已開發票金額', '試車款已收金額', '試車款催收金額', '試車款催收次數',
'交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額','交車款已開金額','交車款未開金額', '交車款已收金額', '交車款催收金額', '交車款催收次數', '官檢驗收款名稱', '官檢驗收款金額', '官檢驗收款應收金額', '官檢驗收款已開發票金額', '官檢驗收款已收金額', '官檢驗收款催收金額', '官檢驗收款催收次數',
'尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額','尾款已開金額','尾款未開金額', '尾款已收金額', '尾款催收金額', '尾款催收次數', '移交款名稱', '移交款金額', '移交款應收金額', '移交款已開發票金額', '移交款已收金額', '移交款催收金額', '移交款催收次數',
'作番狀態', '合約-設備金額','合約-安裝金額','作番合約總金額', '作番總應收金額' '尾款名稱', '尾款金額', '尾款應收金額', '尾款已開發票金額', '尾款已收金額', '尾款催收金額', '尾款催收次數'
];
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($Bill as $item) {
$sheet->fromArray($item, 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', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BK', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ',
'CA', 'CB', 'CC', 'CD', 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL', 'CM', 'CN', 'CO', 'CP', 'CQ', 'CR', 'CS', 'CT', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ',
'DA', 'DB', 'DC', 'DD', 'DE', 'DF', 'DG', 'DH', 'DI', 'DJ', 'DK', 'DL', 'DM', 'DN', 'DO', 'DP', 'DQ', 'DR', 'DS', 'DT', 'DU', 'DV', 'DW', 'DX', 'DY', 'DZ',
'EA', 'EB', 'EC', 'ED', 'EE', 'EF', 'EG', 'EH', 'EI', 'EJ', 'EK', 'EL', 'EM', 'EN', 'EO', 'EP', 'EQ', 'ER', 'ES', 'ET', 'EU', 'EV', 'EW', 'EX', 'EY', 'EZ',
];
foreach ($column as $col) {
if ($col == 'U') {
$sheet->getColumnDimension('U')->setWidth(35);
$sheet->getStyle('U')->getAlignment()->setWrapText(true);
} else {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
}
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-contract.xlsx';
$writer->save($excelFileName);
} elseif ($type == 'facility') {
$colomnHeader = [
'T8單據日期', '作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金名稱', '訂金合約金額', '訂金應收日期', '訂金目前應收金額', '訂金已開金額', '訂金未開金額', '訂金已收金額', '訂金催收金額', '訂金催收次數',
'二次款名稱', '二次款合約金額', '二次款應收日期', '二次款目前應收金額', '二次款已開金額', '二次款未開金額', '二次款已收金額', '二次款催收金額', '二次款催收次數',
'貨抵工地款名稱', '貨抵工地款合約金額', '貨抵工地款應收日期', '貨抵工地款目前應收金額', '貨抵工地款已開金額', '貨抵工地款未開金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數',
'安裝款名稱', '安裝款合約金額', '安裝款應收日期', '安裝款目前應收金額', '安裝款已開金額', '安裝款未開金額', '安裝款已收金額', '安裝款催收金額', '安裝款催收次數',
'試車款名稱', '試車款合約金額', '試車款應收日期', '試車款目前應收金額', '試車款已開金額', '試車款未開金額', '試車款已收金額', '試車款催收金額', '試車款催收次數',
'官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已開金額', '官檢款未開金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數',
'交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已開金額', '交車款未開金額', '交車款已收金額', '交車款催收金額', '交車款催收次數',
'尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已開金額', '尾款未開金額', '尾款已收金額', '尾款催收金額', '尾款催收次數',
'作番狀態', '合約-設備金額', '合約-安裝金額', '作番合約總金額', '作番總應收金額'
]; ];
$sheet->fromArray($colomnHeader, NULL, 'A1'); $sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2; $rowIndex = 2;
@ -34,7 +73,7 @@ if ($type == 'facility') {
$column = [ $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', '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', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP','BQ','BR','BK' 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BK'
]; ];
foreach ($column as $col) { foreach ($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true); $sheet->getColumnDimension($col)->setAutoSize(true);
@ -47,16 +86,16 @@ if ($type == 'facility') {
$writer->save($excelFileName); $writer->save($excelFileName);
} else { } else {
$colomnHeader = [ $colomnHeader = [
'T8單據日期','合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', 'T8單據日期', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金', '訂金目前應收', '訂金已開票金額','訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', '訂金', '訂金目前應收', '訂金已開票金額', '訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數',
'二次款', '二次款目前應收', '二次款已開票金額','二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', '二次款', '二次款目前應收', '二次款已開票金額', '二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額','貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額', '貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數',
'安裝款', '安裝款目前應收', '安裝款已開票金額','安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', '安裝款', '安裝款目前應收', '安裝款已開票金額', '安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數',
'試車款', '試車款目前應收', '試車款已開票金額','試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', '試車款', '試車款目前應收', '試車款已開票金額', '試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數',
'官檢款', '官檢款目前應收', '官檢款已開票金額','官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', '官檢款', '官檢款目前應收', '官檢款已開票金額', '官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數',
'交車款', '交車款目前應收', '交車款已開票金額','交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', '交車款', '交車款目前應收', '交車款已開票金額', '交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數',
'尾款', '尾款目前應收', '尾款已開票金額','尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', '尾款', '尾款目前應收', '尾款已開票金額', '尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數',
'合約設備金額','合約安裝金額','合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' '合約設備金額', '合約安裝金額', '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態'
]; ];
$sheet->fromArray($colomnHeader, NULL, 'A1'); $sheet->fromArray($colomnHeader, NULL, 'A1');
@ -67,7 +106,7 @@ if ($type == 'facility') {
'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', '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', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ',
'CA','CB','CC','CD' 'CA', 'CB', 'CC', 'CD'
]; ];
foreach ($column as $col) { foreach ($column as $col) {
if ($col == 'CC') { if ($col == 'CC') {

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

@ -123,6 +123,7 @@ if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepart
$sql_all_contract .= ")"; $sql_all_contract .= ")";
}; };
} }
$sql_all_contract .= " ORDER BY MainAll.PersonId ASC ";
$str_numbers = ""; $str_numbers = "";
$query_all_contract = $conn->query($sql_all_contract); $query_all_contract = $conn->query($sql_all_contract);
if (is_iterable($query_all_contract)) { if (is_iterable($query_all_contract)) {
@ -326,11 +327,11 @@ foreach ($PayStage_array as $key => &$value) {
case '寶佳出貨前30天': case '寶佳出貨前30天':
$payvalue['stage'] = '訂金'; $payvalue['stage'] = '訂金';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time - (30 * 86400); $signtime = $estimate_time - (30 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) {
$estimate_time = strtotime($wip['real_contract_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']);
$signtime = $estimate_time - (30 * 86400); $signtime = $estimate_time - (30 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -340,7 +341,7 @@ foreach ($PayStage_array as $key => &$value) {
case '寶佳出貨後10天': case '寶佳出貨後10天':
$payvalue['stage'] = '二次款'; $payvalue['stage'] = '二次款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time + (10 * 86400); $signtime = $estimate_time + (10 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -350,7 +351,7 @@ foreach ($PayStage_array as $key => &$value) {
case '貨抵工地後90天': case '貨抵工地後90天':
$payvalue['stage'] = '貨抵工地款'; $payvalue['stage'] = '貨抵工地款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time + (90 * 86400); $signtime = $estimate_time + (90 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -360,7 +361,7 @@ foreach ($PayStage_array as $key => &$value) {
case '安裝試車後90天': case '安裝試車後90天':
$payvalue['stage'] = '試車款'; $payvalue['stage'] = '試車款';
if ($wip_array[$payvalue['facilityno']]['tryrun_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['tryrun_end_date'])) { if ($wip_array[$payvalue['facilityno']]['tryrun_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['tryrun_end_date'])) {
$estimate_time = strtotime($wip['tryrun_end_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']);
$signtime = $estimate_time + (90 * 86400); $signtime = $estimate_time + (90 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -370,30 +371,41 @@ foreach ($PayStage_array as $key => &$value) {
case '交車後270天': case '交車後270天':
$payvalue['stage'] = '尾款'; $payvalue['stage'] = '尾款';
if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) { if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) {
$estimate_time = strtotime($wip['delivery_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']);
$signtime = $estimate_time + (270 * 86400); $signtime = $estimate_time + (270 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = NULL;
} }
break; break;
case '交車後180天':
$payvalue['stage'] = '尾款';
if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) {
$estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']);
$signtime = $estimate_time + (180 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else {
$payvalue['PlanPayDate'] = NULL;
}
break;
case (in_array($payvalue['PayStage'], $arrival)): case (in_array($payvalue['PayStage'], $arrival)):
$payvalue['stage'] = '貨抵工地款'; $payvalue['stage'] = '貨抵工地款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time + (10 * 86400); $signtime = $estimate_time ;
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = 'NULL';
} }
break; break;
case '二次款': case '二次款':
$payvalue['stage'] = '二次款'; $payvalue['stage'] = '二次款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) {
$estimate_time = strtotime($wip['real_contract_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = NULL;
@ -402,11 +414,11 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)') || stristr($payvalue['PayStage'], '建照核發時')): case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)') || stristr($payvalue['PayStage'], '建照核發時')):
$payvalue['stage'] = '二次款'; $payvalue['stage'] = '二次款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time - (30 * 86400); $signtime = $estimate_time - (30 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) {
$estimate_time = strtotime($wip['real_contract_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']);
$signtime = $estimate_time - (30 * 86400); $signtime = $estimate_time - (30 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -416,11 +428,11 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '出貨前60')): case (stristr($payvalue['PayStage'], '出貨前60')):
$payvalue['stage'] = '二次款'; $payvalue['stage'] = '二次款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time - (60 * 86400); $signtime = $estimate_time - (60 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) {
$estimate_time = strtotime($wip['real_contract_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']);
$signtime = $estimate_time - (60 * 86400); $signtime = $estimate_time - (60 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -430,11 +442,11 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '出貨前90')): case (stristr($payvalue['PayStage'], '出貨前90')):
$payvalue['stage'] = '二次款'; $payvalue['stage'] = '二次款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time - (90 * 86400); $signtime = $estimate_time - (90 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) {
$estimate_time = strtotime($wip['real_contract_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']);
$signtime = $estimate_time - (90 * 86400); $signtime = $estimate_time - (90 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -444,11 +456,11 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '出貨前120')): case (stristr($payvalue['PayStage'], '出貨前120')):
$payvalue['stage'] = '二次款'; $payvalue['stage'] = '二次款';
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']);
$signtime = $estimate_time - (120 * 86400); $signtime = $estimate_time - (120 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) {
$estimate_time = strtotime($wip['real_contract_arrival_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']);
$signtime = $estimate_time - (120 * 86400); $signtime = $estimate_time - (120 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime);
} else { } else {
@ -493,7 +505,7 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '試車')): case (stristr($payvalue['PayStage'], '試車')):
$payvalue['stage'] = '試車款'; $payvalue['stage'] = '試車款';
if ($wip_array[$payvalue['facilityno']]['tryrun_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['tryrun_end_date'])) { if ($wip_array[$payvalue['facilityno']]['tryrun_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['tryrun_end_date'])) {
$estimate_time = strtotime($wip['tryrun_end_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = NULL;
@ -502,7 +514,7 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '安裝') || stristr($payvalue['PayStage'], '貨抵工地且完工')): case (stristr($payvalue['PayStage'], '安裝') || stristr($payvalue['PayStage'], '貨抵工地且完工')):
$payvalue['stage'] = '安裝款'; $payvalue['stage'] = '安裝款';
if ($wip_array[$payvalue['facilityno']]['install_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['install_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['install_end_date'])) { if ($wip_array[$payvalue['facilityno']]['install_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['install_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['install_end_date'])) {
$estimate_time = strtotime($wip['install_end_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['install_end_date']);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = NULL;
@ -511,7 +523,7 @@ foreach ($PayStage_array as $key => &$value) {
case (in_array($payvalue['PayStage'], $final6)): case (in_array($payvalue['PayStage'], $final6)):
$payvalue['stage'] = '尾款'; $payvalue['stage'] = '尾款';
if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) { if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) {
$estimate_time = strtotime($wip['delivery_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']);
$estimate_time = $estimate_time + (180 * 86400); $estimate_time = $estimate_time + (180 * 86400);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} else { } else {
@ -521,7 +533,7 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '合格') || stristr($payvalue['PayStage'], '驗收') || stristr($payvalue['PayStage'], '驗收')): case (stristr($payvalue['PayStage'], '合格') || stristr($payvalue['PayStage'], '驗收') || stristr($payvalue['PayStage'], '驗收')):
$payvalue['stage'] = '官檢驗收款'; $payvalue['stage'] = '官檢驗收款';
if ($wip_array[$payvalue['facilityno']]['official_check_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['official_check_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['official_check_date'])) { if ($wip_array[$payvalue['facilityno']]['official_check_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['official_check_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['official_check_date'])) {
$estimate_time = strtotime($wip['official_check_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['official_check_date']);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = NULL;
@ -530,7 +542,7 @@ foreach ($PayStage_array as $key => &$value) {
case (stristr($payvalue['PayStage'], '交車') || stristr($payvalue['PayStage'], '移交') || stristr($payvalue['PayStage'], '完工') || stristr($payvalue['PayStage'], '許可') || stristr($payvalue['PayStage'], '核可')): case (stristr($payvalue['PayStage'], '交車') || stristr($payvalue['PayStage'], '移交') || stristr($payvalue['PayStage'], '完工') || stristr($payvalue['PayStage'], '許可') || stristr($payvalue['PayStage'], '核可')):
$payvalue['stage'] = '交車款'; $payvalue['stage'] = '交車款';
if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) { if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) {
$estimate_time = strtotime($wip['delivery_date']); $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']);
$payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time);
} else { } else {
$payvalue['PlanPayDate'] = NULL; $payvalue['PlanPayDate'] = NULL;
@ -639,7 +651,6 @@ foreach ($final_paystage as $key => &$value) {
$collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate'])); $collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate']));
if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) { if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) {
$value[$sequenceNumber]['hadtopay'] = 'V'; $value[$sequenceNumber]['hadtopay'] = 'V';
$arrayData[$key]['receivable_budget'] += $value[$sequenceNumber]['PlanPayAmt'];
} else { } else {
$value[$sequenceNumber]['hadtopay'] = '--'; $value[$sequenceNumber]['hadtopay'] = '--';
} }
@ -683,9 +694,14 @@ foreach ($final_paystage as $key => $value) {
foreach ($arrayData[$key]['PayStage'] as $arkey => &$arvalue) { foreach ($arrayData[$key]['PayStage'] as $arkey => &$arvalue) {
if ($arvalue['PayStage'] == $value[$sequence]['PayStage']) { if ($arvalue['PayStage'] == $value[$sequence]['PayStage']) {
if (isset($arvalue['receivable_budget']) && isset($arvalue['received_budget']) && isset($arvalue['invoice_budget'])) { if (isset($arvalue['receivable_budget']) && isset($arvalue['received_budget']) && isset($arvalue['invoice_budget'])) {
$arvalue['receivable_budget'] += $value[$sequence]['PlanPayAmt'];
$arvalue['received_budget'] += $value[$sequence]['received_budget']; $arvalue['received_budget'] += $value[$sequence]['received_budget'];
$arvalue['invoice_budget'] += $value[$sequence]['invoice_budget']; $arvalue['invoice_budget'] += $value[$sequence]['invoice_budget'];
if ($value[$sequence]['hadtopay'] == 'V') {
$arvalue['receivable_budget'] += $value[$sequence]['PlanPayAmt'];
$arrayData[$key]['receivable_budget'] += $value[$sequence]['PlanPayAmt'];
} else {
$arvalue['receivable_budget'] = 0;
}
if ($arvalue['collect_month'] < $value[$sequence]['collect_month']) { if ($arvalue['collect_month'] < $value[$sequence]['collect_month']) {
$arvalue['collect_month'] = $value[$sequence]['collect_month']; $arvalue['collect_month'] = $value[$sequence]['collect_month'];
} }
@ -694,7 +710,12 @@ foreach ($final_paystage as $key => $value) {
$sum_invoice_budget += $value[$sequence]['invoice_budget']; $sum_invoice_budget += $value[$sequence]['invoice_budget'];
} else { } else {
$arvalue['stage'] = $value[$sequence]['stage']; $arvalue['stage'] = $value[$sequence]['stage'];
if ($value[$sequence]['hadtopay'] == 'V') {
$arvalue['receivable_budget'] = $value[$sequence]['PlanPayAmt']; $arvalue['receivable_budget'] = $value[$sequence]['PlanPayAmt'];
$arrayData[$key]['receivable_budget'] += $value[$sequence]['PlanPayAmt'];
} else {
$arvalue['receivable_budget'] = 0;
}
$arvalue['received_budget'] = $value[$sequence]['received_budget']; $arvalue['received_budget'] = $value[$sequence]['received_budget'];
$arvalue['invoice_budget'] = $value[$sequence]['invoice_budget']; $arvalue['invoice_budget'] = $value[$sequence]['invoice_budget'];
$arvalue['collect_month'] = $value[$sequence]['collect_month']; $arvalue['collect_month'] = $value[$sequence]['collect_month'];
@ -724,15 +745,15 @@ $average_contract_facility = $sum_facility / $sum_contract;
// 21 訂金名稱; 22 訂金金額; 23 應收金額; 24 已開發票金額; 25 已收金額; 26 催收金額; 27 催收次數; // 21 訂金名稱; 22 訂金金額; 23 應收金額; 24 已開發票金額; 25 已收金額; 26 催收金額; 27 催收次數;
// 28 二次款名稱; 29 二次款金額; 30 應收金額; 31 已開發票金額; 32 已收金額; 33 催收金額; 34 催收次數; // 28 二次款名稱; 29 二次款金額; 30 應收金額; 31 已開發票金額; 32 已收金額; 33 催收金額; 34 催收次數;
$excel_contract_array = array(); $excel_contract_array = array();
$excel_contract_boga_array= array(); $excel_contract_boga_array = array();
$excel_contract_noboga_array= array(); $excel_contract_noboga_array = array();
// 0 作番號; 1 合約號; 2 合約單據日期; 3 客戶編號; 4 客戶名稱; 5 客戶地址; 6 部門ID; 7 部門名稱; 8 營業員工號; 9 營業員名稱; 10 部門主管工號; 11 部門主管名稱; // 0 作番號; 1 合約號; 2 合約單據日期; 3 客戶編號; 4 客戶名稱; 5 客戶地址; 6 部門ID; 7 部門名稱; 8 營業員工號; 9 營業員名稱; 10 部門主管工號; 11 部門主管名稱;
// 12 作番總金額; 13 A40001 金額; 14 A40008 金額; 15 目前應收金額; 16 已開發票金額; 17 已收金額; 18 催收金額; 19 催收次數; 20 作番狀態 // 12 作番總金額; 13 A40001 金額; 14 A40008 金額; 15 目前應收金額; 16 已開發票金額; 17 已收金額; 18 催收金額; 19 催收次數; 20 作番狀態
$excel_facility_array = array(); $excel_facility_array = array();
foreach ($arrayData as $key => $value) { foreach ($arrayData as $key => $value) {
// echo $key . "<br>********************<br>";
$excel_contract_array[$key]=array_fill(0, 76, ''); $excel_contract_array[$key] = array_fill(0, 76, '');
$excel_contract_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : ''; $excel_contract_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : '';
$excel_contract_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : ''; $excel_contract_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : '';
$excel_contract_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : ''; $excel_contract_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
@ -744,21 +765,23 @@ foreach ($arrayData as $key => $value) {
$excel_contract_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : ''; $excel_contract_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
$excel_contract_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : ''; $excel_contract_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
$excel_contract_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : ''; $excel_contract_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? $value['OAmountWithTax'] : 0; $excel_contract_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? number_format(round($value['OAmountWithTax'])) : '0';
$excel_contract_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? $value['A40001'] : 0; $excel_contract_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? number_format(round($value['A40001'])) : '0';
$excel_contract_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? $value['A40008'] : 0; $excel_contract_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? number_format(round($value['A40008'])) : '0';
$excel_contract_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0; $excel_contract_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0;
$excel_contract_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? $value['invoice_budget'] : 0; $excel_contract_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? number_format(round($value['invoice_budget'])) : '0';
$excel_contract_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0; $excel_contract_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_array[$key][17] = $excel_contract_array[$key][14] - $excel_contract_array[$key][16]; $excel_contract_array[$key][17] = number_format(round($excel_contract_array[$key][14] - $excel_contract_array[$key][16]));
$excel_contract_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? $value['collect_month'] : 0; $excel_contract_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? number_format(round($value['collect_month'])) : '0';
$excel_contract_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? $value['facility_num'] : 0; $excel_contract_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? number_format(round($value['facility_num'])) : '0';
$excel_contract_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : 0; $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 (isset($value['PayStage']) && is_iterable($value['PayStage'])) {
$isBoga = 0; $isBoga = 0;
if(stristr($value['PayStage'][1]['PayStage'],'寶佳')){ if (stristr($value['PayStage'][1]['PayStage'], '寶佳')) {
$isBoga=1; $isBoga = 1;
$excel_contract_boga_array[$key]=array_fill(0, 76, ''); $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][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][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][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
@ -770,18 +793,20 @@ foreach ($arrayData as $key => $value) {
$excel_contract_boga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : ''; $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][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][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_boga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? $value['OAmountWithTax'] : 0; $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'])) ? $value['A40001'] : 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'])) ? $value['A40008'] : 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][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'])) ? $value['invoice_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][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_boga_array[$key][17] = $excel_contract_array[$key][14] - $excel_contract_array[$key][16]; $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'])) ? $value['collect_month'] : 0; $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'])) ? $value['facility_num'] : 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'] : 0; $excel_contract_boga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--';
}else{ $excel_contract_boga_array[$key][14] = number_format(round($excel_contract_boga_array[$key][14]));
$excel_contract_noboga_array[$key]=array_fill(0, 76, ''); $excel_contract_boga_array[$key][16] = number_format(round($excel_contract_boga_array[$key][16]));
} 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][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][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][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
@ -793,204 +818,258 @@ foreach ($arrayData as $key => $value) {
$excel_contract_noboga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : ''; $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][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][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_noboga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? $value['OAmountWithTax'] : 0; $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'])) ? $value['A40001'] : 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'])) ? $value['A40008'] : 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][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'])) ? $value['invoice_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][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_noboga_array[$key][17] = $excel_contract_array[$key][14] - $excel_contract_array[$key][16]; $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'])) ? $value['collect_month'] : 0; $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'])) ? $value['facility_num'] : 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'] : 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]));
} }
foreach ($value['PayStage'] as $paykey => $payvalue) { foreach ($value['PayStage'] as $paykey => $payvalue) {
switch ($payvalue['stage']) { switch ($payvalue['stage']) {
case "訂金": case "訂金":
$excel_contract_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][26] = $excel_contract_array[$key][23] - $excel_contract_array[$key][25]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if($isBoga == 1){ $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][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][26] = $excel_contract_array[$key][23] - $excel_contract_array[$key][25]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_boga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
}else{ $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][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][26] = $excel_contract_array[$key][23] - $excel_contract_array[$key][25]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "二次款": case "二次款":
$excel_contract_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][33] = $excel_contract_array[$key][30] - $excel_contract_array[$key][32]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if($isBoga ==1){ $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][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][33] = $excel_contract_array[$key][30] - $excel_contract_array[$key][32]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_boga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
}else{ $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][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][33] = $excel_contract_array[$key][30] - $excel_contract_array[$key][32]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "貨抵工地款": case "貨抵工地款":
$excel_contract_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][40] = $excel_contract_array[$key][37] - $excel_contract_array[$key][39]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if($isBoga == 1){ $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][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][40] = $excel_contract_array[$key][37] - $excel_contract_array[$key][39]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_boga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
}else{ $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][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][40] = $excel_contract_array[$key][37] - $excel_contract_array[$key][39]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "安裝款": case "安裝款":
$excel_contract_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][44] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][44] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][45] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][45] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][47] = $excel_contract_array[$key][44] - $excel_contract_array[$key][46]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$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][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][47] = $excel_contract_array[$key][44] - $excel_contract_array[$key][46]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "試車款": case "試車款":
$excel_contract_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][54] = $excel_contract_array[$key][51] - $excel_contract_array[$key][53]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if($isBoga ==1){ $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][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][54] = $excel_contract_array[$key][51] - $excel_contract_array[$key][53]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_boga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
}else{ $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][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][54] = $excel_contract_array[$key][51] - $excel_contract_array[$key][53]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "官檢驗收款": case "官檢驗收款":
$excel_contract_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][58] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][58] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][59] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][59] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][61] = $excel_contract_array[$key][58] - $excel_contract_array[$key][60]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$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][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][61] = $excel_contract_array[$key][58] - $excel_contract_array[$key][60]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "交車款": case "交車款":
$excel_contract_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][65] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][65] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][66] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][66] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][68] = $excel_contract_array[$key][65] - $excel_contract_array[$key][67]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$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][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][68] = $excel_contract_array[$key][65] - $excel_contract_array[$key][67]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
case "尾款": case "尾款":
$excel_contract_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; $excel_contract_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $excel_contract_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; $excel_contract_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0; $excel_contract_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][75] = $excel_contract_array[$key][72] - $excel_contract_array[$key][74]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
if($isBoga ==1){ $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][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][75] = $excel_contract_array[$key][72] - $excel_contract_array[$key][74]; $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'])) ? $payvalue['collect_month'] : 0; $excel_contract_boga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
}else{ $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][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0; $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][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'])) ? $payvalue['invoice_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][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][75] = $excel_contract_array[$key][72] - $excel_contract_array[$key][74]; $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'])) ? $payvalue['collect_month'] : 0; $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; break;
} }
} }
} }
} }
foreach($arrayData as $key => $value){
echo $key."<br>";
foreach($value as $k => $v){
echo $k."<br>";
print_r($v);
echo "<br><br>";
}
exit();
}
$total_data = json_encode($excel_contract_array); $total_data = json_encode($excel_contract_array);
$boga_data = json_encode($excel_contract_boga_array); $boga_data = json_encode($excel_contract_boga_array);
@ -1006,7 +1085,8 @@ $noboga_data = json_encode($excel_contract_noboga_array);
td { td {
word-wrap: break-word; word-wrap: break-word;
} }
th{
th {
text-align: center; text-align: center;
} }
@ -1046,20 +1126,260 @@ $noboga_data = json_encode($excel_contract_noboga_array);
</div> </div>
</div> </div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong>合約 (新梯)統整資訊</strong></h3>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<label for="sum_total_budget">合約總金額</label>
<input type="text" class="form-control" id="sum_total_budget" name="sum_total_budget" value="<?= number_format($sum_total_budget) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40001">合約設備總金額</label>
<input type="text" class="form-control" id="sum_A40001" name="sum_A40001" value="<?= number_format($sum_A40001) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40008">合約安裝總金額</label>
<input type="text" class="form-control" id="sum_A40008" name="sum_A40008" value="<?= number_format($sum_A40008) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_facility">總台數</label>
<input type="text" class="form-control" id="sum_facility" name="sum_facility" value="<?= number_format($sum_facility) ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="average_facility_budget">作番平均金額 (元/台)</label>
<input type="text" class="form-control" id="average_facility_budget" name="average_facility_budget" value="<?= number_format($average_facility_budget) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40001">設備平均金額 (元/台)</label>
<input type="text" class="form-control" id="average_A40001" name="average_A40001" value="<?= number_format($average_A40001) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40008">安裝平均金額 (元/台)</label>
<input type="text" class="form-control" id="average_A40008" name="average_A40008" value="<?= number_format($average_A40008) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_contract_facility">平均台數 (台/合約)</label>
<input type="text" class="form-control" id="average_contract_facility" name="average_contract_facility" value="<?= number_format($average_contract_facility) ?>" disabled>
</div>
</div>
</form>
</div>
<?php
include "./footer.php";
?>
<div style="width:98%;margin:1% ;overflow-x: auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<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>
<th style="width: 300px;">作番狀態</th>
<th style="width: 150px;">合約-設備金額</th>
<th style="width: 150px;">合約-安裝金額</th>
<th style="width: 150px;">合約總金額</th>
<th style="width: 150px;">合約目前應收</th>
<th style="width: 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: 120px;">訂金 <br>名稱</th>
<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: 120px;">訂金<br>催收金額</th>
<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: 120px;">二次款<br>已開金額</th>
<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: 120px;">貨抵工地款<br>合約金額</th>
<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: 120px;">貨抵工地款<br>催收次數</th>
<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: 120px;">安裝款<br>已收金額</th>
<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: 120px;">試車款<br>應收金額</th>
<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: 120px;">官檢驗收款 <br>名稱</th>
<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: 120px;">官檢驗收款<br>催收金額</th>
<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: 120px;">交車款<br>已開金額</th>
<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: 120px;">尾款<br>合約金額</th>
<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: 120px;">尾款<br>催收次數</th>
</tr>
</thead>
<tbody>
<?php
foreach ($excel_contract_array as $key => $value) {
?>
<tr>
<th><?= $key ?></th>
<td style="text-align: center;"><?= $value['Dept']."<br>".$value['DeptName'] ?></td>
<td style="text-align: center;"><?= $value['ManagerId']."<br>".$value['ManagerName'] ?></td>
<td style="text-align: center;"><?= $value['PersonId']."<br>".$value['PersonName'] ?></td>
<td style="text-align: center;"><?= $value['CustomerId']."<br>".$value['CustomerName'] ?></td>
<td style="text-align: end;"><?= $value['facility_status'] ?></td>
<td style="text-align: end;"><?= $value['A40001'] ?></td>
<td style="text-align: end;"><?= $value['A40008'] ?></td>
<td style="text-align: end;"><?= $value['total_budget'] ?></td>
<td style="text-align: end;"><?= $value['receivable_budget'] ?></td>
<td style="text-align: end;"><?= $value['invoice_budget'] ?></td>
<td style="text-align: end;"><?= $value['received_budget'] ?></td>
<td style="text-align: end;"><?= $value['collect_budget'] ?></td>
<td style="text-align: end;"><?= $value['collect_month'] ?></td>
<td style="text-align: end;"><?= $value['facility_num'] ?></td>
<td style="text-align: end;"><?= $value['PayStage'] ?></td>
<td style="text-align: end;"><?= $value[20] ?></td>
<td style="text-align: end;"><?= $value[21] ?></td>
<td style="text-align: end;"><?= $value[22] ?></td>
<td style="text-align: end;"><?= $value[23] ?></td>
<td style="text-align: end;"><?= $value[24] ?></td>
<td style="text-align: end;"><?= $value[25] ?></td>
<td style="text-align: end;"><?= $value[26] ?></td>
<td style="text-align: end;"><?= $value[27] ?></td>
<td style="text-align: end;"><?= $value[28] ?></td>
<td style="text-align: end;"><?= $value[29] ?></td>
<td style="text-align: end;"><?= $value[30] ?></td>
<td style="text-align: end;"><?= $value[31] ?></td>
<td style="text-align: end;"><?= $value[32] ?></td>
<td style="text-align: end;"><?= $value[33] ?></td>
<td style="text-align: end;"><?= $value[34] ?></td>
<td style="text-align: end;"><?= $value[35] ?></td>
<td style="text-align: end;"><?= $value[36] ?></td>
<td style="text-align: end;"><?= $value[37] ?></td>
<td style="text-align: end;"><?= $value[38] ?></td>
<td style="text-align: end;"><?= $value[39] ?></td>
<td style="text-align: end;"><?= $value[40] ?></td>
<td style="text-align: end;"><?= $value[41] ?></td>
<td style="text-align: end;"><?= $value[42] ?></td>
<td style="text-align: end;"><?= $value[43] ?></td>
<td style="text-align: end;"><?= $value[44] ?></td>
<td style="text-align: end;"><?= $value[45] ?></td>
<td style="text-align: end;"><?= $value[46] ?></td>
<td style="text-align: end;"><?= $value[47] ?></td>
<td style="text-align: end;"><?= $value[48] ?></td>
<td style="text-align: end;"><?= $value[49] ?></td>
<td style="text-align: end;"><?= $value[50] ?></td>
<td style="text-align: end;"><?= $value[51] ?></td>
<td style="text-align: end;"><?= $value[52] ?></td>
<td style="text-align: end;"><?= $value[53] ?></td>
<td style="text-align: end;"><?= $value[54] ?></td>
<td style="text-align: end;"><?= $value[55] ?></td>
<td style="text-align: end;"><?= $value[56] ?></td>
<td style="text-align: end;"><?= $value[57] ?></td>
<td style="text-align: end;"><?= $value[58] ?></td>
<td style="text-align: end;"><?= $value[59] ?></td>
<td style="text-align: end;"><?= $value[60] ?></td>
<td style="text-align: end;"><?= $value[61] ?></td>
<td style="text-align: end;"><?= $value[62] ?></td>
<td style="text-align: end;"><?= $value[63] ?></td>
<td style="text-align: end;"><?= $value[64] ?></td>
<td style="text-align: end;"><?= $value[65] ?></td>
<td style="text-align: end;"><?= $value[66] ?></td>
<td style="text-align: end;"><?= $value[67] ?></td>
<td style="text-align: end;"><?= $value[68] ?></td>
<td style="text-align: end;"><?= $value[69] ?></td>
<td style="text-align: end;"><?= $value[70] ?></td>
<td style="text-align: end;"><?= $value[71] ?></td>
<td style="text-align: end;"><?= $value[72] ?></td>
<td style="text-align: end;"><?= $value[73] ?></td>
<td style="text-align: end;"><?= $value[74] ?></td>
<td style="text-align: end;"><?= $value[75] ?></td>
<td style="text-align: end;"><?= $value[76] ?></td>
<td style="text-align: end;"><?= $value[77] ?></td>
<td style="text-align: end;"><?= $value[78] ?></td>
<td style="text-align: end;"><?= $value[79] ?></td>
<td style="text-align: end;"><?= $value[80] ?></td>
<td style="text-align: end;"><?= $value[81] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<script> <script>
function downloadData(content) { function downloadData(content) {
console.log(content);
if (content == 'all') { if (content == 'all') {
var BillData = <?= $total_data ?>; var BillData = <?= $total_data ?>;
var filename = "全部應收帳款" + "<?= date('Y/m/d-H:m') ?>" + ".xlsx"; var filename = "全部應收帳款" + "<?= date('Ymd-Hm') ?>" + ".xlsx";
} else if (content == 'noboga') { } else if (content == 'noboga') {
var BillData = <?= $noboga_data ?>; var BillData = <?= $noboga_data ?>;
var filename = "不含寶佳應收帳款" + "<?= date('Y/m/d-H:m') ?>" + ".xlsx"; var filename = "不含寶佳應收帳款" + "<?= date('Ymd-Hm') ?>" + ".xlsx";
} else if (content == 'boga') { } else if (content == 'boga') {
var BillData = <?= $boga_data ?>; var BillData = <?= $boga_data ?>;
var filename = "寶佳應收帳款" + "<?= date('Y/m/d-H:m') ?>" + ".xlsx"; var filename = "寶佳應收帳款" + "<?= date('Ymd-Hm') ?>" + ".xlsx";
} }
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?type=newContract&<?= $token_link ?>"; var url = window.location.origin + "/wms/account-receivable-excel.php?type=newContract&<?= $token_link ?>";
@ -1068,7 +1388,7 @@ $noboga_data = json_encode($excel_contract_noboga_array);
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) { if (xhr.readyState === 4 && xhr.status === 200) {
var link = document.createElement('a'); var link = document.createElement('a');
link.setAttribute('href', window.location.origin + "/wms/account-receivable-facility.xlsx"); link.setAttribute('href', window.location.origin + "/wms/account-receivable-contract.xlsx");
link.setAttribute('download', filename); link.setAttribute('download', filename);
link.style.display = 'none'; link.style.display = 'none';
document.body.appendChild(link); document.body.appendChild(link);

Loading…
Cancel
Save