|
|
@ -25,11 +25,12 @@ $sql_contractNumber = "SELECT Distinct BillNo FROM salSalesOrder WHERE ModeId = |
|
|
|
// T8發票 (有專案的發票) |
|
|
|
$sql_invoice = "SELECT DISTINCT |
|
|
|
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, |
|
|
|
b.ProjectId |
|
|
|
b.FromSalSalesOrder |
|
|
|
FROM arSellInvoice as a |
|
|
|
LEFT JOIN arSellInvoiceMaterial as b |
|
|
|
LEFT JOIN (SELECT CH.FromSalSalesOrder, SE.* FROM arSellInvoiceMaterial AS SE |
|
|
|
LEFT JOIN arCheckBillDetail AS CH ON SE.FromBillNo=CH.BillNo) as b |
|
|
|
ON a.BillNo=b.BillNo |
|
|
|
WHERE DATALENGTH(b.ProjectId)>0 |
|
|
|
WHERE DATALENGTH(b.FromSalSalesOrder)>0 |
|
|
|
ORDER BY InvoiceTime ASC"; |
|
|
|
|
|
|
|
// T8核銷 |
|
|
@ -61,11 +62,9 @@ SELECT * FROM account_received "; |
|
|
|
// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的 |
|
|
|
if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210')))) { |
|
|
|
} else { |
|
|
|
$sql_contract .= "AND (s.PersonId = '$user_id'"; |
|
|
|
// $sql_received .= " AND (PersonId = '$user_id'"; |
|
|
|
$sql_opening .= " OR person_id = '$user_id'"; |
|
|
|
$sql_contractNumber .= " AND (PersonId = '$user_id'"; |
|
|
|
$sql_contract_budget .= " AND (PersonId = '$user_id'"; |
|
|
|
if (count($follower) > 0) { |
|
|
|
$column_str = "('$user_id'" . ",'"; |
|
|
|
$column_str .= implode("','", $follower); |
|
|
@ -76,7 +75,6 @@ if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepart |
|
|
|
$sql_opening .= " OR person_id IN $column_str)"; |
|
|
|
// $sql_contract_budget .= " OR PersonId IN $column_str )ORDER BY BillNo, CU_MaterialId"; |
|
|
|
} else { |
|
|
|
$sql_contract .= ")"; |
|
|
|
// $sql_received .= ")"; |
|
|
|
$sql_opening .= ")"; |
|
|
|
$sql_contractNumber .= ")"; |
|
|
@ -128,19 +126,25 @@ FROM department |
|
|
|
ON d.department_id = tmp2.department_id"; |
|
|
|
|
|
|
|
//T8 銷售訂單 階段收款計畫 |
|
|
|
$sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, |
|
|
|
$sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, s.DeptId, s.DeptName, |
|
|
|
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a |
|
|
|
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo |
|
|
|
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId |
|
|
|
WHERE s.BillNo IN $str_numbers "; |
|
|
|
LEFT JOIN (SELECT O.*, DE.DeptName FROM salSalesOrder AS O LEFT JOIN comDepartment AS DE ON O.DeptId=DE.DeptId) AS s on a.BillNo = s.BillNo |
|
|
|
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId "; |
|
|
|
if (isset($str_numbers)) { |
|
|
|
$sql_contract .= "WHERE s.BillNo IN $str_numbers "; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// T8 銷售訂單 作番金額 |
|
|
|
$sql_contract_budget = "SELECT A.BillNo,A.MaterialId, A.OAmountWithTax,A.CU_MaterialId FROM salSalesOrderDetail AS A |
|
|
|
LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo |
|
|
|
WHERE B.ModeId='T' AND A.ItemType=1 AND A.BillNo IN $str_numbers "; |
|
|
|
|
|
|
|
WHERE B.ModeId='T' AND A.ItemType=1 "; |
|
|
|
if (isset($str_numbers)) { |
|
|
|
$sql_contract_budget .= "AND A.BillNo IN $str_numbers "; |
|
|
|
} |
|
|
|
$contract = $conn->query($sql_contract); |
|
|
|
$contract_data = array(); |
|
|
|
$manager_list = array(); |
|
|
|
// 將T8合約收款階段資料依據款別分類放進arraData裡 |
|
|
|
foreach ($contract as $cont) { |
|
|
|
$BillNo = $cont['BillNo']; |
|
|
@ -153,6 +157,11 @@ foreach ($contract as $cont) { |
|
|
|
$TaxNo = $cont['TaxNo']; |
|
|
|
$ContactAddress = $cont['ContactAddress']; |
|
|
|
$RowNo = $cont['RowNo']; |
|
|
|
$salesId = $cont['PersonId']; |
|
|
|
if (!in_array($salesId, $manager_list)) { |
|
|
|
array_push($manager_list, $salesId); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//['type'] A:比照新梯、B:純分期、C:其他 |
|
|
|
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期 |
|
|
@ -161,6 +170,9 @@ foreach ($contract as $cont) { |
|
|
|
if (!(isset($arrayData[$BillNo]))) { |
|
|
|
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號 |
|
|
|
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
|
|
|
$arrayData[$BillNo][0] = $cont['DeptId']; |
|
|
|
$arrayData[$BillNo][1] = $cont['DeptName']; |
|
|
|
$arrayData[$BillNo][3] = $salesId; |
|
|
|
$arrayData[$BillNo][5] = $partnerName; |
|
|
|
$arrayData[$BillNo][6] = $EnterpriseName; |
|
|
|
$arrayData[$BillNo][7] = $TaxNo; |
|
|
@ -197,11 +209,26 @@ $opening_data = mysqli_query($link, $sql_opening); |
|
|
|
$invoice_data = $conn->query($sql_invoice); |
|
|
|
$contract_budget_data = $conn->query($sql_contract_budget); |
|
|
|
|
|
|
|
// 查WMS 契約員主管 |
|
|
|
$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 "; |
|
|
|
$managers = mysqli_query($link, $sql_manager); |
|
|
|
|
|
|
|
$find_manager = array(); |
|
|
|
foreach ($managers as $manager) { |
|
|
|
$find_manager[$manager['accountid']] = $manager; |
|
|
|
} |
|
|
|
// 將T8銷售訂單明細 每個作番金額存入arrayData |
|
|
|
$contract_budget = array(); |
|
|
|
foreach ($contract_budget_data as $cont) { |
|
|
|
$BillNo = $cont['BillNo']; |
|
|
|
if (isset($arrayData[$BillNo])) { |
|
|
|
$salesid = $arrayData[$BillNo][3]; |
|
|
|
if (isset($find_manager[$salesid])) { |
|
|
|
$arrayData[$BillNo][2] = $find_manager[$salesid]['manager_name']; |
|
|
|
$arrayData[$BillNo][4] = $find_manager[$salesid]['name']; |
|
|
|
$arrayData[$BillNo][11] = $find_manager[$salesid]['manager']; |
|
|
|
} |
|
|
|
$arrayData[$BillNo]['total_budget'] += $cont['OAmountWithTax']; |
|
|
|
$arrayData[$BillNo][$cont['MaterialId']] += $cont['OAmountWithTax']; |
|
|
|
if (isset($arrayData[$BillNo]['facility'][$cont['CU_MaterialId']])) { |
|
|
@ -273,11 +300,11 @@ foreach ($wipwhole_array as $wip) { |
|
|
|
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 |
|
|
|
if (isset($arrayData[$wip['contractno']])) { |
|
|
|
// 整理合約資料 |
|
|
|
$arrayData[$wip['contractno']][0] = $wip['department_id'];; |
|
|
|
$arrayData[$wip['contractno']][1] = $wip['depart_name']; |
|
|
|
$arrayData[$wip['contractno']][2] = $wip['manager_name']; |
|
|
|
$arrayData[$wip['contractno']][3] = $wip['salesid']; |
|
|
|
$arrayData[$wip['contractno']][4] = $wip['name']; |
|
|
|
// $arrayData[$wip['contractno']][0] = $wip['department_id'];; |
|
|
|
// $arrayData[$wip['contractno']][1] = $wip['depart_name']; |
|
|
|
// $arrayData[$wip['contractno']][2] = $wip['manager_name']; |
|
|
|
// $arrayData[$wip['contractno']][3] = $wip['salesid']; |
|
|
|
// $arrayData[$wip['contractno']][4] = $wip['name']; |
|
|
|
$arrayData[$wip['contractno']][10] = $wip['contractno']; |
|
|
|
$arrayData[$wip['contractno']]['A40001'] = (isset($contract_budget[$wip['contractno']]['A40001']) && !is_null($contract_budget[$wip['contractno']]['A40001'])) ? $contract_budget[$wip['contractno']]['A40001'] : 0; |
|
|
|
$arrayData[$wip['contractno']]['A40008'] = (isset($contract_budget[$wip['contractno']]['A40008']) && !is_null($contract_budget[$wip['contractno']]['A40008'])) ? $contract_budget[$wip['contractno']]['A40008'] : 0; |
|
|
@ -299,8 +326,9 @@ $sign_array = ['訂金', '簽約', '合約']; |
|
|
|
// 將所有facility的paystage放入一個array以便計算順序 |
|
|
|
$allPayStages = []; |
|
|
|
foreach ($arrayData as &$value) { |
|
|
|
if (is_iterable($value['facility'])) { |
|
|
|
if (isset($value['facility']) && is_iterable($value['facility'])) { |
|
|
|
foreach ($value['facility'] as $fakey => &$facility) { |
|
|
|
if (isset($contract_budget[$value[10]])) { |
|
|
|
$ratio = get_contract_ratio($fakey, $contract_budget[$value[10]]); |
|
|
|
for ($stage = 1; $stage < (count($value['PayStage']) + 1); $stage++) { |
|
|
|
$facility['PayStage'][$stage] = $value['PayStage'][$stage]; |
|
|
@ -359,46 +387,46 @@ foreach ($arrayData as &$value) { |
|
|
|
switch ($facility['PayStage'][$stage]['name']) { |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '試車')): |
|
|
|
if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['tryrun_end_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '完工')): |
|
|
|
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '尾款')): |
|
|
|
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '交車')): |
|
|
|
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '驗收')): |
|
|
|
if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '安裝')): |
|
|
|
if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['install_end_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
|
case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): |
|
|
|
if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_arrival_date']))); |
|
|
|
} elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { |
|
|
|
$haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); |
|
|
|
$haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; |
|
|
|
$facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date']))); |
|
|
|
} |
|
|
|
break; |
|
|
@ -417,6 +445,7 @@ foreach ($arrayData as &$value) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
foreach ($allPayStages as $paykey => $pay) { |
|
|
|
uasort($allPayStages[$paykey], 'comparePlanPayDate'); |
|
|
|
} |
|
|
@ -440,9 +469,9 @@ foreach ($allPayStages as $key => &$payStage) { |
|
|
|
|
|
|
|
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號] |
|
|
|
foreach ($invoice_data as $invoice) { |
|
|
|
if (isset($arrayData[$invoice['ProjectId']])) { |
|
|
|
$arrayData[$invoice['ProjectId']]['invoice_budget'] += intval($invoice['OAmountWithTax']); |
|
|
|
$arrayData[$invoice['ProjectId']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; |
|
|
|
if (isset($arrayData[$invoice['FromSalSalesOrder']])) { |
|
|
|
$arrayData[$invoice['FromSalSalesOrder']]['invoice_budget'] += intval($invoice['OAmountWithTax']); |
|
|
|
$arrayData[$invoice['FromSalSalesOrder']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -490,173 +519,48 @@ foreach($final_paystage as $key => &$payStage){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// foreach($final_paystage as $key => $payStage){ |
|
|
|
// echo $key."<br>"; |
|
|
|
// for($sequence = 1; $sequence <= count($payStage); $sequence++){ |
|
|
|
// print_r($payStage[$sequence]); |
|
|
|
// echo "<br>"; |
|
|
|
// } |
|
|
|
// echo "---------------------<br>"; |
|
|
|
// } |
|
|
|
|
|
|
|
foreach ($arrayData as &$value) { |
|
|
|
// if (is_iterable($value['facility'])) { |
|
|
|
// foreach ($value['facility'] as $fakey => &$facility) { |
|
|
|
// // foreach ($facility['PayStage'] as $index => &$payStage) { |
|
|
|
// // // $payStage['sequenceNumber'] = $allPayStages[$value[10]][$index]['sequenceNumber']; |
|
|
|
// // echo $index." => "; |
|
|
|
// // print_r($payStage); |
|
|
|
// // echo "<br>"; |
|
|
|
// // } |
|
|
|
// echo $fakey." => "; |
|
|
|
// print_r($facility); |
|
|
|
// echo "<br>"; |
|
|
|
// } |
|
|
|
// } |
|
|
|
print_r($value); |
|
|
|
echo "---------------------<br>"; |
|
|
|
} |
|
|
|
exit(); |
|
|
|
//========================================================================================================================================================= |
|
|
|
|
|
|
|
|
|
|
|
//產生excel的array |
|
|
|
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號 |
|
|
|
// 0 合約號 1 作番號 2 部門id 3 部門名稱 4 經理名稱 5 營業員id 6 營業員名稱 7 客戶名稱 8 抬頭 9 統編 10 通訊地址 |
|
|
|
// 11 收款階段名稱 12 應收日期 13 收款金額 14 已開金額 15 已收金額 16 催收次數 |
|
|
|
$excel_aray = array(); |
|
|
|
$boga_array = array(); |
|
|
|
$exclude_boga_array = array(); |
|
|
|
$facility_array = array(); |
|
|
|
$facility_boga_array = array(); |
|
|
|
$facility_exclude_boga_array = array(); |
|
|
|
$today = strtotime(date('Ymt')); |
|
|
|
foreach ($arrayData as $key => $value) { |
|
|
|
$sum_A40001 += isset($value['A40001']) ? $value['A40001'] : 0; |
|
|
|
$sum_A40008 += isset($value['A40008']) ? $value['A40008'] : 0; |
|
|
|
$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; |
|
|
|
$value['install'][3] = (isset($value['install'][3])) ? $value['install'][3] : 0; |
|
|
|
$value['tryrun'][3] = (isset($value['tryrun'][3])) ? $value['tryrun'][3] : 0; |
|
|
|
$value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0; |
|
|
|
$value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0; |
|
|
|
$value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0; |
|
|
|
$value[9] = (isset($value[9])) ? Date('Ymd', strtotime($value[9])) : 0; |
|
|
|
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); |
|
|
|
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; |
|
|
|
$value['A40001'] = (isset($value['A40001'])) ? $value['A40001'] : 0; |
|
|
|
$value['A40008'] = (isset($value['A40008'])) ? $value['A40008'] : 0; |
|
|
|
}; |
|
|
|
|
|
|
|
if (isset($value['sign'][0]) && $value['sign'][0] == "寶佳出貨前30天") { |
|
|
|
$boga_array[$key] = [ |
|
|
|
$value[9], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], |
|
|
|
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('<br>', '; ', $value['facilities']) |
|
|
|
]; |
|
|
|
} else { |
|
|
|
$exclude_boga_array[$key] = [ |
|
|
|
$value[9], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], |
|
|
|
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('<br>', '; ', $value['facilities']) |
|
|
|
]; |
|
|
|
if (isset($final_paystage[$key])) { |
|
|
|
for ($sequence = 1; $sequence <= count($final_paystage[$key]); $sequence++) { |
|
|
|
$value[4] = (isset($value[4]) && !empty($value[4])) ? $value[4] : '--'; |
|
|
|
$value[5] = (isset($value[5]) && !empty($value[5])) ? $value[5] : '--'; |
|
|
|
$value[6] = (isset($value[6]) && !empty($value[6])) ? $value[6] : '--'; |
|
|
|
$value[7] = (isset($value[7]) && !empty($value[7])) ? $value[7] : '--'; |
|
|
|
$value[8] = (isset($value[8]) && !empty($value[8])) ? $value[8] : '--'; |
|
|
|
$value[11] = (isset($value[11]) && !empty($value[11])) ? $value[11] : '--'; |
|
|
|
$value[12] = (isset($value[12]) && !empty($value[12])) ? date('Y/m/d', strtotime($value[12])) : '--'; |
|
|
|
$thisPayStage = $final_paystage[$key][$sequence]; |
|
|
|
$keyname = $key . "/" . $final_paystage[$key][$sequence]['facilityno'] . "/" . $value[5]; |
|
|
|
$havetopay = ($today >= strtotime($thisPayStage['PlanPayDate'])) ? "V" : "--"; |
|
|
|
switch ($havetopay) { |
|
|
|
case "V": |
|
|
|
$unInvoiceAmount = $thisPayStage['PayAmount'] - $thisPayStage['InvoiceAmount']; |
|
|
|
$unReceivedAmount = $thisPayStage['PayAmount'] - $thisPayStage['receivedAmount']; |
|
|
|
break; |
|
|
|
default: |
|
|
|
$unInvoiceAmount = 0; |
|
|
|
$unReceivedAmount = 0; |
|
|
|
break; |
|
|
|
} |
|
|
|
$excel_aray[$keyname] = [ |
|
|
|
$value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], |
|
|
|
$thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay, |
|
|
|
number_format(round($thisPayStage['PayAmount'])), |
|
|
|
number_format(round($thisPayStage['InvoiceAmount'])), number_format(round($unInvoiceAmount)), |
|
|
|
number_format(round($thisPayStage['receivedAmount'])), number_format(round($unReceivedAmount)), |
|
|
|
number_format(round($thisPayStage['collect_month'])) |
|
|
|
|
|
|
|
$excel_aray[$key] = [ |
|
|
|
$value[9], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], |
|
|
|
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('<br>', '; ', $value['facilities']) |
|
|
|
]; |
|
|
|
|
|
|
|
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 |
|
|
|
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 |
|
|
|
if (isset($value['facility'])) { |
|
|
|
foreach ($value['facility'] as $valkey => $val) { |
|
|
|
foreach ($contractstage as $stage) { |
|
|
|
$val[$stage][0] = (!(isset($val[$stage][0])) || is_null($val[$stage][0])) ? "-" : $val[$stage][0]; |
|
|
|
$val[$stage][1] = (!(isset($val[$stage][1])) || is_null($val[$stage][1])) ? 0 : $val[$stage][1]; |
|
|
|
$val[$stage][2] = (!(isset($val[$stage][2])) || is_null($val[$stage][2])) ? "-" : $val[$stage][2]; |
|
|
|
$val[$stage][3] = (!(isset($val[$stage][3])) || is_null($val[$stage][3])) ? 0 : $val[$stage][3]; |
|
|
|
$val[$stage][4] = (!(isset($val[$stage][4])) || is_null($val[$stage][4])) ? 0 : $val[$stage][4]; |
|
|
|
$val[$stage][5] = (!(isset($val[$stage][5])) || is_null($val[$stage][5])) ? 0 : $val[$stage][5]; |
|
|
|
$val[$stage][6] = (!(isset($val[$stage][6])) || is_null($val[$stage][6])) ? 0 : $val[$stage][6]; |
|
|
|
} |
|
|
|
$facility_array[$valkey] = [ |
|
|
|
$value[9], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], |
|
|
|
$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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($val['final'][6])), |
|
|
|
str_replace('<br>', '; ', $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] = [ |
|
|
|
$value[9], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], |
|
|
|
$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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($val['final'][6])), |
|
|
|
str_replace('<br>', '; ', $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] = [ |
|
|
|
$value[9], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], |
|
|
|
$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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($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])), number_format(round($val['final'][6])), |
|
|
|
str_replace('<br>', '; ', $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); |
|
|
|
|
|
|
|
$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); |
|
|
|
$facility_boga_data = json_encode($facility_boga_array); |
|
|
|
$facility_exclude_boga_data = json_encode($facility_exclude_boga_array); |
|
|
|
|
|
|
|
?> |
|
|
|
<style> |
|
|
@ -699,206 +603,101 @@ $facility_exclude_boga_data = json_encode($facility_exclude_boga_array); |
|
|
|
.hiddenTable { |
|
|
|
display: none; |
|
|
|
} |
|
|
|
|
|
|
|
.hidden { |
|
|
|
display: none; |
|
|
|
} |
|
|
|
</style> |
|
|
|
|
|
|
|
<div style="width: 98%;margin: 1%;"> |
|
|
|
<div class="btn-group btn-group-md " style="padding:10 px; width: 100%;"> |
|
|
|
<button type="button" style="width: 12%;" onclick="downloadData()" class="btn btn-success">全部<span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
<button type="button" style="width: 12%;" onclick="exclude_bogaData()" class="btn btn-info">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
<button type="button" style="width: 12%;" onclick="bogaData()" class="btn btn-warning">寶佳<span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div style="width: 98%;margin: 1%;"> |
|
|
|
<div class="btn-group btn-group-md" style="width: 100%;"> |
|
|
|
<button type="button" style="width: 12%;" onclick="downloadFacilityData('AllData')" class="btn btn-success btn-md">作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
<button type="button" style="width: 12%;" onclick="downloadFacilityData('ExcludeData')" class="btn btn-info btn-md">不含寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
<button type="button" style="width: 12%;" onclick="downloadFacilityData('BogaData')" class="btn btn-warning btn-md">寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
|
|
|
|
<button type="button" style="width: 12%;" onclick="downloadData()" class="btn btn-success">下載 <span class="glyphicon glyphicon-download-alt"></span></button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="container"> |
|
|
|
<div class="text-center" style="margin-bottom: 20px;"> |
|
|
|
<h3><strong>合約 (新梯)統整資訊</strong></h3> |
|
|
|
</div> |
|
|
|
<form class="form-horizontal"> |
|
|
|
<div class="form-group"> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="sum_total_budget">合約總金額</label> |
|
|
|
<input type="text" class="form-control" id="sum_total_budget" name="sum_total_budget" value="<?= number_format($sum_total_budget) ?>" disabled> |
|
|
|
</div> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="sum_A40001">合約設備總金額</label> |
|
|
|
<input type="text" class="form-control" id="sum_A40001" name="sum_A40001" value="<?= number_format($sum_A40001) ?>" disabled> |
|
|
|
</div> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="sum_A40008">合約安裝總金額</label> |
|
|
|
<input type="text" class="form-control" id="sum_A40008" name="sum_A40008" value="<?= number_format($sum_A40008) ?>" disabled> |
|
|
|
</div> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="sum_facility">總台數</label> |
|
|
|
<input type="text" class="form-control" id="sum_facility" name="sum_facility" value="<?= number_format($sum_facility) ?>" disabled> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="average_budget">平均金額</label> |
|
|
|
<input type="text" class="form-control" id="average_budget" name="average_budget" value="<?= number_format($average_budget) ?>" disabled> |
|
|
|
</div> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="average_A40001">設備平均金額</label> |
|
|
|
<input type="text" class="form-control" id="average_A40001" name="average_A40001" value="<?= number_format($average_A40001) ?>" disabled> |
|
|
|
</div> |
|
|
|
<div class="col-md-3"> |
|
|
|
<label for="average_A40008">安裝平均金額</label> |
|
|
|
<input type="text" class="form-control" id="average_A40008" name="average_A40008" value="<?= number_format($average_A40008) ?>" disabled> |
|
|
|
</div> |
|
|
|
<h3><strong>合約 (汰改)統整資訊</strong></h3> |
|
|
|
</div> |
|
|
|
</form> |
|
|
|
</div> |
|
|
|
|
|
|
|
<?php |
|
|
|
include "./footer.php"; |
|
|
|
?> |
|
|
|
|
|
|
|
|
|
|
|
<div style="width:98%;margin:1% ;overflow-x: auto;"> |
|
|
|
<table id="table_index" class="table table-striped table-bordered" style="width:100%;"> |
|
|
|
<div style="width: 20%;float:right;margin-right:5%; "> |
|
|
|
<label>查詢條件</label> |
|
|
|
<input type="text" id="search" name="search" class="form-control" placeholder="請輸入合約號/作番號/客戶名稱" oninput="searchData()"> |
|
|
|
</div> |
|
|
|
<div style="width: 98%; margin:1%;" <div style="overflow-x:auto;"> |
|
|
|
<table class="table table-striped table-bordered" style="width:100%"> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<th style="width: 120px;">合約號</th> |
|
|
|
<th style="width: 120px;">部門</th> |
|
|
|
<th style="width: 120px;">經理</th> |
|
|
|
<th style="width: 120px;">營業員</th> |
|
|
|
<th style="width: 120px;">客戶名稱</th> |
|
|
|
<th style="width: 120px;">簽約款</th> |
|
|
|
<th style="width: 120px;">應收簽約金額</th> |
|
|
|
<th style="width: 120px;">簽約最小催收次數</th> |
|
|
|
<th style="width: 120px;">簽約最大催收次數</th> |
|
|
|
<th style="width: 120px;">二次款</th> |
|
|
|
<th style="width: 120px;">應收二次金額</th> |
|
|
|
<th style="width: 120px;">二次最小催收次數</th> |
|
|
|
<th style="width: 120px;">二次最大催收次數</th> |
|
|
|
<th style="width: 120px;">貨抵工地款</th> |
|
|
|
<th style="width: 120px;">應收貨抵工地金額</th> |
|
|
|
<th style="width: 120px;">貨抵工地最小催收次數</th> |
|
|
|
<th style="width: 120px;">貨抵工地最大催收次數</th> |
|
|
|
<th style="width: 120px;">安裝款</th> |
|
|
|
<th style="width: 120px;">應收安裝金額</th> |
|
|
|
<th style="width: 120px;">安裝最小催收次數</th> |
|
|
|
<th style="width: 120px;">安裝最大催收次數</th> |
|
|
|
<th style="width: 120px;">試車款</th> |
|
|
|
<th style="width: 120px;">應收試車金額</th> |
|
|
|
<th style="width: 120px;">試車最小催收次數</th> |
|
|
|
<th style="width: 120px;">試車最大催收次數</th> |
|
|
|
<th style="width: 120px;">官檢款</th> |
|
|
|
<th style="width: 120px;">應收官檢金額</th> |
|
|
|
<th style="width: 120px;">官檢最小催收次數</th> |
|
|
|
<th style="width: 120px;">官檢最大催收次數</th> |
|
|
|
<th style="width: 120px;">移交款</th> |
|
|
|
<th style="width: 120px;">應收移交金額</th> |
|
|
|
<th style="width: 120px;">移交最小催收次數</th> |
|
|
|
<th style="width: 120px;">移交最大催收次數</th> |
|
|
|
<th style="width: 120px;">尾款</th> |
|
|
|
<th style="width: 120px;">應收尾款金額</th> |
|
|
|
<th style="width: 120px;">尾款最小催收次數</th> |
|
|
|
<th style="width: 120px;">尾款最大催收次數</th> |
|
|
|
<th style="width: 120px;">合約總金額</th> |
|
|
|
<th style="width: 120px;" style="width: 120px;">目前應收</th> |
|
|
|
<th style="width: 120px;" style="width: 120px;">已開發票金額</th> |
|
|
|
<th style="width: 120px;">已收金額</th> |
|
|
|
<!-- <th>作番狀態</th> --> |
|
|
|
<th style="width: 350px;">收款狀態</th> |
|
|
|
|
|
|
|
<th style='text-align:center;vertical-align: middle;width:120px'>合約號</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;width:120px'>作番號</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;width:110px'>部門</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;'>主管</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;'>契約員</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;width:130px'>客戶名稱</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;'>收款階段</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;'>應收日期</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;'>是否應收</th> |
|
|
|
<th style='text-align:end;vertical-align: middle;'>應收金額</th> |
|
|
|
<th style='text-align:end;vertical-align: middle;'>已開金額</th> |
|
|
|
<th style='text-align:end;vertical-align: middle;'>未開金額</th> |
|
|
|
<th style='text-align:end;vertical-align: middle;'>已收金額</th> |
|
|
|
<th style='text-align:end;vertical-align: middle;'>催收金額</th> |
|
|
|
<th style='text-align:center;vertical-align: middle;'>催收次數</th> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
<tbody> |
|
|
|
<?php |
|
|
|
foreach ($arrayData as $key => $value) { |
|
|
|
?> |
|
|
|
<tr> |
|
|
|
<th><a onclick="showContract('<?= $key ?>')"><?= $key ?> </a></th> |
|
|
|
<td><?= $value[1] ?></td> |
|
|
|
<td><?= $value[2] ?></td> |
|
|
|
<td><?= $value[4] ?></td> |
|
|
|
<td><?= $value[5] ?></td> |
|
|
|
<td><?= number_format(round($value['sign'][1])) ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['sign'][3]) ? number_format(round($value['sign'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['sign']['min']) ? $value['sign']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['sign']['max']) ? $value['sign']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['second'][1]) ? number_format(round($value['second'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['second'][3]) ? number_format(round($value['second'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['second']['min']) ? $value['second']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['second']['max']) ? $value['second']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['arrive'][1]) ? number_format(round($value['arrive'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['arrive'][3]) ? number_format(round($value['arrive'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['arrive']['min']) ? $value['arrive']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['arrive']['max']) ? $value['arrive']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['install'][1]) ? number_format(round($value['install'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['install'][3]) ? number_format(round($value['install'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['install']['min']) ? $value['install']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['install']['max']) ? $value['install']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['tryrun'][1]) ? number_format(round($value['tryrun'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['tryrun'][3]) ? number_format(round($value['tryrun'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['tryrun']['min']) ? $value['tryrun']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['tryrun']['max']) ? $value['tryrun']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['check'][1]) ? number_format(round($value['check'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['check'][3]) ? number_format(round($value['check'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['check']['min']) ? $value['check']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['check']['max']) ? $value['check']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['delivery'][1]) ? number_format(round($value['delivery'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['delivery'][3]) ? number_format(round($value['delivery'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['delivery']['min']) ? $value['delivery']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['delivery']['max']) ? $value['delivery']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['final'][1]) ? number_format(round($value['final'][1])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['final'][3]) ? number_format(round($value['final'][3])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['final']['min']) ? $value['final']['min'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['final']['max']) ? $value['final']['max'] : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['total_budget']) ? number_format(round($value['total_budget'])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['receivable_budget']) ? number_format(round($value['receivable_budget'])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['invoice_budget']) ? number_format(round($value['invoice_budget'])) : '--' ?></td> |
|
|
|
<td style="text-align: end;"><?= isset($value['received_budget']) ? number_format(round($value['received_budget'])) : '--' ?></td> |
|
|
|
<td style="text-align: start;"><?= $value['facilities'] ?></td> |
|
|
|
<!-- <td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
|
|
|
|
</td> --> |
|
|
|
<?php foreach ($excel_aray as $key => $row) { ?> |
|
|
|
<tr class="data-row" style="display: '';" id="<?= $key; ?>"> |
|
|
|
<td><?= $row[0]; ?></td> |
|
|
|
<td><?= $row[1]; ?></td> |
|
|
|
<td><?= $row[2] . "<br>" . $row[3]; ?></td> |
|
|
|
<td><?= $row[4] . "<br>" . $row[5]; ?></td> |
|
|
|
<td><?= $row[6] . "<br>" . $row[7]; ?></td> |
|
|
|
<td><?= $row[8]; ?></td> |
|
|
|
<td><?= $row[12]; ?></td> |
|
|
|
<td><?= $row[13]; ?></td> |
|
|
|
<td><?= $row[14]; ?></td> |
|
|
|
<td><?= $row[15]; ?></td> |
|
|
|
<td><?= $row[16]; ?></td> |
|
|
|
<td><?= $row[17]; ?></td> |
|
|
|
<td><?= $row[18]; ?></td> |
|
|
|
<td><?= $row[19]; ?></td> |
|
|
|
<td><?= $row[20]; ?></td> |
|
|
|
</tr> |
|
|
|
<?php |
|
|
|
} |
|
|
|
?> |
|
|
|
<?php } ?> |
|
|
|
</tbody> |
|
|
|
</table> |
|
|
|
</div> |
|
|
|
|
|
|
|
<script> |
|
|
|
function showContract(BillNo) { |
|
|
|
window.open('account-receivable-contract.php?BillNo=' + BillNo + '&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200'); |
|
|
|
function searchData() { |
|
|
|
var searchTerm = document.getElementById('search').value.toLowerCase(); |
|
|
|
var rows = document.getElementsByClassName('data-row'); |
|
|
|
for (var i = 0; i < rows.length; i++) { |
|
|
|
var rowText = rows[i].textContent.toLowerCase(); |
|
|
|
// var rowText = rows[i].id.toLowerCase(); |
|
|
|
if (rowText.includes(searchTerm)) { |
|
|
|
console.log(rowText); |
|
|
|
rows[i].style.display = ''; |
|
|
|
} else { |
|
|
|
rows[i].style.display = 'none'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function test() { |
|
|
|
var BillData = <?= $boga_data ?>; |
|
|
|
var form = document.createElement("form"); |
|
|
|
form.method = 'POST'; |
|
|
|
form.action = "account-receivable-excel.php?type=facility&<?= $token_link ?>"; |
|
|
|
var input = document.createElement("input"); |
|
|
|
input.type = "hidden"; |
|
|
|
input.name = "Bill"; |
|
|
|
input.value = JSON.stringify(BillData); |
|
|
|
form.appendChild(input); |
|
|
|
document.body.appendChild(form); |
|
|
|
form.submit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function downloadData() { |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
var url = window.location.origin + "/wms/account-receivable-excel.php?type=all&<?= $token_link ?>"; |
|
|
|
var url = window.location.origin + "/wms/account-receivable-renovate-excel.php?type=all&<?= $token_link ?>"; |
|
|
|
xhr.open('POST', url, true); |
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json'); |
|
|
|
xhr.onreadystatechange = function() { |
|
|
|
if (xhr.readyState === 4 && xhr.status === 200) { |
|
|
|
var file_path = xhr.responseText; |
|
|
|
var link = document.createElement('a'); |
|
|
|
var name = "全部應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx"); |
|
|
|
var name = "汰改應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
link.setAttribute('href', window.location.origin + "/wms/account-receivable-renovate.xlsx"); |
|
|
|
link.setAttribute('download', name); |
|
|
|
link.style.display = 'none'; |
|
|
|
document.body.appendChild(link); |
|
|
@ -912,85 +711,8 @@ include "./footer.php"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function bogaData() { |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
var url = window.location.origin + "/wms/account-receivable-excel.php?type=boga&<?= $token_link ?>"; |
|
|
|
xhr.open('POST', url, true); |
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json'); |
|
|
|
xhr.onreadystatechange = function() { |
|
|
|
if (xhr.readyState === 4 && xhr.status === 200) { |
|
|
|
var file_path = xhr.responseText; |
|
|
|
var link = document.createElement('a'); |
|
|
|
var name = "寶佳應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx"); |
|
|
|
link.setAttribute('download', name); |
|
|
|
link.style.display = 'none'; |
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
document.body.removeChild(link); |
|
|
|
} |
|
|
|
} |
|
|
|
xhr.send(JSON.stringify({ |
|
|
|
Bill: <?= $boga_data ?> |
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function downloadFacilityData(content) { |
|
|
|
|
|
|
|
if (content == 'AllData') { |
|
|
|
var BillData = <?= $facility_data ?>; |
|
|
|
var filename = "作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
} else if (content == 'ExcludeData') { |
|
|
|
var BillData = <?= $facility_exclude_boga_data ?>; |
|
|
|
var filename = "不含寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
} else if (content == 'BogaData') { |
|
|
|
var BillData = <?= $facility_boga_data ?>; |
|
|
|
var filename = "寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
} |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
var url = window.location.origin + "/wms/account-receivable-excel.php?type=facility&<?= $token_link ?>"; |
|
|
|
xhr.open('POST', url, true); |
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json'); |
|
|
|
xhr.onreadystatechange = function() { |
|
|
|
if (xhr.readyState === 4 && xhr.status === 200) { |
|
|
|
var file_path = xhr.responseText; |
|
|
|
var link = document.createElement('a'); |
|
|
|
link.setAttribute('href', window.location.origin + "/wms/account-receivable-facility.xlsx"); |
|
|
|
link.setAttribute('download', filename); |
|
|
|
link.style.display = 'none'; |
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
document.body.removeChild(link); |
|
|
|
} |
|
|
|
} |
|
|
|
xhr.send(JSON.stringify({ |
|
|
|
Bill: BillData |
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function exclude_bogaData() { |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
var url = window.location.origin + "/wms/account-receivable-excel.php?type=exclude_boga&<?= $token_link ?>"; |
|
|
|
xhr.open('POST', url, true); |
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json'); |
|
|
|
xhr.onreadystatechange = function() { |
|
|
|
if (xhr.readyState === 4 && xhr.status === 200) { |
|
|
|
var file_path = xhr.responseText; |
|
|
|
var link = document.createElement('a'); |
|
|
|
var name = "不含寶佳應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|
|
|
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx"); |
|
|
|
link.setAttribute('download', name); |
|
|
|
link.style.display = 'none'; |
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
document.body.removeChild(link); |
|
|
|
} |
|
|
|
} |
|
|
|
xhr.send(JSON.stringify({ |
|
|
|
Bill: <?= $exclude_boga_data ?> |
|
|
|
})); |
|
|
|
function check(searchname) { |
|
|
|
console.log(searchname); |
|
|
|
|
|
|
|
} |
|
|
|
</script> |