diff --git a/wms/account-receivable-contract.xlsx b/wms/account-receivable-contract.xlsx new file mode 100644 index 00000000..f95f90d1 Binary files /dev/null and b/wms/account-receivable-contract.xlsx differ diff --git a/wms/account-receivable-excel.php b/wms/account-receivable-excel.php index db546b37..c48360ed 100644 --- a/wms/account-receivable-excel.php +++ b/wms/account-receivable-excel.php @@ -13,18 +13,57 @@ $Bill = json_decode(file_get_contents("php://input"), true); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); // file_put_contents('account-receivable.txt', json_encode($Bill)); -if ($type == 'facility') { +if ($type == 'newContract') { $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'); $rowIndex = 2; @@ -34,7 +73,7 @@ if ($type == 'facility') { $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' + 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BK' ]; foreach ($column as $col) { $sheet->getColumnDimension($col)->setAutoSize(true); @@ -47,16 +86,16 @@ if ($type == 'facility') { $writer->save($excelFileName); } else { $colomnHeader = [ - 'T8單據日期','合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', - '訂金', '訂金目前應收', '訂金已開票金額','訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', - '二次款', '二次款目前應收', '二次款已開票金額','二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', - '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額','貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', - '安裝款', '安裝款目前應收', '安裝款已開票金額','安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', - '試車款', '試車款目前應收', '試車款已開票金額','試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', - '官檢款', '官檢款目前應收', '官檢款已開票金額','官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', - '交車款', '交車款目前應收', '交車款已開票金額','交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', - '尾款', '尾款目前應收', '尾款已開票金額','尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', - '合約設備金額','合約安裝金額','合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' + 'T8單據日期', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', + '訂金', '訂金目前應收', '訂金已開票金額', '訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', + '二次款', '二次款目前應收', '二次款已開票金額', '二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', + '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額', '貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', + '安裝款', '安裝款目前應收', '安裝款已開票金額', '安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', + '試車款', '試車款目前應收', '試車款已開票金額', '試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', + '官檢款', '官檢款目前應收', '官檢款已開票金額', '官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', + '交車款', '交車款目前應收', '交車款已開票金額', '交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', + '尾款', '尾款目前應收', '尾款已開票金額', '尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', + '合約設備金額', '合約安裝金額', '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' ]; $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', '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', - 'CA','CB','CC','CD' + 'CA', 'CB', 'CC', 'CD' ]; foreach ($column as $col) { if ($col == 'CC') { diff --git a/wms/account-receivable-new-index.php b/wms/account-receivable-new-index.php index 8530ea7b..309a5607 100644 --- a/wms/account-receivable-new-index.php +++ b/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 .= " ORDER BY MainAll.PersonId ASC "; $str_numbers = ""; $query_all_contract = $conn->query($sql_all_contract); if (is_iterable($query_all_contract)) { @@ -326,11 +327,11 @@ foreach ($PayStage_array as $key => &$value) { case '寶佳出貨前30天': $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time - (30 * 86400); $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'])) { - $estimate_time = strtotime($wip['real_contract_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']); $signtime = $estimate_time - (30 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -340,7 +341,7 @@ foreach ($PayStage_array as $key => &$value) { case '寶佳出貨後10天': $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time + (10 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -350,7 +351,7 @@ foreach ($PayStage_array as $key => &$value) { case '貨抵工地後90天': $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time + (90 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -360,7 +361,7 @@ foreach ($PayStage_array as $key => &$value) { case '安裝試車後90天': $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'])) { - $estimate_time = strtotime($wip['tryrun_end_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']); $signtime = $estimate_time + (90 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -370,30 +371,41 @@ foreach ($PayStage_array as $key => &$value) { case '交車後270天': $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['delivery_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']); $signtime = $estimate_time + (270 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { $payvalue['PlanPayDate'] = NULL; } 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)): $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); - $signtime = $estimate_time + (10 * 86400); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); + $signtime = $estimate_time ; $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { - $payvalue['PlanPayDate'] = NULL; + $payvalue['PlanPayDate'] = 'NULL'; } break; case '二次款': $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'])) { - $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); } 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); } else { $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'], '建照核發時')): $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time - (30 * 86400); $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'])) { - $estimate_time = strtotime($wip['real_contract_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']); $signtime = $estimate_time - (30 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -416,11 +428,11 @@ foreach ($PayStage_array as $key => &$value) { case (stristr($payvalue['PayStage'], '出貨前60')): $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time - (60 * 86400); $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'])) { - $estimate_time = strtotime($wip['real_contract_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']); $signtime = $estimate_time - (60 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -430,11 +442,11 @@ foreach ($PayStage_array as $key => &$value) { case (stristr($payvalue['PayStage'], '出貨前90')): $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time - (90 * 86400); $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'])) { - $estimate_time = strtotime($wip['real_contract_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']); $signtime = $estimate_time - (90 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -444,11 +456,11 @@ foreach ($PayStage_array as $key => &$value) { case (stristr($payvalue['PayStage'], '出貨前120')): $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'])) { - $estimate_time = strtotime($wip['real_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']); $signtime = $estimate_time - (120 * 86400); $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'])) { - $estimate_time = strtotime($wip['real_contract_arrival_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']); $signtime = $estimate_time - (120 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); } else { @@ -493,7 +505,7 @@ foreach ($PayStage_array as $key => &$value) { case (stristr($payvalue['PayStage'], '試車')): $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'])) { - $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); } else { $payvalue['PlanPayDate'] = NULL; @@ -502,7 +514,7 @@ foreach ($PayStage_array as $key => &$value) { case (stristr($payvalue['PayStage'], '安裝') || stristr($payvalue['PayStage'], '貨抵工地且完工')): $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'])) { - $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); } else { $payvalue['PlanPayDate'] = NULL; @@ -511,7 +523,7 @@ foreach ($PayStage_array as $key => &$value) { case (in_array($payvalue['PayStage'], $final6)): $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['delivery_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']); $estimate_time = $estimate_time + (180 * 86400); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); } else { @@ -521,7 +533,7 @@ foreach ($PayStage_array as $key => &$value) { case (stristr($payvalue['PayStage'], '合格') || stristr($payvalue['PayStage'], '驗收') || stristr($payvalue['PayStage'], '驗收')): $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'])) { - $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); } else { $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'], '核可')): $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['delivery_date']); + $estimate_time = strtotime($wip_array[$payvalue['facilityno']]['delivery_date']); $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); } else { $payvalue['PlanPayDate'] = NULL; @@ -639,7 +651,6 @@ foreach ($final_paystage as $key => &$value) { $collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate'])); if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) { $value[$sequenceNumber]['hadtopay'] = 'V'; - $arrayData[$key]['receivable_budget'] += $value[$sequenceNumber]['PlanPayAmt']; } else { $value[$sequenceNumber]['hadtopay'] = '--'; } @@ -683,9 +694,14 @@ foreach ($final_paystage as $key => $value) { foreach ($arrayData[$key]['PayStage'] as $arkey => &$arvalue) { if ($arvalue['PayStage'] == $value[$sequence]['PayStage']) { 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['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']) { $arvalue['collect_month'] = $value[$sequence]['collect_month']; } @@ -694,7 +710,12 @@ foreach ($final_paystage as $key => $value) { $sum_invoice_budget += $value[$sequence]['invoice_budget']; } else { $arvalue['stage'] = $value[$sequence]['stage']; - $arvalue['receivable_budget'] = $value[$sequence]['PlanPayAmt']; + if ($value[$sequence]['hadtopay'] == 'V') { + $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['invoice_budget'] = $value[$sequence]['invoice_budget']; $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 催收次數; // 28 二次款名稱; 29 二次款金額; 30 應收金額; 31 已開發票金額; 32 已收金額; 33 催收金額; 34 催收次數; $excel_contract_array = array(); -$excel_contract_boga_array= array(); -$excel_contract_noboga_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 . "
********************
"; - $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][1] = (isset($value['BillDate']) && !is_null($value['BillDate'])) ? $value['BillDate'] : ''; $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][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][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'])) ? number_format(round($value['A40001'])) : '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][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][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; + $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'])) ? number_format(round($value['collect_month'])) : '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'] : '--'; + $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'])) { $isBoga = 0; - if(stristr($value['PayStage'][1]['PayStage'],'寶佳')){ - $isBoga=1; - $excel_contract_boga_array[$key]=array_fill(0, 76, ''); + 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'] : ''; @@ -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][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][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'])) ? $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][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_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])); + } 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'] : ''; @@ -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][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][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'])) ? $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][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; + $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])); } 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][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][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][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_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'; + $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'])) ? $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][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][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_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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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_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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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_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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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_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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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; + $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'] : '--'; - $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][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][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_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'; + $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'])) ? $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][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][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_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'])) ? $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][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][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; + $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; } } } } +foreach($arrayData as $key => $value){ + echo $key."
"; + foreach($value as $k => $v){ + echo $k."
"; + print_r($v); + echo "

"; + } + exit(); +} $total_data = json_encode($excel_contract_array); $boga_data = json_encode($excel_contract_boga_array); @@ -1006,7 +1085,8 @@ $noboga_data = json_encode($excel_contract_noboga_array); td { word-wrap: break-word; } - th{ + + th { text-align: center; } @@ -1046,20 +1126,260 @@ $noboga_data = json_encode($excel_contract_noboga_array); +
+
+

合約 (新梯)統整資訊

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $value) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
合約號部門經理營業員客戶作番狀態合約-設備金額合約-安裝金額合約總金額合約目前應收已開發票金額已收金額金額催收金額金額催收次數作番數量訂金
名稱
訂金
合約金額
訂金
應收金額
訂金
已開金額
訂金
已收金額
訂金
催收金額
訂金
催收次數
二次款
名稱
二次款
合約金額
二次款
應收金額
二次款
已開金額
二次款
已收金額
二次款
催收金額
二次款
催收次數
貨抵工地款
名稱
貨抵工地款
合約金額
貨抵工地款
應收金額
貨抵工地款
已開金額
貨抵工地款
已收金額
貨抵工地款
催收金額
貨抵工地款
催收次數
安裝款
名稱
安裝款
合約金額
安裝款
應收金額
安裝款
已開金額
安裝款
已收金額
安裝款
催收金額
安裝款
催收次數
試車款
名稱
試車款
合約金額
試車款
應收金額
試車款
已開金額
試車款
已收金額
試車款
催收金額
試車款
催收次數
官檢驗收款
名稱
官檢驗收款
合約金額
官檢驗收款
應收金額
官檢驗收款
已開金額
官檢驗收款
已收金額
官檢驗收款
催收金額
官檢驗收款
催收次數
交車款
名稱
交車款
合約金額
交車款
應收金額
交車款
已開金額
交車款
已收金額
交車款
催收金額
交車款
催收次數
尾款
名稱
尾款
合約金額
尾款
應收金額
尾款
已開金額
尾款
已收金額
尾款
催收金額
尾款
催收次數
".$value['DeptName'] ?>".$value['ManagerName'] ?>".$value['PersonName'] ?>".$value['CustomerName'] ?>
+