Browse Source

應收帳款(新梯) v2 合約excel完成

gary
Ellin 1 year ago
parent
commit
97959757b6
  1. 420
      wms/account-receivable-new-index.php

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

@ -7,11 +7,12 @@ $sum_contract = 0;
$sum_A40001 = 0;
$sum_A40008 = 0;
$sum_total_budget = 0;
$average_budget = 0;
$average_facility_budget = 0;
$average_A40001 = 0;
$average_A40008 = 0;
$sum_invoice_budget = 0;
$sum_received_budget = 0;
$sum_receivable_budget = 0;
$sum_collect_budget = 0;
// 主要array
@ -147,8 +148,10 @@ if (is_iterable($query_all_contract)) {
$arrayData[$contract_numbers['BillNo']]['collect_budget'] = 0;
$arrayData[$contract_numbers['BillNo']]['A40001'] = 0;
$arrayData[$contract_numbers['BillNo']]['A40008'] = 0;
$arrayData[$contract_numbers['BillNo']]['collect_month'] = 0;
$arrayData[$contract_numbers['BillNo']]['facility_status'] = "";
$arrayData[$contract_numbers['BillNo']]['facility'] = array();
$arrayData[$contract_numbers['BillNo']]['facility_num'] = 0;
$arrayData[$contract_numbers['BillNo']]['total_budget'] = $contract_numbers['OAmountWithTax'];
$sum_total_budget += $contract_numbers['OAmountWithTax'];
$sum_contract += 1;
@ -177,17 +180,16 @@ foreach ($query_contract_budget as $contract_budget) {
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']] = $contract_budget['OAmountWithTax'];
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['status'] = "";
$sum_facility += 1;
$arrayData[$contract_budget['BillNo']]['facility_num'] += 1;
}
switch($contract_budget['CU_MaterialId']){
switch ($contract_budget['MaterialId']) {
case "A40001":
$sum_A40001 += $contract_budget['OAmountWithTax'];
break;
case "A40008":
$sum_A40008 += $contract_budget['OAmountWithTax'];
break;
}
}
}
@ -215,6 +217,7 @@ foreach ($query_PayStage as $PayStage) {
$arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['PayStage'] = $PayStage['PayStage'];
$arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['PlanPayAmt'] = $PayStage['PlanPayAmt'];
$arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['PlanPayDate'] = $PayStage['PlanPayDate'];
$arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['stage'] = '';
if (isset($arrayData[$PayStage['BillNo']]['facility']) && is_iterable($arrayData[$PayStage['BillNo']]['facility'])) {
foreach ($arrayData[$PayStage['BillNo']]['facility'] as $key => &$value) {
$tmpkey = $key . $PayStage['RowNo'];
@ -644,9 +647,9 @@ foreach ($final_paystage as $key => &$value) {
$collect_month = 0;
$value[$sequenceNumber]['hadtopay'] = '--';
}
if ($tmpinvoice >= $value[$sequenceNumber]['PlanPayAmt']) {
if ($tmpinvoice > $value[$sequenceNumber]['PlanPayAmt']) {
$value[$sequenceNumber]['invoice_budget'] = $value[$sequenceNumber]['PlanPayAmt'];
$tmpinvoice -= $value[$sequenceNumber]['invoice_budget'];
$tmpinvoice = $tmpinvoice - $value[$sequenceNumber]['invoice_budget'];
} elseif ($tmpinvoice > 0) {
$value[$sequenceNumber]['invoice_budget'] = $tmpinvoice;
$tmpinvoice = 0;
@ -655,7 +658,7 @@ foreach ($final_paystage as $key => &$value) {
}
if ($tmpreceived > $value[$sequenceNumber]['PlanPayAmt']) {
$value[$sequenceNumber]['received_budget'] = $value[$sequenceNumber]['PlanPayAmt'];
$tmpinvoice -= $value[$sequenceNumber]['received_budget'];
$tmpreceived -= $value[$sequenceNumber]['received_budget'];
} elseif ($tmpreceived > 0) {
$value[$sequenceNumber]['received_budget'] = $tmpreceived;
$tmpreceived = 0;
@ -670,17 +673,9 @@ foreach ($final_paystage as $key => &$value) {
}
}
// foreach($final_paystage as $key => $value) {
// echo $key."<br>";
// echo "---------------------<br>";
// foreach($value as $key2 => $value2) {
// echo $key2."<br>";
// print_r($value2);
// echo "<br>";
// }
// echo "<br>==================<br>";
// }
// exit();
//合約資料填回arrayData
foreach ($final_paystage as $key => $value) {
for ($sequence = 1; $sequence <= count($value); $sequence++) {
if (isset($arrayData[$key]) && isset($arrayData[$key]['facility']) && isset($arrayData[$key]['facility'][$value[$sequence]['facilityno']]) && isset($arrayData[$key]['facility'][$value[$sequence]['facilityno']]['PayStage'])) {
@ -694,28 +689,397 @@ foreach ($final_paystage as $key => $value) {
if ($arvalue['collect_month'] < $value[$sequence]['collect_month']) {
$arvalue['collect_month'] = $value[$sequence]['collect_month'];
}
$sum_receivable_budget += $value[$sequence]['PlanPayAmt'];
$sum_received_budget += $value[$sequence]['received_budget'];
$sum_invoice_budget += $value[$sequence]['invoice_budget'];
} else {
$arvalue['stage'] = $value[$sequence]['stage'];
$arvalue['receivable_budget'] = $value[$sequence]['PlanPayAmt'];
$arvalue['received_budget'] = $value[$sequence]['received_budget'];
$arvalue['invoice_budget'] = $value[$sequence]['invoice_budget'];
$arvalue['collect_month'] = $value[$sequence]['collect_month'];
$sum_receivable_budget += $value[$sequence]['PlanPayAmt'];
$sum_received_budget += $value[$sequence]['received_budget'];
$sum_invoice_budget += $value[$sequence]['invoice_budget'];
}
if ($value[$sequence]['collect_month'] > $arrayData[$key]['collect_month']) {
$arrayData[$key]['collect_month'] = $value[$sequence]['collect_month'];
}
}
}
}
}
}
$average_A40001 = $sum_A40001 / $sum_facility;
$average_A40008 = $sum_A40008 / $sum_facility;
$average_facility_budget = $sum_total_budget / $sum_facility;
$average_contract_budget = $sum_total_budget / $sum_contract;
$average_contract_facility = $sum_facility / $sum_contract;
// 存進excel_array
$excel_array = array();
// excel 結果
// 0 合約號; 1 單據日期; 2 客戶編號; 3 客戶名稱; 4 客戶地址; 5 部門ID; 6 部門名稱; 7 營業員工號; 8 營業員名稱; 9 部門主管工號; 10 部門主管名稱;
// 11 合約總金額; 12 A40001總金額; 13 A40008總金額; 14 目前應收金額; 15 已開發票金額; 16 已收金額; 17 催收金額; 18 催收次數; 19 作番總數; 20 作番狀態
// 21 訂金名稱; 22 訂金金額; 23 應收金額; 24 已開發票金額; 25 已收金額; 26 催收金額; 27 催收次數;
// 28 二次款名稱; 29 二次款金額; 30 應收金額; 31 已開發票金額; 32 已收金額; 33 催收金額; 34 催收次數;
$excel_contract_array = array();
$excel_contract_boga_array= array();
$excel_contract_noboga_array= array();
// 0 作番號; 1 合約號; 2 合約單據日期; 3 客戶編號; 4 客戶名稱; 5 客戶地址; 6 部門ID; 7 部門名稱; 8 營業員工號; 9 營業員名稱; 10 部門主管工號; 11 部門主管名稱;
// 12 作番總金額; 13 A40001 金額; 14 A40008 金額; 15 目前應收金額; 16 已開發票金額; 17 已收金額; 18 催收金額; 19 催收次數; 20 作番狀態
$excel_facility_array = array();
foreach ($arrayData as $key => $value) {
echo $key . "<br>********************<br>";
print_r($value);
// foreach($value['facility'] as $key2 => $value2) {
// echo $key2."<br>";
// print_r($value2['PayStage']);
// echo "<br>";
// }
echo "<br>-------------------------------<br>";
// echo $key . "<br>********************<br>";
$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][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][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : '';
$excel_contract_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : '';
$excel_contract_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : '';
$excel_contract_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : '';
$excel_contract_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : '';
$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][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][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? $value['A40001'] : 0;
$excel_contract_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? $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][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? $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][17] = $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][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? $value['facility_num'] : 0;
$excel_contract_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : 0;
if (isset($value['PayStage']) && is_iterable($value['PayStage'])) {
$isBoga = 0;
if(stristr($value['PayStage'][1]['PayStage'],'寶佳')){
$isBoga=1;
$excel_contract_boga_array[$key]=array_fill(0, 76, '');
$excel_contract_boga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : '';
$excel_contract_boga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : '';
$excel_contract_boga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
$excel_contract_boga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : '';
$excel_contract_boga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : '';
$excel_contract_boga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : '';
$excel_contract_boga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : '';
$excel_contract_boga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : '';
$excel_contract_boga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
$excel_contract_boga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
$excel_contract_boga_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_boga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? $value['OAmountWithTax'] : 0;
$excel_contract_boga_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? $value['A40001'] : 0;
$excel_contract_boga_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? $value['A40008'] : 0;
$excel_contract_boga_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0;
$excel_contract_boga_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? $value['invoice_budget'] : 0;
$excel_contract_boga_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_boga_array[$key][17] = $excel_contract_array[$key][14] - $excel_contract_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][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? $value['facility_num'] : 0;
$excel_contract_boga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : 0;
}else{
$excel_contract_noboga_array[$key]=array_fill(0, 76, '');
$excel_contract_noboga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : '';
$excel_contract_noboga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : '';
$excel_contract_noboga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : '';
$excel_contract_noboga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : '';
$excel_contract_noboga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : '';
$excel_contract_noboga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : '';
$excel_contract_noboga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : '';
$excel_contract_noboga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : '';
$excel_contract_noboga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
$excel_contract_noboga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
$excel_contract_noboga_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_noboga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? $value['OAmountWithTax'] : 0;
$excel_contract_noboga_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? $value['A40001'] : 0;
$excel_contract_noboga_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? $value['A40008'] : 0;
$excel_contract_noboga_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? $value['invoice_budget'] : 0;
$excel_contract_noboga_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$excel_contract_noboga_array[$key][17] = $excel_contract_array[$key][14] - $excel_contract_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][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? $value['facility_num'] : 0;
$excel_contract_noboga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : 0;
}
foreach ($value['PayStage'] as $paykey => $payvalue) {
switch ($payvalue['stage']) {
case "訂金":
$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][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][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][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
if($isBoga == 1){
$excel_contract_boga_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_boga_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_boga_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][26] = $excel_contract_array[$key][23] - $excel_contract_array[$key][25];
$excel_contract_boga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}else{
$excel_contract_noboga_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_noboga_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_noboga_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][26] = $excel_contract_array[$key][23] - $excel_contract_array[$key][25];
$excel_contract_noboga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}
break;
case "二次款":
$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][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][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][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
if($isBoga ==1){
$excel_contract_boga_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_boga_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_boga_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][33] = $excel_contract_array[$key][30] - $excel_contract_array[$key][32];
$excel_contract_boga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}else{
$excel_contract_noboga_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_noboga_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_noboga_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][33] = $excel_contract_array[$key][30] - $excel_contract_array[$key][32];
$excel_contract_noboga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}
break;
case "貨抵工地款":
$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][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][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][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
if($isBoga == 1){
$excel_contract_boga_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_boga_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_boga_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][40] = $excel_contract_array[$key][37] - $excel_contract_array[$key][39];
$excel_contract_boga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}else{
$excel_contract_noboga_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_noboga_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_noboga_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][40] = $excel_contract_array[$key][37] - $excel_contract_array[$key][39];
$excel_contract_noboga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}
break;
case "安裝款":
$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][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][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][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
$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][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][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][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
break;
case "試車款":
$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][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][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][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
if($isBoga ==1){
$excel_contract_boga_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_boga_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_boga_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][54] = $excel_contract_array[$key][51] - $excel_contract_array[$key][53];
$excel_contract_boga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}else{
$excel_contract_noboga_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_noboga_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_noboga_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][54] = $excel_contract_array[$key][51] - $excel_contract_array[$key][53];
$excel_contract_noboga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}
break;
case "官檢驗收款":
$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][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][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][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
$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][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][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][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
break;
case "交車款":
$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][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][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][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
$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][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][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][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
break;
case "尾款":
$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][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][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][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
if($isBoga ==1){
$excel_contract_boga_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_boga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_boga_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_boga_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_boga_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_boga_array[$key][75] = $excel_contract_array[$key][72] - $excel_contract_array[$key][74];
$excel_contract_boga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}else{
$excel_contract_noboga_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_noboga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? $payvalue['PlanPayAmt'] : 0;
$excel_contract_noboga_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_noboga_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? $payvalue['invoice_budget'] : 0;
$excel_contract_noboga_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_noboga_array[$key][75] = $excel_contract_array[$key][72] - $excel_contract_array[$key][74];
$excel_contract_noboga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? $payvalue['collect_month'] : 0;
}
break;
}
}
}
}
$total_data = json_encode($excel_contract_array);
$boga_data = json_encode($excel_contract_boga_array);
$noboga_data = json_encode($excel_contract_noboga_array);
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
th{
text-align: center;
}
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
</style>
<div style="width: 98%;margin: 1%;">
<div class="btn-group btn-group-md " style="padding:10 px; width: 100%;">
<button type="button" style="width: 12%;" onclick="downloadData('all')" class="btn btn-success">全部<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="downloadData('noboga')" class="btn btn-info">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="downloadData('boga')" class="btn btn-warning">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div>
<script>
function downloadData(content) {
console.log(content);
if (content == 'all') {
var BillData = <?= $total_data ?>;
var filename = "全部應收帳款" + "<?= date('Y/m/d-H:m') ?>" + ".xlsx";
} else if (content == 'noboga') {
var BillData = <?= $noboga_data ?>;
var filename = "不含寶佳應收帳款" + "<?= date('Y/m/d-H:m') ?>" + ".xlsx";
} else if (content == 'boga') {
var BillData = <?= $boga_data ?>;
var filename = "寶佳應收帳款" + "<?= date('Y/m/d-H:m') ?>" + ".xlsx";
}
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?type=newContract&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var link = document.createElement('a');
link.setAttribute('href', window.location.origin + "/wms/account-receivable-facility.xlsx");
link.setAttribute('download', filename);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: BillData
}));
}
</script>
Loading…
Cancel
Save