|
@ -60,23 +60,28 @@ function get_ratio($facilityno, $contractno, $arrayData) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 查WMS 員工與對應主管 |
|
|
// 查WMS 員工與對應主管 |
|
|
$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A |
|
|
// $sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A |
|
|
LEFT JOIN account AS B ON A.manager = B.accountid "; |
|
|
// LEFT JOIN account AS B ON A.manager = B.accountid "; |
|
|
$managers = mysqli_query($link, $sql_manager); |
|
|
// $managers = mysqli_query($link, $sql_manager); |
|
|
// $find_manager['員工工號'] = array('員工姓名', '主管工號', '主管姓名'); |
|
|
// // $find_manager['員工工號'] = array('員工姓名', '主管工號', '主管姓名'); |
|
|
$find_manager = array(); |
|
|
// $find_manager = array(); |
|
|
if (is_iterable($managers)) { |
|
|
// if (is_iterable($managers)) { |
|
|
foreach ($managers as $manager) { |
|
|
// foreach ($managers as $manager) { |
|
|
$find_manager[$manager['accountid']] = $manager; |
|
|
// $find_manager[$manager['accountid']] = $manager; |
|
|
} |
|
|
// } |
|
|
} |
|
|
// } |
|
|
$follower = find_follow($user_id); |
|
|
$follower = find_follow($user_id); |
|
|
|
|
|
|
|
|
// T8所有合約號 |
|
|
// T8所有合約號 |
|
|
$sql_all_contract = "SELECT MainAll.* , |
|
|
$sql_all_contract = "SELECT |
|
|
|
|
|
MainAll.*, |
|
|
Person.PersonName, |
|
|
Person.PersonName, |
|
|
Dept.DeptName FROM |
|
|
Dept.DeptName, |
|
|
(SELECT |
|
|
Dept.LeaderId, |
|
|
|
|
|
Leader.PersonName AS LeaderName |
|
|
|
|
|
FROM |
|
|
|
|
|
( |
|
|
|
|
|
SELECT |
|
|
Main.BillNo, |
|
|
Main.BillNo, |
|
|
Main.BillDate, |
|
|
Main.BillDate, |
|
|
Main.BizPartnerId, |
|
|
Main.BizPartnerId, |
|
@ -88,11 +93,15 @@ Main.PersonId, |
|
|
Main.DeptId, |
|
|
Main.DeptId, |
|
|
Main.ModeId, |
|
|
Main.ModeId, |
|
|
Main.CurrentState |
|
|
Main.CurrentState |
|
|
FROM salSalesOrder AS Main |
|
|
FROM |
|
|
LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId) AS MainAll |
|
|
salSalesOrder AS Main |
|
|
|
|
|
LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId |
|
|
|
|
|
) AS MainAll |
|
|
LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId = Person.PersonId |
|
|
LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId = Person.PersonId |
|
|
LEFT JOIN comDepartment AS Dept ON MainAll.DeptId = Dept.DeptId |
|
|
LEFT JOIN comDepartment AS Dept ON MainAll.DeptId = Dept.DeptId |
|
|
WHERE MainAll.ModeId = 'M' AND (MainAll.CurrentState=2 OR MainAll.CurrentState=4) "; |
|
|
LEFT JOIN comGroupPerson AS Leader ON Dept.LeaderId = Leader.PersonId |
|
|
|
|
|
WHERE |
|
|
|
|
|
MainAll.ModeId = 'M' AND (MainAll.CurrentState = 2 OR MainAll.CurrentState = 4) "; |
|
|
if (!is_null($start_date)) { |
|
|
if (!is_null($start_date)) { |
|
|
$start_date = (int)date('Ymd', strtotime($start_date)); |
|
|
$start_date = (int)date('Ymd', strtotime($start_date)); |
|
|
$sql_all_contract .= " AND MainAll.BillDate >= $start_date "; |
|
|
$sql_all_contract .= " AND MainAll.BillDate >= $start_date "; |
|
@ -130,8 +139,8 @@ if (is_iterable($query_all_contract)) { |
|
|
$arrayData[$contract_numbers['BillNo']]['PersonName'] = isset($contract_numbers['PersonName']) ? $contract_numbers['PersonName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['PersonName'] = isset($contract_numbers['PersonName']) ? $contract_numbers['PersonName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['DeptName'] = isset($contract_numbers['DeptName']) ? $contract_numbers['DeptName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['DeptName'] = isset($contract_numbers['DeptName']) ? $contract_numbers['DeptName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['ShortName'] = isset($contract_numbers['ShortName']) ? $contract_numbers['ShortName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['ShortName'] = isset($contract_numbers['ShortName']) ? $contract_numbers['ShortName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['ManagerId'] = !empty($find_manager[$contract_numbers['PersonId']]['manager']) ? $find_manager[$contract_numbers['PersonId']]['manager'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['ManagerId'] = isset($contract_numbers['LeaderId']) ? $contract_numbers['LeaderId'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['ManagerName'] = !empty($find_manager[$contract_numbers['PersonId']]['manager_name']) ? $find_manager[$contract_numbers['PersonId']]['manager_name'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['ManagerName'] = isset($contract_numbers['LeaderName']) ? $contract_numbers['LeaderName'] : '--'; |
|
|
$arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0; |
|
|
$arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0; |
|
|
$arrayData[$contract_numbers['BillNo']]['received_budget'] = 0; |
|
|
$arrayData[$contract_numbers['BillNo']]['received_budget'] = 0; |
|
|
$arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0; |
|
|
$arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0; |
|
@ -142,6 +151,7 @@ if (is_iterable($query_all_contract)) { |
|
|
$arrayData[$contract_numbers['BillNo']]['facility'] = array(); |
|
|
$arrayData[$contract_numbers['BillNo']]['facility'] = array(); |
|
|
$arrayData[$contract_numbers['BillNo']]['total_budget'] = $contract_numbers['OAmountWithTax']; |
|
|
$arrayData[$contract_numbers['BillNo']]['total_budget'] = $contract_numbers['OAmountWithTax']; |
|
|
$sum_total_budget += $contract_numbers['OAmountWithTax']; |
|
|
$sum_total_budget += $contract_numbers['OAmountWithTax']; |
|
|
|
|
|
$sum_contract +=1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
$str_numbers .= "('" . implode("','", $contractNumbers) . "')"; |
|
|
$str_numbers .= "('" . implode("','", $contractNumbers) . "')"; |
|
@ -166,7 +176,18 @@ foreach ($query_contract_budget as $contract_budget) { |
|
|
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['total_budget'] = $contract_budget['OAmountWithTax']; |
|
|
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['total_budget'] = $contract_budget['OAmountWithTax']; |
|
|
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']] = $contract_budget['OAmountWithTax']; |
|
|
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']] = $contract_budget['OAmountWithTax']; |
|
|
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['status'] = ""; |
|
|
$arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['status'] = ""; |
|
|
|
|
|
$sum_facility +=1; |
|
|
} |
|
|
} |
|
|
|
|
|
switch($contract_budget['CU_MaterialId']){ |
|
|
|
|
|
case "A40001": |
|
|
|
|
|
$sum_A40001 += $contract_budget['OAmountWithTax']; |
|
|
|
|
|
break; |
|
|
|
|
|
case "A40008": |
|
|
|
|
|
$sum_A40008 += $contract_budget['OAmountWithTax']; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -205,6 +226,7 @@ foreach ($query_PayStage as $PayStage) { |
|
|
} else { |
|
|
} else { |
|
|
$PayStage_array[$PayStage['BillNo']] = $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage']; |
|
|
$PayStage_array[$PayStage['BillNo']] = $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage']; |
|
|
} |
|
|
} |
|
|
|
|
|
$arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'] = array(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -264,25 +286,25 @@ foreach ($query_wip as $wip) { |
|
|
if (isset($arrayData[$wip['contractno']]) && isset($arrayData[$wip['contractno']]['facility'][$wip['facilityno']])) { |
|
|
if (isset($arrayData[$wip['contractno']]) && isset($arrayData[$wip['contractno']]['facility'][$wip['facilityno']])) { |
|
|
if ($wip['delivery_date'] != NULL && $wip['delivery_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['delivery_date'])) { |
|
|
if ($wip['delivery_date'] != NULL && $wip['delivery_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['delivery_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['delivery_date'] . "已移交"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['delivery_date'] . "已移交"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) ; "; |
|
|
} elseif ($wip['official_check_date'] != NULL && $wip['official_check_date'] != '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['official_check_date'])) { |
|
|
} elseif ($wip['official_check_date'] != NULL && $wip['official_check_date'] != '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['official_check_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['official_check_date'] . "官檢完畢"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['official_check_date'] . "官檢完畢"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) ; "; |
|
|
} elseif ($wip['tryrun_end_date'] != NULL && $wip['tryrun_end_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['tryrun_end_date'])) { |
|
|
} elseif ($wip['tryrun_end_date'] != NULL && $wip['tryrun_end_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['tryrun_end_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['tryrun_end_date'] . "試車完畢"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['tryrun_end_date'] . "試車完畢"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) ; "; |
|
|
} elseif ($wip['install_end_date'] != NULL && $wip['install_end_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['install_end_date'])) { |
|
|
} elseif ($wip['install_end_date'] != NULL && $wip['install_end_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['install_end_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['install_end_date'] . "安裝完畢"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['install_end_date'] . "安裝完畢"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) ; "; |
|
|
} elseif ($wip['real_arrival_date'] != NULL && $wip['real_arrival_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['real_arrival_date'])) { |
|
|
} elseif ($wip['real_arrival_date'] != NULL && $wip['real_arrival_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['real_arrival_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['real_arrival_date'] . "貨抵工地"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['real_arrival_date'] . "貨抵工地"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) ; "; |
|
|
} elseif ($wip['real_contract_arrival_date'] != NULL && $wip['real_contract_arrival_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['real_contract_arrival_date'])) { |
|
|
} elseif ($wip['real_contract_arrival_date'] != NULL && $wip['real_contract_arrival_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['real_contract_arrival_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['real_contract_arrival_date'] . "預計出貨"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['real_contract_arrival_date'] . "預計出貨"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨) ; "; |
|
|
} elseif ($wip['estimated_shipping_date'] != NULL && $wip['estimated_shipping_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['estimated_shipping_date'])) { |
|
|
} elseif ($wip['estimated_shipping_date'] != NULL && $wip['estimated_shipping_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['estimated_shipping_date'])) { |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['estimated_shipping_date'] . "預計出港"; |
|
|
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['estimated_shipping_date'] . "預計出港"; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港) "; |
|
|
$arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港) ; "; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -294,7 +316,6 @@ $sign0 = array('簽約', '簽訂', '合約簽訂', '訂金'); |
|
|
$arrival = array('貨抵工地', '貨底工地', '工地動工'); |
|
|
$arrival = array('貨抵工地', '貨底工地', '工地動工'); |
|
|
$final6 = array('核可函取得後6個月', '得合格函後6個月'); |
|
|
$final6 = array('核可函取得後6個月', '得合格函後6個月'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($PayStage_array as $key => &$value) { |
|
|
foreach ($PayStage_array as $key => &$value) { |
|
|
foreach ($value as $paykey => &$payvalue) { |
|
|
foreach ($value as $paykey => &$payvalue) { |
|
|
if (isset($wip_array[$payvalue['facilityno']])) { |
|
|
if (isset($wip_array[$payvalue['facilityno']])) { |
|
@ -375,7 +396,7 @@ foreach ($PayStage_array as $key => &$value) { |
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)')): |
|
|
case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)') ||stristr($payvalue['PayStage'], '建照核發時')): |
|
|
$payvalue['stage'] = '二次款'; |
|
|
$payvalue['stage'] = '二次款'; |
|
|
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { |
|
|
if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { |
|
|
$estimate_time = strtotime($wip['real_arrival_date']); |
|
|
$estimate_time = strtotime($wip['real_arrival_date']); |
|
@ -431,6 +452,12 @@ foreach ($PayStage_array as $key => &$value) { |
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
|
|
|
case "簽定30天內": |
|
|
|
|
|
$payvalue['stage'] = '二次款'; |
|
|
|
|
|
$estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); |
|
|
|
|
|
$signtime = $estimate_time + (30 * 86400); |
|
|
|
|
|
$payvalue['PlanPayDate'] = date('Y-m-d', $signtime); |
|
|
|
|
|
break; |
|
|
case (in_array($payvalue['PayStage'], $sign60)): |
|
|
case (in_array($payvalue['PayStage'], $sign60)): |
|
|
$payvalue['stage'] = '二次款'; |
|
|
$payvalue['stage'] = '二次款'; |
|
|
$estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); |
|
|
$estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); |
|
@ -513,6 +540,9 @@ foreach ($PayStage_array as $key => &$value) { |
|
|
if (strtotime($payvalue['PlanPayDate']) < 975686400) { |
|
|
if (strtotime($payvalue['PlanPayDate']) < 975686400) { |
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
$payvalue['PlanPayDate'] = NULL; |
|
|
|
|
|
$payvalue['stage'] = "大日程無作番"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -606,6 +636,7 @@ foreach ($final_paystage as $key => &$value) { |
|
|
$collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate'])); |
|
|
$collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate'])); |
|
|
if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) { |
|
|
if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) { |
|
|
$value[$sequenceNumber]['hadtopay'] = 'V'; |
|
|
$value[$sequenceNumber]['hadtopay'] = 'V'; |
|
|
|
|
|
$arrayData[$key]['receivable_budget'] += $value[$sequenceNumber]['PlanPayAmt']; |
|
|
} else { |
|
|
} else { |
|
|
$value[$sequenceNumber]['hadtopay'] = '--'; |
|
|
$value[$sequenceNumber]['hadtopay'] = '--'; |
|
|
} |
|
|
} |
|
@ -616,49 +647,75 @@ foreach ($final_paystage as $key => &$value) { |
|
|
if ($tmpinvoice >= $value[$sequenceNumber]['PlanPayAmt']) { |
|
|
if ($tmpinvoice >= $value[$sequenceNumber]['PlanPayAmt']) { |
|
|
$value[$sequenceNumber]['invoice_budget'] = $value[$sequenceNumber]['PlanPayAmt']; |
|
|
$value[$sequenceNumber]['invoice_budget'] = $value[$sequenceNumber]['PlanPayAmt']; |
|
|
$tmpinvoice -= $value[$sequenceNumber]['invoice_budget']; |
|
|
$tmpinvoice -= $value[$sequenceNumber]['invoice_budget']; |
|
|
}else{ |
|
|
} elseif ($tmpinvoice > 0) { |
|
|
$value[$sequenceNumber]['invoice_budget'] = $tmpinvoice; |
|
|
$value[$sequenceNumber]['invoice_budget'] = $tmpinvoice; |
|
|
$tmpinvoice = 0; |
|
|
$tmpinvoice = 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
$value[$sequenceNumber]['invoice_budget'] = 0; |
|
|
} |
|
|
} |
|
|
if ($tmpreceived > $value[$sequenceNumber]['PlanPayAmt']) { |
|
|
if ($tmpreceived > $value[$sequenceNumber]['PlanPayAmt']) { |
|
|
$value[$sequenceNumber]['received_budget'] = $value[$sequenceNumber]['PlanPayAmt']; |
|
|
$value[$sequenceNumber]['received_budget'] = $value[$sequenceNumber]['PlanPayAmt']; |
|
|
$tmpinvoice -= $value[$sequenceNumber]['received_budget']; |
|
|
$tmpinvoice -= $value[$sequenceNumber]['received_budget']; |
|
|
}else{ |
|
|
} elseif ($tmpreceived > 0) { |
|
|
$value[$sequenceNumber]['received_budget'] = $tmpreceived; |
|
|
$value[$sequenceNumber]['received_budget'] = $tmpreceived; |
|
|
$tmpreceived = 0; |
|
|
$tmpreceived = 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
$value[$sequenceNumber]['received_budget'] = 0; |
|
|
} |
|
|
} |
|
|
if ($collect_month > 0 && $value[$sequenceNumber]['PlanPayAmt'] > $value[$sequenceNumber]['received_budget']) { |
|
|
if ($collect_month > 0 && $value[$sequenceNumber]['PlanPayAmt'] > $value[$sequenceNumber]['received_budget']) { |
|
|
$value[$sequenceNumber]['collect_month'] = $collect_month; |
|
|
$value[$sequenceNumber]['collect_month'] = $collect_month; |
|
|
} else { |
|
|
} else { |
|
|
$value[$sequenceNumber]['collect_month'] = 0; |
|
|
$value[$sequenceNumber]['collect_month'] = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// foreach($final_paystage as $key => $value) { |
|
|
// foreach($final_paystage as $key => $value) { |
|
|
// echo $key." => <br>"; |
|
|
// echo $key."<br>"; |
|
|
|
|
|
// echo "---------------------<br>"; |
|
|
// foreach($value as $key2 => $value2) { |
|
|
// foreach($value as $key2 => $value2) { |
|
|
// echo $key2."<br>"; |
|
|
// echo $key2."<br>"; |
|
|
// print_r($value2); |
|
|
// print_r($value2); |
|
|
// echo "<br>"; |
|
|
// echo "<br>"; |
|
|
// } |
|
|
// } |
|
|
// echo "<br>-------------------------------<br>"; |
|
|
// echo "<br>==================<br>"; |
|
|
// } |
|
|
// } |
|
|
// exit(); |
|
|
// exit(); |
|
|
|
|
|
foreach ($final_paystage as $key => $value) { |
|
|
|
|
|
for ($sequence = 1; $sequence <= count($value); $sequence++) { |
|
|
|
|
|
if (isset($arrayData[$key]) && isset($arrayData[$key]['facility']) && isset($arrayData[$key]['facility'][$value[$sequence]['facilityno']]) && isset($arrayData[$key]['facility'][$value[$sequence]['facilityno']]['PayStage'])) { |
|
|
|
|
|
array_push($arrayData[$key]['facility'][$value[$sequence]['facilityno']]['PayStage'], $value[$sequence]); |
|
|
|
|
|
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 ($arvalue['collect_month'] < $value[$sequence]['collect_month']) { |
|
|
|
|
|
$arvalue['collect_month'] = $value[$sequence]['collect_month']; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
$arvalue['stage'] = $value[$sequence]['stage']; |
|
|
|
|
|
$arvalue['receivable_budget'] = $value[$sequence]['PlanPayAmt']; |
|
|
|
|
|
$arvalue['received_budget'] = $value[$sequence]['received_budget']; |
|
|
|
|
|
$arvalue['invoice_budget'] = $value[$sequence]['invoice_budget']; |
|
|
|
|
|
$arvalue['collect_month'] = $value[$sequence]['collect_month']; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 存進excel_array |
|
|
// 存進excel_array |
|
|
// $excel_array = array(); |
|
|
$excel_array = array(); |
|
|
// $today = strtotime(date('Ymt')); |
|
|
|
|
|
foreach ($arrayData as $key => $value) { |
|
|
foreach ($arrayData as $key => $value) { |
|
|
echo $key."<br>"; |
|
|
echo $key . "<br>********************<br>"; |
|
|
foreach($value['facility'] as $key2 => $value2) { |
|
|
print_r($value); |
|
|
echo $key2."<br>"; |
|
|
// foreach($value['facility'] as $key2 => $value2) { |
|
|
foreach($value2 as $key3 => $value3){ |
|
|
// echo $key2."<br>"; |
|
|
echo $key3." <br> "; |
|
|
// print_r($value2['PayStage']); |
|
|
print_r($value3); |
|
|
// echo "<br>"; |
|
|
echo "<br>*********************<br>"; |
|
|
// } |
|
|
} |
|
|
|
|
|
echo "<br>==================<br>"; |
|
|
|
|
|
} |
|
|
|
|
|
echo "<br>-------------------------------<br>"; |
|
|
echo "<br>-------------------------------<br>"; |
|
|
} |
|
|
} |