diff --git a/wms/account-receivable-contract.xlsx b/wms/account-receivable-contract.xlsx index 637c6d7c..cb3cc542 100644 Binary files a/wms/account-receivable-contract.xlsx and b/wms/account-receivable-contract.xlsx differ diff --git a/wms/account-receivable-excel.php b/wms/account-receivable-excel.php index 72c73f5a..64fab766 100644 --- a/wms/account-receivable-excel.php +++ b/wms/account-receivable-excel.php @@ -14,7 +14,6 @@ $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); if ($type == 'newContract') { - $excel_array = array(); $colomnHeader = [ '合約號', '客戶名稱', '營業員', '合約金額', '台數', '作番狀態', '催收金額', '催收次數', '訂金催收金額', '訂金催收次數', '二次款催收金額', '二次款催收次數', '貨抵工地款催收金額', '貨抵工地款催收次數', @@ -24,32 +23,24 @@ if ($type == 'newContract') { '交車款催收金額', '交車款催收次數', '尾款催收金額', '尾款催收次數' ]; - foreach ($Bill as $key => $value) { - $excel_array[$key] = [ - $value[0], $value[3], $value[8], $value[11], $value[19], $value[20], $value[17], $value[18], $value[26], $value[27], $value[33], $value[34], - $value[40], $value[41], - $value[47], $value[48], - $value[54], $value[55], - $value[61], $value[62], - $value[68], $value[69], - $value[75], $value[76] - ]; - } - file_put_contents('account-receivable.txt', json_encode($excel_array, JSON_UNESCAPED_UNICODE)); + file_put_contents('account-receivable.txt', json_encode($Bill, JSON_UNESCAPED_UNICODE)); $sheet->fromArray($colomnHeader, NULL, 'A1'); $rowIndex = 2; - foreach ($excel_array as $item) { - $sheet->fromArray($item, NULL, 'A' . $rowIndex); + foreach ($Bill as $key => $value) { + + $sheet->fromArray($value, NULL, 'A' . $rowIndex); $column = [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X' + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y' ]; foreach ($column as $col) { if ($col == 'F') { $sheet->getColumnDimension('F')->setWidth(35); $sheet->getStyle('F')->getAlignment()->setWrapText(true); } else { - $sheet->getColumnDimension($col)->setAutoSize(true); + // $sheet->getColumnDimension($col)->setAutoSize(true); + $sheet->getColumnDimension($col)->setWidth(10); + $sheet->getStyle($col)->getAlignment()->setWrapText(true); } } $rowIndex++; diff --git a/wms/account-receivable-new-index.php b/wms/account-receivable-new-index.php index 615366e2..59fc1f88 100644 --- a/wms/account-receivable-new-index.php +++ b/wms/account-receivable-new-index.php @@ -613,7 +613,7 @@ foreach ($query_invoice as $invoice) { //未在T8的收款資料 $sql_wms = "SELECT * FROM account_received WHERE type='M' AND BillNo IN $str_numbers"; $query_wms = mysqli_query($link, $sql_wms); -foreach($query_wms as $wms){ +foreach ($query_wms as $wms) { if (isset($arrayData[$wms['BillNo']]) && isset($arrayData[$wms['BillNo']]['invoice_budget'])) { $arrayData[$wms['BillNo']]['invoice_budget'] += $wms['invoice_budget']; } @@ -756,6 +756,7 @@ $average_contract_facility = $sum_facility / $sum_contract; // 21 訂金名稱; 22 訂金金額; 23 應收金額; 24 已開發票金額; 25 已收金額; 26 催收金額; 27 催收次數; // 28 二次款名稱; 29 二次款金額; 30 應收金額; 31 已開發票金額; 32 已收金額; 33 催收金額; 34 催收次數; $excel_contract_array = array(); +$excel_contract_all_array = array(); $excel_contract_boga_array = array(); $excel_contract_noboga_array = array(); @@ -786,59 +787,38 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--'; $excel_contract_array[$key][14] = number_format(round($excel_contract_array[$key][14])); $excel_contract_array[$key][16] = number_format(round($excel_contract_array[$key][16])); - if (isset($value['PayStage']) && is_iterable($value['PayStage'])) { + if ($excel_contract_array[$key][17] > 1 && isset($value['PayStage']) && is_iterable($value['PayStage'])) { + $excel_contract_all_array[$key] = array_fill(0, 24, 0); + $excel_contract_all_array[$key][0] = $excel_contract_array[$key][0]; + $excel_contract_all_array[$key][1] = $excel_contract_array[$key][3]; + $excel_contract_all_array[$key][2] = $excel_contract_array[$key][8]; + $excel_contract_all_array[$key][3] = $excel_contract_array[$key][11]; + $excel_contract_all_array[$key][4] = $excel_contract_array[$key][19]; + $excel_contract_all_array[$key][5] = $excel_contract_array[$key][20]; + $excel_contract_all_array[$key][6] = $excel_contract_array[$key][17]; + $excel_contract_all_array[$key][7] = $excel_contract_array[$key][18]; $isBoga = 0; if (stristr($value['PayStage'][1]['PayStage'], '寶佳')) { $isBoga = 1; - $excel_contract_boga_array[$key] = array_fill(0, 76, ''); - $excel_contract_boga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : ''; - $excel_contract_boga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : ''; - $excel_contract_boga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : ''; - $excel_contract_boga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : ''; - $excel_contract_boga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : ''; - $excel_contract_boga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : ''; - $excel_contract_boga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : ''; - $excel_contract_boga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : ''; - $excel_contract_boga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : ''; - $excel_contract_boga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : ''; - $excel_contract_boga_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : ''; - $excel_contract_boga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? number_format(round($value['OAmountWithTax'])) : '0'; - $excel_contract_boga_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? number_format(round($value['A40001'])) : '0'; - $excel_contract_boga_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? number_format(round($value['A40008'])) : '0'; - $excel_contract_boga_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0; - $excel_contract_boga_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? number_format(round($value['invoice_budget'])) : '0'; - $excel_contract_boga_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0; - $excel_contract_boga_array[$key][17] = number_format(round($excel_contract_boga_array[$key][14] - $excel_contract_boga_array[$key][16])); - $excel_contract_boga_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? number_format(round($value['collect_month'])) : '0'; - $excel_contract_boga_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? number_format(round($value['facility_num'])) : '0'; - $excel_contract_boga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--'; - $excel_contract_boga_array[$key][14] = number_format(round($excel_contract_boga_array[$key][14])); - $excel_contract_boga_array[$key][16] = number_format(round($excel_contract_boga_array[$key][16])); + $excel_contract_boga_array[$key] = array_fill(0, 24, ''); + $excel_contract_boga_array[$key][0] = $excel_contract_array[$key][0]; + $excel_contract_boga_array[$key][1] = $excel_contract_array[$key][3]; + $excel_contract_boga_array[$key][2] = $excel_contract_array[$key][8]; + $excel_contract_boga_array[$key][3] = $excel_contract_array[$key][11]; + $excel_contract_boga_array[$key][4] = $excel_contract_array[$key][19]; + $excel_contract_boga_array[$key][5] = $excel_contract_array[$key][20]; + $excel_contract_boga_array[$key][6] = $excel_contract_array[$key][17]; + $excel_contract_boga_array[$key][7] = $excel_contract_array[$key][18]; } else { - $excel_contract_noboga_array[$key] = array_fill(0, 76, ''); - $excel_contract_noboga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : ''; - $excel_contract_noboga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : ''; - $excel_contract_noboga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : ''; - $excel_contract_noboga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : ''; - $excel_contract_noboga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : ''; - $excel_contract_noboga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : ''; - $excel_contract_noboga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : ''; - $excel_contract_noboga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : ''; - $excel_contract_noboga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : ''; - $excel_contract_noboga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : ''; - $excel_contract_noboga_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : ''; - $excel_contract_noboga_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? number_format(round($value['OAmountWithTax'])) : '0'; - $excel_contract_noboga_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? number_format(round($value['A40001'])) : '0'; - $excel_contract_noboga_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? number_format(round($value['A40008'])) : '0'; - $excel_contract_noboga_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? number_format(round($value['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0; - $excel_contract_noboga_array[$key][17] = number_format(round($excel_contract_noboga_array[$key][14] - $excel_contract_noboga_array[$key][16])); - $excel_contract_noboga_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? number_format(round($value['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? number_format(round($value['facility_num'])) : '0'; - $excel_contract_noboga_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--'; - $excel_contract_noboga_array[$key][14] = number_format(round($excel_contract_noboga_array[$key][14])); - $excel_contract_noboga_array[$key][16] = number_format(round($excel_contract_noboga_array[$key][16])); + $excel_contract_noboga_array[$key] = array_fill(0, 24, ''); + $excel_contract_noboga_array[$key][0] = $excel_contract_array[$key][0]; + $excel_contract_noboga_array[$key][1] = $excel_contract_array[$key][3]; + $excel_contract_noboga_array[$key][2] = $excel_contract_array[$key][8]; + $excel_contract_noboga_array[$key][3] = $excel_contract_array[$key][11]; + $excel_contract_noboga_array[$key][4] = $excel_contract_array[$key][19]; + $excel_contract_noboga_array[$key][5] = $excel_contract_array[$key][20]; + $excel_contract_noboga_array[$key][6] = $excel_contract_array[$key][17]; + $excel_contract_noboga_array[$key][7] = $excel_contract_array[$key][18]; } foreach ($value['PayStage'] as $paykey => $payvalue) { switch ($payvalue['stage']) { @@ -850,29 +830,21 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][26] = number_format(round($excel_contract_array[$key][23] - $excel_contract_array[$key][25])); $excel_contract_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][8] = number_format(round($excel_contract_array[$key][23] - $excel_contract_array[$key][25])); + $excel_contract_all_array[$key][9] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if ($isBoga == 1) { + $excel_contract_boga_array[$key][8] = $excel_contract_all_array[$key][8]; + $excel_contract_boga_array[$key][9] = $excel_contract_all_array[$key][9]; + } else { + $excel_contract_noboga_array[$key][8] = $excel_contract_all_array[$key][8]; + $excel_contract_noboga_array[$key][9] = $excel_contract_all_array[$key][9]; + } + } $excel_contract_array[$key][23] = number_format(round($excel_contract_array[$key][23])); $excel_contract_array[$key][25] = number_format(round($excel_contract_array[$key][25])); - if ($isBoga == 1) { - $excel_contract_boga_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_boga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_boga_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_boga_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_boga_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_boga_array[$key][26] = number_format(round($excel_contract_boga_array[$key][23] - $excel_contract_boga_array[$key][25])); - $excel_contract_boga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_boga_array[$key][23] = number_format(round($excel_contract_boga_array[$key][23])); - $excel_contract_boga_array[$key][25] = number_format(round($excel_contract_boga_array[$key][25])); - } else { - $excel_contract_noboga_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][26] = number_format(round($excel_contract_noboga_array[$key][23] - $excel_contract_noboga_array[$key][25])); - $excel_contract_noboga_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][23] = number_format(round($excel_contract_noboga_array[$key][23])); - $excel_contract_noboga_array[$key][25] = number_format(round($excel_contract_noboga_array[$key][25])); - } + + break; case "二次款": $excel_contract_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -882,30 +854,22 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][33] = number_format(round($excel_contract_array[$key][30] - $excel_contract_array[$key][32])); $excel_contract_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][10] = number_format(round($excel_contract_array[$key][30] - $excel_contract_array[$key][32])); + $excel_contract_all_array[$key][11] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if ($isBoga == 1) { + $excel_contract_boga_array[$key][10] = $excel_contract_all_array[$key][10]; + $excel_contract_boga_array[$key][11] = $excel_contract_all_array[$key][11]; + } else { + $excel_contract_noboga_array[$key][10] = $excel_contract_all_array[$key][10]; + $excel_contract_noboga_array[$key][11] = $excel_contract_all_array[$key][11]; + } + } + $excel_contract_array[$key][30] = number_format(round($excel_contract_array[$key][30])); $excel_contract_array[$key][32] = number_format(round($excel_contract_array[$key][32])); - if ($isBoga == 1) { - $excel_contract_boga_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_boga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_boga_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_boga_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_boga_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_boga_array[$key][33] = number_format(round($excel_contract_boga_array[$key][30] - $excel_contract_boga_array[$key][32])); - $excel_contract_boga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_boga_array[$key][30] = number_format(round($excel_contract_boga_array[$key][30])); - $excel_contract_boga_array[$key][32] = number_format(round($excel_contract_boga_array[$key][32])); - } else { - $excel_contract_noboga_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][33] = number_format(round($excel_contract_noboga_array[$key][30] - $excel_contract_noboga_array[$key][32])); - $excel_contract_noboga_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][30] = number_format(round($excel_contract_noboga_array[$key][30])); - $excel_contract_noboga_array[$key][32] = number_format(round($excel_contract_noboga_array[$key][32])); - } + break; case "貨抵工地款": $excel_contract_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -915,29 +879,20 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][40] = number_format(round($excel_contract_array[$key][37] - $excel_contract_array[$key][39])); $excel_contract_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][12] = number_format(round($excel_contract_array[$key][37] - $excel_contract_array[$key][39])); + $excel_contract_all_array[$key][13] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if ($isBoga == 1) { + $excel_contract_boga_array[$key][12] = $excel_contract_all_array[$key][12]; + $excel_contract_boga_array[$key][13] = $excel_contract_all_array[$key][13]; + } else { + $excel_contract_noboga_array[$key][12] = $excel_contract_all_array[$key][12]; + $excel_contract_noboga_array[$key][13] = $excel_contract_all_array[$key][13]; + } + } $excel_contract_array[$key][37] = number_format(round($excel_contract_array[$key][37])); $excel_contract_array[$key][39] = number_format(round($excel_contract_array[$key][39])); - if ($isBoga == 1) { - $excel_contract_boga_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_boga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_boga_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_boga_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_boga_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_boga_array[$key][40] = number_format(round($excel_contract_boga_array[$key][37] - $excel_contract_boga_array[$key][39])); - $excel_contract_boga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_boga_array[$key][37] = number_format(round($excel_contract_boga_array[$key][37])); - $excel_contract_boga_array[$key][39] = number_format(round($excel_contract_boga_array[$key][39])); - } else { - $excel_contract_noboga_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][40] = number_format(round($excel_contract_noboga_array[$key][37] - $excel_contract_noboga_array[$key][39])); - $excel_contract_noboga_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][37] = number_format(round($excel_contract_noboga_array[$key][37])); - $excel_contract_noboga_array[$key][39] = number_format(round($excel_contract_noboga_array[$key][39])); - } + break; case "安裝款": $excel_contract_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -947,18 +902,14 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][47] = number_format(round($excel_contract_array[$key][44] - $excel_contract_array[$key][46])); $excel_contract_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][14] = number_format(round($excel_contract_array[$key][44] - $excel_contract_array[$key][46])); + $excel_contract_all_array[$key][15] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + $excel_contract_noboga_array[$key][14] = $excel_contract_all_array[$key][14]; + $excel_contract_noboga_array[$key][15] = $excel_contract_all_array[$key][15]; + } $excel_contract_array[$key][44] = number_format(round($excel_contract_array[$key][44])); $excel_contract_array[$key][46] = number_format(round($excel_contract_array[$key][46])); - - $excel_contract_noboga_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][44] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][45] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][47] = number_format(round($excel_contract_noboga_array[$key][44] - $excel_contract_noboga_array[$key][46])); - $excel_contract_noboga_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][44] = number_format(round($excel_contract_noboga_array[$key][44])); - $excel_contract_noboga_array[$key][46] = number_format(round($excel_contract_noboga_array[$key][46])); break; case "試車款": $excel_contract_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -968,29 +919,20 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][54] = number_format(round($excel_contract_array[$key][51] - $excel_contract_array[$key][53])); $excel_contract_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][16] = number_format(round($excel_contract_array[$key][51] - $excel_contract_array[$key][53])); + $excel_contract_all_array[$key][17] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if ($isBoga == 1) { + $excel_contract_boga_array[$key][16] = $excel_contract_all_array[$key][16]; + $excel_contract_boga_array[$key][17] = $excel_contract_all_array[$key][17]; + } else { + $excel_contract_noboga_array[$key][16] = $excel_contract_all_array[$key][16]; + $excel_contract_noboga_array[$key][17] = $excel_contract_all_array[$key][17]; + } + } $excel_contract_array[$key][51] = number_format(round($excel_contract_array[$key][51])); $excel_contract_array[$key][53] = number_format(round($excel_contract_array[$key][53])); - if ($isBoga == 1) { - $excel_contract_boga_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_boga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_boga_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_boga_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_boga_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_boga_array[$key][54] = number_format(round($excel_contract_boga_array[$key][51] - $excel_contract_boga_array[$key][53])); - $excel_contract_boga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_boga_array[$key][51] = number_format(round($excel_contract_boga_array[$key][51])); - $excel_contract_boga_array[$key][53] = number_format(round($excel_contract_boga_array[$key][53])); - } else { - $excel_contract_noboga_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][54] = number_format(round($excel_contract_noboga_array[$key][51] - $excel_contract_noboga_array[$key][53])); - $excel_contract_noboga_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][51] = number_format(round($excel_contract_noboga_array[$key][51])); - $excel_contract_noboga_array[$key][53] = number_format(round($excel_contract_noboga_array[$key][53])); - } + break; case "官檢驗收款": $excel_contract_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -1000,18 +942,16 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][61] = number_format(round($excel_contract_array[$key][58] - $excel_contract_array[$key][60])); $excel_contract_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][18] = number_format(round($excel_contract_array[$key][58] - $excel_contract_array[$key][60])); + $excel_contract_all_array[$key][19] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + + $excel_contract_noboga_array[$key][18] = $excel_contract_all_array[$key][18]; + $excel_contract_noboga_array[$key][19] = $excel_contract_all_array[$key][19]; + } $excel_contract_array[$key][58] = number_format(round($excel_contract_array[$key][58])); $excel_contract_array[$key][60] = number_format(round($excel_contract_array[$key][60])); - $excel_contract_noboga_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][58] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][59] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][61] = number_format(round($excel_contract_noboga_array[$key][58] - $excel_contract_noboga_array[$key][60])); - $excel_contract_noboga_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][58] = number_format(round($excel_contract_noboga_array[$key][58])); - $excel_contract_noboga_array[$key][60] = number_format(round($excel_contract_noboga_array[$key][60])); break; case "交車款": $excel_contract_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -1021,18 +961,15 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][68] = number_format(round($excel_contract_array[$key][65] - $excel_contract_array[$key][67])); $excel_contract_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][20] = number_format(round($excel_contract_array[$key][65] - $excel_contract_array[$key][67])); + $excel_contract_all_array[$key][21] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + $excel_contract_noboga_array[$key][20] = $excel_contract_all_array[$key][20]; + $excel_contract_noboga_array[$key][21] = $excel_contract_all_array[$key][21]; + } $excel_contract_array[$key][65] = number_format(round($excel_contract_array[$key][65])); $excel_contract_array[$key][67] = number_format(round($excel_contract_array[$key][67])); - $excel_contract_noboga_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][65] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][66] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][68] = number_format(round($excel_contract_noboga_array[$key][65] - $excel_contract_noboga_array[$key][67])); - $excel_contract_noboga_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][65] = number_format(round($excel_contract_noboga_array[$key][65])); - $excel_contract_noboga_array[$key][67] = number_format(round($excel_contract_noboga_array[$key][67])); break; case "尾款": $excel_contract_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; @@ -1042,29 +979,20 @@ foreach ($arrayData as $key => $value) { $excel_contract_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; $excel_contract_array[$key][75] = number_format(round($excel_contract_array[$key][72] - $excel_contract_array[$key][74])); $excel_contract_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if (isset($excel_contract_all_array[$key])) { + $excel_contract_all_array[$key][22] = number_format(round($excel_contract_array[$key][72] - $excel_contract_array[$key][74])); + $excel_contract_all_array[$key][23] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; + if ($isBoga == 1) { + $excel_contract_boga_array[$key][22] = $excel_contract_all_array[$key][22]; + $excel_contract_boga_array[$key][23] = $excel_contract_all_array[$key][23]; + } else { + $excel_contract_noboga_array[$key][22] = $excel_contract_all_array[$key][22]; + $excel_contract_noboga_array[$key][23] = $excel_contract_all_array[$key][23]; + } + } $excel_contract_array[$key][72] = number_format(round($excel_contract_array[$key][72])); $excel_contract_array[$key][74] = number_format(round($excel_contract_array[$key][74])); - if ($isBoga == 1) { - $excel_contract_boga_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_boga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_boga_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_boga_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_boga_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_boga_array[$key][75] = number_format(round($excel_contract_boga_array[$key][72] - $excel_contract_boga_array[$key][74])); - $excel_contract_boga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_boga_array[$key][72] = number_format(round($excel_contract_boga_array[$key][72])); - $excel_contract_boga_array[$key][74] = number_format(round($excel_contract_boga_array[$key][74])); - } else { - $excel_contract_noboga_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--'; - $excel_contract_noboga_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0'; - $excel_contract_noboga_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0; - $excel_contract_noboga_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0'; - $excel_contract_noboga_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0; - $excel_contract_noboga_array[$key][75] = number_format(round($excel_contract_noboga_array[$key][72] - $excel_contract_noboga_array[$key][74])); - $excel_contract_noboga_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0'; - $excel_contract_noboga_array[$key][72] = number_format(round($excel_contract_noboga_array[$key][72])); - $excel_contract_noboga_array[$key][74] = number_format(round($excel_contract_noboga_array[$key][74])); - } + break; } } @@ -1085,36 +1013,8 @@ foreach ($arrayData as $key => $value) { } } } -// $excel_contract_noboga_array[$key] = array_fill(0, 76, ''); -// $excel_contract_noboga_array[$key][0] = (isset($value['BillNo']) && !is_null($value['BillNo'])) ? $value['BillNo'] : ''; -// $excel_contract_noboga_array[$key][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : ''; -// $excel_contract_noboga_array[$key][2] = (isset($value['CustomerId']) && !is_null($value['CustomerId'])) ? $value['CustomerId'] : ''; -// $excel_contract_noboga_array[$key][3] = (isset($value['CustomerName']) && !is_null($value['CustomerName'])) ? $value['CustomerName'] : ''; -// $excel_contract_noboga_array[$key][4] = (isset($value['CustomerAddress']) && !is_null($value['CustomerAddress'])) ? $value['CustomerAddress'] : ''; -// $excel_contract_noboga_array[$key][5] = (isset($value['DeptId']) && !is_null($value['DeptId'])) ? $value['DeptId'] : ''; -// $excel_contract_noboga_array[$key][6] = (isset($value['DeptName']) && !is_null($value['DeptName'])) ? $value['DeptName'] : ''; -// $excel_contract_noboga_array[$key][7] = (isset($value['PersonId']) && !is_null($value['PersonId'])) ? $value['PersonId'] : ''; -// $excel_contract_noboga_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : ''; -// $excel_contract_noboga_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : ''; -// $excel_contract_noboga_array[$key][10] = (isset($value['ManagerName']) && !is -// foreach ($arrayData as $key => $value) { -// echo $key . "
"; -// foreach ($value as $k => $v) { -// if ($k == 'facility') { -// foreach ($v as $fkey => $fvalue) { -// echo $fkey . "
"; -// print_r($fvalue); -// echo "

"; -// } -// } -// // echo $k . "
"; -// // print_r($v); -// // echo "

"; -// } -// exit(); -// } -$total_data = json_encode($excel_contract_array); +$total_data = json_encode($excel_contract_all_array); $boga_data = json_encode($excel_contract_boga_array); $noboga_data = json_encode($excel_contract_noboga_array); ?> @@ -1210,6 +1110,31 @@ $noboga_data = json_encode($excel_contract_noboga_array); +
+ + + + + + + + + + + + +
合約日期 + + ~ + + +
合約催收次數 + + ≤ 催收次數 ≤ + + +
+
合約號 部門 - 經理 + 主管 營業員 客戶 @@ -1235,8 +1160,8 @@ include "./footer.php"; 已開發票金額 已收金額金額 催收金額金額 - 催收次數 - 作番數量 + 催收次數 + 作番數量 訂金
名稱 訂金
合約金額 @@ -1244,7 +1169,7 @@ include "./footer.php"; 訂金
已開金額 訂金
已收金額 訂金
催收金額 - 訂金
催收次數 + 訂金
催收次數 二次款
名稱 二次款
合約金額 @@ -1252,7 +1177,7 @@ include "./footer.php"; 二次款
已開金額 二次款
已收金額 二次款
催收金額 - 二次款
催收次數 + 二次款
催收次數 貨抵工地款
名稱 貨抵工地款
合約金額 @@ -1260,7 +1185,7 @@ include "./footer.php"; 貨抵工地款
已開金額 貨抵工地款
已收金額 貨抵工地款
催收金額 - 貨抵工地款
催收次數 + 貨抵工地款
催收次數 安裝款
名稱 安裝款
合約金額 @@ -1268,7 +1193,7 @@ include "./footer.php"; 安裝款
已開金額 安裝款
已收金額 安裝款
催收金額 - 安裝款
催收次數 + 安裝款
催收次數 試車款
名稱 試車款
合約金額 @@ -1276,7 +1201,7 @@ include "./footer.php"; 試車款
已開金額 試車款
已收金額 試車款
催收金額 - 試車款
催收次數 + 試車款
催收次數 官檢驗收款
名稱 官檢驗收款
合約金額 @@ -1284,7 +1209,7 @@ include "./footer.php"; 官檢驗收款
已開金額 官檢驗收款
已收金額 官檢驗收款
催收金額 - 官檢驗收款
催收次數 + 官檢驗收款
催收次數 交車款
名稱 交車款
合約金額 @@ -1292,7 +1217,7 @@ include "./footer.php"; 交車款
已開金額 交車款
已收金額 交車款
催收金額 - 交車款
催收次數 + 交車款
催收次數 尾款
名稱 尾款
合約金額 @@ -1300,7 +1225,7 @@ include "./footer.php"; 尾款
已開金額 尾款
已收金額 尾款
催收金額 - 尾款
催收次數 + 尾款
催收次數 diff --git a/wms/account-receivable-renovate-index.php b/wms/account-receivable-renovate-index.php index 01f1540e..1b3df449 100644 --- a/wms/account-receivable-renovate-index.php +++ b/wms/account-receivable-renovate-index.php @@ -119,11 +119,6 @@ FROM arWriteOffBillDetail WHERE CheckDetail.ModeId = 'T'"; -// 期初收款資訊 -$sql_opening = " -SELECT * FROM account_received "; - - $contractNumbers = array(); $query_contract_number = $conn->query($sql_contractNumber); foreach ($query_contract_number as $contract_numbers) { @@ -261,7 +256,7 @@ foreach ($contract as $cont) { $arrayData[$BillNo]['invoice'] = array(); $arrayData[$BillNo]['received_budget'] = 0; $arrayData[$BillNo]['invoice_budget'] = 0; - $arrayData[$BillNo]['A40002'] = $arrayData[$BillNo]['A40009'] = $arrayData[$BillNo]['A40010'] =$arrayData[$BillNo]['A40019'] = 0; + $arrayData[$BillNo]['A40002'] = $arrayData[$BillNo]['A40009'] = $arrayData[$BillNo]['A40010'] = $arrayData[$BillNo]['A40019'] = 0; $arrayData[$BillNo]['total_facility_num'] = 0; } $arrayData[$BillNo]['PayStage'][$RowNo]['type'] = 0; @@ -283,7 +278,6 @@ foreach ($contract as $cont) { } } $received_array = $conn->query($sql_received); -$opening_data = mysqli_query($link, $sql_opening); $invoice_data = $conn->query($sql_invoice); $contract_budget_data = $conn->query($sql_contract_budget); @@ -596,11 +590,23 @@ foreach ($received_array as $received) { $BillNo = $received['OrderBillNo']; if (isset($arrayData[$BillNo])) { // if (isset($received['InvoiceNo']) && isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { - $arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount']; + $arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount']; // array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); // } } } +//未在T8的收款資料 +$sql_wms = "SELECT * FROM account_received WHERE type='T' "; +$query_wms = mysqli_query($link, $sql_wms); +foreach ($query_wms as $wms) { + if (isset($arrayData[$wms['BillNo']]) && isset($arrayData[$wms['BillNo']]['invoice_budget'])) { + $arrayData[$wms['BillNo']]['invoice_budget'] += $wms['invoice_budget']; + $arrayData[$wms['BillNo']]['invoice'][$wms['invoice_no']] = [date("Y-m-d", strtotime($wms['invoice_date'])), $wms['invoice_budget'], 1]; + } + if (isset($arrayData[$wms['BillNo']]) && isset($arrayData[$wms['BillNo']]['received_budget'])) { + $arrayData[$wms['BillNo']]['received_budget'] += $wms['received_budget']; + } +} // $final_paystage ['type'] ['PlanPayDate'] ['PayAmount'] ['facilityno'] ['sequenceNumber'] ['name'] ['InvoiceAmount'] ['receivedAmount'] foreach ($final_paystage as $key => &$payStage) { if (isset($arrayData[$key]['invoice_budget']) && isset($arrayData[$key]['received_budget'])) { @@ -640,6 +646,7 @@ foreach ($final_paystage as $key => &$payStage) { // 0 合約號 1 作番號 2 部門id 3 部門名稱 4 經理名稱 5 營業員id 6 營業員名稱 7 客戶名稱 8 抬頭 9 統編 10 通訊地址 // 11 收款階段名稱 12 應收日期 13 收款金額 14 已開金額 15 已收金額 16 催收次數 $excel_aray = array(); +$print_array = array(); $today = strtotime(date('Ymt')); foreach ($arrayData as $key => $value) { if (isset($final_paystage[$key])) { @@ -664,6 +671,17 @@ foreach ($arrayData as $key => $value) { $unReceivedAmount = 0; break; } + if ($havetopay == "V" && $unReceivedAmount > 1) { + $print_array[$keyname] = [ + $value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], + $thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay, + number_format(round($final_paystage[$key][$sequence]['PayAmount'])), + number_format(round($final_paystage[$key][$sequence]['InvoiceAmount'])), number_format(round($unInvoiceAmount)), + number_format(round($final_paystage[$key][$sequence]['receivedAmount'])), number_format(round($unReceivedAmount)), + number_format(round($final_paystage[$key][$sequence]['collect_month'])) + + ]; + } $excel_aray[$keyname] = [ $value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay, @@ -676,7 +694,7 @@ foreach ($arrayData as $key => $value) { } } } -$total_data = json_encode($excel_aray); +$total_data = json_encode($print_array); ?>