diff --git a/wms/account-receivable-excel.php b/wms/account-receivable-excel.php
index ba579837..891156a6 100644
--- a/wms/account-receivable-excel.php
+++ b/wms/account-receivable-excel.php
@@ -12,10 +12,10 @@ $array_data = array();
$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') {
$colomnHeader = [
- '作番號','合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
+ '作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金名稱', '訂金合約金額', '訂金應收日期', '訂金目前應收金額', '訂金已收金額', '訂金催收金額', '訂金催收次數',
'二次款名稱', '二次款合約金額', '二次款應收日期', '二次款目前應收金額', '二次款已收金額', '二次款催收金額', '二次款催收次數',
'貨抵工地款名稱', '貨抵工地款合約金額', '貨抵工地款應收日期', '貨抵工地款目前應收金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數',
@@ -24,17 +24,17 @@ if ($type == 'facility') {
'官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數',
'交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數',
'尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數',
- '作番狀態', '作番合約總金額', '作番總應收金額'
+ '作番狀態', '合約-設備金額','合約-安裝金額','作番合約總金額', '作番總應收金額'
];
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($Bill as $key => $value) {
-
- $sheet->fromArray($value, NULL, 'A' . $rowIndex,true);
+
+ $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', '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'
+ 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP','BQ','BR'
];
foreach ($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true);
@@ -48,15 +48,15 @@ if ($type == 'facility') {
} else {
$colomnHeader = [
'合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
- '訂金', '訂金目前應收', '訂金最大催收次數', '訂金最小催收次數',
- '二次款', '二次款目前應收', '二次款最大催收次數', '二次款最小催收次數',
- '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款最小催收次數', '貨抵工地款最小催收次數',
- '安裝款', '安裝款目前應收', '安裝款最大催收次數', '安裝款最小催收次數',
- '試車款', '試車款目前應收', '試車款最大催收次數', '試車款最小催收次數',
- '官檢款', '官檢款目前應收', '官檢款最大催收次數', '官檢款最小催收次數',
- '交車款', '交車款目前應收', '交車款最大催收次數', '交車款最小催收次數',
- '尾款', '尾款目前應收', '尾款最大催收次數', '尾款最小催收次數',
- '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態'
+ '訂金', '訂金目前應收', '訂金已開票金額','訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數',
+ '二次款', '二次款目前應收', '二次款已開票金額','二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數',
+ '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額','貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數',
+ '安裝款', '安裝款目前應收', '安裝款已開票金額','安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數',
+ '試車款', '試車款目前應收', '試車款已開票金額','試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數',
+ '官檢款', '官檢款目前應收', '官檢款已開票金額','官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數',
+ '交車款', '交車款目前應收', '交車款已開票金額','交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數',
+ '尾款', '尾款目前應收', '尾款已開票金額','尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數',
+ '合約設備金額','合約安裝金額','合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態'
];
$sheet->fromArray($colomnHeader, NULL, 'A1');
@@ -65,16 +65,20 @@ if ($type == 'facility') {
$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', 'Y', 'Z',
- 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT'
+ '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'
];
foreach ($column as $col) {
- if ($col == 'AT') {
- $sheet->getStyle('AT' . $rowIndex)->getAlignment()->setWrapText(true);
+ if ($col == 'CB') {
+ $sheet->getColumnDimension('CB')->setWidth(40);
+ $sheet->getStyle('CB')->getAlignment()->setWrapText(true);
} else {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
}
+
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
diff --git a/wms/account-receivable-facility.xlsx b/wms/account-receivable-facility.xlsx
index 80c882a6..17779853 100644
Binary files a/wms/account-receivable-facility.xlsx and b/wms/account-receivable-facility.xlsx differ
diff --git a/wms/account-receivable-index-ing.php b/wms/account-receivable-index-ing.php
index 69f1cd80..a3312ef3 100644
--- a/wms/account-receivable-index-ing.php
+++ b/wms/account-receivable-index-ing.php
@@ -1,6 +1,15 @@
0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
@@ -110,7 +119,7 @@ if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql .= " ORDER BY contractno";
$sql_contract_budget .= ")";
};
-}else{
+} else {
$sql .= " ORDER BY contractno";
$sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId";
}
@@ -123,19 +132,43 @@ $contract_budget_data = $conn->query($sql_contract_budget);
$contract_budget = array();
foreach ($contract_budget_data as $cont) {
- if(isset($contract_budget[$cont['BillNo']])){
+ if (isset($contract_budget[$cont['BillNo']])) {
$contract_budget[$cont['BillNo']]['total'] += $cont['OAmountWithTax'];
- }else{
+ } else {
$contract_budget[$cont['BillNo']]['total'] = $cont['OAmountWithTax'];
}
- if(isset($contract_budget[$cont['BillNo']][$cont['CU_MaterialId']])){
- $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']] += $cont['OAmountWithTax'];
- }else{
- $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']] = $cont['OAmountWithTax'];
+ if (isset($contract_budget[$cont['BillNo']][$cont['CU_MaterialId']])) {
+ $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']]['total'] += $cont['OAmountWithTax'];
+ } else {
+ $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']]['total'] = $cont['OAmountWithTax'];
};
+ if (isset($contract_budget[$cont['BillNo']][$cont['MaterialId']])) {
+ $contract_budget[$cont['BillNo']][$cont['MaterialId']] += $cont['OAmountWithTax'];
+ } else {
+ $contract_budget[$cont['BillNo']][$cont['MaterialId']] = $cont['OAmountWithTax'];
+ }
+ $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']][$cont['MaterialId']] = $cont['OAmountWithTax'];
}
-
+/* 計算比例
+@param $facility_list array
+@param $contract_no string
+@param $contract_budget array
+return float */
+function get_ratio($facility_list, $contract_no, $contract_budget)
+{
+ $ratio = 0;
+ if (empty($facility_list)) {
+ return 0;
+ } else {
+ foreach ($facility_list as $every) {
+ if (isset($contract_budget[$contract_no][$every]['total']) && isset($contract_budget[$contract_no]['total'])) {
+ $ratio += $contract_budget[$contract_no][$every]['total'] / $contract_budget[$contract_no]['total'];
+ }
+ }
+ return $ratio;
+ }
+}
// 合約收款階段內容分類
$sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天');
@@ -177,7 +210,7 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['sign']['max'] = $arrayData[$BillNo]['second']['max'] = $arrayData[$BillNo]['arrive']['max'] = $arrayData[$BillNo]['install']['max'] = $arrayData[$BillNo]['tryrun']['max'] = $arrayData[$BillNo]['check']['max'] = $arrayData[$BillNo]['delivery']['max'] = $arrayData[$BillNo]['final']['max'] = array();
$arrayData[$BillNo]['facilities'] = "";
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['sign_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
- $arrayData[$BillNo]['total_facility_list']= $arrayData[$BillNo]['sign_list'] = $arrayData[$BillNo]['second_list'] = $arrayData[$BillNo]['arrive_list'] = $arrayData[$BillNo]['install_list'] = $arrayData[$BillNo]['tryrun_list'] = $arrayData[$BillNo]['check_list'] = $arrayData[$BillNo]['delivery_list'] = $arrayData[$BillNo]['final_list'] = [];
+ $arrayData[$BillNo]['total_list'] = $arrayData[$BillNo]['sign_list'] = $arrayData[$BillNo]['second_list'] = $arrayData[$BillNo]['arrive_list'] = $arrayData[$BillNo]['install_list'] = $arrayData[$BillNo]['tryrun_list'] = $arrayData[$BillNo]['check_list'] = $arrayData[$BillNo]['delivery_list'] = $arrayData[$BillNo]['final_list'] = [];
}
if (stristr($PayStage, '二次款') || (stristr($PayStage, '出貨前') && $PayStage != "寶佳出貨前30天") || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) {
$arrayData[$BillNo]['second'][0] = $PayStage;
@@ -267,12 +300,16 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno'];
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
+ $arrayData[$wip['contractno']]['A40001'] = $contract_budget[$wip['contractno']]['A40001'];
+ $arrayData[$wip['contractno']]['A40008'] = $contract_budget[$wip['contractno']]['A40008'];
// [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno'];
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = "";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['total_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['receivable_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['collect_budget'] = 0;
+ $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40001'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40001']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40001'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40001'] : 0;
+ $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40008'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40008']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40008'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40008'] : 0;
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
@@ -364,7 +401,6 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = "";
array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']);
- //-##############################################################################################################################################
$today = strtotime(date('Ymd'));
$contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($contractday);
@@ -382,6 +418,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//貨抵工地款
@@ -393,6 +430,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['arrive_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
@@ -405,6 +443,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
@@ -417,6 +456,8 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
+ array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
@@ -434,6 +475,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $facility_status;
} else {
$signtime = strtotime($arrayData[$wip['contractno']]['sign'][2]);
+ array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']);
$month = collect_month($signtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = strval(date('Ymd', $signtime));
@@ -447,10 +489,15 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交)
";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['install_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']);
@@ -458,6 +505,8 @@ foreach ($wipwhole_array as $wip) {
$month = collect_month($arrivetime);
if ($today > $arrivetime) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
+ array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
}
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $arrivetime));
@@ -467,7 +516,10 @@ foreach ($wipwhole_array as $wip) {
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
+ array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['check_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']);
$deliverytime = strtotime($wip['delivery_date']);
$month = collect_month($deliverytime);
@@ -538,11 +590,17 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢)
";
$arrayData[$wip['contractno']]['check_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['install_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
@@ -619,10 +677,15 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢)
";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['install_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
@@ -677,9 +740,13 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢)
";
$arrayData[$wip['contractno']]['install_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
@@ -726,8 +793,11 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地)
";
$arrayData[$wip['contractno']]['arrive_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
@@ -756,9 +826,12 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (已達二次款收款條件)
";
$arrayData[$wip['contractno']]['second_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
} else {
$arrayData[$wip['contractno']]['sign_num'] += 1;
+ array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日)
";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日)
";
@@ -773,9 +846,29 @@ foreach ($wipwhole_array as $wip) {
}
}
}
-print_r($contract_budget['D23070082']);
-echo "
";
-exit();
+// foreach ($arrayData as $key => $value) {
+// echo $key."
";
+// print_r($value['total_list']);
+// echo " / 總 ";
+// print_r($value['sign_list']);
+// echo " / 訂金
";
+// print_r($value['arrive_list']);
+// echo " / 貨抵 ";
+// print_r($value['install_list']);
+// echo " / 安裝
";
+// print_r($value['tryrun_list']);
+// echo " / 試車 ";
+// print_r($value['check_list']);
+// echo " / 官檢
";
+// print_r($value['delivery_list']);
+// echo " / 移交 ";
+// print_r($value['final_list']);
+// echo " / 結案
";
+// echo "---------------------------
";
+// foreach($value['sign_list'] as $fac){
+// echo $fac."=========";
+// }
+// }
// 計算每個合約的應收款、作番總數
@@ -783,27 +876,36 @@ $today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) {
- $value['receivable_budget'] = $value['sign'][1] * ($contract_budget[$value[10]]['total'] / $contract_budget[$value[10]]['total']) + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
- ($value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num'])) + ($value['install'][1] * ($value['install_num'] / $value['total_facility_num'])) +
- ($value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num'])) + ($value['check'][1] * ($value['check_num'] / $value['total_facility_num'])) +
- (($value['delivery'][1] + $value['final'][1]) * ($value['delivery_num'] / $value['total_facility_num']));
- $value['sign'][3] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']);
- $value['second'][3] = $value['second'][1] * ($value['second_num'] / $value['total_facility_num']);
- $value['arrive'][3] = $value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num']);
- $value['install'][3] = $value['install'][1] * ($value['install_num'] / $value['total_facility_num']);
- $value['tryrun'][3] = $value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num']);
- $value['check'][3] = $value['check'][1] * ($value['check_num'] / $value['total_facility_num']);
- $value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']);
- $value['final'][3] = $value['final'][1] * ($value['delivery_num'] / $value['total_facility_num']);
+ $sign_ratio = get_ratio($value['sign_list'], $value[10], $contract_budget);
+ $value['sign'][3] = $value['sign'][1] * $sign_ratio;
+ $second_ratio = get_ratio($value['second_list'], $value[10], $contract_budget);
+ $value['second'][3] = $value['second'][1] * $second_ratio;
+ $arrive_ratio = get_ratio($value['arrive_list'], $value[10], $contract_budget);
+ $value['arrive'][3] = $value['arrive'][1] * $arrive_ratio;
+ $install_ratio = get_ratio($value['install_list'], $value[10], $contract_budget);
+ $value['install'][3] = $value['install'][1] * $install_ratio;
+ $tryrun_ratio = get_ratio($value['tryrun_list'], $value[10], $contract_budget);
+ $value['tryrun'][3] = $value['tryrun'][1] * $tryrun_ratio;
+ $check_ratio = get_ratio($value['check_list'], $value[10], $contract_budget);
+ $value['check'][3] = $value['check'][1] * $check_ratio;
+ $delivery_ratio = get_ratio($value['delivery_list'], $value[10], $contract_budget);
+ $value['delivery'][3] = $value['delivery'][1] * $delivery_ratio;
+ $final_ratio = get_ratio($value['final_list'], $value[10], $contract_budget);
+ $value['final'][3] = $value['final'][1] * $final_ratio;
+ $value['receivable_budget'] = $value['sign'][3] + $value['second'][3] + $value['arrive'][3] + $value['install'][3] + $value['tryrun'][3] + $value['check'][3] + $value['delivery'][3] + $value['final'][3];
}
-
+ //['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
// 計算每台作番金額與各階段應收金額
foreach ($value['facility'] as &$val) {
-
foreach ($contractstage as $stage) {
if (isset($value[$stage][0]) && !empty($value[$stage][0])) {
$val[$stage][0] = $value[$stage][0];
- $val[$stage][1] = $value[$stage][1] / $value['total_facility_num'];
+ if (isset($contract_budget[$value[10]]['total']) && isset($contract_budget[$value[10]][$val['no']]['total'])) {
+ $ratio = $contract_budget[$value[10]][$val['no']]['total'] / $contract_budget[$value[10]]['total'];
+ } else {
+ $ratio = 0;
+ }
+ $val[$stage][1] = $value[$stage][1] * $ratio;
$val[$stage][3] = (!(isset($val[$stage][6])) || $val[$stage][6] == 0) ? 0 : $val[$stage][1];
$val['total_budget'] += $val[$stage][1];
$val['receivable_budget'] += $val[$stage][3];
@@ -882,6 +984,284 @@ foreach ($received_array as $received) {
}
}
+//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 4 已收金額 5 催收金額 6 已開發票金額 7 未開發票金額 min 最早應收月份 max 最晚應收月份
+foreach ($arrayData as $key => &$data) {
+ $tmp_data = $data['received_budget'];
+ $tmp_invoice = $data['invoice_budget'];
+
+ if ($data['sign'][3] > 0) {
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['sign'][3]) >= 0) {
+ $data['sign'][4] = $data['sign'][3];
+ $tmp_data -= $data['sign'][3];
+ } else {
+ $data['sign'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['sign'][5] = $data['sign'][3] - $data['sign'][4];
+ } else {
+ $data['sign'][4] = 0;
+ $data['sign'][5] = $data['sign'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['sign'][3]) >= 0) {
+ $data['sign'][6] = $data['sign'][3];
+ $tmp_invoice -= $data['sign'][3];
+ } else {
+ $data['sign'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['sign'][7] = $data['sign'][3] - $data['sign'][6];
+ } else {
+ $data['sign'][6] = 0;
+ $data['sign'][7] = $data['sign'][3];
+ }
+ } else {
+ $data['sign'][4] = 0;
+ $data['sign'][5] = 0;
+ $data['sign'][6] = 0;
+ $data['sign'][7] = 0;
+ }
+ if ($data['second'][3] > 0) {
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['second'][3]) >= 0) {
+ $data['second'][4] = $data['second'][3];
+ $tmp_data -= $data['second'][3];
+ } else {
+ $data['second'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['second'][5] = $data['second'][3] - $data['second'][4];
+ } else {
+ $data['second'][4] = 0;
+ $data['second'][5] = $data['second'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['second'][3]) >= 0) {
+ $data['second'][6] = $data['second'][3];
+ $tmp_invoice -= $data['second'][3];
+ } else {
+ $data['second'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['second'][7] = $data['second'][3] - $data['second'][6];
+ } else {
+ $data['second'][6] = 0;
+ $data['second'][7] = $data['second'][3];
+ }
+ } else {
+ $data['second'][4] = 0;
+ $data['second'][5] = 0;
+ $data['second'][6] = 0;
+ $data['second'][7] = 0;
+ }
+
+ if ($data['arrive'][3] > 0) {
+
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['arrive'][1]) >= 0) {
+ $data['arrive'][4] = $data['arrive'][3];
+ $tmp_data -= $data['arrive'][3];
+ } else {
+ $data['arrive'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['arrive'][5] = $data['arrive'][3] - $data['arrive'][4];
+ } else {
+ $data['arrive'][4] = 0;
+ $data['arrive'][5] = $data['arrive'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['arrive'][3]) >= 0) {
+ $data['arrive'][6] = $data['arrive'][3];
+ $tmp_invoice -= $data['arrive'][3];
+ } else {
+ $data['arrive'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['arrive'][7] = $data['arrive'][3] - $data['arrive'][6];
+ } else {
+ $data['arrive'][6] = 0;
+ $data['arrive'][7] = $data['arrive'][3];
+ }
+ } else {
+ $data['arrive'][4] = 0;
+ $data['arrive'][5] = 0;
+ $data['arrive'][6] = 0;
+ $data['arrive'][7] = 0;
+ }
+
+ if ($data['install'][3] > 0) {
+
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['install'][1]) >= 0) {
+ $data['install'][4] = $data['install'][3];
+ $tmp_data -= $data['install'][3];
+ } else {
+ $data['install'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['install'][5] = $data['install'][3] - $data['install'][4];
+ } else {
+ $data['install'][4] = 0;
+ $data['install'][5] = $data['install'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['install'][3]) >= 0) {
+ $data['install'][6] = $data['install'][3];
+ $tmp_invoice -= $data['install'][3];
+ } else {
+ $data['install'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['install'][7] = $data['install'][3] - $data['install'][6];
+ } else {
+ $data['install'][6] = 0;
+ $data['install'][7] = $data['install'][3];
+ }
+ } else {
+ $data['install'][4] = 0;
+ $data['install'][5] = 0;
+ $data['install'][6] = 0;
+ $data['install'][7] = 0;
+ }
+
+
+ if ($data['tryrun'][3] > 0) {
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['tryrun'][1]) >= 0) {
+ $data['tryrun'][4] = $data['tryrun'][3];
+ $tmp_data -= $data['tryrun'][3];
+ } else {
+ $data['tryrun'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['tryrun'][5] = $data['tryrun'][3] - $data['tryrun'][4];
+ } else {
+ $data['tryrun'][4] = 0;
+ $data['tryrun'][5] = $data['tryrun'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['tryrun'][3]) >= 0) {
+ $data['tryrun'][6] = $data['tryrun'][3];
+ $tmp_invoice -= $data['tryrun'][3];
+ } else {
+ $data['tryrun'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['tryrun'][7] = $data['tryrun'][3] - $data['tryrun'][6];
+ } else {
+ $data['tryrun'][6] = 0;
+ $data['tryrun'][7] = $data['tryrun'][3];
+ }
+ } else {
+ $data['tryrun'][4] = 0;
+ $data['tryrun'][5] = 0;
+ $data['tryrun'][6] = 0;
+ $data['tryrun'][7] = 0;
+ }
+
+ if ($data['check'][3] > 0) {
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['check'][1]) >= 0) {
+ $data['check'][4] = $data['check'][3];
+ $tmp_data -= $data['check'][3];
+ } else {
+ $data['check'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['check'][5] = $data['check'][3] - $data['check'][4];
+ } else {
+ $data['check'][4] = 0;
+ $data['check'][5] = $data['check'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['check'][3]) >= 0) {
+ $data['check'][6] = $data['check'][3];
+ $tmp_invoice -= $data['check'][3];
+ } else {
+ $data['check'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['check'][7] = $data['check'][3] - $data['check'][6];
+ } else {
+ $data['check'][6] = 0;
+ $data['check'][7] = $data['check'][3];
+ }
+ } else {
+ $data['check'][4] = 0;
+ $data['check'][5] = 0;
+ $data['check'][6] = 0;
+ $data['check'][7] = 0;
+ }
+ if ($data['delivery'][3] > 0) {
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['delivery'][1]) >= 0) {
+ $data['delivery'][4] = $data['delivery'][3];
+ $tmp_data -= $data['delivery'][3];
+ } else {
+ $data['delivery'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['delivery'][5] = $data['delivery'][3] - $data['delivery'][4];
+ } else {
+ $data['delivery'][4] = 0;
+ $data['delivery'][5] = $data['delivery'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['delivery'][3]) >= 0) {
+ $data['delivery'][6] = $data['delivery'][3];
+ $tmp_invoice -= $data['delivery'][3];
+ } else {
+ $data['delivery'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['delivery'][7] = $data['delivery'][3] - $data['delivery'][6];
+ } else {
+ $data['delivery'][6] = 0;
+ $data['delivery'][7] = $data['delivery'][3];
+ }
+ } else {
+ $data['delivery'][4] = 0;
+ $data['delivery'][5] = 0;
+ $data['delivery'][6] = 0;
+ $data['delivery'][7] = 0;
+ }
+
+ if ($data['final'][3] > 0) {
+ if ($tmp_data > 0) {
+ if (($tmp_data - $data['final'][1]) >= 0) {
+ $data['final'][4] = $data['final'][3];
+ $tmp_data -= $data['final'][3];
+ } else {
+ $data['final'][4] = $tmp_data;
+ $tmp_data = 0;
+ }
+ $data['final'][5] = $data['final'][3] - $data['final'][4];
+ } else {
+ $data['final'][4] = 0;
+ $data['final'][5] = $data['final'][3];
+ }
+ if ($tmp_invoice > 0) {
+ if (($tmp_invoice - $data['final'][3]) >= 0) {
+ $data['final'][6] = $data['final'][3];
+ $tmp_invoice -= $data['final'][3];
+ } else {
+ $data['final'][6] = $tmp_invoice;
+ $tmp_invoice = 0;
+ }
+ $data['final'][7] = $data['final'][3] - $data['final'][6];
+ } else {
+ $data['final'][6] = 0;
+ $data['final'][7] = $data['final'][3];
+ }
+ } else {
+ $data['final'][4] = 0;
+ $data['final'][5] = 0;
+ $data['final'][6] = 0;
+ $data['final'][7] = 0;
+ }
+}
//產生excel的array
$excel_aray = array();
@@ -891,6 +1271,10 @@ $facility_array = array();
$facility_boga_array = array();
$facility_exclude_boga_array = array();
foreach ($arrayData as $key => $value) {
+ $sum_A40001 += $value['A40001'];
+ $sum_A40008 += $value['A40008'];
+ $sum_total_budget += $value['total_budget'];
+ $sum_facility += $value['total_facility_num'];
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
$value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0;
@@ -903,50 +1287,51 @@ foreach ($arrayData as $key => $value) {
foreach ($contractstage as $i) {
$value[$i]['max'] = (empty($value[$i]['max']) || is_null($value[$i]['max'])) ? 0 : $value[$i]['max'];
$value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min'];
+ $value[$i][4] = (isset($value[$i][4])) ? $value[$i][4] : 0;
+ $value[$i][5] = (isset($value[$i][5])) ? $value[$i][5] : 0;
};
if ($value['sign'][0] == "寶佳出貨前30天") {
$boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
- $value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
- $value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
- $value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
- $value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
- $value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
- $value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
- $value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
- $value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
- $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('
', '; ', $value['facilities'])
+ number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'],
+ number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'],
+ number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'],
+ number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'],
+ number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'],
+ number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'],
+ number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'],
+ number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'],
+ number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('
', '; ', $value['facilities'])
];
} else {
$exclude_boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
- $value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
- $value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
- $value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
- $value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
- $value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
- $value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
- $value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
- $value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
- $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('
', '; ', $value['facilities'])
+ number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'],
+ number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'],
+ number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'],
+ number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'],
+ number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'],
+ number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'],
+ number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'],
+ number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'],
+ number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('
', '; ', $value['facilities'])
];
}
-
-
$excel_aray[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
- $value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
- $value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
- $value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
- $value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
- $value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
- $value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
- $value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
- $value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
- $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('
', '; ', $value['facilities'])
+ number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'],
+ number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'],
+ number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'],
+ number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'],
+ number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'],
+ number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'],
+ number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'],
+ number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'],
+ number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('
', '; ', $value['facilities'])
];
+
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
foreach ($value['facility'] as $valkey => $val) {
@@ -961,48 +1346,50 @@ foreach ($arrayData as $key => $value) {
}
$facility_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
- $val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
- $val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
- $val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
- $val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
- $val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
- $val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
- $val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
- $val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
- str_replace('
', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
+ $val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), $val['sign'][6],
+ $val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), $val['second'][6],
+ $val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), $val['arrive'][6],
+ $val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), $val['install'][6],
+ $val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), $val['tryrun'][6],
+ $val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), $val['check'][6],
+ $val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), $val['delivery'][6],
+ $val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), $val['final'][6],
+ str_replace('
', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget']))
];
if ($value['sign'][0] == "寶佳出貨前30天") {
$facility_boga_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
- $val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
- $val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
- $val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
- $val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
- $val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
- $val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
- $val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
- $val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
- str_replace('
', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
+ $val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), $val['sign'][6],
+ $val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), $val['second'][6],
+ $val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), $val['arrive'][6],
+ $val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), $val['install'][6],
+ $val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), $val['tryrun'][6],
+ $val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), $val['check'][6],
+ $val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), $val['delivery'][6],
+ $val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), $val['final'][6],
+ str_replace('
', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget']))
];
} else {
$facility_exclude_boga_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
- $val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
- $val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
- $val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
- $val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
- $val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
- $val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
- $val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
- $val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
- str_replace('
', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
+ $val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), $val['sign'][6],
+ $val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), $val['second'][6],
+ $val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), $val['arrive'][6],
+ $val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), $val['install'][6],
+ $val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), $val['tryrun'][6],
+ $val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), $val['check'][6],
+ $val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), $val['delivery'][6],
+ $val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), $val['final'][6],
+ str_replace('
', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget']))
];
}
}
}
+$average_A40001 = round($sum_A40001 / $sum_facility, 2);
+$average_A40008 = round($sum_A40008 / $sum_facility, 2);
+$average_budget = round($sum_total_budget / $sum_facility, 2);
-
-$data = json_encode($excel_aray);
+$total_data = json_encode($excel_aray);
$boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_boga_array);
$facility_data = json_encode($facility_array);
@@ -1060,10 +1447,55 @@ $facility_exclude_boga_data = json_encode($facility_exclude_boga_array);
-
+
+
+
+
+