diff --git a/wms/account-receivable-.xlsx b/wms/account-receivable-.xlsx deleted file mode 100644 index d5274026..00000000 Binary files a/wms/account-receivable-.xlsx and /dev/null differ diff --git a/wms/account-receivable-check.php b/wms/account-receivable-check.php deleted file mode 100644 index 4ed786aa..00000000 --- a/wms/account-receivable-check.php +++ /dev/null @@ -1,201 +0,0 @@ - - -
- -
- - - -
- -
-
-
-

-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
目前應收已開發票金額未開發票金額已收金額未收金額
-
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
簽約款二次款貨抵工地款安裝款試車款官檢款交車款
-
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
發票日期發票金額收款日期收款金額說明功能
- - - - - -
-
- \ No newline at end of file diff --git a/wms/account-receivable-contract.php b/wms/account-receivable-contract.php index dc849699..dbdf791d 100644 --- a/wms/account-receivable-contract.php +++ b/wms/account-receivable-contract.php @@ -1,239 +1,2615 @@ "; -$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName -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 = '$BillNo'"; +$sum_facility = 0; +$sum_A40001 = 0; +$sum_A40008 = 0; +$sum_total_budget = 0; +$average_budget = 0; +$average_A40001 = 0; +$average_A40008 = 0; + -// T8發票 -//M220478 -$sql_invoice = "SELECT DISTINCT +$follower = find_follow($user_id); +$arrayData = []; +$receivable_array = []; +// T8發票 (有專案的發票) +$sql_invoice = "SELECT DISTINCT a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, b.ProjectId FROM arSellInvoice as a LEFT JOIN arSellInvoiceMaterial as b ON a.BillNo=b.BillNo -WHERE b.ProjectId='$BillNo'"; +WHERE DATALENGTH(b.ProjectId)>0"; + +// T8核銷 +$sql_received = "SELECT +a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount, +b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee, +c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate +FROM arWriteOffBill AS a +LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo +LEFT JOIN + (SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo + FROM arCheckBill + LEFT JOIN arCheckBillInvInfo + ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 + ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c +ON a.BillNo=c.BillNo +WHERE DATALENGTH(c.OrderBillNo) >0"; + +//T8 銷售訂單 階段收款計畫 +$sql_contract = "SELECT a.BillNo,s.BillDate, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, +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.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; + +// T8 銷售訂單 作番金額 +$sql_contract_budget = "SELECT A.BillNo, A.OAmountWithTax,A.CU_MaterialId, A.MaterialId FROM salSalesOrderDetail AS A +LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo +WHERE B.ModeId='M' AND A.ItemType=1 "; + +//作番大日程 +$sql = "SELECT +tmp2.*, +d.name AS depart_name +FROM( +SELECT + a.manager, + a2.name as manager_name, + a.name, + a.department_id, + w.salesid, + w.contractno, + w.facilityno, + w.estimated_shipping_date, + w.real_contract_arrival_date, +w.actual_tofactory_date, + w.real_arrival_date, + w.install_end_date, + w.tryrun_end_date, + w.official_check_date, + w.delivery_date +from wipwholestatus AS w +left join account AS a +ON w.salesid = a.accountid +left join account AS a2 +ON a2.accountid = a.manager +where w.status = '1' AND w.contract_type='A' +)AS tmp2 +left join ( +SELECT DISTINCT + department_id, + name +FROM department + +) AS d +ON d.department_id = tmp2.department_id "; + +//ORDER BY contractno + +// 期初收款資訊 +$sql_opening = " +SELECT * FROM account_received "; +// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的 +if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210')))) { + $sql .= " ORDER BY contractno"; + $sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId"; +} else { + $sql_contract .= "AND (s.PersonId = '$user_id'"; + // $sql_received .= " AND (PersonId = '$user_id'"; + $sql_opening .= " OR person_id = '$user_id'"; + $sql .= " WHERE salesid = '$user_id'"; + $sql_contract_budget .= " AND (PersonId = '$user_id'"; + if (count($follower) > 0) { + $column_str = "('$user_id'" . ",'"; + $column_str .= implode("','", $follower); + $column_str .= "')"; + $sql_contract .= " OR s.PersonId IN $column_str)"; + // $sql_received .= " OR PersonId IN $column_str)"; + $sql_opening .= " OR person_id IN $column_str)"; + $sql .= " OR salesid IN $column_str ORDER BY contractno"; + $sql_contract_budget .= " OR PersonId IN $column_str )ORDER BY BillNo, CU_MaterialId"; + } else { + $sql_contract .= ")"; + // $sql_received .= ")"; + $sql_opening .= ")"; + $sql .= " ORDER BY contractno"; + $sql_contract_budget .= ")"; + }; +} $contract = $conn->query($sql_contract); -$invoices = $conn->query($sql_invoice); +$received_array = $conn->query($sql_received); +$opening_data = mysqli_query($link, $sql_opening); +$invoice_data = $conn->query($sql_invoice); +$contract_budget_data = $conn->query($sql_contract_budget); -// foreach($contract as $con){ -// print_r($con); -// echo "
"; -// } +$contract_budget = array(); +foreach ($contract_budget_data as $cont) { + if (isset($contract_budget[$cont['BillNo']])) { + $contract_budget[$cont['BillNo']]['total'] += $cont['OAmountWithTax']; + } else { + $contract_budget[$cont['BillNo']]['total'] = $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']; + $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']]['A40001'] = 0; + $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']]['A40008'] = 0; + }; + 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天'); +$sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天'); +$sign120 = array('簽約後120天', '簽約後120日', '簽訂後120天'); +// 將T8合約收款階段資料依據款別分類放進arraData裡 +foreach ($contract as $cont) { + if ($cont['BillNo'] == 'SO20230801001') { + $BillNo = 'M230947'; + } elseif ($cont['BillNo'] == 'SO20230801002') { + $BillNo = 'M231067'; + } else { + $BillNo = $cont['BillNo']; + }; + $BillDate = $cont['BillDate']; + $PayStage = $cont['PayStage']; + $PlanPayDate = $cont['PlanPayDate']; + $PayAmount = $cont['PlanPayAmt']; + $partnerName = $cont['BizPartnerName']; + $EnterpriseName = $cont['EnterpriseName']; + $TaxNo = $cont['TaxNo']; + $ContactAddress = $cont['ContactAddress']; + //['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期 + //['tryrun'] 0 試車款名 1試車金額 2 試車收款日期 ['check'] 0 官檢款名 1 官檢金額 2 官檢收款日期 ['delivery'] 0 交車款名 1 交車金額 2 交車收款日期 ['final'] 0 尾款名 1 尾款金額 2 尾款收款日期 + //['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 + if (!(isset($arrayData[$BillNo]))) { + // 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 + $arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + $arrayData[$BillNo][5] = $partnerName; + $arrayData[$BillNo][6] = $EnterpriseName; + $arrayData[$BillNo][7] = $TaxNo; + $arrayData[$BillNo][8] = $ContactAddress; + $arrayData[$BillNo][9] = $BillDate; + $arrayData[$BillNo]['total_budget'] = 0; + $arrayData[$BillNo]['invoice'] = array(); + $arrayData[$BillNo]['received_budget'] = 0; + $arrayData[$BillNo]['invoice_budget'] = 0; + $arrayData[$BillNo]['sign'][1] = $arrayData[$BillNo]['second'][1] = $arrayData[$BillNo]['arrive'][1] = $arrayData[$BillNo]['install'][1] = $arrayData[$BillNo]['tryrun'][1] = $arrayData[$BillNo]['check'][1] = $arrayData[$BillNo]['delivery'][1] = $arrayData[$BillNo]['final'][1] = 0; + $arrayData[$BillNo]['sign']['min'] = $arrayData[$BillNo]['second']['min'] = $arrayData[$BillNo]['arrive']['min'] = $arrayData[$BillNo]['install']['min'] = $arrayData[$BillNo]['tryrun']['min'] = $arrayData[$BillNo]['check']['min'] = $arrayData[$BillNo]['delivery']['min'] = $arrayData[$BillNo]['final']['min'] = array(); + $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_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, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) { + $arrayData[$BillNo]['second'][0] = $PayStage; + $arrayData[$BillNo]['second'][1] = $PayAmount; + $arrayData[$BillNo]['second'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + if (isset($arrayData[$BillNo]['sign'][2]) && !is_null($arrayData[$BillNo]['sign'][2])) { + $signtime = strtotime(strval($arrayData[$BillNo]['sign'][2])); + if (in_array($PayStage, $sign60)) { + $secondtime = $signtime + (60 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$BillNo]['second'][2] = strval($secondtime); + } elseif (in_array($PayStage, $sign90)) { + $secondtime = $signtime + (90 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$BillNo]['second'][2] = strval($secondtime); + } elseif (in_array($PayStage, $sign120)) { + $secondtime = $signtime + (120 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$BillNo]['second'][2] = strval($secondtime); + } elseif (stristr($PayStage, '簽訂後30天')) { + $secondtime = $signtime + (30 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$BillNo]['second'][2] = strval($secondtime); + } + } + } elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工') || $PayStage == '寶佳出貨前30天') { + $arrayData[$BillNo]['sign'][0] = $PayStage; + $arrayData[$BillNo]['sign'][1] = $PayAmount; + $arrayData[$BillNo]['sign'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + $arrayData[$BillNo]['receivable_budget'] += $PayAmount; + if (isset($PlanPayDate) && !empty($PlanPayDate) && $PayStage != "寶佳出貨前30天") { + array_push($arrayData[$BillNo]['sign']['min'], strtotime(strval($PlanPayDate))); + array_push($arrayData[$BillNo]['sign']['max'], strtotime(strval($PlanPayDate))); + } + } elseif (stristr($PayStage, '試車')) { + $arrayData[$BillNo]['tryrun'][0] = $PayStage; + $arrayData[$BillNo]['tryrun'][1] = $PayAmount; + $arrayData[$BillNo]['tryrun'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } elseif (stristr($PayStage, '安裝') || stristr($PayStage, '貨抵工地且完工')) { + $arrayData[$BillNo]['install'][0] = $PayStage; + $arrayData[$BillNo]['install'][1] = $PayAmount; + $arrayData[$BillNo]['install'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) { + $arrayData[$BillNo]['arrive'][0] = $PayStage; + $arrayData[$BillNo]['arrive'][1] = $PayAmount; + $arrayData[$BillNo]['arrive'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) { + $arrayData[$BillNo]['delivery'][0] = $PayStage; + $arrayData[$BillNo]['delivery'][1] = $PayAmount; + $arrayData[$BillNo]['delivery'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) { + $arrayData[$BillNo]['check'][0] = $PayStage; + $arrayData[$BillNo]['check'][1] = $PayAmount; + $arrayData[$BillNo]['check'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } elseif (stristr($PayStage, '驗收完成')) { + $arrayData[$BillNo]['final'][0] = $PayStage; + $arrayData[$BillNo]['final'][1] = $PayAmount; + $arrayData[$BillNo]['final'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } else { + $arrayData[$BillNo]['other'][1] = $PayAmount; + $arrayData[$BillNo]['other'][2] = $PlanPayDate; + $arrayData[$BillNo]['total_budget'] += $PayAmount; + } +} +//取作番大日程作番與時程 +// real_contract_arrival_date 預計出貨日 +// real_arrival_date 實際出貨日 +$wipwhole_array = mysqli_query($link, $sql); +foreach ($wipwhole_array as $wip) { + $today = strtotime(date('Ymd')); + //[合約號]['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']][10] = $wip['contractno']; + $arrayData[$wip['contractno']]['total_facility_num'] += 1; + $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; + // [合約號]['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; -// foreach ($contract as $cont) { -// if ($cont['BillNo'] == 'SO20230801002') { -// $BillNo = 'M231067'; -// }else{ -// $BillNo = $cont['BillNo']; -// }; -// $PayStage = $cont['PayStage']; -// $PayAmount = $cont['PlanPayAmt']; -// $partnerName = $cont['BizPartnerName']; -// if(isset($arrayData[$BillNo])){ -// array_push($arrayData[$BillNo], $PayStage); -// array_push($arrayData[$BillNo], $PayAmount); + // [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期] + // [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] + // [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期] + $contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); + foreach ($contractstage as $i) { + $arrayData[$wip['contractno']][$wip['facilityno']][$i] = ['', 0, '', 0, 0, 0, 0]; + $arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['date'] = ""; + $arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0; + $arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = ""; + $arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['budget'] = 0; + $arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['date'] = (isset($arrayData[$wip['contractno']][$i][2])) ? $arrayData[$wip['contractno']][$i][2] : ""; + $arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['budget'] = 0; + } + // 補上寶佳 (出貨前) 收款時間 -// }else{ -// $arrayData[$BillNo][0] = $BillNo; -// $arrayData[$BillNo][1] = $partnerName; -// array_push($arrayData[$BillNo], $PayStage); -// array_push($arrayData[$BillNo], $PayAmount); + if (isset($arrayData[$wip['contractno']]['sign'][0]) && $arrayData[$wip['contractno']]['sign'][0] == '寶佳出貨前30天') { + if ($wip['real_arrival_date'] != NULL) { + $estimate_delivery_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_delivery_time - (30 * 86400); + $signtime = date('Ymd', $signtime); + $arrayData[$wip['contractno']]['sign'][2] = strval($signtime); + array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime))); + array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime))); + } elseif ($wip['real_contract_arrival_date'] != NULL) { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $signtime = $estimate_delivery_time - (30 * 86400); + $signtime = date('Ymd', $signtime); + $arrayData[$wip['contractno']]['sign'][2] = strval($signtime); + array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime))); + array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime))); + } + } + // 補上二次款 (出貨前) 收款時間,條件不是"出貨前"就pass + if (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前30天')) { + if (empty($wip['real_contract_arrival_date'])) { + } else { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $secondtime = $estimate_delivery_time - (30 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['second'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); + array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); + } + } elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前90天')) { + if (empty($wip['real_contract_arrival_date'])) { + } else { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $secondtime = $estimate_delivery_time - (90 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['second'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); + array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); + } + } elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前120天')) { + if (empty($wip['real_contract_arrival_date'])) { + } else { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $secondtime = $estimate_delivery_time - (120 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['second'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); + array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); + } + } elseif (isset($arrayData[$wip['contractno']]['second'][0]) && $arrayData[$wip['contractno']]['second'][0] == '寶佳出貨後10天') { + + if ($wip['real_arrival_date'] != NULL) { + $estimate_delivery_time = strtotime($wip['real_arrival_date']); + $secondtime = $estimate_delivery_time + (10 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['second'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); + array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); + } else { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $secondtime = $estimate_delivery_time + (10 * 86400); + $secondtime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['second'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['second']['max'], strtotime($secondtime)); + array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); + } + } + //根據作番狀態填入facilities,計算各階段數量、一個合約有幾個作番,增加作番資料 + // real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地 + // real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地 + //----------------------------------------寶佳的另外處理--------------------------------------------------- + $sign_status_tmp = !empty($arrayData[$wip['contractno']]['sign'][0]) ? $arrayData[$wip['contractno']]['sign'][0] : null; + if ($sign_status_tmp == "寶佳出貨前30天") { + // 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); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = $arrayData[$wip['contractno']]['sign'][2]; + if ($today > $contractday) { + $arrayData[$wip['contractno']]['sign_num'] += 1; + array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); + $facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過)
"; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; + //二次款 + $contractday = strtotime($arrayData[$wip['contractno']]['second'][2]); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = $arrayData[$wip['contractno']]['second'][2]; + $month = collect_month($contractday); + $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; + //貨抵工地款 + if ($wip['real_arrival_date'] != NULL) { + $estimate_time = strtotime($wip['real_arrival_date']); + $contractday = $estimate_time + (90 * 86400); + $month = collect_month($contractday); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $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; + //試車款 + if ($wip['tryrun_end_date'] != NULL) { + $estimate_time = strtotime($wip['tryrun_end_date']); + $contractday = $estimate_time + (90 * 86400); + $month = collect_month($contractday); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month; + $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; + //交車款 + if ($wip['delivery_date'] != NULL) { + $estimate_time = strtotime($wip['delivery_date']); + $contractday = $estimate_time + (270 * 86400); + $month = collect_month($contractday); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month; + $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; + } + } + } + } + } + } + } + } else { + $facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "未到)
"; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; + } + $arrayData[$wip['contractno']]['facilities'] .= $facility_status; + } else { + $sign_tmp = !empty($arrayData[$wip['contractno']]['sign'][2]) ? $arrayData[$wip['contractno']]['sign'][2] : ''; + $signtime = strtotime($sign_tmp); + // $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)); + if (isset($arrayData[$wip['contractno']]['second'][2]) && ($arrayData[$wip['contractno']]['second'][2] !== NULL)) { + $secondtime = strtotime($arrayData[$wip['contractno']]['second'][2]); + $month = collect_month($secondtime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime)); + } + if ($wip['delivery_date'] != NULL) { + $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 (isset($arrayData[$wip['contractno']]['delivery'][0]) && $arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { + $estimate_delivery_time = strtotime($wip['delivery_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $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)); + $arrivetime = date('Ymd', $arrivetime); + $arrayData[$wip['contractno']]['delivery'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime))); + 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); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $deliverytime)); + array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($wip['delivery_date']))); + array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($wip['delivery_date']))); + } + 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']))); + $checktime = strtotime($wip['official_check_date']); + $month = collect_month($checktime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][2] = strval(date('Ymd', $checktime)); + } + if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { + if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") { + $estimate_delivery_time = strtotime($wip['tryrun_end_date']); + $tryruntime = $estimate_delivery_time + (90 * 86400); + $tryruntime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime))); + array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($tryruntime))); + $month = collect_month($tryruntime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime)); + } else { + $arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']); + 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']))); + $tryruntime = strtotime($wip['tryrun_end_date']); + $month = collect_month($tryruntime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime)); + } + } + if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { + array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date']))); + array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date']))); + $installtime = strtotime($wip['install_end_date']); + $month = collect_month($installtime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime)); + } + if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { + if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrivetime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrivetime = strtotime($wip['real_arrival_date']); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); + } + } + } elseif ($wip['official_check_date'] != NULL) { + $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']))); + $checktime = strtotime($wip['official_check_date']); + $month = collect_month($checktime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][2] = strval(date('Ymd', $checktime)); + } + + if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { + if (isset($arrayData[$wip['contractno']]['tryrun'][0]) && $arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") { + $estimate_delivery_time = strtotime($wip['tryrun_end_date']); + $tryruntime = $estimate_delivery_time + (90 * 86400); + $month = collect_month($tryruntime); + $tryruntime = date('Ymd', $tryruntime); + $arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime))); + array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($tryruntime))); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval($tryruntime); + } else { + $tryruntime = strtotime($wip['tryrun_end_date']); + $month = collect_month($tryruntime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime)); + $arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']); + 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']))); + } + } + if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { + $installtime = strtotime($wip['install_end_date']); + $month = collect_month($installtime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime)); + array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date']))); + array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date']))); + } + if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { + if (isset($arrayData[$wip['contractno']]['arrive'][0]) && $arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrivetime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); + $arrivetime = strtotime($wip['real_arrival_date']); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + } + } else { + if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $arrivetime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); + } + } + } elseif ($wip['tryrun_end_date'] != NULL) { + $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']))); + $tryruntime = strtotime($wip['tryrun_end_date']); + $month = collect_month($tryruntime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime)); + } + if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { + array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date']))); + array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date']))); + $installtime = strtotime($wip['install_end_date']); + $month = collect_month($installtime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime)); + } + if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { + if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrivetime = date('Ymd', $arrivetime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrivetime = strtotime($wip['real_arrival_date']); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); + } + } else { + if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $arrivetime = date('Ymd', $arrivetime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); + } + } + } elseif ($wip['install_end_date'] != NULL) { + $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); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime)); + array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date']))); + array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date'])))); + } + if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { + if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrivetime = date('Ymd', $arrivetime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrivetime = strtotime($wip['real_arrival_date']); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); + } + } else { + if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { + $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $arrivetime = date('Ymd', $secondtime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); + } + } + } elseif ($wip['real_arrival_date'] != NULL) { + $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']); + $arrivetime = $estimate_delivery_time + (90 * 86400); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrivetime = date('Ymd', $arrivetime); + $arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); + } else { + $arrivetime = strtotime($wip['real_arrival_date']); + $month = collect_month($arrivetime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime)); + $arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); + array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); + array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); + } + } elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) { + $secondtime = strtotime($arrayData[$wip['contractno']]['second'][2]); + $month = collect_month($secondtime); + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime)); + $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'] . "預計出貨日)
"; + } elseif ($wip['estimated_shipping_date'] != NULL) { + $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日)
"; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日)
"; + } else { + $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認)
"; + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (預計出港日待確認)
"; + } + } + } + } +} +// 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."========="; // } -// }; -// foreach($arrayData as $data){ -// foreach($data as $value){ -// echo $value.";"; -// } -// echo "
"; // } +// 計算每個合約的應收款、作番總數 +$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d'))))); +$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); +foreach ($arrayData as &$value) { + if ($value['total_facility_num'] > 0) { + $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 催收次數 + // 計算每台作番金額與各階段應收金額 + if (isset($value['facility'])) { + foreach ($value['facility'] as &$val) { + foreach ($contractstage as $stage) { + if (isset($value[$stage][0]) && !empty($value[$stage][0])) { + $val[$stage][0] = $value[$stage][0]; + 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]; + } + } + } + } + + + + // 計算最大催收次數與最小催收次數 + foreach ($contractstage as $i) { + if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) { + $latest_timestamp = max($value[$i]['min']); + $latest_date = new DateTime(); + $latest_date->setTimestamp($latest_timestamp); + if ($latest_date < $today_date) { + $interval = $latest_date->diff($today_date); + $month = $interval->format('%m'); + $value[$i]['min'] = $month; + } else { + $value[$i]['min'] = 0; + } + } else { + $value[$i]['min'] = 0; + }; + if (!empty($value[$i]['max']) && count($value[$i]['max']) > 0) { + $latest_timestamp = min($value[$i]['max']); + $latest_date = new DateTime(); + $latest_date->setTimestamp($latest_timestamp); + if ($latest_date < $today_date) { + $interval = $latest_date->diff($today_date); + $month = $interval->format('%m'); + $value[$i]['max'] = $month; + } else { + $value[$i]['max'] = 0; + } + } else { + $value[$i]['max'] = 0; + }; + } +} + +// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期] +// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] +// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期] +foreach ($wipwhole_array as $wip) { + if (isset($arrayData[$wip['contractno']]) && isset($arrayData[$wip['contractno']][$wip['facilityno']]) && !empty($arrayData[$wip['contractno']]['total_facility_num'])) { + $stagearray = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); + foreach ($stagearray as $stage) { + $arrayData[$wip['contractno']][$wip['facilityno']][$stage]['con'] = $arrayData[$wip['contractno']][$stage][1] / $arrayData[$wip['contractno']]['total_facility_num']; + } + } +} +// [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']]; + } +} + +// 把核銷單的內容補到發票資料中 +foreach ($received_array as $received) { + if ($received['OrderBillNo'] == 'SO20230801001') { + $BillNo = 'M230947'; + } elseif ($received['OrderBillNo'] == 'SO20230801002') { + $BillNo = 'M231067'; + } else { + $BillNo = $received['OrderBillNo']; + }; + if (isset($arrayData[$BillNo])) { + if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { + $arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; + array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); + } + } +} + +//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 4 已收金額 5 催收金額 6 已開發票金額 7 未開發票金額 min 最早應收月份 max 最晚應收月份 +foreach ($arrayData as $key => &$data) { + //['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 7 已開發票金額 8 未開發票金額 + //作番 + $facilities = array(); + if (isset($data['facility'])) { + foreach ($data['facility'] as $fakey => $val) { + array_push($facilities, $fakey); + } + } + + $tmp_data = $data['received_budget']; + $tmp_invoice = $data['invoice_budget']; + if (isset($data['sign'][3]) && $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]; + $tmp_facility_received = $data['sign'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['sign'][3]) && $data['facility'][$this_facility]['sign'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['sign'][3]) { + $data['facility'][$this_facility]['sign'][4] = $data['facility'][$this_facility]['sign'][3]; + $data['facility'][$this_facility]['sign'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['sign'][3]; + } else { + $data['facility'][$this_facility]['sign'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['sign'][5] = $data['facility'][$this_facility]['sign'][3] - $data['facility'][$this_facility]['sign'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['sign'][4] = 0; + $data['facility'][$this_facility]['sign'][5] = $data['facility'][$this_facility]['sign'][3]; + } + } else { + $data['facility'][$this_facility]['sign'][4] = 0; + $data['facility'][$this_facility]['sign'][5] = 0; + } + if ($data['facility'][$this_facility]['sign'][5] == 0) { + $data['facility'][$this_facility]['sign'][6] = 0; + } + } + } else { + $data['sign'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['sign'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['sign'][3]) && $data['facility'][$this_facility]['sign'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['sign'][3]) { + $data['facility'][$this_facility]['sign'][4] = $data['facility'][$this_facility]['sign'][3]; + $data['facility'][$this_facility]['sign'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['sign'][3]; + } else { + $data['facility'][$this_facility]['sign'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['sign'][5] = $data['facility'][$this_facility]['sign'][3] - $data['facility'][$this_facility]['sign'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['sign'][4] = 0; + $data['facility'][$this_facility]['sign'][5] = $data['facility'][$this_facility]['sign'][3]; + } + } else { + $data['facility'][$this_facility]['sign'][4] = 0; + $data['facility'][$this_facility]['sign'][5] = 0; + } + if ($data['facility'][$this_facility]['sign'][5] == 0) { + $data['facility'][$this_facility]['sign'][6] = 0; + } + } + } + $data['sign'][5] = $data['sign'][3] - $data['sign'][4]; + } else { + $data['sign'][4] = 0; + $data['sign'][5] = $data['sign'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['sign'][4] = 0; + $data['facility'][$this_facility]['sign'][5] = $data['facility'][$this_facility]['sign'][3]; + if ($data['facility'][$this_facility]['sign'][5] == 0) { + $data['facility'][$this_facility]['sign'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['sign'][3]) >= 0) { + $data['sign'][6] = $data['sign'][3]; + $tmp_invoice -= $data['sign'][3]; + $tmp_facility_invoice = $data['sign'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['sign'][3]) && $data['facility'][$this_facility]['sign'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['sign'][3]) { + $data['facility'][$this_facility]['sign'][7] = $data['facility'][$this_facility]['sign'][3]; + $data['facility'][$this_facility]['sign'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['sign'][3]; + } else { + $data['facility'][$this_facility]['sign'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['sign'][8] = $data['facility'][$this_facility]['sign'][3] - $data['facility'][$this_facility]['sign'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['sign'][7] = 0; + $data['facility'][$this_facility]['sign'][8] = $data['facility'][$this_facility]['sign'][3]; + } + } else { + $data['facility'][$this_facility]['sign'][7] = 0; + $data['facility'][$this_facility]['sign'][8] = 0; + } + + } + } else { + $data['sign'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['sign'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['sign'][3]) && $data['facility'][$this_facility]['sign'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['sign'][3]) { + $data['facility'][$this_facility]['sign'][7] = $data['facility'][$this_facility]['sign'][3]; + $data['facility'][$this_facility]['sign'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['sign'][3]; + } else { + $data['facility'][$this_facility]['sign'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['sign'][8] = $data['facility'][$this_facility]['sign'][3] - $data['facility'][$this_facility]['sign'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['sign'][7] = 0; + $data['facility'][$this_facility]['sign'][8] = $data['facility'][$this_facility]['sign'][3]; + } + } else { + $data['facility'][$this_facility]['sign'][7] = 0; + $data['facility'][$this_facility]['sign'][8] = 0; + } + } + } + $data['sign'][7] = $data['sign'][3] - $data['sign'][6]; + } else { + $data['sign'][6] = 0; + $data['sign'][7] = $data['sign'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['sign'][7] = 0; + $data['facility'][$this_facility]['sign'][8] = $data['facility'][$this_facility]['sign'][3]; + } + } + } else { + $data['sign'][4] = 0; + $data['sign'][5] = 0; + $data['sign'][6] = 0; + $data['sign'][7] = 0; + } + if (isset($data['second'][3]) && $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]; + $tmp_facility_received = $data['second'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['second'][3]) && $data['facility'][$this_facility]['second'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['second'][3]) { + $data['facility'][$this_facility]['second'][4] = $data['facility'][$this_facility]['second'][3]; + $data['facility'][$this_facility]['second'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['second'][3]; + } else { + $data['facility'][$this_facility]['second'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['second'][5] = $data['facility'][$this_facility]['second'][3] - $data['facility'][$this_facility]['second'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['second'][4] = 0; + $data['facility'][$this_facility]['second'][5] = $data['facility'][$this_facility]['second'][3]; + } + } else { + $data['facility'][$this_facility]['second'][4] = 0; + $data['facility'][$this_facility]['second'][5] = 0; + $data['facility'][$this_facility]['second'][6] = 0; + } + if ($data['facility'][$this_facility]['second'][5] == 0) { + $data['facility'][$this_facility]['second'][6] = 0; + } + } + } else { + $data['second'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['second'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['second'][3]) && $data['facility'][$this_facility]['second'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['second'][3]) { + $data['facility'][$this_facility]['second'][4] = $data['facility'][$this_facility]['second'][3]; + $data['facility'][$this_facility]['second'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['second'][3]; + } else { + $data['facility'][$this_facility]['second'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['second'][5] = $data['facility'][$this_facility]['second'][3] - $data['facility'][$this_facility]['second'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['second'][4] = 0; + $data['facility'][$this_facility]['second'][5] = $data['facility'][$this_facility]['second'][3]; + } + } else { + $data['facility'][$this_facility]['second'][4] = 0; + $data['facility'][$this_facility]['second'][5] = 0; + $data['facility'][$this_facility]['second'][6] = 0; + } + if ($data['facility'][$this_facility]['second'][5] == 0) { + $data['facility'][$this_facility]['second'][6] = 0; + } + } + } + $data['second'][5] = $data['second'][3] - $data['second'][4]; + } else { + $data['second'][4] = 0; + $data['second'][5] = $data['second'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['second'][4] = 0; + $data['facility'][$this_facility]['second'][5] = $data['facility'][$this_facility]['second'][3]; + if ($data['facility'][$this_facility]['second'][5] == 0) { + $data['facility'][$this_facility]['second'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['second'][3]) >= 0) { + $data['second'][6] = $data['second'][3]; + $tmp_invoice -= $data['second'][3]; + $tmp_facility_invoice = $data['second'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['second'][3]) && $data['facility'][$this_facility]['second'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['second'][3]) { + $data['facility'][$this_facility]['second'][7] = $data['facility'][$this_facility]['second'][3]; + $data['facility'][$this_facility]['second'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['second'][3]; + } else { + $data['facility'][$this_facility]['second'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['second'][8] = $data['facility'][$this_facility]['second'][3] - $data['facility'][$this_facility]['second'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['second'][7] = 0; + $data['facility'][$this_facility]['second'][8] = $data['facility'][$this_facility]['second'][3]; + } + } else { + $data['facility'][$this_facility]['second'][7] = 0; + $data['facility'][$this_facility]['second'][8] = 0; + } + + } + } else { + $data['second'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['second'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['second'][3]) && $data['facility'][$this_facility]['second'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['second'][3]) { + $data['facility'][$this_facility]['second'][7] = $data['facility'][$this_facility]['second'][3]; + $data['facility'][$this_facility]['second'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['second'][3]; + } else { + $data['facility'][$this_facility]['second'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['second'][8] = $data['facility'][$this_facility]['second'][3] - $data['facility'][$this_facility]['second'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['second'][7] = 0; + $data['facility'][$this_facility]['second'][8] = $data['facility'][$this_facility]['second'][3]; + } + } else { + $data['facility'][$this_facility]['second'][7] = 0; + $data['facility'][$this_facility]['second'][8] = 0; + } + } + } + $data['second'][7] = $data['second'][3] - $data['second'][6]; + } else { + $data['second'][6] = 0; + $data['second'][7] = $data['second'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['second'][7] = 0; + $data['facility'][$this_facility]['second'][8] = $data['facility'][$this_facility]['second'][3]; + } + } + } else { + $data['second'][4] = 0; + $data['second'][5] = 0; + $data['second'][6] = 0; + $data['second'][7] = 0; + } + + if (isset($data['arrive'][3]) && $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]; + $tmp_facility_received = $data['arrive'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['arrive'][3]) && $data['facility'][$this_facility]['arrive'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['arrive'][3]) { + $data['facility'][$this_facility]['arrive'][4] = $data['facility'][$this_facility]['arrive'][3]; + $data['facility'][$this_facility]['arrive'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['arrive'][3]; + } else { + $data['facility'][$this_facility]['arrive'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['arrive'][5] = $data['facility'][$this_facility]['arrive'][3] - $data['facility'][$this_facility]['arrive'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['arrive'][4] = 0; + $data['facility'][$this_facility]['arrive'][5] = $data['facility'][$this_facility]['arrive'][3]; + } + } else { + $data['facility'][$this_facility]['arrive'][4] = 0; + $data['facility'][$this_facility]['arrive'][5] = 0; + $data['facility'][$this_facility]['arrive'][6] = 0; + } + if ($data['facility'][$this_facility]['arrive'][5] == 0) { + $data['facility'][$this_facility]['arrive'][6] = 0; + } + } + } else { + $data['arrive'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['arrive'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['arrive'][3]) && $data['facility'][$this_facility]['arrive'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['arrive'][3]) { + $data['facility'][$this_facility]['arrive'][4] = $data['facility'][$this_facility]['arrive'][3]; + $data['facility'][$this_facility]['arrive'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['arrive'][3]; + } else { + $data['facility'][$this_facility]['arrive'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['arrive'][5] = $data['facility'][$this_facility]['arrive'][3] - $data['facility'][$this_facility]['arrive'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['arrive'][4] = 0; + $data['facility'][$this_facility]['arrive'][5] = $data['facility'][$this_facility]['arrive'][3]; + } + } else { + $data['facility'][$this_facility]['arrive'][4] = 0; + $data['facility'][$this_facility]['arrive'][5] = 0; + $data['facility'][$this_facility]['arrive'][6] = 0; + } + if ($data['facility'][$this_facility]['arrive'][5] == 0) { + $data['facility'][$this_facility]['arrive'][6] = 0; + } + } + } + $data['arrive'][5] = $data['arrive'][3] - $data['arrive'][4]; + } else { + $data['arrive'][4] = 0; + $data['arrive'][5] = $data['arrive'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['arrive'][4] = 0; + $data['facility'][$this_facility]['arrive'][5] = $data['facility'][$this_facility]['arrive'][3]; + if ($data['facility'][$this_facility]['arrive'][5] == 0) { + $data['facility'][$this_facility]['arrive'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['arrive'][3]) >= 0) { + $data['arrive'][6] = $data['arrive'][3]; + $tmp_invoice -= $data['arrive'][3]; + $tmp_facility_invoice = $data['arrive'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['arrive'][3]) && $data['facility'][$this_facility]['arrive'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['arrive'][3]) { + $data['facility'][$this_facility]['arrive'][7] = $data['facility'][$this_facility]['arrive'][3]; + $data['facility'][$this_facility]['arrive'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['sign'][3]; + } else { + $data['facility'][$this_facility]['arrive'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['arrive'][8] = $data['facility'][$this_facility]['arrive'][3] - $data['facility'][$this_facility]['arrive'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['arrive'][7] = 0; + $data['facility'][$this_facility]['arrive'][8] = $data['facility'][$this_facility]['arrive'][3]; + } + } else { + $data['facility'][$this_facility]['arrive'][7] = 0; + $data['facility'][$this_facility]['arrive'][8] = 0; + } + + } + } else { + $data['arrive'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['arrive'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['arrive'][3]) && $data['facility'][$this_facility]['arrive'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['arrive'][3]) { + $data['facility'][$this_facility]['arrive'][7] = $data['facility'][$this_facility]['arrive'][3]; + $data['facility'][$this_facility]['arrive'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['arrive'][3]; + } else { + $data['facility'][$this_facility]['arrive'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['arrive'][8] = $data['facility'][$this_facility]['arrive'][3] - $data['facility'][$this_facility]['arrive'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['arrive'][7] = 0; + $data['facility'][$this_facility]['arrive'][8] = $data['facility'][$this_facility]['arrive'][3]; + } + } else { + $data['facility'][$this_facility]['arrive'][7] = 0; + $data['facility'][$this_facility]['arrive'][8] = 0; + } + } + } + $data['arrive'][7] = $data['arrive'][3] - $data['arrive'][6]; + } else { + $data['arrive'][6] = 0; + $data['arrive'][7] = $data['arrive'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['arrive'][7] = 0; + $data['facility'][$this_facility]['arrive'][8] = $data['facility'][$this_facility]['arrive'][3]; + } + } + } else { + $data['arrive'][4] = 0; + $data['arrive'][5] = 0; + $data['arrive'][6] = 0; + $data['arrive'][7] = 0; + } + + if (isset($data['install'][3]) && $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]; + $tmp_facility_received = $data['install'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['install'][3]) && $data['facility'][$this_facility]['install'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['install'][3]) { + $data['facility'][$this_facility]['install'][4] = $data['facility'][$this_facility]['install'][3]; + $data['facility'][$this_facility]['install'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['install'][3]; + } else { + $data['facility'][$this_facility]['install'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['install'][5] = $data['facility'][$this_facility]['install'][3] - $data['facility'][$this_facility]['install'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['install'][4] = 0; + $data['facility'][$this_facility]['install'][5] = $data['facility'][$this_facility]['install'][3]; + } + } else { + $data['facility'][$this_facility]['install'][4] = 0; + $data['facility'][$this_facility]['install'][5] = 0; + $data['facility'][$this_facility]['install'][6] = 0; + } + if ($data['facility'][$this_facility]['install'][5] == 0) { + $data['facility'][$this_facility]['install'][6] = 0; + } + } + } else { + $data['install'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['install'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['install'][3]) && $data['facility'][$this_facility]['install'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['install'][3]) { + $data['facility'][$this_facility]['install'][4] = $data['facility'][$this_facility]['install'][3]; + $data['facility'][$this_facility]['install'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['install'][3]; + } else { + $data['facility'][$this_facility]['install'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['install'][5] = $data['facility'][$this_facility]['install'][3] - $data['facility'][$this_facility]['install'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['install'][4] = 0; + $data['facility'][$this_facility]['install'][5] = $data['facility'][$this_facility]['install'][3]; + } + } else { + $data['facility'][$this_facility]['install'][4] = 0; + $data['facility'][$this_facility]['install'][5] = 0; + $data['facility'][$this_facility]['install'][6] = 0; + } + if ($data['facility'][$this_facility]['install'][5] == 0) { + $data['facility'][$this_facility]['install'][6] = 0; + } + } + } + $data['install'][5] = $data['install'][3] - $data['install'][4]; + } else { + $data['install'][4] = 0; + $data['install'][5] = $data['install'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['install'][4] = 0; + $data['facility'][$this_facility]['install'][5] = $data['facility'][$this_facility]['install'][3]; + if ($data['facility'][$this_facility]['install'][5] == 0) { + $data['facility'][$this_facility]['install'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['install'][3]) >= 0) { + $data['install'][6] = $data['install'][3]; + $tmp_invoice -= $data['install'][3]; + $tmp_facility_invoice = $data['install'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['install'][3]) && $data['facility'][$this_facility]['install'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['install'][3]) { + $data['facility'][$this_facility]['install'][7] = $data['facility'][$this_facility]['install'][3]; + $data['facility'][$this_facility]['install'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['install'][3]; + } else { + $data['facility'][$this_facility]['install'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['install'][8] = $data['facility'][$this_facility]['install'][3] - $data['facility'][$this_facility]['install'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['install'][7] = 0; + $data['facility'][$this_facility]['install'][8] = $data['facility'][$this_facility]['install'][3]; + } + } else { + $data['facility'][$this_facility]['install'][7] = 0; + $data['facility'][$this_facility]['install'][8] = 0; + } + + } + } else { + $data['install'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['install'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['install'][3]) && $data['facility'][$this_facility]['install'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['install'][3]) { + $data['facility'][$this_facility]['install'][7] = $data['facility'][$this_facility]['install'][3]; + $data['facility'][$this_facility]['install'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['install'][3]; + } else { + $data['facility'][$this_facility]['install'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['install'][8] = $data['facility'][$this_facility]['install'][3] - $data['facility'][$this_facility]['install'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['install'][7] = 0; + $data['facility'][$this_facility]['install'][8] = $data['facility'][$this_facility]['install'][3]; + } + } else { + $data['facility'][$this_facility]['install'][7] = 0; + $data['facility'][$this_facility]['install'][8] = 0; + } + } + } + $data['install'][7] = $data['install'][3] - $data['install'][6]; + } else { + $data['install'][6] = 0; + $data['install'][7] = $data['install'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['install'][7] = 0; + $data['facility'][$this_facility]['install'][8] = $data['facility'][$this_facility]['install'][3]; + } + } + } else { + $data['install'][4] = 0; + $data['install'][5] = 0; + $data['install'][6] = 0; + $data['install'][7] = 0; + } + + + if (isset($data['tryrun'][3]) && $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]; + $tmp_facility_received = $data['tryrun'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['tryrun'][3]) && $data['facility'][$this_facility]['tryrun'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['tryrun'][3]) { + $data['facility'][$this_facility]['tryrun'][4] = $data['facility'][$this_facility]['tryrun'][3]; + $data['facility'][$this_facility]['tryrun'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['tryrun'][3]; + } else { + $data['facility'][$this_facility]['tryrun'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['tryrun'][5] = $data['facility'][$this_facility]['tryrun'][3] - $data['facility'][$this_facility]['tryrun'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['tryrun'][4] = 0; + $data['facility'][$this_facility]['tryrun'][5] = $data['facility'][$this_facility]['tryrun'][3]; + } + } else { + $data['facility'][$this_facility]['tryrun'][4] = 0; + $data['facility'][$this_facility]['tryrun'][5] = 0; + $data['facility'][$this_facility]['tryrun'][6] = 0; + } + if ($data['facility'][$this_facility]['tryrun'][5] == 0) { + $data['facility'][$this_facility]['tryrun'][6] = 0; + } + } + } else { + $data['tryrun'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['tryrun'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['tryrun'][3]) && $data['facility'][$this_facility]['tryrun'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['tryrun'][3]) { + $data['facility'][$this_facility]['tryrun'][4] = $data['facility'][$this_facility]['tryrun'][3]; + $data['facility'][$this_facility]['tryrun'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['tryrun'][3]; + } else { + $data['facility'][$this_facility]['tryrun'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['tryrun'][5] = $data['facility'][$this_facility]['tryrun'][3] - $data['facility'][$this_facility]['tryrun'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['tryrun'][4] = 0; + $data['facility'][$this_facility]['tryrun'][5] = $data['facility'][$this_facility]['tryrun'][3]; + } + } else { + $data['facility'][$this_facility]['tryrun'][4] = 0; + $data['facility'][$this_facility]['tryrun'][5] = 0; + $data['facility'][$this_facility]['tryrun'][6] = 0; + } + if ($data['facility'][$this_facility]['tryrun'][5] == 0) { + $data['facility'][$this_facility]['tryrun'][6] = 0; + } + } + } + $data['tryrun'][5] = $data['tryrun'][3] - $data['tryrun'][4]; + } else { + $data['tryrun'][4] = 0; + $data['tryrun'][5] = $data['tryrun'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['tryrun'][4] = 0; + $data['facility'][$this_facility]['tryrun'][5] = $data['facility'][$this_facility]['tryrun'][3]; + if ($data['facility'][$this_facility]['tryrun'][5] == 0) { + $data['facility'][$this_facility]['tryrun'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['tryrun'][3]) >= 0) { + $data['tryrun'][6] = $data['tryrun'][3]; + $tmp_invoice -= $data['tryrun'][3]; + $tmp_facility_invoice = $data['tryrun'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['tryrun'][3]) && $data['facility'][$this_facility]['tryrun'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['tryrun'][3]) { + $data['facility'][$this_facility]['tryrun'][7] = $data['facility'][$this_facility]['tryrun'][3]; + $data['facility'][$this_facility]['tryrun'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['tryrun'][3]; + } else { + $data['facility'][$this_facility]['tryrun'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['tryrun'][8] = $data['facility'][$this_facility]['tryrun'][3] - $data['facility'][$this_facility]['tryrun'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['tryrun'][7] = 0; + $data['facility'][$this_facility]['tryrun'][8] = $data['facility'][$this_facility]['tryrun'][3]; + } + } else { + $data['facility'][$this_facility]['tryrun'][7] = 0; + $data['facility'][$this_facility]['tryrun'][8] = 0; + } + + } + } else { + $data['tryrun'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['tryrun'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['tryrun'][3]) && $data['facility'][$this_facility]['tryrun'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['tryrun'][3]) { + $data['facility'][$this_facility]['tryrun'][7] = $data['facility'][$this_facility]['tryrun'][3]; + $data['facility'][$this_facility]['tryrun'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['tryrun'][3]; + } else { + $data['facility'][$this_facility]['tryrun'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['tryrun'][8] = $data['facility'][$this_facility]['tryrun'][3] - $data['facility'][$this_facility]['tryrun'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['tryrun'][7] = 0; + $data['facility'][$this_facility]['tryrun'][8] = $data['facility'][$this_facility]['tryrun'][3]; + } + } else { + $data['facility'][$this_facility]['tryrun'][7] = 0; + $data['facility'][$this_facility]['tryrun'][8] = 0; + } + } + } + $data['tryrun'][7] = $data['tryrun'][3] - $data['tryrun'][6]; + } else { + $data['tryrun'][6] = 0; + $data['tryrun'][7] = $data['tryrun'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['tryrun'][7] = 0; + $data['facility'][$this_facility]['tryrun'][8] = $data['facility'][$this_facility]['tryrun'][3]; + } + } + } else { + $data['tryrun'][4] = 0; + $data['tryrun'][5] = 0; + $data['tryrun'][6] = 0; + $data['tryrun'][7] = 0; + } + + if (isset($data['check'][3]) && $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]; + $tmp_facility_received = $data['check'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['check'][3]) && $data['facility'][$this_facility]['check'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['check'][3]) { + $data['facility'][$this_facility]['check'][4] = $data['facility'][$this_facility]['check'][3]; + $data['facility'][$this_facility]['check'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['check'][3]; + } else { + $data['facility'][$this_facility]['check'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['check'][5] = $data['facility'][$this_facility]['check'][3] - $data['facility'][$this_facility]['check'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['check'][4] = 0; + $data['facility'][$this_facility]['check'][5] = $data['facility'][$this_facility]['check'][3]; + } + } else { + $data['facility'][$this_facility]['check'][4] = 0; + $data['facility'][$this_facility]['check'][5] = 0; + $data['facility'][$this_facility]['check'][6] = 0; + } + if ($data['facility'][$this_facility]['check'][5] == 0) { + $data['facility'][$this_facility]['check'][6] = 0; + } + } + } else { + $data['check'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['check'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['check'][3]) && $data['facility'][$this_facility]['check'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['check'][3]) { + $data['facility'][$this_facility]['check'][4] = $data['facility'][$this_facility]['check'][3]; + $data['facility'][$this_facility]['check'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['check'][3]; + } else { + $data['facility'][$this_facility]['check'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['check'][5] = $data['facility'][$this_facility]['check'][3] - $data['facility'][$this_facility]['check'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['check'][4] = 0; + $data['facility'][$this_facility]['check'][5] = $data['facility'][$this_facility]['check'][3]; + } + } else { + $data['facility'][$this_facility]['check'][4] = 0; + $data['facility'][$this_facility]['check'][5] = 0; + $data['facility'][$this_facility]['check'][6] = 0; + } + if ($data['facility'][$this_facility]['check'][5] == 0) { + $data['facility'][$this_facility]['check'][6] = 0; + } + } + } + $data['check'][5] = $data['check'][3] - $data['check'][4]; + } else { + $data['check'][4] = 0; + $data['check'][5] = $data['check'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['check'][4] = 0; + $data['facility'][$this_facility]['check'][5] = $data['facility'][$this_facility]['check'][3]; + if ($data['facility'][$this_facility]['check'][5] == 0) { + $data['facility'][$this_facility]['check'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['check'][3]) >= 0) { + $data['check'][6] = $data['check'][3]; + $tmp_invoice -= $data['check'][3]; + $tmp_facility_invoice = $data['check'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['check'][3]) && $data['facility'][$this_facility]['check'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['check'][3]) { + $data['facility'][$this_facility]['check'][7] = $data['facility'][$this_facility]['check'][3]; + $data['facility'][$this_facility]['check'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['check'][3]; + } else { + $data['facility'][$this_facility]['check'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['check'][8] = $data['facility'][$this_facility]['check'][3] - $data['facility'][$this_facility]['check'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['check'][7] = 0; + $data['facility'][$this_facility]['check'][8] = $data['facility'][$this_facility]['check'][3]; + } + } else { + $data['facility'][$this_facility]['check'][7] = 0; + $data['facility'][$this_facility]['check'][8] = 0; + } + + } + } else { + $data['check'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['check'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['check'][3]) && $data['facility'][$this_facility]['check'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['check'][3]) { + $data['facility'][$this_facility]['check'][7] = $data['facility'][$this_facility]['check'][3]; + $data['facility'][$this_facility]['check'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['check'][3]; + } else { + $data['facility'][$this_facility]['check'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['check'][8] = $data['facility'][$this_facility]['check'][3] - $data['facility'][$this_facility]['check'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['check'][7] = 0; + $data['facility'][$this_facility]['check'][8] = $data['facility'][$this_facility]['check'][3]; + } + } else { + $data['facility'][$this_facility]['check'][7] = 0; + $data['facility'][$this_facility]['check'][8] = 0; + } + } + } + $data['check'][7] = $data['check'][3] - $data['check'][6]; + } else { + $data['check'][6] = 0; + $data['check'][7] = $data['check'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['check'][7] = 0; + $data['facility'][$this_facility]['check'][8] = $data['facility'][$this_facility]['check'][3]; + } + } + } else { + $data['check'][4] = 0; + $data['check'][5] = 0; + $data['check'][6] = 0; + $data['check'][7] = 0; + } + if (isset($data['delivery'][3]) && $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]; + $tmp_facility_received = $data['delivery'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['delivery'][3]) && $data['facility'][$this_facility]['delivery'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['delivery'][3]) { + $data['facility'][$this_facility]['delivery'][4] = $data['facility'][$this_facility]['delivery'][3]; + $data['facility'][$this_facility]['delivery'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['delivery'][3]; + } else { + $data['facility'][$this_facility]['delivery'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['delivery'][5] = $data['facility'][$this_facility]['delivery'][3] - $data['facility'][$this_facility]['delivery'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['delivery'][4] = 0; + $data['facility'][$this_facility]['delivery'][5] = $data['facility'][$this_facility]['delivery'][3]; + } + } else { + $data['facility'][$this_facility]['delivery'][4] = 0; + $data['facility'][$this_facility]['delivery'][5] = 0; + $data['facility'][$this_facility]['delivery'][6] = 0; + } + if ($data['facility'][$this_facility]['delivery'][5] == 0) { + $data['facility'][$this_facility]['delivery'][6] = 0; + } + } + } else { + $data['delivery'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['delivery'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['delivery'][3]) && $data['facility'][$this_facility]['delivery'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['delivery'][3]) { + $data['facility'][$this_facility]['delivery'][4] = $data['facility'][$this_facility]['delivery'][3]; + $data['facility'][$this_facility]['delivery'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['delivery'][3]; + } else { + $data['facility'][$this_facility]['delivery'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['delivery'][5] = $data['facility'][$this_facility]['delivery'][3] - $data['facility'][$this_facility]['delivery'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['delivery'][4] = 0; + $data['facility'][$this_facility]['delivery'][5] = $data['facility'][$this_facility]['delivery'][3]; + } + } else { + $data['facility'][$this_facility]['delivery'][4] = 0; + $data['facility'][$this_facility]['delivery'][5] = 0; + $data['facility'][$this_facility]['delivery'][6] = 0; + } + if ($data['facility'][$this_facility]['delivery'][5] == 0) { + $data['facility'][$this_facility]['delivery'][6] = 0; + } + } + } + $data['delivery'][5] = $data['delivery'][3] - $data['delivery'][4]; + } else { + $data['delivery'][4] = 0; + $data['delivery'][5] = $data['delivery'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['delivery'][4] = 0; + $data['facility'][$this_facility]['delivery'][5] = $data['facility'][$this_facility]['delivery'][3]; + if ($data['facility'][$this_facility]['sign'][5] == 0) { + $data['facility'][$this_facility]['sign'][6] = 0; + } + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['delivery'][3]) >= 0) { + $data['delivery'][6] = $data['delivery'][3]; + $tmp_invoice -= $data['delivery'][3]; + $tmp_facility_invoice = $data['delivery'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['delivery'][3]) && $data['facility'][$this_facility]['delivery'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['delivery'][3]) { + $data['facility'][$this_facility]['delivery'][7] = $data['facility'][$this_facility]['delivery'][3]; + $data['facility'][$this_facility]['delivery'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['sign'][3]; + } else { + $data['facility'][$this_facility]['delivery'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['delivery'][8] = $data['facility'][$this_facility]['delivery'][3] - $data['facility'][$this_facility]['delivery'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['delivery'][7] = 0; + $data['facility'][$this_facility]['delivery'][8] = $data['facility'][$this_facility]['delivery'][3]; + } + } else { + $data['facility'][$this_facility]['delivery'][7] = 0; + $data['facility'][$this_facility]['delivery'][8] = 0; + } + + } + } else { + $data['delivery'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['delivery'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['delivery'][3]) && $data['facility'][$this_facility]['delivery'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['delivery'][3]) { + $data['facility'][$this_facility]['delivery'][7] = $data['facility'][$this_facility]['delivery'][3]; + $data['facility'][$this_facility]['delivery'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['delivery'][3]; + } else { + $data['facility'][$this_facility]['delivery'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['delivery'][8] = $data['facility'][$this_facility]['delivery'][3] - $data['facility'][$this_facility]['delivery'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['delivery'][7] = 0; + $data['facility'][$this_facility]['delivery'][8] = $data['facility'][$this_facility]['delivery'][3]; + } + } else { + $data['facility'][$this_facility]['delivery'][7] = 0; + $data['facility'][$this_facility]['delivery'][8] = 0; + } + } + } + $data['delivery'][7] = $data['delivery'][3] - $data['delivery'][6]; + } else { + $data['delivery'][6] = 0; + $data['delivery'][7] = $data['delivery'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['delivery'][7] = 0; + $data['facility'][$this_facility]['delivery'][8] = $data['facility'][$this_facility]['delivery'][3]; + } + } + } else { + $data['delivery'][4] = 0; + $data['delivery'][5] = 0; + $data['delivery'][6] = 0; + $data['delivery'][7] = 0; + } + + if (isset($data['final'][3]) && $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]; + $tmp_facility_received = $data['final'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['final'][3]) && $data['facility'][$this_facility]['final'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['final'][3]) { + $data['facility'][$this_facility]['final'][4] = $data['facility'][$this_facility]['final'][3]; + $data['facility'][$this_facility]['final'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['final'][3]; + } else { + $data['facility'][$this_facility]['final'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['final'][5] = $data['facility'][$this_facility]['final'][3] - $data['facility'][$this_facility]['final'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['final'][4] = 0; + $data['facility'][$this_facility]['final'][5] = $data['facility'][$this_facility]['final'][3]; + } + } else { + $data['facility'][$this_facility]['final'][4] = 0; + $data['facility'][$this_facility]['final'][5] = 0; + $data['facility'][$this_facility]['final'][6] = 0; + } + if ($data['facility'][$this_facility]['final'][5] == 0) { + $data['facility'][$this_facility]['final'][6] = 0; + } + } + } else { + $data['final'][4] = $tmp_data; + $tmp_data = 0; + $tmp_facility_received = $data['final'][4]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['final'][3]) && $data['facility'][$this_facility]['final'][3] > 0) { + if ($tmp_facility_received > 0) { + if ($tmp_facility_received >= $data['facility'][$this_facility]['final'][3]) { + $data['facility'][$this_facility]['final'][4] = $data['facility'][$this_facility]['final'][3]; + $data['facility'][$this_facility]['final'][5] = 0; + $tmp_facility_received -= $data['facility'][$this_facility]['final'][3]; + } else { + $data['facility'][$this_facility]['final'][4] = $tmp_facility_received; + $data['facility'][$this_facility]['final'][5] = $data['facility'][$this_facility]['final'][3] - $data['facility'][$this_facility]['final'][4]; + $tmp_facility_received = 0; + } + } else { + $data['facility'][$this_facility]['final'][4] = 0; + $data['facility'][$this_facility]['final'][5] = $data['facility'][$this_facility]['final'][3]; + } + } else { + $data['facility'][$this_facility]['final'][4] = 0; + $data['facility'][$this_facility]['final'][5] = 0; + $data['facility'][$this_facility]['final'][6] = 0; + } + if ($data['facility'][$this_facility]['final'][5] == 0) { + $data['facility'][$this_facility]['final'][6] = 0; + } + } + } + $data['final'][5] = $data['final'][3] - $data['final'][4]; + } else { + $data['final'][4] = 0; + $data['final'][5] = $data['final'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['final'][4] = 0; + $data['facility'][$this_facility]['final'][5] = $data['facility'][$this_facility]['final'][3]; + } + if ($data['facility'][$this_facility]['final'][5] == 0) { + $data['facility'][$this_facility]['final'][6] = 0; + } + } + if ($tmp_invoice > 0) { + if (($tmp_invoice - $data['final'][3]) >= 0) { + $data['final'][6] = $data['final'][3]; + $tmp_invoice -= $data['final'][3]; + $tmp_facility_invoice = $data['final'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['final'][3]) && $data['facility'][$this_facility]['final'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['final'][3]) { + $data['facility'][$this_facility]['final'][7] = $data['facility'][$this_facility]['final'][3]; + $data['facility'][$this_facility]['final'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['final'][3]; + } else { + $data['facility'][$this_facility]['final'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['final'][8] = $data['facility'][$this_facility]['final'][3] - $data['facility'][$this_facility]['final'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['final'][7] = 0; + $data['facility'][$this_facility]['final'][8] = $data['facility'][$this_facility]['final'][3]; + } + } else { + $data['facility'][$this_facility]['final'][7] = 0; + $data['facility'][$this_facility]['final'][8] = 0; + } + + } + } else { + $data['final'][6] = $tmp_invoice; + $tmp_invoice = 0; + $tmp_facility_invoice = $data['final'][6]; + foreach ($facilities as $this_facility) { + if (isset($data['facility'][$this_facility]['final'][3]) && $data['facility'][$this_facility]['final'][3] > 0) { + if ($tmp_facility_invoice > 0) { + if ($tmp_facility_invoice >= $data['facility'][$this_facility]['final'][3]) { + $data['facility'][$this_facility]['final'][7] = $data['facility'][$this_facility]['final'][3]; + $data['facility'][$this_facility]['final'][8] = 0; + $tmp_facility_invoice -= $data['facility'][$this_facility]['final'][3]; + } else { + $data['facility'][$this_facility]['final'][7] = $tmp_facility_invoice; + $data['facility'][$this_facility]['final'][8] = $data['facility'][$this_facility]['final'][3] - $data['facility'][$this_facility]['final'][7]; + $tmp_facility_invoice = 0; + } + } else { + $data['facility'][$this_facility]['final'][7] = 0; + $data['facility'][$this_facility]['final'][8] = $data['facility'][$this_facility]['final'][3]; + } + } else { + $data['facility'][$this_facility]['final'][7] = 0; + $data['facility'][$this_facility]['final'][8] = 0; + } + } + } + $data['final'][7] = $data['final'][3] - $data['final'][6]; + } else { + $data['final'][6] = 0; + $data['final'][7] = $data['final'][3]; + foreach ($facilities as $this_facility) { + $data['facility'][$this_facility]['final'][7] = 0; + $data['facility'][$this_facility]['final'][8] = $data['facility'][$this_facility]['final'][3]; + } + } + } else { + $data['final'][4] = 0; + $data['final'][5] = 0; + $data['final'][6] = 0; + $data['final'][7] = 0; + } +} + + +//產生excel的array +$excel_aray = array(); +$boga_array = array(); +$exclude_boga_array = array(); +$facility_array = array(); +$facility_boga_array = array(); +$facility_exclude_boga_array = array(); +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('
', '; ', $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('
', '; ', $value['facilities']) + ]; + } + + $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('
', '; ', $value['facilities']) + ]; + + //['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 + //[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 7 已開發票金額 8 未開發票金額 + 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] =="19700101"?"-":$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]; + $val[$stage][7] = (!(isset($val[$stage][7])) || is_null($val[$stage][7])) ? 0 : $val[$stage][7]; + $val[$stage][8] = (!(isset($val[$stage][8])) || is_null($val[$stage][8])) ? 0 : $val[$stage][8]; + } + $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'][7])), number_format(round($val['sign'][8])), 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'][7])), number_format(round($val['second'][8])), 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'][7])), number_format(round($val['arrive'][8])), 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'][7])), number_format(round($val['install'][8])), 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'][7])), number_format(round($val['tryrun'][8])), 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'][7])), number_format(round($val['check'][8])), 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'][7])), number_format(round($val['delivery'][8])), 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'][7])), number_format(round($val['final'][8])), number_format(round($val['final'][4])),number_format(round($val['final'][5])), number_format(round($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'])) + ]; + $sign_status_tmp = !empty($value['sign'][0]) ? $value['sign'][0] : null; + if ($sign_status_tmp == "寶佳出貨前30天") { + // 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'][7])), number_format(round($val['sign'][8])), 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'][7])), number_format(round($val['second'][8])), 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'][7])), number_format(round($val['arrive'][8])), 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'][7])), number_format(round($val['install'][8])), 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'][7])), number_format(round($val['tryrun'][8])), 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'][7])), number_format(round($val['check'][8])), 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'][7])), number_format(round($val['delivery'][8])), 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'][7])), number_format(round($val['final'][8])), number_format(round($val['final'][4])),number_format(round($val['final'][5])), number_format(round($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] = [ + $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'][7])), number_format(round($val['sign'][8])), 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'][7])), number_format(round($val['second'][8])), 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'][7])), number_format(round($val['arrive'][8])), 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'][7])), number_format(round($val['install'][8])), 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'][7])), number_format(round($val['tryrun'][8])), 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'][7])), number_format(round($val['check'][8])), 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'][7])), number_format(round($val['delivery'][8])), 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'][7])), number_format(round($val['final'][8])), number_format(round($val['final'][4])),number_format(round($val['final'][5])), number_format(round($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); + +$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); ?> + +
+
+ + + +
+
+
+
+ + + + +
+
+
-

+

合約 (新梯)統整資訊

- - + +
- - + +
- - + +
- - + +
-
- - + +
- - + +
-
- - +
+ +
-
- - -
-
- - - - - - - - + - - - - - - - - - + - - -
目前應收已開發票金額未開發票金額已收金額未收金額
-
+
+ + + + + + + + + -
-
作番號合約號部門經理營業員客戶名稱
- - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - -
簽約款二次款貨抵工地款安裝款試車款官檢款交車款作番狀態合約-設備金額合約-安裝金額作番總金額作番目前應收訂金
名稱
訂金
合約金額
訂金
應收日期
訂金
應收金額
訂金
已開金額
訂金
未開金額
訂金
已收金額
訂金
催收金額
訂金
催收次數
二次款
名稱
二次款
合約金額
二次款
應收日期
二次款
應收金額
二次款
已開金額
二次款
未開金額
二次款
已收金額
二次款
催收金額
二次款
催收次數
貨抵工地款
名稱
貨抵工地款
合約金額
貨抵工地款
應收日期
貨抵工地款
應收金額
貨抵工地款
已開金額
貨抵工地款
未開金額
貨抵工地款
已收金額
貨抵工地款
催收金額
貨抵工地款
催收次數
安裝款
名稱
安裝款
合約金額
安裝款
應收日期
安裝款
應收金額
安裝款
已開金額
安裝款
未開金額
安裝款
已收金額
安裝款
催收金額
安裝款
催收次數
試車款
名稱
試車款
合約金額
試車款
應收日期
試車款
應收金額
試車款
已開金額
試車款
未開金額
試車款
已收金額
試車款
催收金額
試車款
催收次數
官檢款
名稱
官檢款
合約金額
官檢款
應收日期
官檢款
應收金額
官檢款
已開金額
官檢款
未開金額
官檢款
已收金額
官檢款
催收金額
官檢款
催收次數
交車款
名稱
交車款
合約金額
交車款
應收日期
交車款
應收金額
交車款
已開金額
交車款
未開金額
交車款
已收金額
交車款
催收金額
交車款
催收次數
尾款
名稱
尾款
合約金額
尾款
應收日期
尾款
應收金額
尾款
已開金額
尾款
未開金額
尾款
已收金額
尾款
催收金額
尾款
催收次數
-
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - + $value) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
發票號碼發票日期發票金額收款日期收款金額說明功能
- - - - - -
\ No newline at end of file diff --git a/wms/account-receivable-index.php b/wms/account-receivable-index.php index 87f59c7b..784bd4b2 100644 --- a/wms/account-receivable-index.php +++ b/wms/account-receivable-index.php @@ -17,32 +17,38 @@ $follower = find_follow($user_id); $arrayData = []; $receivable_array = []; // T8發票 (有專案的發票) -$sql_invoice = "SELECT DISTINCT -a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, -b.ProjectId -FROM arSellInvoice as a -LEFT JOIN arSellInvoiceMaterial as b -ON a.BillNo=b.BillNo -WHERE DATALENGTH(b.ProjectId)>0"; +$sql_invoice = "SELECT +Detail.BillNo AS InvoiceBillNo, +Detail.MaterialId, +Detail.LAmountWithTax, +Main.InvoiceNo, +CheckAll.FromSalSalesOrder AS BillNo + FROM arSellInvoiceMaterial AS Detail + LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo + LEFT JOIN ( + SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo + FROM arCheckBillDetail AS CheckDetail ) + AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo + WHERE Detail.ItemType=0 AND Main.InvoiceState!=2"; // T8核銷 $sql_received = "SELECT -a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount, -b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee, -c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate -FROM arWriteOffBill AS a -LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo -LEFT JOIN - (SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail - LEFT JOIN - (SELECT - arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo - FROM arCheckBill - LEFT JOIN arCheckBillInvInfo - ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 - ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c -ON a.BillNo=c.BillNo -WHERE DATALENGTH(c.OrderBillNo) >0"; +CheckDetail.OrderBillNo, +arWriteOffBillDetail.FromBillNo AS CheckBillNo, +arWriteOffBillDetail.FromRowCode AS CheckRowCode, +arWriteOffBillDetail.CurrStandOffOAmount +FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBillDetail.BillNo, + arCheckBillDetail.RowCode, + arCheckBillDetail.FromSalSalesOrder AS OrderBillNo, + salSalesOrder.TypeId + FROM arCheckBillDetail + LEFT JOIN salSalesOrder + ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder ) + AS CheckDetail + ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode"; //T8 銷售訂單 階段收款計畫 $sql_contract = "SELECT a.BillNo,s.BillDate, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, @@ -104,7 +110,6 @@ if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepart $sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId"; } else { $sql_contract .= "AND (s.PersonId = '$user_id'"; - // $sql_received .= " AND (PersonId = '$user_id'"; $sql_opening .= " OR person_id = '$user_id'"; $sql .= " WHERE salesid = '$user_id'"; $sql_contract_budget .= " AND (PersonId = '$user_id'"; @@ -112,14 +117,12 @@ if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepart $column_str = "('$user_id'" . ",'"; $column_str .= implode("','", $follower); $column_str .= "')"; - $sql_contract .= " OR s.PersonId IN $column_str)"; - // $sql_received .= " OR PersonId IN $column_str)"; + $sql_contract .= " OR s.PersonId IN $column_str)";; $sql_opening .= " OR person_id IN $column_str)"; $sql .= " OR salesid IN $column_str ORDER BY contractno"; $sql_contract_budget .= " OR PersonId IN $column_str )ORDER BY BillNo, CU_MaterialId"; } else { $sql_contract .= ")"; - // $sql_received .= ")"; $sql_opening .= ")"; $sql .= " ORDER BY contractno"; $sql_contract_budget .= ")"; @@ -508,7 +511,7 @@ foreach ($wipwhole_array as $wip) { $arrayData[$wip['contractno']]['sign_num'] += 1; array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); - if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { + if (isset($arrayData[$wip['contractno']]['delivery'][0]) && $arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { $estimate_delivery_time = strtotime($wip['delivery_date']); $arrivetime = $estimate_delivery_time + (90 * 86400); $month = collect_month($arrivetime); @@ -972,9 +975,9 @@ foreach ($wipwhole_array as $wip) { } // [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['BillNo']])) { + $arrayData[$invoice['BillNo']]['invoice_budget'] += intval($invoice['OAmountWithTax']); + $arrayData[$invoice['BillNo']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; } } @@ -987,11 +990,13 @@ foreach ($received_array as $received) { } else { $BillNo = $received['OrderBillNo']; }; + if (isset($arrayData[$BillNo])) { - if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { - $arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; - array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); - } + $arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount']; + // if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { + // $arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; + // array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); + // } } } @@ -2153,6 +2158,9 @@ $facility_array = array(); $facility_boga_array = array(); $facility_exclude_boga_array = array(); foreach ($arrayData as $key => $value) { + // if($key == "M230860"){ + // print_r($value); + // } $sum_A40001 += isset($value['A40001']) ? $value['A40001'] : 0; $sum_A40008 += isset($value['A40008']) ? $value['A40008'] : 0; $sum_total_budget += $value['total_budget']; diff --git a/wms/account-receivable-invoice.php b/wms/account-receivable-invoice.php deleted file mode 100644 index b3d9bbc7..00000000 --- a/wms/account-receivable-invoice.php +++ /dev/null @@ -1 +0,0 @@ -= $start_date "; +} +if (!is_null($end_date)) { + $end_date = (int)date('Ymd', strtotime($end_date)); + $sql_all_contract .= " AND MainAll.BillDate <= $end_date "; +} +if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) { +} else { + $sql_all_contract .= " AND (MainAll.PersonId = '$user_id'"; + if (count($follower) > 0) { + $column_str = "('$user_id'" . ",'"; + $column_str .= implode("','", $follower); + $column_str .= "')"; + $sql_all_contract .= " OR MainAll.PersonId IN $column_str)"; + } else { + $sql_all_contract .= ")"; + }; +} +$str_numbers = ""; +$query_all_contract = $conn->query($sql_all_contract); +if (is_iterable($query_all_contract)) { + foreach ($query_all_contract as $contract_numbers) { + if (!in_array($contract_numbers['BillNo'], $contractNumbers)) { + array_push($contractNumbers, $contract_numbers['BillNo']); + $arrayData[$contract_numbers['BillNo']]['BillNo'] = isset($contract_numbers['BillNo']) ? $contract_numbers['BillNo'] : '--'; + $arrayData[$contract_numbers['BillNo']]['BillDate'] = isset($contract_numbers['BillDate']) ? $contract_numbers['BillDate'] : '--'; + $arrayData[$contract_numbers['BillNo']]['CustomerId'] = isset($contract_numbers['BizPartnerId']) ? $contract_numbers['BizPartnerId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['CustomerName'] = isset($contract_numbers['BizPartnerName']) ? $contract_numbers['BizPartnerName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['CustomerAddress'] = isset($contract_numbers['ContactAddress']) ? $contract_numbers['ContactAddress'] : '--'; + $arrayData[$contract_numbers['BillNo']]['OAmountWithTax'] = isset($contract_numbers['OAmountWithTax']) ? $contract_numbers['OAmountWithTax'] : 0; + $arrayData[$contract_numbers['BillNo']]['PersonId'] = isset($contract_numbers['PersonId']) ? $contract_numbers['PersonId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['DeptId'] = isset($contract_numbers['DeptId']) ? $contract_numbers['DeptId'] : '--'; + $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']]['ShortName'] = isset($contract_numbers['ShortName']) ? $contract_numbers['ShortName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['ManagerId'] = isset($contract_numbers['LeaderId']) ? $contract_numbers['LeaderId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['ManagerName'] = isset($contract_numbers['LeaderName']) ? $contract_numbers['LeaderName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0; + $arrayData[$contract_numbers['BillNo']]['received_budget'] = 0; + $arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0; + $arrayData[$contract_numbers['BillNo']]['collect_budget'] = 0; + $arrayData[$contract_numbers['BillNo']]['A40001'] = 0; + $arrayData[$contract_numbers['BillNo']]['A40008'] = 0; + $arrayData[$contract_numbers['BillNo']]['facility_status'] = ""; + $arrayData[$contract_numbers['BillNo']]['facility'] = array(); + $arrayData[$contract_numbers['BillNo']]['total_budget'] = $contract_numbers['OAmountWithTax']; + $sum_total_budget += $contract_numbers['OAmountWithTax']; + $sum_contract +=1; + } + } + $str_numbers .= "('" . implode("','", $contractNumbers) . "')"; +} + +// T8 銷售訂單 作番總金額、作番A40001金額、作番A40008金額、合約A40001金額、合約A40008金額 +$sql_contract_budget = "SELECT A.BillNo, A.OAmountWithTax,A.CU_MaterialId, A.MaterialId FROM salSalesOrderDetail AS A +LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo +WHERE B.ModeId='M' AND A.ItemType=1 "; +$query_contract_budget = $conn->query($sql_contract_budget); +foreach ($query_contract_budget as $contract_budget) { + if (isset($arrayData[$contract_budget['BillNo']])) { + $arrayData[$contract_budget['BillNo']][$contract_budget['MaterialId']] += $contract_budget['OAmountWithTax']; + if (isset($arrayData[$contract_budget['BillNo']]['facility']) && isset($arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']])) { + $arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['total_budget'] += $contract_budget['OAmountWithTax']; + if (isset($arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']])) { + $arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']] += $contract_budget['OAmountWithTax']; + } else { + $arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']] = $contract_budget['OAmountWithTax']; + } + } else { + $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']]['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; + + } + + } +} + +//T8 銷售訂單 階段收款計畫 +$sql_PayStage = "SELECT +a.RowNo, +a.BillNo, +s.BillDate, +a.PayStage, +a.PlanPayAmt, +a.PlanPayDate, +s.BizPartnerId, +s.PersonId + FROM salOrderStagePay AS a + LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo + WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; +if (!empty($str_numbers)) { + $sql_PayStage .= " AND s.BillNo IN " . $str_numbers; +} + +$query_PayStage = $conn->query($sql_PayStage); +// 把階段收款計畫放進arrayData內 +foreach ($query_PayStage as $PayStage) { + if (isset($arrayData[$PayStage['BillNo']])) { + $arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['PayStage'] = $PayStage['PayStage']; + $arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['PlanPayAmt'] = $PayStage['PlanPayAmt']; + $arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]['PlanPayDate'] = $PayStage['PlanPayDate']; + if (isset($arrayData[$PayStage['BillNo']]['facility']) && is_iterable($arrayData[$PayStage['BillNo']]['facility'])) { + foreach ($arrayData[$PayStage['BillNo']]['facility'] as $key => &$value) { + $tmpkey = $key . $PayStage['RowNo']; + $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'][$tmpkey] = $arrayData[$PayStage['BillNo']]['PayStage'][$PayStage['RowNo']]; + $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'][$tmpkey]['PlanPayAmt'] = $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'][$tmpkey]['PlanPayAmt'] * get_ratio($key, $PayStage['BillNo'], $arrayData); + $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'][$tmpkey]['facilityno'] = $key; + if (isset($PayStage_array[$PayStage['BillNo']])) { + $PayStage_array[$PayStage['BillNo']] = array_merge($PayStage_array[$PayStage['BillNo']], $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage']); + } else { + $PayStage_array[$PayStage['BillNo']] = $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage']; + } + $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'] = array(); + } + } + } +} + + +//作番大日程 +$sql_wip = "SELECT +tmp2.*, +d.name AS depart_name +FROM( +SELECT + a.manager, + a2.name as manager_name, + a.name, + a.department_id, + w.salesid, + w.contractno, + w.facilityno, + w.estimated_shipping_date, + w.real_contract_arrival_date, +w.actual_tofactory_date, + w.real_arrival_date, + w.install_end_date, + w.tryrun_end_date, + w.official_check_date, + w.delivery_date +from wipwholestatus AS w +left join account AS a +ON w.salesid = a.accountid +left join account AS a2 +ON a2.accountid = a.manager +where w.status = '1' AND w.contract_type='A' +)AS tmp2 +left join ( +SELECT DISTINCT + department_id, + name +FROM department + +) AS d +ON d.department_id = tmp2.department_id "; + +// 將作番大日程新梯資料存入array中方便查詢 +// 作番號 -> estimated_shipping_date 預計出港日; real_contract_arrival_date 預計出貨日; real_arrival_date 實際出貨日; +// install_end_date 安裝完畢日; tryrun_end_date 試車完畢日; official_check_date 官檢日; delivery_date 移交完畢日 +$wip_array = array(); +$query_wip = mysqli_query($link, $sql_wip); +foreach ($query_wip as $wip) { + $wip_array[$wip['facilityno']]['estimated_shipping_date'] = $wip['estimated_shipping_date']; + $wip_array[$wip['facilityno']]['real_contract_arrival_date'] = $wip['real_contract_arrival_date']; + $wip_array[$wip['facilityno']]['real_arrival_date'] = $wip['real_arrival_date']; + $wip_array[$wip['facilityno']]['install_end_date'] = $wip['install_end_date']; + $wip_array[$wip['facilityno']]['tryrun_end_date'] = $wip['tryrun_end_date']; + $wip_array[$wip['facilityno']]['official_check_date'] = $wip['official_check_date']; + $wip_array[$wip['facilityno']]['delivery_date'] = $wip['delivery_date']; + 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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $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'])) { + $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['estimated_shipping_date'] . "預計出港"; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港) ; "; + } + } +} +// 合約收款階段內容分類 +$sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天'); +$sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天'); +$sign120 = array('簽約後120天', '簽約後120日', '簽訂後120天', '合約簽訂後120天'); +$sign0 = array('簽約', '簽訂', '合約簽訂', '訂金'); +$arrival = array('貨抵工地', '貨底工地', '工地動工'); +$final6 = array('核可函取得後6個月', '得合格函後6個月'); + +foreach ($PayStage_array as $key => &$value) { + foreach ($value as $paykey => &$payvalue) { + if (isset($wip_array[$payvalue['facilityno']])) { + switch ($payvalue['PayStage']) { + case '寶佳出貨前30天': + $payvalue['stage'] = '訂金'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time - (30 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { + $estimate_time = strtotime($wip['real_contract_arrival_date']); + $signtime = $estimate_time - (30 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case '寶佳出貨後10天': + $payvalue['stage'] = '二次款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time + (10 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case '貨抵工地後90天': + $payvalue['stage'] = '貨抵工地款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time + (90 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case '安裝試車後90天': + $payvalue['stage'] = '試車款'; + if ($wip_array[$payvalue['facilityno']]['tryrun_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['tryrun_end_date'])) { + $estimate_time = strtotime($wip['tryrun_end_date']); + $signtime = $estimate_time + (90 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case '交車後270天': + $payvalue['stage'] = '尾款'; + if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) { + $estimate_time = strtotime($wip['delivery_date']); + $signtime = $estimate_time + (270 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (in_array($payvalue['PayStage'], $arrival)): + $payvalue['stage'] = '貨抵工地款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time + (10 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case '二次款': + $payvalue['stage'] = '二次款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { + $estimate_time = strtotime($wip['real_contract_arrival_date']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)') ||stristr($payvalue['PayStage'], '建照核發時')): + $payvalue['stage'] = '二次款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time - (30 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { + $estimate_time = strtotime($wip['real_contract_arrival_date']); + $signtime = $estimate_time - (30 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '出貨前60')): + $payvalue['stage'] = '二次款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time - (60 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { + $estimate_time = strtotime($wip['real_contract_arrival_date']); + $signtime = $estimate_time - (60 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '出貨前90')): + $payvalue['stage'] = '二次款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time - (90 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { + $estimate_time = strtotime($wip['real_contract_arrival_date']); + $signtime = $estimate_time - (90 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '出貨前120')): + $payvalue['stage'] = '二次款'; + if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { + $estimate_time = strtotime($wip['real_arrival_date']); + $signtime = $estimate_time - (120 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } elseif ($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_contract_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_contract_arrival_date'])) { + $estimate_time = strtotime($wip['real_contract_arrival_date']); + $signtime = $estimate_time - (120 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + } else { + $payvalue['PlanPayDate'] = NULL; + } + 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)): + $payvalue['stage'] = '二次款'; + $estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); + $signtime = $estimate_time + (60 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + break; + case (in_array($payvalue['PayStage'], $sign90)): + $payvalue['stage'] = '二次款'; + $estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); + $signtime = $estimate_time + (90 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + break; + case (in_array($payvalue['PayStage'], $sign120)): + $payvalue['stage'] = '二次款'; + $estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); + $signtime = $estimate_time + (120 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + break; + case (stristr($payvalue['PayStage'], '簽訂後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'], $sign0)): + $payvalue['stage'] = '訂金'; + $estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + break; + case (stristr($payvalue['PayStage'], '試車')): + $payvalue['stage'] = '試車款'; + if ($wip_array[$payvalue['facilityno']]['tryrun_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['tryrun_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['tryrun_end_date'])) { + $estimate_time = strtotime($wip['tryrun_end_date']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '安裝') || stristr($payvalue['PayStage'], '貨抵工地且完工')): + $payvalue['stage'] = '安裝款'; + if ($wip_array[$payvalue['facilityno']]['install_end_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['install_end_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['install_end_date'])) { + $estimate_time = strtotime($wip['install_end_date']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (in_array($payvalue['PayStage'], $final6)): + $payvalue['stage'] = '尾款'; + if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) { + $estimate_time = strtotime($wip['delivery_date']); + $estimate_time = $estimate_time + (180 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '合格') || stristr($payvalue['PayStage'], '驗收') || stristr($payvalue['PayStage'], '驗收')): + $payvalue['stage'] = '官檢驗收款'; + if ($wip_array[$payvalue['facilityno']]['official_check_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['official_check_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['official_check_date'])) { + $estimate_time = strtotime($wip['official_check_date']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + case (stristr($payvalue['PayStage'], '交車') || stristr($payvalue['PayStage'], '移交') || stristr($payvalue['PayStage'], '完工') || stristr($payvalue['PayStage'], '許可') || stristr($payvalue['PayStage'], '核可')): + $payvalue['stage'] = '交車款'; + if ($wip_array[$payvalue['facilityno']]['delivery_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['delivery_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['delivery_date'])) { + $estimate_time = strtotime($wip['delivery_date']); + $payvalue['PlanPayDate'] = date('Y-m-d', $estimate_time); + } else { + $payvalue['PlanPayDate'] = NULL; + } + break; + default: + $payvalue['PlanPayDate'] = NULL; + break; + } + if (strtotime($payvalue['PlanPayDate']) < 975686400) { + $payvalue['PlanPayDate'] = NULL; + } + } else { + $payvalue['PlanPayDate'] = NULL; + $payvalue['stage'] = "大日程無作番"; + } + } +} + + +// 在$PayStage_array中排序 +foreach ($PayStage_array as $key => $value) { + uasort($PayStage_array[$key], 'comparePlanPayDate'); +} +// 加入序號 +foreach ($PayStage_array as &$payStage) { + $sequenceNumber = 1; + foreach ($payStage as $tk => &$pstage) { + $pstage['sequenceNumber'] = $sequenceNumber; + $sequenceNumber += 1; + } +} + +// 整理好的收款階段放入 $final_paystage +$final_paystage = array(); +foreach ($PayStage_array as $key => &$payStage) { + if (is_iterable($payStage)) { + foreach ($payStage as $key2 => $pstage) { + $final_paystage[$key][$pstage['sequenceNumber']] = $pstage; + } + } +} + +// 發票資訊 +$sql_invoice = "SELECT +Detail.BillNo AS InvoiceBillNo, +Detail.MaterialId, +Detail.LAmountWithTax, +Main.InvoiceNo, +Main.InvoiceDate, +Main.InvoiceState, +CheckAll.FromSalSalesOrder AS BillNo + FROM arSellInvoiceMaterial AS Detail + LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo + LEFT JOIN ( + SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo + FROM arCheckBillDetail AS CheckDetail ) + AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo + WHERE Main.InvoiceState!=2 AND LEN(CheckAll.FromSalSalesOrder)>0"; +$query_invoice = $conn->query($sql_invoice); + +//發票資訊回填到arrayData +foreach ($query_invoice as $invoice) { + if (isset($arrayData[$invoice['BillNo']])) { + $arrayData[$invoice['BillNo']]['invoice_budget'] += $invoice['LAmountWithTax']; + } +} + +// 核銷資訊 +$sql_received = "SELECT +CheckDetail.OrderBillNo, +arWriteOffBillDetail.FromBillNo AS CheckBillNo, +arWriteOffBillDetail.FromRowCode AS CheckRowCode, +arWriteOffBillDetail.CurrStandOffOAmount, +CheckDetail.TypeId +FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBillDetail.BillNo, + arCheckBillDetail.RowCode, + arCheckBillDetail.FromSalSalesOrder AS OrderBillNo, + salSalesOrder.TypeId, + salSalesOrder.ModeId + FROM arCheckBillDetail + LEFT JOIN salSalesOrder + ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder ) + AS CheckDetail + ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode +WHERE CheckDetail.ModeId = 'M'"; +$query_received = $conn->query($sql_received); + +// 核銷資訊回填到arrayData +foreach ($query_received as $received) { + if (isset($arrayData[$received['OrderBillNo']])) { + $arrayData[$received['OrderBillNo']]['received_budget'] += $received['CurrStandOffOAmount']; + } +} + +// 將發票與核銷資訊 分別計算作番收款階段金額 與 催收次數 +$today = strtotime(date('Y-m-t')); +foreach ($final_paystage as $key => &$value) { + $tmpinvoice = $arrayData[$key]['invoice_budget']; + $tmpreceived = $arrayData[$key]['received_budget']; + for ($sequenceNumber = 1; $sequenceNumber <= count($value); $sequenceNumber++) { + if (isset($value[$sequenceNumber]['PlanPayDate'])) { + $collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate'])); + if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) { + $value[$sequenceNumber]['hadtopay'] = 'V'; + $arrayData[$key]['receivable_budget'] += $value[$sequenceNumber]['PlanPayAmt']; + } else { + $value[$sequenceNumber]['hadtopay'] = '--'; + } + } else { + $collect_month = 0; + $value[$sequenceNumber]['hadtopay'] = '--'; + } + if ($tmpinvoice >= $value[$sequenceNumber]['PlanPayAmt']) { + $value[$sequenceNumber]['invoice_budget'] = $value[$sequenceNumber]['PlanPayAmt']; + $tmpinvoice -= $value[$sequenceNumber]['invoice_budget']; + } elseif ($tmpinvoice > 0) { + $value[$sequenceNumber]['invoice_budget'] = $tmpinvoice; + $tmpinvoice = 0; + } else { + $value[$sequenceNumber]['invoice_budget'] = 0; + } + if ($tmpreceived > $value[$sequenceNumber]['PlanPayAmt']) { + $value[$sequenceNumber]['received_budget'] = $value[$sequenceNumber]['PlanPayAmt']; + $tmpinvoice -= $value[$sequenceNumber]['received_budget']; + } elseif ($tmpreceived > 0) { + $value[$sequenceNumber]['received_budget'] = $tmpreceived; + $tmpreceived = 0; + } else { + $value[$sequenceNumber]['received_budget'] = 0; + } + if ($collect_month > 0 && $value[$sequenceNumber]['PlanPayAmt'] > $value[$sequenceNumber]['received_budget']) { + $value[$sequenceNumber]['collect_month'] = $collect_month; + } else { + $value[$sequenceNumber]['collect_month'] = 0; + } + } +} + +// foreach($final_paystage as $key => $value) { +// echo $key."
"; +// echo "---------------------
"; +// foreach($value as $key2 => $value2) { +// echo $key2."
"; +// print_r($value2); +// echo "
"; +// } +// echo "
==================
"; +// } +// 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 = array(); +foreach ($arrayData as $key => $value) { + echo $key . "
********************
"; + print_r($value); + // foreach($value['facility'] as $key2 => $value2) { + // echo $key2."
"; + // print_r($value2['PayStage']); + // echo "
"; + // } + echo "
-------------------------------
"; +} diff --git a/wms/account-receivable-received-create.php b/wms/account-receivable-received-create.php deleted file mode 100644 index c734ab03..00000000 --- a/wms/account-receivable-received-create.php +++ /dev/null @@ -1,124 +0,0 @@ - -
- -
- -
-
-
-
-

-

新增收款資訊

-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - - - - - -
-
-
-
-
- -
-
-
-
- - - - \ No newline at end of file diff --git a/wms/account-receivable-received-edit.php b/wms/account-receivable-received-edit.php deleted file mode 100644 index 5f0e95a2..00000000 --- a/wms/account-receivable-received-edit.php +++ /dev/null @@ -1,142 +0,0 @@ -"; -// print_r($BillData); -$sql_pay = "SELECT * from account_received where pay_id = '$pay_id'"; -$pay = mysqli_query($link, $sql_pay); -$pay = mysqli_fetch_assoc($pay); - -?> -
- -
- -
-
- - -
-
-

-

編輯收款資訊

-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - - - -
-
-
-
-
- -
-
-
-
- - - - - \ No newline at end of file diff --git a/wms/account-receivable-received-submit.php b/wms/account-receivable-received-submit.php deleted file mode 100644 index b9b18f0f..00000000 --- a/wms/account-receivable-received-submit.php +++ /dev/null @@ -1,96 +0,0 @@ - - \ No newline at end of file diff --git a/wms/account-receivable-renovate-index.php b/wms/account-receivable-renovate-index.php index a4f2f82e..49093379 100644 --- a/wms/account-receivable-renovate-index.php +++ b/wms/account-receivable-renovate-index.php @@ -14,69 +14,153 @@ $average_budget = 0; $average_A40002 = 0; $average_A40009 = 0; $average_A40010 = 0; +$start_date = empty($_POST['date_start']) ? null : $_POST['date_start']; +$end_date = empty($_POST['date_end']) ? null : $_POST['date_end']; +// 查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(); +if (is_iterable($managers)) { + foreach ($managers as $manager) { + $find_manager[$manager['accountid']] = $manager; + } +} $follower = find_follow($user_id); $arrayData = []; $receivable_array = []; // T8所有合約號 -$sql_contractNumber = "SELECT Distinct BillNo FROM salSalesOrder WHERE ModeId = 'T' AND (CurrentState=2 OR CurrentState=4) "; +$sql_contractNumber = "SELECT MainAll.* , +Person.PersonName, +Dept.DeptName FROM + (SELECT +Main.BillNo, +Main.BillDate, +Main.BizPartnerId, +Biz.ShortName, +Biz.BizPartnerName, +Biz.ContactAddress, +Main.OAmountWithTax, +Main.PersonId, +Main.DeptId, +Main.TypeId, +Main.ModeId, +Main.CurrentState + FROM 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 comDepartment AS Dept ON MainAll.DeptId= Dept.DeptId + WHERE MainAll.ModeId = 'T' AND (MainAll.CurrentState=2 OR MainAll.CurrentState=4) "; + +if (!is_null($start_date)) { + $start_date = (int)date('Ymd', strtotime($start_date)); + $sql_contractNumber .= " AND MainAll.BillDate >= $start_date "; +} +if (!is_null($end_date)) { + $end_date = (int)date('Ymd', strtotime($end_date)); + $sql_contractNumber .= " AND MainAll.BillDate <= $end_date "; +} +if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) { +} else { + $sql_contractNumber .= " AND (MainAll.PersonId = '$user_id'"; + if (count($follower) > 0) { + $column_str = "('$user_id'" . ",'"; + $column_str .= implode("','", $follower); + $column_str .= "')"; + $sql_contractNumber .= " OR MainAll.PersonId IN $column_str)"; + } else { + $sql_contractNumber .= ")"; + }; +} + // T8發票 (有專案的發票) -$sql_invoice = "SELECT DISTINCT -a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, -b.FromSalSalesOrder -FROM arSellInvoice as a -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.FromSalSalesOrder)>0 -ORDER BY InvoiceTime ASC"; +$sql_invoice = "SELECT +Detail.BillNo AS InvoiceBillNo, +Detail.MaterialId, +Detail.LAmountWithTax, +Main.InvoiceNo, +Main.InvoiceDate, +Main.InvoiceState, +CheckAll.FromSalSalesOrder AS BillNo + FROM arSellInvoiceMaterial AS Detail + LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo + LEFT JOIN ( + SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo + FROM arCheckBillDetail AS CheckDetail ) + AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo + WHERE Main.InvoiceState!=2"; // T8核銷 $sql_received = "SELECT -a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount, -b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee, -c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate -FROM arWriteOffBill AS a -LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo -LEFT JOIN - (SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail - LEFT JOIN - (SELECT - arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo - FROM arCheckBill - LEFT JOIN arCheckBillInvInfo - ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 - ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c -ON a.BillNo=c.BillNo -WHERE DATALENGTH(c.OrderBillNo) >0"; +CheckDetail.OrderBillNo, +arWriteOffBillDetail.FromBillNo AS CheckBillNo, +arWriteOffBillDetail.FromRowCode AS CheckRowCode, +arWriteOffBillDetail.CurrStandOffOAmount, +CheckDetail.TypeId +FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBillDetail.BillNo, + arCheckBillDetail.RowCode, + arCheckBillDetail.FromSalSalesOrder AS OrderBillNo, + salSalesOrder.TypeId, + salSalesOrder.ModeId + FROM arCheckBillDetail + LEFT JOIN salSalesOrder + ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder ) + AS CheckDetail + ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode +WHERE CheckDetail.ModeId = 'T'"; // 期初收款資訊 $sql_opening = " SELECT * FROM account_received "; -// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的 -if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210')))) { -} else { - $sql_opening .= " OR person_id = '$user_id'"; - $sql_contractNumber .= " AND (PersonId = '$user_id'"; - if (count($follower) > 0) { - $column_str = "('$user_id'" . ",'"; - $column_str .= implode("','", $follower); - $column_str .= "')"; - $sql_contractNumber .= " OR PersonId IN $column_str)"; - $sql_opening .= " OR person_id IN $column_str)"; - } else { - $sql_opening .= ")"; - $sql_contractNumber .= ")"; - }; -} + $contractNumbers = array(); $query_contract_number = $conn->query($sql_contractNumber); foreach ($query_contract_number as $contract_numbers) { - array_push($contractNumbers, $contract_numbers['BillNo']); + $billNo = $contract_numbers['BillNo']; + // switch ($contract_numbers['BillNo']) { + // case 'SO20230701001': + // $billNo = 'M220104'; + // break; + // case 'SO20230701002': + // $billNo = 'M230098'; + // break; + // case 'SO20230701003': + // $billNo = 'M230159'; + // break; + // case 'SO20230901001': + // $billNo = 'M230992'; + // break; + // case 'SO20231110001': + // $billNo = 'M230492'; + // break; + // case 'SO20231110002': + // $billNo = 'M230557'; + // break; + // case 'SO20231110003': + // $billNo = 'M230496'; + // break; + // case 'SP20240108001': + // $billNo = 'M230683'; + // break; + // case 'SP20240116004': + // $billNo = 'B230726'; + // break; + // case 'T220035': + // $billNo = 'M220035'; + // break; + // case 'T230098': + // $billNo = 'M230098'; + // break; + // } + array_push($contractNumbers, $billNo); $str_numbers = "('" . implode("','", $contractNumbers) . "')"; } //作番大日程 @@ -121,18 +205,18 @@ $sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a 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 "; -} +// 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 "; -if (isset($str_numbers)) { - $sql_contract_budget .= "AND A.BillNo IN $str_numbers "; -} +// if (isset($str_numbers)) { +// $sql_contract_budget .= "AND A.BillNo IN $str_numbers "; +// } $contract = $conn->query($sql_contract); $contract_data = array(); $manager_list = array(); @@ -288,26 +372,62 @@ $today = strtotime(date('Ymd')); $wipwhole_array = mysqli_query($link, $sql); $wipwhole_status = array(); foreach ($wipwhole_array as $wip) { + $billno = $wip['contractno']; + switch ($wip['contractno']) { + case 'M220104': + $billNo = 'SO20230701001'; + break; + case 'M230098': + $billNo = 'SO20230701002'; + break; + case 'M230159': + $billNo = 'SO20230701003'; + break; + case 'M230992': + $billNo = 'SO20230901001'; + break; + case 'M230492': + $billNo = 'SO20231110001'; + break; + case 'M230557': + $billNo = 'SO20231110002'; + break; + case 'M230496': + $billNo = 'SO20231110003'; + break; + case 'M230683': + $billNo = 'SP20240108001'; + break; + case 'B230726': + $billNo = 'SP20240116004'; + break; + case 'M220035': + $billNo = 'T220035'; + break; + case 'M230098': + $billNo = 'T230098'; + break; + } //[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 - if (isset($arrayData[$wip['contractno']])) { + if (isset($arrayData[$billno])) { // 整理合約資料 // $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; + $arrayData[$billno][10] = $wip['contractno']; + $arrayData[$billno]['A40001'] = (isset($contract_budget[$billno]['A40001']) && !is_null($contract_budget[$billno]['A40001'])) ? $contract_budget[$billno]['A40001'] : 0; + $arrayData[$billno]['A40008'] = (isset($contract_budget[$billno]['A40008']) && !is_null($contract_budget[$billno]['A40008'])) ? $contract_budget[$billno]['A40008'] : 0; // [合約號]['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']]['A40002'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40002']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40002'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40002'] : 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; - $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40010'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40010']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40010'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40010'] : 0; + $arrayData[$billno]['facility'][$wip['facilityno']]['no'] = $wip['facilityno']; + $arrayData[$billno]['facility'][$wip['facilityno']]['status'] = ""; + $arrayData[$billno]['facility'][$wip['facilityno']]['total_budget'] = 0; + $arrayData[$billno]['facility'][$wip['facilityno']]['receivable_budget'] = 0; + $arrayData[$billno]['facility'][$wip['facilityno']]['collect_budget'] = 0; + $arrayData[$billno]['facility'][$wip['facilityno']]['A40002'] = (isset($contract_budget[$billno][$wip['facilityno']]['A40002']) && !is_null($contract_budget[$billno][$wip['facilityno']]['A40002'])) ? $contract_budget[$billno][$wip['facilityno']]['A40002'] : 0; + $arrayData[$billno]['facility'][$wip['facilityno']]['A40008'] = (isset($contract_budget[$billno][$wip['facilityno']]['A40008']) && !is_null($contract_budget[$billno][$wip['facilityno']]['A40008'])) ? $contract_budget[$billno][$wip['facilityno']]['A40008'] : 0; + $arrayData[$billno]['facility'][$wip['facilityno']]['A40010'] = (isset($contract_budget[$billno][$wip['facilityno']]['A40010']) && !is_null($contract_budget[$billno][$wip['facilityno']]['A40010'])) ? $contract_budget[$billno][$wip['facilityno']]['A40010'] : 0; } $wipwhole_status[$wip['facilityno']] = $wip; } @@ -460,9 +580,9 @@ foreach ($allPayStages as $key => &$payStage) { // [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號] foreach ($invoice_data as $invoice) { - 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']]; + if (isset($invoice['BillNo']) && isset($arrayData[$invoice['BillNo']])) { + $arrayData[$invoice['BillNo']]['invoice_budget'] += intval($invoice['LAmountWithTax']); + $arrayData[$invoice['BillNo']]['invoice'][$invoice['InvoiceNo']] = [date("Y-m-d", strtotime($invoice['InvoiceDate'])), $invoice['LAmountWithTax'], $invoice['InvoiceState']]; } } @@ -470,10 +590,10 @@ foreach ($invoice_data as $invoice) { foreach ($received_array as $received) { $BillNo = $received['OrderBillNo']; if (isset($arrayData[$BillNo])) { - if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { - $arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; - array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); - } + // if (isset($received['InvoiceNo']) && isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { + $arrayData[$BillNo]['received_budget'] += $received['CurrStandOffOAmount']; + // array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); + // } } } // $final_paystage ['type'] ['PlanPayDate'] ['PayAmount'] ['facilityno'] ['sequenceNumber'] ['name'] ['InvoiceAmount'] ['receivedAmount'] @@ -527,12 +647,12 @@ foreach ($arrayData as $key => $value) { $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" : "--"; + $keyname = $key . "_" . $final_paystage[$key][$sequence]['facilityno'] . "_" . $sequence; + $havetopay = ($today >= strtotime($final_paystage[$key][$sequence]['PlanPayDate'])) ? "V" : "--"; switch ($havetopay) { case "V": - $unInvoiceAmount = $thisPayStage['PayAmount'] - $thisPayStage['InvoiceAmount']; - $unReceivedAmount = $thisPayStage['PayAmount'] - $thisPayStage['receivedAmount']; + $unInvoiceAmount = $final_paystage[$key][$sequence]['PayAmount'] - $final_paystage[$key][$sequence]['InvoiceAmount']; + $unReceivedAmount = $final_paystage[$key][$sequence]['PayAmount'] - $final_paystage[$key][$sequence]['receivedAmount']; break; default: $unInvoiceAmount = 0; @@ -542,10 +662,10 @@ foreach ($arrayData as $key => $value) { $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'])) + number_format(round($final_paystage[$key][$sequence]['PayAmount'])), + number_format(round($final_paystage[$key][$sequence]['InvoiceAmount'])), number_format(round($unInvoiceAmount)), + number_format(round($final_paystage[$key][$sequence]['receivedAmount'])), number_format(round($unReceivedAmount)), + number_format(round($final_paystage[$key][$sequence]['collect_month'])) ]; } @@ -621,15 +741,16 @@ include "./footer.php"; - - + + - + + @@ -651,6 +772,7 @@ include "./footer.php"; + diff --git a/wms/account-receivable-repair-index.php b/wms/account-receivable-repair-index.php index bd1d7acc..f02835ca 100644 --- a/wms/account-receivable-repair-index.php +++ b/wms/account-receivable-repair-index.php @@ -23,8 +23,10 @@ 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; +if (is_iterable($managers)) { + foreach ($managers as $manager) { + $find_manager[$manager['accountid']] = $manager; + } } $follower = find_follow($user_id); $arrayData = array(); @@ -361,14 +363,14 @@ $total_data = json_encode($excel_aray); -
+
"; // } -$sql = "SELECT A.BillNo,B.CU_MaterialId, B.ProjectId FROM salSalesOrder AS A -LEFT JOIN salSalesOrderDetail AS B ON A.BillNo=B.BillNo -WHERE A.ModeId='T' AND B.ItemType=0 AND A.BillNo != B.ProjectId AND A.CurrentState=4"; -$query = $conn->query($sql); -foreach($query as $key => $value) { - echo $value['BillNo'] .";".$value['CU_MaterialId'].";".$value['ProjectId']. "
"; -} \ No newline at end of file +// $sql = "SELECT A.BillNo,B.CU_MaterialId, B.ProjectId FROM salSalesOrder AS A +// LEFT JOIN salSalesOrderDetail AS B ON A.BillNo=B.BillNo +// WHERE A.ModeId='T' AND B.ItemType=0 AND A.BillNo != B.ProjectId AND A.CurrentState=4"; +// $query = $conn->query($sql); +// foreach($query as $key => $value) { +// echo $value['BillNo'] .";".$value['CU_MaterialId'].";".$value['ProjectId']. "
"; +// } + + +// 發貨單 沒有ProjectId的資料 +// $sql = "SELECT DISTINCT salDispatchListMaster.BillNo, salDispatchListMaster.ModeId,salDispatchListMaster.BillDate FROM salDispatchListDetail +// LEFT JOIN salDispatchListMaster ON salDispatchListMaster.BillNo=salDispatchListDetail.BillNo +// WHERE salDispatchListDetail.ItemType=0 AND LEN(salDispatchListDetail.ProjectId)=0"; +// $query = $conn->query($sql); +// foreach($query as $key => $value) { +// switch($value['ModeId']) { +// case 'B': +// $mode = '保養'; +// break; +// case 'T': +// $mode = '汰改'; +// break; +// case 'M': +// $mode = '新梯'; +// break; +// case 'Z': +// $mode = '維修'; +// break; +// } +// echo $value['BillNo'] .";".$mode.";".$value['BillDate']. "
"; +// } + +// 銷售訂單 沒有ProjectId的資料 +// $sql = "SELECT Main.*, comBusinessPartner.BizPartnerName, salDispatchListMaster.BillNo AS DispBillNo , salDispatchListMaster.BillDate AS DispBillDate FROM +// (SELECT DISTINCT salSalesOrder.BillNo,salSalesOrder.BizPartnerId, salSalesOrder.TypeId, salSalesOrder.ModeId, salSalesOrderDetail.ProjectId, salSalesOrderDetail.CU_MaterialId FROM salSalesOrderDetail +// LEFT JOIN salSalesOrder ON salSalesOrder.BillNo= salSalesOrderDetail.BillNo +// WHERE (LEN(salSalesOrderDetail.ProjectId)=0 AND salSalesOrderDetail.ItemType=0) OR LEN(salSalesOrderDetail.CU_MaterialId)=0 ) AS Main +// LEFT JOIN comBusinessPartner ON comBusinessPartner.BizPartnerId = Main.BizPartnerId +// LEFT JOIN salDispatchListMaster ON salDispatchListMaster.FromBillNo= Main.BillNo +// WHERE salDispatchListMaster.BillDate >20231031 OR salDispatchListMaster.BillDate IS NULL"; +// $query = $conn->query($sql); +// foreach ($query as $key => $value) { +// $mode = ''; +// switch ($value['ModeId']) { +// case 'B': +// $mode = '保養'; +// break; +// case 'T': +// $mode = '汰改'; +// break; +// case 'M': +// $mode = '新梯'; +// break; +// case 'Z': +// $mode = '維修'; +// break; +// } +// echo $value['BillNo'] . ";" . $mode . ";" . $value['BizPartnerId'] .";".$value['BizPartnerName'].";".$value['ProjectId']. ";".$value['CU_MaterialId']. ";".$value['DispBillNo'].";" . $value['DispBillDate'] ."
"; +// } + + +$TIME = strtotime('2000-12-02'); + +echo $TIME; \ No newline at end of file diff --git a/wms/cont/.DS_Store b/wms/cont/.DS_Store new file mode 100644 index 00000000..514e625b Binary files /dev/null and b/wms/cont/.DS_Store differ diff --git a/wms/cont/FormHelper.php b/wms/cont/FormHelper.php new file mode 100644 index 00000000..8025239a --- /dev/null +++ b/wms/cont/FormHelper.php @@ -0,0 +1,509 @@ + 'post', 'accept-charset' => 'utf-8'), $attributes); + + return "'; + } + + /** + * Form closing tag + * + * @static + * @return string + */ + public static function close() + { + return ''; + } + + /** + * Creates a label for an input + * + * @param string $text The label text + * @param string $fieldName Name of the input element + * @param array $attributes HTML attributes + * @return string + */ + public static function label($text, $fieldName = null, array $attributes = array()) + { + if (!isset($attributes['for']) && $fieldName !== null) { + $attributes['for'] = static::autoId($fieldName); + } + if (!isset($attributes['id']) && isset($attributes['for'])) { + $attributes['id'] = $attributes['for'] . '-label'; + } + + return self::tag('label', $attributes, $text); + } + + /** + * Creates a text field + * + * @param string $name + * @param string $value + * @param array $attributes HTML attributes + * @return string + */ + public static function text($name, $value = null, array $attributes = array(),$type='text') + { + $attributes = array_merge(array( + 'id' => static::autoId($name), + 'name' => $name, + 'type' => $type, + 'value' => $value, + ), $attributes); + + return self::tag('input', $attributes); + } + + /** + * Creates a password input field + * + * @static + * @param string $name + * @param string $value + * @param array $attributes HTML attributes + * @return string + */ + public static function password($name, $value = null, array $attributes = array()) + { + $attributes = array_merge(array( + 'id' => static::autoId($name), + 'name' => $name, + 'type' => 'password', + 'value' => $value, + ), $attributes); + + return self::tag('input', $attributes); + } + + /** + * Creates a hidden input field + * + * @static + * @param string $name + * @param string $value + * @param array $attributes + * @return string + */ + public static function hidden($name, $value, array $attributes = array()) + { + $attributes = array_merge(array( + 'id' => static::autoId($name), + 'name' => $name, + 'type' => 'hidden', + 'value' => $value, + ), $attributes); + + return self::tag('input', $attributes); + } + + /** + * Creates a textarea + * + * @param string $name + * @param string $text + * @param array $attributes HTML attributes + * @return string + */ + public static function textArea($name, $text = null, array $attributes = array()) + { + $attributes = array_merge(array( + 'id' => static::autoId($name), + 'name' => $name, + ), $attributes); + + return self::tag('textarea', $attributes, (string)$text); + } + + /** + * Creates a check box. + * By default creates a hidden field with the value of 0, so that the field is present in $_POST even when not checked + * + * @param string $name + * @param bool $checked + * @param mixed $value Checked value + * @param array $attributes HTML attributes + * @param bool|string $withHiddenField Pass false to omit the hidden field or "array" to return both parts as an array + * @return string + */ + public static function checkBox( + $name, + $checked = false, + $value = 1, + array $attributes = array(), + $withHiddenField = true + ) { + $auto_id = static::autoId($name); + + $checkboxAttributes = array_merge(array( + 'name' => $name, + 'type' => 'checkbox', + 'value' => $value, + 'id' => $auto_id, + 'checked' => (bool)$checked, + ), $attributes); + $checkbox = self::tag('input', $checkboxAttributes); + + if ($withHiddenField === false) { + return $checkbox; + } + + $hiddenAttributes = array( + 'name' => $name, + 'type' => 'hidden', + 'value' => 0, + 'id' => $auto_id . '-hidden', + ); + $hidden = self::tag('input', $hiddenAttributes); + + return $withHiddenField === 'array' + ? array($hidden, $checkbox) + : $hidden . $checkbox; + } + + /** + * Creates multiple checkboxes for a has-many association. + * + * @param string $name + * @param array $collection + * @param array|\Traversable $checked Collection of checked values + * @param array $labelAttributes + * @param bool $returnAsArray + * @throws \InvalidArgumentException + * @return string + */ + public static function collectionCheckBoxes($name, array $collection, $checked, array $labelAttributes = array(), $returnAsArray = false) + { + // TODO: Does this check cover all options? + if (!(is_array($checked) || $checked instanceof \Traversable)) { + throw new \InvalidArgumentException("$name must be an array or Traversable!"); + } + + $checkBoxes = array(); + foreach ($collection as $value => $label) { + $checkBoxes[] = self::tag( + 'label', + $labelAttributes, + FormHelper::checkBox("{$name}[]", in_array($value, $checked, true), $value, array(), false) . self::escape($label), + false + ); + } + + return $returnAsArray ? $checkBoxes : implode('', $checkBoxes); + } + + /** + * Creates a radio button + * + * @static + * @param string $name + * @param string $value + * @param bool $checked + * @param array $attributes + * @return string + */ + public static function radio($name, $value, $checked = false, array $attributes = array()) + { + $attributes = array_merge(array( + 'type' => 'radio', + 'name' => $name, + 'value' => $value, + 'checked' => (bool)$checked, + ), $attributes); + + return self::tag('input', $attributes); + } + + /** + * Creates multiple radio buttons with labels + * + * @static + * @param string $name + * @param array $collection + * @param mixed $checked Checked value + * @param array $labelAttributes + * @param bool $returnAsArray + * @return array|string + */ + public static function collectionRadios($name, array $collection, $checked, array $labelAttributes = array(), $returnAsArray = false) + { + $radioButtons = array(); + foreach ($collection as $value => $label) { + $radioButtons[] = self::tag( + 'label', + $labelAttributes, + FormHelper::radio($name, $value, $value === $checked) . self::escape($label), + false + ); + } + + return $returnAsArray ? $radioButtons : implode('', $radioButtons); + } + + /** + * Creates a select tag + * + * // Simple select + * select('coffee_id', array('b' => 'black', 'w' => 'white')); + * + * With option groups + * select('beverage', array( + * 'Coffee' => array('bc' => 'black', 'wc' => 'white'), + * 'Tea' => array('gt' => 'Green', 'bt' => 'Black'), + * )); + * + * + * @param string $name Name of the attribute + * @param array $collection An associative array used for the option values + * @param mixed $selected Selected option Can be array or scalar + * @param array $attributes HTML attributes + * @return string + */ + public static function select($name, array $collection, $selected = null, array $attributes = array()) + { + $attributes = array_merge(array( + 'name' => $name, + 'id' => static::autoId($name), + 'multiple' => false, + ), $attributes); + + if (is_string($selected) || is_numeric($selected)) { + $selected = array($selected => 1); + } else if (is_array($selected)) { + $selected = array_flip($selected); + } else { + $selected = array(); + } + + $content = self::option('', '', $selected); + foreach ($collection as $value => $element) { + // Element is an optgroup + $content .= self::option($element['value'], $element['label'], $selected); + } + + return self::tag('select', $attributes, $content, false); + } + + /** + * Creates an option tag + * + * @param string $value + * @param string $label + * @param array $selected + * @return string + */ + private static function option($value, $label, $selected) + { + // Special handling of option tag contents to enable indentation with   + //$label = str_replace('&nbsp;', ' ', self::escape($label)); + + return self::tag( + 'option', + array( + 'value' => $value, + 'selected' => isset($selected[$value]), + ), + $label, + false + ); + } + + /** + * Creates a file input field + * + * @static + * @param string $name + * @param array $attributes HTML attributes + * @return string + */ + public static function file($name, array $attributes = array()) + { + $attributes = array_merge(array( + 'type' => 'file', + 'name' => $name, + 'id' => static::autoId($name), + ), $attributes); + + return self::tag('input', $attributes); + } + + public static function button($name, $text, array $attributes = array()) + { + $attributes = array_merge(array( + 'id' => static::autoId($name), + 'name' => $name, + ), $attributes); + + return self::tag('button', $attributes, $text); + } + + + /** + * Generate an ID given the name of an input + * + * @static + * @param string $name + * @return string|null + */ + public static function autoId($name) + { + // Don't set an id on collection inputs + if (strpos($name, '[]') !== false) { + return null; + } + + // Hyphenate array keys, for example model[field][other_field] => model-field-other_field + $name = preg_replace('/\[([^]]+)\]/u', '-\\1', $name); + + return $name; + } + + /** + * Generates an HTML tag + * + * @param string $tagName Name of the tag + * @param array $attributes HTML attributes + * @param string $content Content of the tag. Omit to create a self-closing tag + * @param bool $escape_content + * + * @see attributes() + * + * @return string + */ + public static function tag($tagName, array $attributes = array(), $content = null, $escape_content = true) + { + $result = '<' . $tagName . static::attributes($attributes) . '>'; + + if ($content !== null) { + $result .= ($escape_content ? static::escape($content) : $content) . ''; + } + + return $result; + } + + /** + * Converts an array of HTML attributes to a string + * + * If an attribute is false or null, it will not be set. + * + * If an attribute is true or is passed without a key, it will + * be set without an explicit value (useful for checked, disabled, ..) + * + * If an array is passed as a value, it will be joined using spaces + * + * Note: Starts with a space + * + * Html::attributes(array('id' => 'some-id', 'selected' => false, 'disabled' => true, 'class' => array('a', 'b'))); + * //=> ' id="some-id" disabled class="a b"' + * + * + * @param array $attributes Associative array of attributes + * + * @return string + */ + public static function attributes(array $attributes) + { + $result = ''; + + foreach ($attributes as $attribute => $value) { + if ($value === false || $value === null) continue; + if ($value === true) { + $result .= ' ' . $attribute; + } else if (is_numeric($attribute)) { + $result .= ' ' . $value; + } else { + if (is_array($value)) { // support cases like 'class' => array('one', 'two') + $value = implode(' ', $value); + } + $result .= ' ' . $attribute . '=\'' . static::escape($value) . '\''; + } + } + + return $result; + } + + /** + * Escapes a string for output in HTML + * + * @static + * @param string $string + * @return string + */ + public static function escape($string) + { + return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); + } + /** + * 输出表单标题 + * + * @param string $title + * @return void + */ + public static function formTitle(string $title) + { + return '
+
+ ' . $title . ' +
+
+ '; + } + /** + * 输出行标题 + * + * @param string $title + * @return void + */ + public static function formRowTitle(string $title) + { + return '
+
+ ' . $title . ' +
+
+ '; + } + /** + * 输出行内容 + * + * @return void + */ + public static function formRowContent($fieldName, string $fieldValue, string $key) + { + return '
+

' . $fieldName . '

+
+
+ +
+ '; + } + /** + * 生成Row + * + * @return void + */ + public function formRow() + { + $_div = "
"; + $_div .= "
"; + } +} diff --git a/wms/cont/MICalculator.php b/wms/cont/MICalculator.php new file mode 100644 index 00000000..a65752c8 --- /dev/null +++ b/wms/cont/MICalculator.php @@ -0,0 +1,324 @@ + 'fail', + 'message' => '無此項目,請聯係業務部創建MI' + ]; + } + public function success($price) + { + return [ + 'status' => 'ok', + 'price' => $price + ]; + } +} diff --git a/wms/cont/MSCalculator.php b/wms/cont/MSCalculator.php new file mode 100644 index 00000000..a5415e76 --- /dev/null +++ b/wms/cont/MSCalculator.php @@ -0,0 +1,322 @@ + 'fail', + 'message' => '無此項目,請聯係業務部創建標準成本' + ]; + } + public function success($price) + { + return [ + 'status' => 'ok', + 'price' => $price + ]; + } +} diff --git a/wms/cont/apply.php b/wms/cont/apply.php new file mode 100644 index 00000000..451eb877 --- /dev/null +++ b/wms/cont/apply.php @@ -0,0 +1,22 @@ +initWorkFlow(ID); + +//加载视图 + +echo '查看全部待签'; diff --git a/wms/cont/apply_form.php b/wms/cont/apply_form.php new file mode 100644 index 00000000..87ac3939 --- /dev/null +++ b/wms/cont/apply_form.php @@ -0,0 +1,859 @@ +0) { + echo""; + exit; +} +*/ + +#係統ID +$system_id = 'con'; +#流程ID +$flow_id = 'con01'; +#表單號 $form_id; +$form_id = ""; +#價審單狀態 +$apply_st = ""; +list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1"); +// echo '
';
+// print_r($apply_key);
+// echo '
'; +// exit; +// if ($salesman != $user_id) { +// echo ''; +// exit; +// } +if (empty($apply_key)) $apply_st = 1; // 準備新增 +else { + //list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); + list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); + if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 + else $apply_st = 9; // 已到下一關,無法䖺改 +} + +// if ($apply_st > 2) { +// echo ""; +// exit; +// } + +if ($apply_st == 1) { + $wf = new WorkFlow($system_id, $flow_id, $form_id); + $wf->initWorkFlow($user_id); + $form_key = $wf->flowContext->getFormKey(); +} else { + $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); +} + +#獲取簽核意見 +$assign_opinions = Assign::get_records($form_key); + +#會簽部門意見 +$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); + +//預設冇有摺扣 +$wf->setFormData(['discount' => 100]); +$flowName = $wf->getFlowName(); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); + +$if_show_assign = true; +//加載流程圖 +//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); +//$path = $fc[0]->wf_file; +//echo dirname(__DIR__)."/../"."$path"; + +//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); +#是否可會簽 +$isSplitable = $wf->isSplitable(); + +//表單數據 +#客戶表 +#1.電梯品牌選項 +$sql = "SELECT code_name value ,content label FROM code WHERE field_name='elevator_brand' order by code_name asc "; +$elevator_brand_opt = DB::result($sql); +#2.保養方式 +$sql = "SELECT code_name value ,content label FROM code WHERE field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.電梯類型 +$sql = "SELECT code_name value ,content label FROM code WHERE field_name='maintain_elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "SELECT code_name value ,content label FROM code WHERE field_name='payment_kind' order by code_name+ 0 asc"; +$payment_kind_opt = DB::result($sql); +#5.契約性質 +$sql = "SELECT code_name value ,content label FROM code WHERE field_name='contract_kind'"; +$contract_kind_opt = DB::result($sql); +#6.是否贈送M1 +$is_m1_bundle_opt = [ + ['label' => '是', 'value' => 'Y'], + ['label' => '否', 'value' => 'N'] + +]; +#7.機種 +$sql = "SELECT code_name value ,content label FROM code WHERE field_name='fp_kind'"; +$fp_kind_opt = DB::result($sql); +#抓取有望客戶資料 + + +$vol_no = $_GET['vol_no']; +$where = " and vol_no='$vol_no'"; +$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; +// print_r($sql); +$hope_contract = DB::result($sql); +$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; +#寫入 con_maintance_examine_apply +if ($apply_st == 1) { + #獲取評審單號 + $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); + //var_dump($hope_contract); + $insert_data = [ + 'apply_key' => $apply_key, + 'vol_no' => $vol_no, + 'form_key' => $form_key, + 'address' => $hope_contract['address'], + 'case_name' => $hope_contract['customer'], + 'num' => $hope_contract['num'], + 'brand' => '', + 'customer' => $hope_contract['customer'], + 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], + 'progress_remark' => $hope_contract['progress_status'] + //'platform_company'=>'', + // 'platforom_company_tel'=> '' + + ]; + //var_dump($insert_data); + DB::insert_table('con_maintance_examine_apply', $insert_data); +} + +$table = 'con_maintance_examine_apply'; +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +$where = " and apply_key='$apply_key'"; + +$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; +$data = []; +$data = DB::result($sql); + +#電梯詳細資料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], + 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], + 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], + 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], + 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], + + 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], + + 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], + + 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], + 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'placeholder' => '契約成交價', 'class' => 'form-control form-control-sm']], + +]; +$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . + " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); + +$j = 0; +$col_count = 12; +$cmecRow = " "; +foreach ($con_maintance_examine_clear_columm as $key => $val) { + $fieldVal = ""; + $_input = $val['tag'] == 'select' ? + FormHelper::select('', $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + // : ""; + $cmecRow .= ""; + if ((++$j % $col_count) == 0) { + if ($j == $col_count) $cmecRow .= ""; + $cmecRow .= ""; + } +} +$cmecRow .= ""; +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} +function get_sequnece_no($seq_name = '', $p_yyyymm = '') +{ + + if (empty($p_yyyymm) || empty($seq_name)) return null; + #當前年月 + list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); + if ($p_yyyymm != $yyyymm) { + DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); + } + // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; + list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); + + + return $seq_no; +} +$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; +list($result) = DB::result($sql); +if ($result['department_id'] == '511') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '512') { + $managerid = 'M0029'; + $managername = '陳家文'; +} else if ($result['department_id'] == '513') { + $managerid = 'M0086'; + $managername = '李烘銘'; +} else if ($result['department_id'] == '514') { + $managerid = 'M0033'; + $managername = '吳育宗'; +} else if ($user_id == 'TEST01') { + $managerid = 'TEST04'; + $managername = '區經理'; +} + +if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} + +?> + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+
+ + + ' /> + + + +
+
+
+

保養契約價格審核單

+
+
+ +
+
+ 契約信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[0][$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + //""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+
+
+ 電梯詳細資料 +
+
合約號作番號合約號作番號 部門 主管 契約員客戶名稱客戶名稱 收款階段 應收日期 是否應收合約金額 應收金額 已開金額 未開金額 0){echo $row[15];}else{echo '0';} ?>
$_input
+ + + + + + + + + + "; + + $i = 0; + $cmecRow = ''; + foreach ($con_maintance_examine_clear_columm as $col => $col_def) { + echo FormHelper::tag("th", ['colspan' => empty($col_def['attr']['colspan']) ? 1 : $col_def['attr']['colspan']], $col_def['label']); + + if ((++$j % $col_count) == 0) { + if ($j == $col_count) echo ""; + echo ""; + } + } + echo ''; + + + ?> + + + + + + $val) { + $j = 0; + $cmecRow = ""; + foreach ($con_maintance_examine_clear_columm as $col => $col_def) { + + $fieldVal = empty($val) ? "" : $val[$col]; + $_input = $col_def['tag'] == 'select' ? + FormHelper::select($col, $col_def['options'], $fieldVal, $col_def['attr']) + : FormHelper::text($col, $fieldVal, $col_def['attr'], $col_def['tag']); + $cmecRow .= ""; + if ((++$j % $col_count) == 0) { + $cmecRow .= ""; + $cmecRow .= ""; + } + } + + + echo $cmecRow . ""; + } + ?> + + +
+ 註意事項: +

1.速度單位是 米/分.

+

2.選擇贈送M1,保養月數需填寫60.

+

3.標準價格未帶出,請聯係業務部建立該規格報價.

+

4.無機房速度20~60米 以60米為標準.

+ + +
操作
+ $_input
+ +
+ +
+
+ 簽核操作 +
+
+ +
+
+
+
+ 簽核狀態 +
+
+ +
+ +
+ 下位簽核者 +
+
+ + +
+
+   + +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申請人 "; ?> + 退回"; ?> + 會簽"; ?> + + + + 簽核於: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/wms/cont/apply_form2.php b/wms/cont/apply_form2.php new file mode 100644 index 00000000..7f07f851 --- /dev/null +++ b/wms/cont/apply_form2.php @@ -0,0 +1,877 @@ +0) { + echo""; + exit; +} +*/ + +#係統ID +$system_id = 'con'; +#流程ID +$flow_id = 'con01'; +#表單號 $form_id; +$form_id = ""; +#價審單狀態 +$apply_st = ""; +list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1"); +// echo '
';
+// print_r($apply_key);
+// echo '
'; +// exit; +// if ($salesman != $user_id) { +// echo ''; +// exit; +// } +if (empty($apply_key)) $apply_st = 1; // 準備新增 +else { + //list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); + list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); + if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 + else $apply_st = 9; // 已到下一關,無法䖺改 +} + +// if ($apply_st > 2) { +// echo ""; +// exit; +// } + +if ($apply_st == 1) { + $wf = new WorkFlow($system_id, $flow_id, $form_id); + $wf->initWorkFlow($user_id); + $form_key = $wf->flowContext->getFormKey(); +} else { + $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); +} + +#獲取簽核意見 +$assign_opinions = Assign::get_records($form_key); + +#會簽部門意見 +$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); + +//預設冇有摺扣 +$wf->setFormData(['discount' => 100]); +$flowName = $wf->getFlowName(); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); +$if_show_assign = true; +//加載流程圖 +//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); +//$path = $fc[0]->wf_file; +//echo dirname(__DIR__)."/../"."$path"; + +//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); +#是否可會簽 +$isSplitable = $wf->isSplitable(); + +//表單數據 +#客戶表 +#1.電梯品牌選項 +$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; +$elevator_brand_opt = DB::result($sql); +#2.保養方式 +$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.電梯類型 +$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; +$payment_kind_opt = DB::result($sql); +#5.契約性質 +$sql = "select code_name value ,content label from code where field_name='contract_kind'"; +$contract_kind_opt = DB::result($sql); +#6.是否贈送M1 +$is_m1_bundle_opt = [ + ['label' => '是', 'value' => 'Y'], + ['label' => '否', 'value' => 'N'] + +]; +#7.機種 +$sql = "select code_name value ,content label from code where field_name='fp_kind'"; +$fp_kind_opt = DB::result($sql); +#抓取有望客戶資料 + +$vol_no = $_GET['vol_no']; +$where = " and vol_no='$vol_no'"; +$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; +$hope_contract = DB::result($sql); +$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; +#寫入 con_maintance_examine_apply +if ($apply_st == 1) { + #獲取評審單號 + $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); + //var_dump($hope_contract); + $insert_data = [ + 'apply_key' => $apply_key, + 'vol_no' => $vol_no, + 'form_key' => $form_key, + 'address' => $hope_contract['address'], + 'case_name' => $hope_contract['customer'], + 'num' => $hope_contract['num'], + 'brand' => '', + 'customer' => $hope_contract['customer'], + 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], + 'progress_remark' => $hope_contract['progress_status'] + //'platform_company'=>'', + // 'platforom_company_tel'=> '' + + ]; + //var_dump($insert_data); + DB::insert_table('con_maintance_examine_apply', $insert_data); +} +#抓使用者主管 +$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; +list($result) = DB::result($sql); +if ($result['department_id'] == '511') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '512') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '513') { + $managerid = 'M0086'; + $managername = '李烘銘'; +} else if ($result['department_id'] == '514') { + $managerid = 'M0033'; + $managername = '吳育宗'; +} + +if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} + +if ($result['department_id'] == 'M0008') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} +$table = 'con_maintance_examine_apply'; +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +$where = " and apply_key='$apply_key'"; + +$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; +$data = []; +$data = DB::result($sql); + +#電梯詳細資料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], + 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], + 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], + 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], + 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], + + 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], + + 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], + + 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], + 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], + +]; +$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . + " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); +$j = 0; +$col_count = 12; +$cmecRow = " "; +foreach ($con_maintance_examine_clear_columm as $key => $val) { + $fieldVal = ""; + $_input = $val['tag'] == 'select' ? + FormHelper::select('', $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + // : ""; + $cmecRow .= "
$_input"; + if ((++$j % $col_count) == 0) { + if ($j == $col_count) $cmecRow .= ""; + $cmecRow .= ""; + } +} + + +$cmecRow .= ""; +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} +function get_sequnece_no($seq_name = '', $p_yyyymm = '') +{ + + if (empty($p_yyyymm) || empty($seq_name)) return null; + #當前年月 + list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); + if ($p_yyyymm != $yyyymm) { + DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); + } + // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; + list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); + + + return $seq_no; +} + + +?> + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+
+ + + ' /> + + + +
+
+
+

保養契約價格審核單

+
+
+ +
+
+ 契約信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[0][$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + //""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+
+
+ 電梯詳細資料 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + +
+ 註意事項: +

1.速度單位是 米/分.

+

2.選擇贈送M1,保養月數需填寫60.

+

3.標準價格未帶出,請聯係業務部建立該規格報價.

+

4.無機房速度20~60米 以60米為標準.

+ + +
電梯許可代碼品牌電梯類型規格型號載重(KG)速度(m/min)停數層數人乘保養次數保養月數保養周期操作
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
人乘贈送M1竣工檢查年度上次年檢日期年檢費用(元)標準價格(元/月)契約報價(元/月)契約成交價(元/月)
+ +
+ +
+
+ 簽核操作 +
+
+ +
+
+
+
+ 簽核狀態 +
+
+ +
+ +
+ 下位簽核者 +
+
+ + +
+
+   + +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申請人 "; ?> + 退回"; ?> + 會簽"; ?> + + + + 簽核於: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ + + +
+ + + + + + \ No newline at end of file diff --git a/wms/cont/async_req.php b/wms/cont/async_req.php new file mode 100644 index 00000000..0d693a1e --- /dev/null +++ b/wms/cont/async_req.php @@ -0,0 +1,20 @@ + $code_name]); +} diff --git a/wms/cont/con_maintance_examine_clear.php b/wms/cont/con_maintance_examine_clear.php new file mode 100644 index 00000000..f2faf705 --- /dev/null +++ b/wms/cont/con_maintance_examine_clear.php @@ -0,0 +1,14 @@ + ['label' => "电梯注册代码", "value" => "", "tag" => 'text', 'class' => ''], + 'brand' => ['label' => "品牌", "value" => "", "tag" => 'text', 'class' => ''], + 'spec' => ['label' => "规格型号", "value" => "", "tag" => 'text', 'class' => ''], + 'weight' => ['label' => "载重", "value" => "", "tag" => 'text', 'class' => ''], + 'speed' => ['label' => "速度", "value" => "", "tag" => 'text', 'class' => ''], + 'stop' => ['label' => "停数", "value" => "", "tag" => 'text', 'class' => ''], + 'useful_years' => ['label' => "使用年限", "value" => "", "tag" => 'text', 'class' => ''], + 'last_check_date' => ['label' => "最近一次年检日期", "value" => "", "tag" => 'text', 'class' => ''], + 'speed_governors_check_expense' => ['label' => "限速器校验费", "value" => "", "tag" => 'text', 'class' => ''], +]; +$con_maintance_examine_clear = DB::result("SELECT * FROM con_maintance_examine_clear where 1=1 and cmstatus='Y' "); diff --git a/wms/cont/crmm06_submit.php b/wms/cont/crmm06_submit.php new file mode 100644 index 00000000..79b54de8 --- /dev/null +++ b/wms/cont/crmm06_submit.php @@ -0,0 +1,21 @@ +fillable; +foreach ($cols as $col) { + if (!in_array($col, array_keys($request))) { + continue; + } + $data[$col] = empty($request[$col]) ? NULL : $request[$col]; +} +$hecm->create( $data); + + +echo""; diff --git a/wms/cont/list.php b/wms/cont/list.php new file mode 100644 index 00000000..a019243e --- /dev/null +++ b/wms/cont/list.php @@ -0,0 +1,168 @@ + $item['system_id'], 'system_name' => $item['system_name']); +}, $res_get); +$system_name_opt = (array_unique($system_name_opt, SORT_REGULAR)); + + +$flow_name_opt = array_map(function ($item) { + return array('flow_id' => $item['flow_id'], 'flow_name' => $item['flow_name']); +}, $res_get); +$flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR)); + +?> + +
+ + + + + + + + + + + + + + + + + + + + + +
+

待签查询

+
系统名称 + + 流程名称
+ +
+
+ + + + + + + + + + + + + $data) : + ?> + + + + + + + + + + + + + +
序号系统名称流程名称接收日期当前签核者
+
+
+ \ No newline at end of file diff --git a/wms/cont/model/ConMaintanceExamineApplyModel.php b/wms/cont/model/ConMaintanceExamineApplyModel.php new file mode 100644 index 00000000..f4824a9a --- /dev/null +++ b/wms/cont/model/ConMaintanceExamineApplyModel.php @@ -0,0 +1,29 @@ +fillable as $col) { + $_data[$col] = empty($data[$col]) ? '' : $data[$col]; + } + DB::insert_table($this->table, $_data); + } + /** + * 创建或更新 + * + * @return void + */ + public function createOrUpdate(array $keyCol, array $data) + { + list($cnt) = DB::fields( + "select count(*) from $this->table where " . $keyCol[0] . " = '" . $keyCol[1] . "'" + ); + if ($cnt == 0) { + self::create(array_merge($data, $keyCol)); + } + } + + public function update(array $keyCol, array $data) + { + $_data = []; + foreach ($this->fillable as $col) { + if (in_array($col, array_keys($data))) $_data[$col] = empty($data[$col]) ? '' : $data[$col]; + } + DB::update_table($this->table, $_data, $keyCol[0] . '=\'' . $keyCol[1] . '\''); + } + /** + * 获取记录 + * + * @param array $cond + * @return void + */ + public function get(array $cond) + { + return []; + } +} diff --git a/wms/cont/query_form.php b/wms/cont/query_form.php new file mode 100644 index 00000000..86e741ed --- /dev/null +++ b/wms/cont/query_form.php @@ -0,0 +1,511 @@ +vol_no; +require_once './MICalculator.php'; +require_once './FormHelper.php'; +require_once './wf_common.php'; +list($form_key) = DB::fields("select form_key from con_maintance_examine_apply where apply_key='$apply_key'"); +//echo $form_key; +$flow = new Flow($form_key); +// 當前節點簽核開始 +//var_dump($flow); +$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $form_key); +#獲取簽核意見 +$assign_opinions = Assign::get_records($form_key); +$flowName = $wf->getFlowName(); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); +//表單數據 +#客戶表 +#客戶表 +#1.電梯品牌選項 +$sql = "select code_name value ,content label from code where field_name='elevator_brand'"; +$elevator_brand_opt = DB::result($sql); +#2.保養方式 +$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.電梯類型 +$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "select code_name value ,content label from code where field_name='payment_kind'"; +$payment_kind_opt = DB::result($sql); +#5.契約性質 +$sql = "select code_name value ,content label from code where field_name='contract_kind'"; +$contract_kind_opt = DB::result($sql); +#6.是否贈送M1 +$is_m1_bundle_opt = [ + ['label' => '是', 'value' => 'Y'], + ['label' => '否', 'value' => 'N'] +]; +#7.機種 +$sql = "select code_name value ,content label from code where field_name='fp_kind'"; +$fp_kind_opt = DB::result($sql); +$table = 'con_maintance_examine_apply'; +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "數量", "value" => "", "tag" => 'number', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + + // 'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + // 'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +$where = " and apply_key='$apply_key'"; + +$sql = "SELECT * FROM $table where 1=1 $where ORDER BY apply_key"; +$data = []; +list($data) = DB::result($sql); + +#電梯詳細資料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'class' => 'form-control form-control-sm']], + //'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], + 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + //'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']], + 'floors' => ['label' => "層數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'floors[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'persons' => ['label' => "人乘", "value" => "", "tag" => 'number', 'attr' => ['name' => 'persons[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + + 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + + + // 'elevator_num' => ['label' => "臺數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'brand_num[]', 'class' => 'form-control form-control-sm']], + 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'required', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'date', 'attr' => ['required', 'name' => 'last_check_date[]', 'colspan' => 2, 'type' => 'date', 'class' => 'form-control form-control-sm']], + //'speed_governors_check_expense' => ['label' => "限速器校驗費", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed_governors_check_expense[]', 'class' => 'form-control form-control-sm']], + // 'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']], + // 'commission_expense' => ['label' => "分成費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'commission_expense[]', 'class' => 'form-control form-control-sm']], + // 'management_expense' => ['label' => "管理費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'management_expense[]', 'class' => 'form-control form-control-sm']], + 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', 'colspan' => 2, 'class' => 'date form-control form-control-sm ']], + //'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']], + 'maintain_times' => ['label' => "保養次數", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "tag" => 'number', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + 'stand_price' => ['label' => "標準價格A(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "契約報價B(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "契約成交價C(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], + + + 'mi_cost' => ['label' => "標準成本D(元/月)", "value" => "", "tag" => 'number', 'attr' => ['readonly=true', 'disabled', 'colspan' => 2, 'name' => 'mi_cost[]', 'class' => 'form-control form-control-sm']], + 'discount' => ['label' => "折扣率E(%)", "value" => "", "tag" => 'number', 'attr' => ['readonly=true', 'disabled', 'colspan' => 2, 'name' => 'mi_cost_rate[]', 'class' => 'form-control form-control-sm']], + 'gross_profit' => ['label' => "毛利率F(%)", "value" => "", "tag" => 'number', 'attr' => ['readonly=true', 'disabled', 'colspan' => 2, 'name' => 'gross_profit[]', 'class' => 'form-control form-control-sm']], + +]; +$con_maintance_examine_clear = DB::result("SELECT register_code, + f_return_content('elevator_brand',elevator_brand) elevator_brand, + f_return_content('maintain_elevator_kind',elevator_kind) elevator_kind, + elevator_kind con_elevator_kind, + spec, + weight, + speed, + floors, + persons, + maintain_times, + maintain_months, + maintain_period, + is_m1_bundle, + + useful_years, + last_check_date, + speed_governors_check_expense, + service_expense, + commission_expense, + management_expense, + annual_survey_expense, + stand_price, + contract_price, + sold_price, + 0 mi_cost , + 0 discount, + 0 gross_profit + FROM + con_maintance_examine_clear + WHERE + 1 = 1 + AND apply_key='" . $apply_key . "' and cmstatus = 'Y'"); + +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} + + +?> + + + + + + + <?php echo $flowName; ?> + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + +
+
+
+

保養契約價格審核單

+
+
+ +
+
+ 契約信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + // print_r($val['label']); + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[$key]; + $fieldVal = empty($data) ? "" : $data[$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) : + FormHelper::tag("label", $val['attr'], $fieldVal); + + // ""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+ +
+
+ 電梯詳細資料 +
+ + + + + + empty($val['attr']['colspan']) + ? 1 : $val['attr']['colspan']], $val['label']); + + if ((++$j % 14) == 0) { + // if ($j == 12) echo ""; + + + echo ""; + } + } + + ?> + + + + + $val) { + $j = 0; + + $cmecRow = " "; + + foreach ($con_maintance_examine_clear_columm as $col => $col_def) { + $fieldVal = empty($val) ? "" : $val[$col]; + if ($col == 'mi_cost') { + $param = [ + 'elevator_type' => $val['con_elevator_kind'], + 'floors' => $val['floors'], + 'speed' => $val['speed'], + 'persons' => $val['persons'], + 'weight' => $val['weight'], + 'maintain_times' => $val['maintain_times'], + 'maintain_months' => $val['maintain_months'], + 'maintain_kind' => $data['maintain_kind'], + 'maintain_period' => $val['maintain_period'], + 'is_m1_bundle' => $val['is_m1_bundle'], + ]; + $mic = new MICalculator(); + $res = $mic->cal($param); + #MI報價 + $con_maintance_examine_clear[$key]['mi_cost'] = $fieldVal = $res['status'] == 'ok' ? $res['price'] : $res['message']; + $con_maintance_examine_clear[$key]['gross_profit'] = $val['gross_profit'] = "/"; //$fieldVal==0?0: (round(($val['sold_price'] - $val['mi_cost']) / $fieldVal, 2) * 100) . "%" + #扣率 + $val['discount'] = (100 * round($val['sold_price'] / $val['stand_price'], 4)) . "%"; + } + + $_input = FormHelper::tag("label", ['colspan' => empty($col_def['attr']['colspan']) ? 1 + : $col_def['attr']['colspan']], $fieldVal); + $cmecRow .= ""; + + $cmecRow = (++$j % 14 == 0) ? $cmecRow . "" : $cmecRow; + } + $tr_class = $tr_class == 'odd' ? "even" : "odd"; + echo $cmecRow . ""; + } + ?> + + + + + + + +
操作
$_input
+
+ + + + + +
+
+ +
+ + + +
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申請人 "; ?> + 退回"; ?> + 會簽"; ?> + + + + 簽核於: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/wms/cont/review_apply_form.php b/wms/cont/review_apply_form.php new file mode 100644 index 00000000..aac97e74 --- /dev/null +++ b/wms/cont/review_apply_form.php @@ -0,0 +1,507 @@ +user_id; +$apply_key = 'MB23060422'; +require_once './FormHelper.php'; +require_once './wf_common.php'; +#系统ID +$system_id = 'con'; +#流程ID +$flow_id = 'con01'; +#表单号 $form_id; +$form_id = ""; + +$wf = new WorkFlow($system_id, $flow_id, $form_id); +$wf->initWorkFlow($user_id); + +$form_key = $wf->flowContext->getFormKey(); + +#获取签核意见 +$assign_opinions = Assign::get_records($form_key); + +#会签部门意见 +$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); + +$flowName = $wf->getFlowName(); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); +$if_show_assign = true; + +#是否可会签 +$isSplitable = $wf->isSplitable(); + +//表单数据 +#客户表 +#1.电梯品牌选项 +$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by convert(content using gbk) asc "; +$elevator_brand_opt = DB::result($sql); +#2.保养方式 +$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.电梯类型 +$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "select code_name value ,content label from code where field_name='payment_kind'"; +$payment_kind_opt = DB::result($sql); +#5.合约性质 +$sql = "select code_name value ,content label from code where field_name='hope_contract_customer_kind'"; +$contract_kind_opt = DB::result($sql); + +#抓取有 + +$where = " and apply_key='$apply_key'"; +$sql = "SELECT * FROM con_maintance_examine_apply where 1=1 $where "; +$res_cmea = DB::result($sql); +$cmea = empty($res_cmea) ? [] : $res_cmea[0]; +#写入 con_maintance_review_apply +#获取评审单号 +//$cmea['payment_kind']; //付款方式 +//月付 12; 季付 三月一次;半年付 6个月一次, 年付 12个月 +// +$insert_data = [ + 'apply_key' => $apply_key, + 'vol_no' => $cmea['vol_no'], + 'form_key' => $cmea, + 'address' => $cmea['address'], + 'case_name' => $cmea['case_name'], + 'num' => $cmea['num'], + 'brand' => $cmea['brand'], + 'customer' => $hope_contract['customer'], + 'salesman' => $hope_contract['salesman'], + 'progress_remark' => $hope_contract['progress_remark'], + 'platform_company' => empty(trim($hope_contract['common_platform_company'])) ? $hope_contract['sales_platform_company'] : $hope_contract['common_platform_company'], + 'platforom_company_tel' => empty(trim($hope_contract['common_platform_tel'])) ? $hope_contract['sales_platform_tel'] : $hope_contract['common_platform_tel'] + +]; +//var_dump($insert_data); +DB::insert_table('con_maintance_examine_apply', $insert_data); +// $ins_sql="INSERT INTO `adm824727563_db`.`hope_contract_customer` (`vol_no`, `customer_kind`, `num`, `case_name`, `customer`, +// `salesman`, `address`, `lm_name`, `lm_tel`, `pre_order_date`, `order_rate`, `visit_date`, `progress_remark`, `common_platform_lm`, `common_platform_tel`, +// `common_platform_company`, `sales_platform_lm`, `sales_platform_tel`, `sales_platform_company`, `is_strategic_customer`, +// `strategic_customer`, `brand`, `partya_end_date`, `created_at`, `creator`, `updated_at`) VALUES ('Q2305047', '1', '47', '辰富佳苑', '上海新桃源物业管理有限公司', 'P0053', '松江广富林路3939弄', '周总', '13482376166', '2023-06-30 00:00:00', '中', '2023-05-23 18:13:05', '该物业为国有企业,本次 拜访物业沈经理引荐周总。经过与周总交流要求我司进行投标,今天进公司注册云采购账号,等公示后进一步了解如何投标再与周总会面细谈。', NULL, NULL, NULL, NULL, NULL, NULL, 'N', NULL, '永大', '2023-06-30 00:00:00', '2023-05-25 10:15:31', 'P0053', '2023-05-29 14:22:35'); +// "; +$table = 'con_maintance_examine_apply'; +#可编辑的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "评审单号", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷号", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + //'form_key' => ['label' => "表单号", "value" => "", "tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]], + 'address' => ['label' => "现场地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "现场名称", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "电梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "电梯台数", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "营业员", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保养方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "合约期限开始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "合约期限结束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'elevator_kind' => ['label' => "电梯类型", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'contract_kind' => ['label' => "合约性质", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'platform_company' => ['label' => "加盟公司名称", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + 'platforom_company_tel' => ['label' => "加盟公司电话", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + 'stand_price' => ['label' => "标准价格(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "合约报价(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "合约成交价(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + 'commission_expense' => ['label' => "加盟分成费(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'management_expense' => ['label' => "我司管理费(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'annual_survey_expense' => ['label' => "年检费用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'date form-control form-control-sm ']], + 'service_expense' => ['label' => "服务费", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm ']], + // 'postgress_remark' => ['label' => "洽商进度", "value" => "", "tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]] + +]; +$vol_no = empty($_GET['vol_no']) ? "" : $_GET['vol_no']; +$where = " and apply_key='$apply_key'"; + +$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; +$data = []; +$data = DB::result($sql); + +#电梯详细资料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "电梯注册代码", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'class' => 'form-control form-control-sm']], + 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'spec' => ['label' => "规格型号", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm']], + 'weight' => ['label' => "载重(KG)", "value" => "", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/s)", "value" => "", "tag" => 'number', 'attr' => ['name' => 'speed[]', 'class' => 'form-control form-control-sm']], + 'stop' => ['label' => "停数", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']], + 'elevator_num' => ['label' => "台数", "value" => "", "tag" => 'number', 'attr' => ['name' => 'brand_num[]', 'class' => 'form-control form-control-sm']], + 'useful_years' => ['label' => "使用年限", "value" => "", "tag" => 'number', 'attr' => ['name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "最近一次年检日期", "value" => "", "tag" => 'date', 'attr' => ['name' => 'last_check_date[]', 'colspan' => 2, 'type' => 'date', 'class' => 'form-control form-control-sm']], + 'speed_governors_check_expense' => ['label' => "限速器校验费", "value" => "", "tag" => 'number', 'attr' => ['name' => 'speed_governors_check_expense[]', 'class' => 'form-control form-control-sm']], +]; +$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . + " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); +$i = 0; +$cmecRow = " "; +foreach ($con_maintance_examine_clear_columm as $key => $val) { + $fieldVal = ""; + $_input = $val['tag'] == 'select' ? + FormHelper::select('', $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + // : ""; + $cmecRow .= "
$_input"; +} +$cmecRow .= ""; +function base_url($url) +{ + return "https://web.platform-cn.com/static/" . $url; +} +function get_sequnece_no($seq_name = '', $p_yyyymm = '') +{ + + if (empty($p_yyyymm) || empty($seq_name)) return null; + #当前年月 + //echo "select yyyymm from sequence where seq_name='$seq_name' "; + list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); + if ($p_yyyymm != $yyyymm) { + DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); + } + // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; + list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring(nextval('$seq_name'),2)) seq_no "); + + + return $seq_no; +} + + +?> + + + + + + + <?php echo $flowName; ?> + + + + + + + + + + + + + + + + + + + + +
+ 流程: + + + +
+ +
+ +
+
+ + + + +
+
+
+

保養合約價格審核單

+
+
+ +
+
+ 合约信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[0][$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + //""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商进度 +
+
+ + +
+
+
+
+ 电梯详细资料 +
+ + + + + + + + empty($val['attr']['colspan']) ? 1 : $val['attr']['colspan']], $val['label']); + //echo ""; + } + echo ""; + ?> + + + + + $val) { + $cmecRow = " "; + foreach ($con_maintance_examine_clear_columm as $col => $col_def) { + $fieldVal = empty($val) ? "" : $val[$col]; + $_input = $col_def['tag'] == 'select' ? + FormHelper::select($col, $col_def['options'], $fieldVal, $col_def['attr']) + : FormHelper::text($col, $fieldVal, $col_def['attr'], $col_def['tag']); + $cmecRow .= ""; + } + echo $cmecRow . ""; + } + ?> + +
" . $val['label'] . "操作
$_input
+ +
+ +
+
+ 签核操作 +
+
+ +
+
+
+
+ 签核状态 +
+
+ +
+ +
+ 下位签核者 +
+
+ + +
+
+ +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申请人 "; ?> + 退回"; ?> + 会签"; ?> + + + + 签核于: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/wms/cont/sign_form.php b/wms/cont/sign_form.php new file mode 100644 index 00000000..4ed488e2 --- /dev/null +++ b/wms/cont/sign_form.php @@ -0,0 +1,577 @@ +vol_no; +require_once './FormHelper.php'; +require_once '../cont/MICalculator.php'; + +require_once './wf_common.php'; +$flow = new Flow($form_key); +// 當前節點簽核開始 + +$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $form_key); +#獲取簽核意見 +$assign_opinions = Assign::get_records($form_key); +$flowName = $wf->getFlowName(); + +//表單數據 +#客戶表 +#1.電梯品牌選項 +$sql = "select code_name value ,content label from code where field_name='elevator_brand'"; +$elevator_brand_opt = DB::result($sql); +#2.保養方式 +$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.電梯類型 +$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "select code_name value ,content label from code where field_name='payment_kind'"; +$payment_kind_opt = DB::result($sql); +#5.契約性質 +$sql = "select code_name value ,content label from code where field_name='contract_kind'"; +$contract_kind_opt = DB::result($sql); +#6.是否贈送M1 +$is_m1_bundle_opt = [ + ['label' => '是', 'value' => 'Y'], + ['label' => '否', 'value' => 'N'] +]; +#7.機種 +$sql = "select code_name value ,content label from code where field_name='fp_kind'"; +$fp_kind_opt = DB::result($sql); +$table = 'con_maintance_examine_apply'; +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "數量", "value" => "", "tag" => 'number', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +$where = " and form_key='$form_key'"; + +$sql = "SELECT " . implode(',', array_keys($editableColumn)) . + " ,progress_remark FROM $table where 1=1 $where ORDER BY apply_key"; + +$data = []; +list($data) = DB::result($sql); + +#電梯詳細資料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "電梯註冊代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'class' => 'form-control form-control-sm']], + //'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], + 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + //'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']], + 'floors' => ['label' => "層數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'floors[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'persons' => ['label' => "人乘", "value" => "", "tag" => 'number', 'attr' => ['name' => 'persons[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + + 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + + + // 'elevator_num' => ['label' => "臺數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'brand_num[]', 'class' => 'form-control form-control-sm']], + 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'required', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'date', 'attr' => ['required', 'name' => 'last_check_date[]', 'colspan' => 2, 'type' => 'date', 'class' => 'form-control form-control-sm']], + //'speed_governors_check_expense' => ['label' => "限速器校驗費", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed_governors_check_expense[]', 'class' => 'form-control form-control-sm']], + // 'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']], + // 'commission_expense' => ['label' => "分成費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'commission_expense[]', 'class' => 'form-control form-control-sm']], + // 'management_expense' => ['label' => "管理費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'management_expense[]', 'class' => 'form-control form-control-sm']], + //'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', 'colspan' => 2, 'class' => 'date form-control form-control-sm ']], + //'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']], + 'maintain_times' => ['label' => "保養次數", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "tag" => 'number', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], + + + 'sold_price' => ['label' => "契約成交價C(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], + 'mi_cost' => ['label' => "標準成本D(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'mi_cost[]', 'class' => 'form-control form-control-sm']], + 'discount' => ['label' => "折扣率E(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'mi_cost_rate[]', 'class' => 'form-control form-control-sm']], + 'gross_profit' => ['label' => "毛利率F(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'gross_profit[]', 'class' => 'form-control form-control-sm']], + +]; +$con_maintance_examine_clear = DB::result("SELECT register_code, + f_return_content('elevator_brand',elevator_brand) elevator_brand, + f_return_content('maintain_elevator_kind',elevator_kind) elevator_kind, + elevator_kind con_elevator_kind, + spec, + weight, + speed, + floors, + persons, + maintain_times, + maintain_months, + maintain_period, + is_m1_bundle, + + useful_years, + last_check_date, + speed_governors_check_expense, + service_expense, + + stand_price, + contract_price, + sold_price, + 0 mi_cost , + 0 discount, + 0 gross_profit + FROM + con_maintance_examine_clear + WHERE + 1 = 1 + AND apply_key='" . $data['apply_key'] . "' and cmstatus='Y'"); + +#總臺數 +$count = count($con_maintance_examine_clear); +$total_sold_price = 0; +#總成交價 +#總標準價格 +$total_stand_price = 0; +#總標準成本 +foreach ($con_maintance_examine_clear as $val) { + $total_sold_price += $val['sold_price']; + $total_stand_price += $val['stand_price']; +} +$total_discount_rate = $total_sold_price == 0 ? 0 + : (100 * round($total_sold_price / $total_stand_price, 4)) . "%"; + +$wf->setFormData(['discount' => substr($total_discount_rate, 0, -1)]); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); + + +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} +function get_sequnece_no($seq_name = '', $p_yyyymm = '') +{ + + if (empty($p_yyyymm) || empty($seq_name)) return null; + #當前年月 + //echo "select yyyymm from sequence where seq_name='$seq_name' "; + list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); + if ($p_yyyymm != $yyyymm) { + DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); + } + // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; + list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring(nextval('$seq_name'),2)) seq_no "); + + + return $seq_no; +} + + +?> + + + + + + + + + + + + + + + + + + + + + + +
+ 流程: + + + +
+ +
+ +
+
+ + + ' /> + + + + +
+
+
+

保養契約價格審核單

+
+
+ +
+
+ 契約信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) : + FormHelper::tag("label", $val['attr'], $fieldVal); + + //""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+
+
+ 電梯詳細資料 +
+ + + + + + empty($val['attr']['colspan']) + ? 1 : $val['attr']['colspan']], $val['label']); + + if ((++$j % 14) == 0) { + // if ($j == 12) echo ""; + + + echo ""; + } + } + + ?> + + + + + $val) { + $j = 0; + + $cmecRow = " "; + + foreach ($con_maintance_examine_clear_columm as $col => $col_def) { + $fieldVal = empty($val) ? "" : $val[$col]; + if ($col == 'mi_cost') { + $param = [ + 'elevator_type' => $val['con_elevator_kind'], + 'floors' => $val['floors'], + 'speed' => $val['speed'], + 'persons' => $val['persons'], + 'weight' => $val['weight'], + 'maintain_times' => $val['maintain_times'], + 'maintain_months' => $val['maintain_months'], + 'maintain_kind' => $data['maintain_kind'], + 'maintain_period' => $val['maintain_period'], + 'is_m1_bundle' => $val['is_m1_bundle'], + ]; + $mic = new MICalculator(); + $res = $mic->cal($param); + #MI報價 + $con_maintance_examine_clear[$key]['mi_cost'] = $fieldVal = ($res['status'] + == 'ok' ? $res['price'] : $res['message']); + $con_maintance_examine_clear[$key]['gross_profit'] = $val['gross_profit'] = "/"; //$fieldVal==0?0: (round(($val['sold_price'] - $val['mi_cost']) / $fieldVal, 2) * 100) . "%" + #扣率 + $val['discount'] = (100 * round($val['sold_price'] / $val['stand_price'], 4)) . "%"; + } + + $_input = FormHelper::tag("label", ['colspan' => empty($col_def['attr']['colspan']) ? 1 + : $col_def['attr']['colspan']], $fieldVal); + $cmecRow .= ""; + + $cmecRow = (++$j % 14 == 0) ? $cmecRow . "" : $cmecRow; + } + $tr_class = $tr_class == 'odd' ? "even" : "odd"; + echo $cmecRow . ""; + } + ?> + + + + + + + +
操作
$_input
+
+ + + + + +
+
+ +
+ +
+
+ 簽核意見 +
+ +
+ +
+
+
+
+ 簽核狀態 +
+
+ +
+ +
+ 下位簽核者 +
+
+ + +
+
+ +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申請人 "; ?> + 退回"; ?> + 會簽"; ?> + + + + 簽核於: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/wms/cont/sign_list.php b/wms/cont/sign_list.php new file mode 100644 index 00000000..d31780b3 --- /dev/null +++ b/wms/cont/sign_list.php @@ -0,0 +1,225 @@ +'; + // print_r($sql_get); + // echo ''; + + $result = mysqli_query($link, $sql_get); + if ($result == false) { + die(mysqli_error($link)); + } + $res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC); + + + foreach ($res_get as $key => $data) { + // 結案隱藏 + if ($data['flow_code'] !== 'Z') { + $test = $data['form_key']; + // $sql = "SELECT mid FROM pricereview_sign WHERE id = $test"; + // $result = mysqli_fetch_all(mysqli_query($link, $sql), MYSQLI_ASSOC); + // echo '
';
+            // print_r($result);
+            // echo '
'; + $id[] = $test; + } + } + $inClause = implode(',', $id); +} + + +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], + 'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + 'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + //'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +// 設置一個空陣列來放資料 +$data = array(); + +$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman']; +//$where = " and salesman like '%'"; +$where = " and salesman = '$salesman'"; + +// 可瀏覽全部資料的部門 +$depart_arr = ["220"]; +$sql = "select department_id from account where accountid = '$user_id'"; +$res = mysqli_query($link, $sql); +$row = mysqli_fetch_row($res); +$user_department_id = $row[0]; +mysqli_free_result($res); +if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $where = ""; + +// 電梯廠牌 +$elevator_brand_arr = []; +$sql = "select code_name ,content from code where field_name='elevator_brand'"; +$res = mysqli_query($link, $sql); +while ($row = mysqli_fetch_row($res)) { + $elevator_brand_arr[$row[0]] = $row[1]; +} +mysqli_free_result($res); +if (!empty($res_get)) { + $sql = "SELECT + apply_key, + vol_no, + address, + case_name, + brand , + num , + f_return_name(salesman) salesman, + f_return_content('maintain_kind',maintain_kind ) maintain_kind, + date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, + date_format(contract_end_date,'%Y/%m/%d') contract_end_date , + f_return_content('contract_kind',contract_kind ) contract_kind, + platform_company, + platforom_company_tel, + form_key, + + f_return_content('payment_kind',payment_kind ) payment_kind FROM $table WHERE form_key IN ($inClause) "; +} else { + $sql = "SELECT + apply_key, + vol_no, + address, + case_name, + brand , + num , + f_return_name(salesman) salesman, + f_return_content('maintain_kind',maintain_kind ) maintain_kind, + date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, + date_format(contract_end_date,'%Y/%m/%d') contract_end_date , + f_return_content('contract_kind',contract_kind ) contract_kind, + platform_company, + platforom_company_tel, + form_key, + + f_return_content('payment_kind',payment_kind ) payment_kind FROM $table + where 1=1 $where ORDER BY vol_no"; +} +// echo $sql; +$data = mysqli_query($link, $sql); +// echo '
';
+// print_r($data);
+// echo '
'; +?> + +Please fill up the required field!

"; + } else { + header("Location:repair-index.php"); + } + } + +?> + + +
+
+ + + + + + + + +
+

(契約)價審單查詢

+
+ + + "; + foreach ($editableColumn as $key => $val) { + + echo ""; + } + echo ""; + // echo ""; + echo ""; + ?> + + + + + $val) { + if ($key == 'apply_key') { + echo ""; + } elseif ($key == 'brand') { + echo ""; + } else { + echo ""; + } + } + //list($signer)=DB::fields("); + //echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ." + list($signer) = mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='" . $row['form_key'] . "'")); + + echo ""; + + ?> + + + + +
" . $val['label'] . "是否結案刪除
" . $row[$key] . "" . (!empty($row[$key]) ? $elevator_brand_arr[$row[$key]] : "") . "" . $row[$key] . "" . (empty($signer) ? "結案" : "N") . "
+
+ +There is no record!"; +endif; + +#代表結束連線 +mysqli_close($link); + +include "../footer.php"; + +?> \ No newline at end of file diff --git a/wms/cont/submit.php b/wms/cont/submit.php new file mode 100644 index 00000000..82838567 --- /dev/null +++ b/wms/cont/submit.php @@ -0,0 +1,78 @@ +"; + echo "alert('請確認電梯資料或未選擇下位簽核者!');"; + echo "history.go(-1);"; + echo ""; + exit; +} + +//更新表单ConMaintanceExamineApplyModel +$cmea = new ConMaintanceExamineApplyModel(); +$apply_key=$request['apply_key']; +$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => ''])); +//更新电梯列表 +if (!empty($request["reg_del"])) { + $register_code_del_arr = explode(",", rtrim($request["reg_del"], ",")); + foreach ($register_code_del_arr as $val) { + $sql = "update con_maintance_examine_clear set cmstatus = 'D' where apply_key = '$apply_key' and register_code = '$val' and cmstatus <> 'D'"; + DB::query($sql); + } +} +if (!empty($request['register_code']) && count($request['register_code']) > 0) { + $cmec = new ConMaintanceExamineClearModel(); + for ($i = 0; $i < count($request['register_code']); $i++) { + $data = [ + 'apply_key' => $request['apply_key'] + ]; + $cols = array_diff($cmec->fillable, ['apply_key']); + foreach ($cols as $col) { + $data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i]; + if ($col=="annual_survey_expense") $data[$col] = '0.00'; + } + $cmec->create($data); + } +} + +//var_dump($_POST); +//var_dump($_GET); + +if ($tosign) { + #流程开始,var_dump($request); + $flow = new Flow($request['form_key']); + // 当前节点签核开始 + $wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']); + $wf->setFormData($request); + $wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']); + //当前节点签核结束 + $responses['flowName'] = $wf->getFlowName(); + $responses['form_key'] = $request['form_key']; + //var_dump($request); + #結案發通知給營業員 + if ($request['assign_status'] == 'F4') { + + list($salesman, $case_name ) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key. "' "); + $ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`) + VALUES ( '1', '契約價審單結案通知(" .$case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')"; + DB::query($ins_notice_sql); + // echo $ins_notice_sql; + } +} +echo ""; diff --git a/wms/cont/success.php b/wms/cont/success.php new file mode 100644 index 00000000..96c2a2f2 --- /dev/null +++ b/wms/cont/success.php @@ -0,0 +1 @@ +

成功提交返回待签

\ No newline at end of file diff --git a/wms/cont/t.php b/wms/cont/t.php new file mode 100644 index 00000000..8bf1a33a --- /dev/null +++ b/wms/cont/t.php @@ -0,0 +1,84 @@ + 'A', + 'floors' => 7, + 'speed' => 1, + 'persons' => 6, + 'weight' => 1000, + 'maintain_times' => 1, + 'maintain_months' => 12, + 'maintain_kind' => 2, + 'maintain_period' => 1, //默认为1月1次, 2是为2月一次 + 'is_m1_bundle' => 'N', +]; + +//货梯 +$param = [ + + 'elevator_type' => 'B', + 'floors' => 7, + 'speed' => 1, + 'persons' => 6, + 'weight' => 1000, + 'maintain_times' => 1, + 'maintain_months' => 12, + 'maintain_kind' => 2, + 'maintain_period' => 1, //默认为1月1次, 2是为2月一次 + 'is_m1_bundle' => 'N', +]; + + +//病床梯 +$param = [ + + 'elevator_type' => 'C', + 'floors' => 28, + 'speed' => 1, + 'persons' => 6, + 'weight' => 1000, + 'maintain_times' => 2, //病床梯一月2次保养 + 'maintain_months' => 12, + 'maintain_kind' => 2, + 'maintain_period' => 1, //默认为1月1次, 2是为2月一次 + 'is_m1_bundle' => 'N', +]; + +//无机房 +$param = [ + 'elevator_type' => 'D', + 'floors' => 3, + 'speed' => 1, + 'persons' => 6, + 'weight' => 1000, + 'maintain_times' => 1, //病床梯一月2次保养 + 'maintain_months' => 12, + 'maintain_kind' => 3, + 'maintain_period' => 1, //默认为1月1次, 2是为2月一次 + 'is_m1_bundle' => 'N', +]; + + +//家用梯 +$param = [ + 'elevator_type' => 'E', + 'floors' => 3, + 'speed' => 1, + 'persons' => 6, + 'weight' => 1000, + 'maintain_times' => 1, //病床梯一月2次保养 + 'maintain_months' => 60, + 'maintain_kind' => 2, + 'maintain_period' => 1, //默认为1月1次, 2是为2月一次 + 'is_m1_bundle' => 'Y', +]; + +$mic = new MSCalculator(); +$price = $mic->cal($_GET); +echo json_encode($price); diff --git a/wms/cont/test.php b/wms/cont/test.php new file mode 100644 index 00000000..55f9873a --- /dev/null +++ b/wms/cont/test.php @@ -0,0 +1,174 @@ + $regions['content'], + #当月件数 + 'd_item_cnt' => 0, + #当月台数 + 'd_mfg_cnt' => 0, + #直销件数 + 'z_item_cnt' => 0, + #直销台数 + 'z_mfg_cnt' => 0, + #平台件数 + 'p_item_cnt' => 0, + #平台台数 + 'p_mfg_cnt' => 0, + #台数合计 + 'mfg_total' => 0, + #件数合计 + 'item_total' => 0, + #营业人数 + 'persons' => 0, + #人均台数 + 'avg_mfg_total' => 0, + #人均件数 + 'avg_item_total' => 0, + ]; + #遍历大区下面所有分公司 + $res_branch = DB::result("select depart_no,depart_name from depart where regions='" . $regions['code_name'] . "' "); + foreach ($res_branch as $branch) { + #遍历分公司下面所有人 + $depart_data = []; + $res_salesman = DB::result("select employee_no,name from employee + where depart_no='" . $branch['depart_no'] . "' "); + $depart_data = [ + 'depart_name' => $branch['depart_name'], + + ]; + foreach ($res_salesman as $salesman) { + //当月预定成交台数 件数 + $d_item_cnt = $d_mfg_cnt = $z_item_cnt = $z_mfg_cnt = $p_item_cnt = $p_mfg_cnt = 0; + list($d_item_cnt, $d_mfg_cnt) = DB::fields("select count(vol_no) item_cnt ,sum(num) mfg_cnt + From hope_contract_customer where salesman='" . $salesman['employee_no'] . "' + and pre_order_date between DATE_FORMAT(concat('$yyyymm','01'),'%Y-%m-%d') + and LAST_DAY(STR_TO_DATE('$yyyymm', '%Y%m'))"); + // 直销 台数 件数 + list($z_item_cnt, $z_mfg_cnt) = DB::fields("select count(vol_no) z_item_cnt ,sum(num) + z_mfg_cnt From hope_contract_customer where salesman=''" . $salesman['employee_no'] . "' + and customer_kind='1'"); + // 平台 台数 件数 + list($p_item_cnt, $p_mfg_cnt) = DB::fields("select count(vol_no) p_item_cnt ,sum(num) + p_mfg_cnt From hope_contract_customer where salesman='" . $salesman['employee_no'] . "' + and customer_kind!='1' + "); + #当月件数 + $d_item_cnt = empty($d_item_cnt) ? 0 : $d_item_cnt; + #当月台数 + $d_mfg_cnt = empty($d_mfg_cnt) ? 0 : $d_mfg_cnt; + #直销件数 + $z_item_cnt = empty($z_item_cnt) ? 0 : $z_item_cnt; + #直销台数 + $z_mfg_cnt = empty($z_mfg_cnt) ? 0 : $z_mfg_cnt; + #平台件数 + $p_item_cnt = empty($p_item_cnt) ? 0 : $p_item_cnt; + #平台台数 + $p_mfg_cnt = empty($p_mfg_cnt) ? 0 : $p_mfg_cnt; + #台数合计 + $mfg_total = $z_mfg_cnt + $p_mfg_cnt; + #件数合计 + $item_total = $z_item_cnt + $p_item_cnt; + #营业人数 + $persons = 1; + #人均台数 + $avg_mfg_total = $z_mfg_cnt + $p_mfg_cnt; + #人均件数 + $avg_item_total = $z_item_cnt + $p_item_cnt; + + #部门数据 + $depart_data = [ + #当月件数 + 'd_item_cnt' => $depart_data['d_item_cnt'] + $d_item_cnt, + #当月台数 + 'd_mfg_cnt' => $depart_data['d_mfg_cnt'] + $d_mfg_cnt, + #直销件数 + 'z_item_cnt' => $depart_data['z_item_cnt'] + $z_item_cnt, + #直销台数 + 'z_mfg_cnt' => $depart_data['z_mfg_cnt'] + $z_mfg_cnt, + #平台件数 + 'p_item_cnt' => $depart_data['p_item_cnt'] + $p_item_cnt, + #平台台数 + 'p_mfg_cnt' => $depart_data['p_mfg_cnt'] + $p_mfg_cnt, + #台数合计 + 'mfg_total' => $depart_data['mfg_total'] + $mfg_total, + #件数合计 + 'item_total' => $depart_data['item_total'] + $item_total, + #营业人数 + 'persons' => $depart_data['persons'] + $persons, + #人均台数 $z_mfg_cnt + $p_mfg_cnt + 'avg_mfg_total' => ($depart_data['z_mfg_cnt'] + $z_mfg_cnt) / ($depart_data['persons'] + $persons), + #人均件数 + 'avg_item_total' => ($depart_data['z_item_cnt'] + $z_item_cnt) / ($depart_data['persons'] + $persons) + ]; + + + $region_data[$regions['code_name']] = [ + #当月件数 + 'd_item_cnt' => $region_data[$regions['code_name']]['d_item_cnt'] + $depart_data['d_item_cnt'], + #当月台数 + 'd_mfg_cnt' => $region_data[$regions['code_name']]['d_mfg_cnt'] + $depart_data['d_mfg_cnt'], + #直销件数 + 'z_item_cnt' => $region_data[$regions['code_name']]['z_item_cnt'] + $depart_data['z_item_cnt'], + #直销台数 + 'z_mfg_cnt' => $region_data[$regions['code_name']]['z_mfg_cnt'] + $depart_data['z_mfg_cnt'], + #平台件数 + 'p_item_cnt' => $region_data[$regions['code_name']]['p_item_cnt'] + $depart_data['p_item_cnt'], + #平台台数 + 'p_mfg_cnt' => $region_data[$regions['code_name']]['p_mfg_cnt'] + $depart_data['p_mfg_cnt'], + #台数合计 + 'mfg_total' => $region_data[$regions['code_name']]['mfg_total'] + $depart_data['mfg_total'], + #件数合计 + 'item_total' => $region_data[$regions['code_name']]['item_total'] + $depart_data['item_total'], + #营业人数 + 'persons' => $region_data[$regions['code_name']]['persons'] + $depart_data['persons'], + #人均台数 $z_mfg_cnt + $p_mfg_cnt + 'avg_mfg_total' => ($region_data[$regions['code_name']]['z_mfg_cnt']) + / ($region_data[$regions['persons']]), + #人均件数 + 'avg_item_total' => ($region_data[$regions['code_name']]['z_item_cnt']) + / ($region_data[$regions['persons']]), + + ]; + $depart_data['children'][] = [ + 'depart_name' => $salesman['name'], + #当月件数 + 'd_item_cnt' => $d_item_cnt, + #当月台数 + 'd_mfg_cnt' => $d_mfg_cnt, + #直销件数 + 'z_item_cnt' => $z_item_cnt, + #直销台数 + 'z_mfg_cnt' => $z_mfg_cnt, + #平台件数 + 'p_item_cnt' => $p_item_cnt, + #平台台数 + 'p_mfg_cnt' => $p_mfg_cnt, + #台数合计 + 'mfg_total' => $z_mfg_cnt + $p_mfg_cnt, + #件数合计 + 'item_total' => $z_item_cnt + $p_item_cnt, + #营业人数 + 'persons' => 1, + #人均台数 + 'avg_mfg_total' => $z_mfg_cnt + $p_mfg_cnt, + #人均件数 + 'avg_item_total' => $z_item_cnt + $p_item_cnt, + ]; + } + #大区资料 + if (empty($region_data[$regions['code_name']])) $region_data[$regions['code_name']] = []; + if ($region_data[$regions['code_name']]['children']) $region_data[$regions['code_name']]['children'] = []; + array_push($region_data[$regions['code_name']]['children'], $depart_data); + } + echo "
";
+    var_dump($region_data);
+}
diff --git a/wms/cont/wf_common.php b/wms/cont/wf_common.php
new file mode 100644
index 00000000..519d341f
--- /dev/null
+++ b/wms/cont/wf_common.php
@@ -0,0 +1,20 @@
+免保期限
                         
                             
- +
個月
@@ -634,7 +634,7 @@ $para = "function_name=pricereview&" . $token_link; const secondPayDeadline = ''; const tradeaddress = ''; const tradedeadline = 180 - const freedeadline = 18; + const freedeadline = 12; const regulations = 10; const workdeadline_a = 60; const workdeadline_b = 7; diff --git a/wms/contract/insertData.php b/wms/contract/insertData.php index 38ee1051..5c4f8a99 100644 --- a/wms/contract/insertData.php +++ b/wms/contract/insertData.php @@ -114,7 +114,10 @@ foreach ($sheet->getRowIterator() as $key => $row) { } elseif ($id == 15) { $kind = 'E'; $subkind = 'E1'; - } elseif ($id == 16) { + } elseif ($id == 17) { + $kind = 'E'; + $subkind = 'E1'; + }elseif ($id == 18) { $kind = 'F'; $subkind = 'F1'; } diff --git a/wms/contract/option/f1.xlsx b/wms/contract/option/f1.xlsx deleted file mode 100644 index 0189dfe9..00000000 Binary files a/wms/contract/option/f1.xlsx and /dev/null differ diff --git a/wms/contract/option/facility.xlsx b/wms/contract/option/facility.xlsx deleted file mode 100644 index f51a3944..00000000 Binary files a/wms/contract/option/facility.xlsx and /dev/null differ diff --git a/wms/contract/option/option1.xlsx b/wms/contract/option/option1.xlsx deleted file mode 100644 index 122bf90a..00000000 Binary files a/wms/contract/option/option1.xlsx and /dev/null differ diff --git a/wms/contract/option/option10.xlsx b/wms/contract/option/option10.xlsx deleted file mode 100644 index 034aaa77..00000000 Binary files a/wms/contract/option/option10.xlsx and /dev/null differ diff --git a/wms/contract/option/option11.xlsx b/wms/contract/option/option11.xlsx deleted file mode 100644 index 5224e609..00000000 Binary files a/wms/contract/option/option11.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option.xlsx b/wms/contract/option/option1127/option.xlsx deleted file mode 100644 index 36c0cece..00000000 Binary files a/wms/contract/option/option1127/option.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option1.xlsx b/wms/contract/option/option1127/option1.xlsx deleted file mode 100644 index 4a197ec5..00000000 Binary files a/wms/contract/option/option1127/option1.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option10.xlsx b/wms/contract/option/option1127/option10.xlsx deleted file mode 100644 index 4087ccf5..00000000 Binary files a/wms/contract/option/option1127/option10.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option11.xlsx b/wms/contract/option/option1127/option11.xlsx deleted file mode 100644 index 9dc16b7e..00000000 Binary files a/wms/contract/option/option1127/option11.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option12.xlsx b/wms/contract/option/option1127/option12.xlsx deleted file mode 100644 index 1f57b701..00000000 Binary files a/wms/contract/option/option1127/option12.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option13.xlsx b/wms/contract/option/option1127/option13.xlsx deleted file mode 100644 index df84bbc7..00000000 Binary files a/wms/contract/option/option1127/option13.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option14.xlsx b/wms/contract/option/option1127/option14.xlsx deleted file mode 100644 index a36ca847..00000000 Binary files a/wms/contract/option/option1127/option14.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option15.xlsx b/wms/contract/option/option1127/option15.xlsx deleted file mode 100644 index 7ef897bc..00000000 Binary files a/wms/contract/option/option1127/option15.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option16.xlsx b/wms/contract/option/option1127/option16.xlsx deleted file mode 100644 index 8e6bce19..00000000 Binary files a/wms/contract/option/option1127/option16.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option2.xlsx b/wms/contract/option/option1127/option2.xlsx deleted file mode 100644 index 17daba20..00000000 Binary files a/wms/contract/option/option1127/option2.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option20.xlsx b/wms/contract/option/option1127/option20.xlsx deleted file mode 100644 index e2422b5d..00000000 Binary files a/wms/contract/option/option1127/option20.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option3.xlsx b/wms/contract/option/option1127/option3.xlsx deleted file mode 100644 index 5c39ee18..00000000 Binary files a/wms/contract/option/option1127/option3.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option4.xlsx b/wms/contract/option/option1127/option4.xlsx deleted file mode 100644 index c44f5df5..00000000 Binary files a/wms/contract/option/option1127/option4.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option5.xlsx b/wms/contract/option/option1127/option5.xlsx deleted file mode 100644 index 170ca69c..00000000 Binary files a/wms/contract/option/option1127/option5.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option6.xlsx b/wms/contract/option/option1127/option6.xlsx deleted file mode 100644 index 68f18ef9..00000000 Binary files a/wms/contract/option/option1127/option6.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option7.xlsx b/wms/contract/option/option1127/option7.xlsx deleted file mode 100644 index ee4d39eb..00000000 Binary files a/wms/contract/option/option1127/option7.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option8.xlsx b/wms/contract/option/option1127/option8.xlsx deleted file mode 100644 index 5f431522..00000000 Binary files a/wms/contract/option/option1127/option8.xlsx and /dev/null differ diff --git a/wms/contract/option/option1127/option9.xlsx b/wms/contract/option/option1127/option9.xlsx deleted file mode 100644 index 90616cc0..00000000 Binary files a/wms/contract/option/option1127/option9.xlsx and /dev/null differ diff --git a/wms/contract/option/option12.xlsx b/wms/contract/option/option12.xlsx deleted file mode 100644 index e2a1ac6f..00000000 Binary files a/wms/contract/option/option12.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option.xlsx b/wms/contract/option/option1220/option.xlsx deleted file mode 100644 index 36c0cece..00000000 Binary files a/wms/contract/option/option1220/option.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option1.xlsx b/wms/contract/option/option1220/option1.xlsx deleted file mode 100644 index 4a197ec5..00000000 Binary files a/wms/contract/option/option1220/option1.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option10.xlsx b/wms/contract/option/option1220/option10.xlsx deleted file mode 100644 index 4087ccf5..00000000 Binary files a/wms/contract/option/option1220/option10.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option11.xlsx b/wms/contract/option/option1220/option11.xlsx deleted file mode 100644 index 9dc16b7e..00000000 Binary files a/wms/contract/option/option1220/option11.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option12.xlsx b/wms/contract/option/option1220/option12.xlsx deleted file mode 100644 index 1f57b701..00000000 Binary files a/wms/contract/option/option1220/option12.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option13.xlsx b/wms/contract/option/option1220/option13.xlsx deleted file mode 100644 index df84bbc7..00000000 Binary files a/wms/contract/option/option1220/option13.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option14.xlsx b/wms/contract/option/option1220/option14.xlsx deleted file mode 100644 index a36ca847..00000000 Binary files a/wms/contract/option/option1220/option14.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option15.xlsx b/wms/contract/option/option1220/option15.xlsx deleted file mode 100644 index 7ef897bc..00000000 Binary files a/wms/contract/option/option1220/option15.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option16.xlsx b/wms/contract/option/option1220/option16.xlsx deleted file mode 100644 index 8e6bce19..00000000 Binary files a/wms/contract/option/option1220/option16.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option2.xlsx b/wms/contract/option/option1220/option2.xlsx deleted file mode 100644 index 17daba20..00000000 Binary files a/wms/contract/option/option1220/option2.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option20.xlsx b/wms/contract/option/option1220/option20.xlsx deleted file mode 100644 index e2422b5d..00000000 Binary files a/wms/contract/option/option1220/option20.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option3.xlsx b/wms/contract/option/option1220/option3.xlsx deleted file mode 100644 index 5c39ee18..00000000 Binary files a/wms/contract/option/option1220/option3.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option4.xlsx b/wms/contract/option/option1220/option4.xlsx deleted file mode 100644 index c44f5df5..00000000 Binary files a/wms/contract/option/option1220/option4.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option5.xlsx b/wms/contract/option/option1220/option5.xlsx deleted file mode 100644 index 170ca69c..00000000 Binary files a/wms/contract/option/option1220/option5.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option6.xlsx b/wms/contract/option/option1220/option6.xlsx deleted file mode 100644 index 68f18ef9..00000000 Binary files a/wms/contract/option/option1220/option6.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option7.xlsx b/wms/contract/option/option1220/option7.xlsx deleted file mode 100644 index ee4d39eb..00000000 Binary files a/wms/contract/option/option1220/option7.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option8.xlsx b/wms/contract/option/option1220/option8.xlsx deleted file mode 100644 index 5f431522..00000000 Binary files a/wms/contract/option/option1220/option8.xlsx and /dev/null differ diff --git a/wms/contract/option/option1220/option9.xlsx b/wms/contract/option/option1220/option9.xlsx deleted file mode 100644 index 90616cc0..00000000 Binary files a/wms/contract/option/option1220/option9.xlsx and /dev/null differ diff --git a/wms/contract/option/option13.xlsx b/wms/contract/option/option13.xlsx deleted file mode 100644 index 74efcbaa..00000000 Binary files a/wms/contract/option/option13.xlsx and /dev/null differ diff --git a/wms/contract/option/option14.xlsx b/wms/contract/option/option14.xlsx deleted file mode 100644 index 07d5b6ce..00000000 Binary files a/wms/contract/option/option14.xlsx and /dev/null differ diff --git a/wms/contract/option/option15.xlsx b/wms/contract/option/option15.xlsx deleted file mode 100644 index 3620e7ca..00000000 Binary files a/wms/contract/option/option15.xlsx and /dev/null differ diff --git a/wms/contract/option/option3.xlsx b/wms/contract/option/option3.xlsx deleted file mode 100644 index 4c3416ef..00000000 Binary files a/wms/contract/option/option3.xlsx and /dev/null differ diff --git a/wms/contract/option/option4.xlsx b/wms/contract/option/option4.xlsx deleted file mode 100644 index 7046969e..00000000 Binary files a/wms/contract/option/option4.xlsx and /dev/null differ diff --git a/wms/contract/option/option5.xlsx b/wms/contract/option/option5.xlsx deleted file mode 100644 index 9e70e1e8..00000000 Binary files a/wms/contract/option/option5.xlsx and /dev/null differ diff --git a/wms/contract/option/option6.xlsx b/wms/contract/option/option6.xlsx deleted file mode 100644 index d647884b..00000000 Binary files a/wms/contract/option/option6.xlsx and /dev/null differ diff --git a/wms/contract/option/option7.xlsx b/wms/contract/option/option7.xlsx deleted file mode 100644 index 3af4c28d..00000000 Binary files a/wms/contract/option/option7.xlsx and /dev/null differ diff --git a/wms/contract/option/option8.xlsx b/wms/contract/option/option8.xlsx deleted file mode 100644 index 7f1c37eb..00000000 Binary files a/wms/contract/option/option8.xlsx and /dev/null differ diff --git a/wms/contract/option/option9.xlsx b/wms/contract/option/option9.xlsx deleted file mode 100644 index 1d43cf6f..00000000 Binary files a/wms/contract/option/option9.xlsx and /dev/null differ diff --git a/wms/crm/crmm01-index.php b/wms/crm/crmm01-index.php index 2ed535b9..58dfaba4 100644 --- a/wms/crm/crmm01-index.php +++ b/wms/crm/crmm01-index.php @@ -41,7 +41,7 @@ $where .= " and salesman_name like '$salesman'"; $sql_cmd = sql_myself($user_id, "salesman"); // max,許紓晴,林慧珊,鄭伊岑 -if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0107" || $user_id == "M0193" || $user_id == "M0149" || $user_id == "M0189" || $user_id == "M0061" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04" ) $sql_cmd = ""; +if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0107" || $user_id == "M0193" || $user_id == "M0149" || $user_id == "M0189" || $user_id == "M0061" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04" || $user_id == "M0175") $sql_cmd = ""; if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd); /* $checkAll = ['p0044', 'M0007']; diff --git a/wms/fun_global.php b/wms/fun_global.php index d4917d8d..72622a54 100644 --- a/wms/fun_global.php +++ b/wms/fun_global.php @@ -14,6 +14,9 @@ function sql_myself($user_id, $column = "creater") global $link; $follower_arr = []; // 下屬列表 + if($user_id == 'M0105'){ + $user_id = "M0137"; + } $sql_cmd = "where ($column = '$user_id'"; $follower_arr = find_follow($user_id); if (count($follower_arr) > 0) { @@ -645,7 +648,7 @@ function getAccounttype($link, $user_id) */ function collect_month($contractday) { - $today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d'))))); + $today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-t'))))); $latest_timestamp = $contractday; $latest_date = new DateTime(); $latest_date->setTimestamp($latest_timestamp); diff --git a/wms/mkt/api/getElevatorMi.php b/wms/mkt/api/getElevatorMi.php new file mode 100644 index 00000000..fbea22cc --- /dev/null +++ b/wms/mkt/api/getElevatorMi.php @@ -0,0 +1,46 @@ +prepare($sql_str); +$stmt->bindParam(':elevator_type', $spec); +$stmt->bindParam(':max_weight', $weight); +$stmt->bindParam(':max_speed', $speed); +$stmt->execute(); +$mi = $stmt->fetch(PDO::FETCH_ASSOC); + + +if(!$mi){ + echo false; + exit; +} + +$stop = $stop > $mi['max_floors'] ? $mi['max_floors'] : $stop; +$stop = $stop < 2 ? 2 : $stop; +$equipment_fee = round($mi['purchase_cost'] + ($stop - $mi['base_floor']) * $mi['material_plus']); +$customs_shipping_fee = round($equipment_fee * 0.09); +$unloading_fee = round($mi['unloading']); +$transport_site_fee = round($mi['transport_site']); +$install_fee = round(($mi['install_price'] + ($stop - $mi['base_floor']) * $mi['install_plus']) + $mi['trial_price'] + ($stop - $mi['base_floor']) * $mi['trial_plus']); +$free1y_fee = round($mi['free1y']); +$other_fee = round($mi['crane'] + $mi['wooden_box'] + $mi['consumables']); + + +$newMI = [ + 'equipment_fee'=>$equipment_fee, + 'customs_shipping_fee'=>$customs_shipping_fee, + 'unloading_fee'=>$unloading_fee, + 'transport_site_fee'=>$transport_site_fee, + 'install_fee'=>$install_fee, + 'free1y_fee'=>$free1y_fee, + 'other_fee'=>$other_fee +]; +echo json_encode($newMI); diff --git a/wms/mkt/api/getElevatorPrice.php b/wms/mkt/api/getElevatorPrice.php new file mode 100644 index 00000000..64b3098c --- /dev/null +++ b/wms/mkt/api/getElevatorPrice.php @@ -0,0 +1,19 @@ +prepare($sql_str); +$stmt->bindParam(':model', $model); +$stmt->execute(); +$el = $stmt->fetch(PDO::FETCH_ASSOC); +if($el){ + $price = $el['price']; + $id = $el['id']; +}else{ + $price = null; + $id = null; +} +echo json_encode(['id'=>$id, 'price'=>$price]); \ No newline at end of file diff --git a/wms/mkt/api/getUsername.php b/wms/mkt/api/getUsername.php new file mode 100644 index 00000000..d959b5aa --- /dev/null +++ b/wms/mkt/api/getUsername.php @@ -0,0 +1,12 @@ +prepare($sql_str); +$stmt->bindParam(':accountid', $accountid); +$stmt->execute(); +$user = $stmt->fetch(PDO::FETCH_ASSOC); +echo $user['name']; \ No newline at end of file diff --git a/wms/mkt/api/postNewElevatorPricereview.php b/wms/mkt/api/postNewElevatorPricereview.php new file mode 100644 index 00000000..5ba7e342 --- /dev/null +++ b/wms/mkt/api/postNewElevatorPricereview.php @@ -0,0 +1,234 @@ +beginTransaction(); + +try{ + + $sql_str = "INSERT INTO pricereview_main (contractno, ekind, person, company, case_name, address, compete, price_lowest, price_total, price_rate, special_fee, predeal_date, facilitok_date, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, attatch1, attatch2, creater, create_at) + VALUES (:contractno, :ekind, :person, :company, :case_name, :address, :compete, :price_lowest, :price_total, :price_rate, :special_fee, :predeal_date, :facilitok_date, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :attatch1, :attatch2, :creater, :create_at)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':contractno', $contractno); + $stmt->bindParam(':ekind', $ekind); + $stmt->bindParam(':person', $person); + $stmt->bindParam(':company', $company); + $stmt->bindParam(':case_name', $case_name); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':compete', $compete); + $stmt->bindParam(':price_lowest', $price_lowest); + $stmt->bindParam(':price_total', $price_total); + $stmt->bindParam(':price_rate', $price_rate); + $stmt->bindParam(':special_fee', $special_fee); + $stmt->bindParam(':predeal_date', $predeal_date); + $stmt->bindParam(':facilitok_date', $facilitok_date); + $stmt->bindParam(':penalty', $penalty); + $stmt->bindParam(':deposit_rate', $deposit_rate); + $stmt->bindParam(':keep_rate', $keep_rate); + $stmt->bindParam(':warranty_rate', $warranty_rate); + $stmt->bindParam(':memo', $memo); + $stmt->bindParam(':status', $status); + $stmt->bindParam(':attatch1', $attatch1); + $stmt->bindParam(':attatch2', $attatch2); + $stmt->bindParam(':creater', $creater); + $stmt->bindParam(':create_at', $create_at); + $stmt->execute(); + $mid = $conn->lastInsertId(); + + //insert 整機單價 + $sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, item_weight, item_op, item_unit_price, item_qty, item_price_bp, item_price_ct, note) + VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :item_weight, :item_op, :item_unit_price, :item_qty, :item_price_bp, :item_price_ct, :note)"; + + foreach(json_decode($elevators, true) as $elevator){ + $price_id = $elevator['facility_id']; + $item_no = $elevator['id']; + $item_group = "A"; + $item_spec = $elevator['specifications'] . "-" . $elevator['person'] . "*" . $elevator['stop'] . "-" . $elevator['open_converted'] . $elevator['speed']; + $item_weight = ""; + $item_op = $elevator['open_converted']; + + $item_unit_price = $elevator['price']; + $item_qty = (int)$elevator['spec_num']; + $item_price_bp = (int)$elevator['price'] * (int)$elevator['spec_num']; + $item_price_ct = $elevator['spec_price']; + $note = $elevator['specifications'] . ',' . $elevator['person'] . ',' . $elevator['stop'] . ',' . $elevator['speed']; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':price_id', $price_id); + $stmt->bindParam(':item_no', $item_no); + $stmt->bindParam(':item_group', $item_group); + $stmt->bindParam(':item_spec', $item_spec); + $stmt->bindParam(':item_weight', $item_weight); + $stmt->bindParam(':item_op', $item_op); + $stmt->bindParam(':item_unit_price', $item_unit_price); + $stmt->bindParam(':item_qty', $item_qty); + $stmt->bindParam(':item_price_bp', $item_price_bp); + $stmt->bindParam(':item_price_ct', $item_price_ct); + $stmt->bindParam(':note', $note); + $stmt->execute(); + } + + //insert options 加價 + $sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp) + VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)"; + + foreach(json_decode($options, true) as $option){ + $price_id = $option['id']; + $item_no = $option['key'] + 1; + $item_group = "B"; + $item_spec = $option['name'] . $option['memo']; + $option_relate_spec = $option['toElevator'][0]['id']; + $item_unit_price = $option['price']; + $item_qty = $option['qty']; + $item_price_bp = $option['price'] * $option['qty']; + + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':price_id', $price_id); + $stmt->bindParam(':item_no', $item_no); + $stmt->bindParam(':item_group', $item_group); + $stmt->bindParam(':item_spec', $item_spec); + $stmt->bindParam(':option_relate_spec', $option_relate_spec); + $stmt->bindParam(':item_unit_price', $item_unit_price); + $stmt->bindParam(':item_qty', $item_qty); + $stmt->bindParam(':item_price_bp', $item_price_bp); + $stmt->execute(); + } + + //insert 除外項目 + $sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp) + VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)"; + + foreach(json_decode($otherOptions, true) as $option){ + $item_no = $option['id'] + 1; + $item_group = "E"; + $item_spec = $option['name']; + $option_relate_spec = $option['toElevator'][0]['id']; + $item_unit_price = $option['price']; + $item_qty = $option['num']; + $item_price_bp = $option['price'] * $option['num']; + + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->bindParam(':item_group', $item_group); + $stmt->bindParam(':item_spec', $item_spec); + $stmt->bindParam(':option_relate_spec', $option_relate_spec); + $stmt->bindParam(':item_unit_price', $item_unit_price); + $stmt->bindParam(':item_qty', $item_qty); + $stmt->bindParam(':item_price_bp', $item_price_bp); + $stmt->execute(); + } + + $sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp) + VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)"; + //insert 保養延長 + foreach(json_decode($maintainOptions, true) as $option){ + $item_no = $option['id'] + 1; + $item_group = "D"; + $item_spec = $option['toElevator'][0]['model']; + $option_relate_spec = $option['toElevator'][0]['id']; + $item_unit_price = $option['price']; + $item_qty = $option['num']; + $item_price_bp = $option['price'] * $option['num']; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->bindParam(':item_group', $item_group); + $stmt->bindParam(':item_spec', $item_spec); + $stmt->bindParam(':option_relate_spec', $option_relate_spec); + $stmt->bindParam(':item_unit_price', $item_unit_price); + $stmt->bindParam(':item_qty', $item_qty); + $stmt->bindParam(':item_price_bp', $item_price_bp); + $stmt->execute(); + } + + + $sql_str = "INSERT INTO pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period) + VALUES (:mid, :pay_kind, :pay_scale, :pay_amount, :pay_period)"; + + foreach(json_decode($paymentRatio, true) as $key=>$pay){ + $pay_kind = $key +1; + $pay_scale = $pay['scale'] == '' ? 0 : $pay['scale']; + $pay_amount = $pay['scale']/100 * $price_total; + $pay_period = ($pay['scale'] == '' || $pay['scale'] == 0) ? '' :$pay['ticket']; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':pay_kind', $pay_kind); + $stmt->bindParam(':pay_scale', $pay_scale); + $stmt->bindParam(':pay_amount', $pay_amount); + $stmt->bindParam(':pay_period', $pay_period); + $stmt->execute(); + } + + $sql_str = "SELECT * FROM account WHERE accountid = :accountid"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':accountid', $creater); + $stmt->execute(); + $account = $stmt->fetch(PDO::FETCH_ASSOC); + $manager = $account['manager']; + + $sign1 = "$manager,,"; //區處長 + $sign2 = NULL; // 業務承辦人 + $sign3 = "M0060,,"; //業務部協理 + + //是否呈核至總經理(M0006) + if($price_rate < 80 || $special_fee > 0){ + $sign4 = "M0006,,"; + $sign_total = 4; + }else{ + $sign4 = NULL; + $sign_total = 3; + } + + $sql_str = "INSERT INTO pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) + VALUES (:mid, :sign1, :sign2, :sign3, :sign4, :sign_total)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':sign1', $sign1); + $stmt->bindParam(':sign2', $sign2); + $stmt->bindParam(':sign3', $sign3); + $stmt->bindParam(':sign4', $sign4); + $stmt->bindParam(':sign_total', $sign_total); + $stmt->execute(); + + + echo "success"; + + $conn->commit(); +}catch (PDOException $e) { + $conn->rollback(); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); +} \ No newline at end of file diff --git a/wms/mkt/api/postPricereviewSign.php b/wms/mkt/api/postPricereviewSign.php new file mode 100644 index 00000000..2a72efa5 --- /dev/null +++ b/wms/mkt/api/postPricereviewSign.php @@ -0,0 +1,40 @@ +prepare($sql_str); + $stmt->bindParam(':sign', $sign_result); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':reviewcomment', $reviewcomment); + $stmt->execute(); + + $sql_str = "UPDATE pricereview_main SET status=:status WHERE id = :id "; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':status', $result); + $stmt->bindParam(':id', $mid); + $stmt->execute(); + + echo 1; +}catch(PDOException $e){ + echo $e->getMessage(); +} diff --git a/wms/mkt/assets/js/pricereviewAlpine.js b/wms/mkt/assets/js/pricereviewAlpine.js index db4e346b..c839c4b5 100644 --- a/wms/mkt/assets/js/pricereviewAlpine.js +++ b/wms/mkt/assets/js/pricereviewAlpine.js @@ -1,7 +1,882 @@ const pricereviewCreate = ()=>{ return { init(){ - console.log(123) - } + this.elevators = elevators; + console.log(this.elevators); + console.log(this.total_spec); + }, + + openFn:{ + 4:'2U', + 5:"4PCO", + 7:"6PCO", + 8:"2S", + 9:"CO" + }, + optionalArr: { + 1:'標配', + 2:'選配', + 3:'選配', + }, + total_spec: total_spec, + options: options, + // orioptions: options, + searchtext: '', + kind: 1, + subkind: 1, + buttons: [], + modalSelectedOptions: {}, + selectedOptions:[], + elevators: [], + toElevators:[], + toElevatorNo: '', + currentOptionKey: '', + currentOtherOptionKey: '', + currentMaintainOptionKey: '', + optionKey:0, + otherOptionKey:0, + maintainOptionKey:0, + modalElevatorInfo:{ + spec:'', + person:'', + stop:'', + speed:'', + open:'CO', + num: 1, + price:'', + sale_price:'', + facility_id: '', + }, + otherOptions: [], + modalOtherOptionInfo:{ + pr_no:"", + name:"", + price: 0, + num:"", + }, + maintainOptions:[], + modalMaintainInfo:{ + price:0, + num:"", + memo:"", + }, + paymentRatio:[ + { + scale: 20, + ticket: 30, + }, + { + scale: 0, + ticket: '', + }, + { + scale: 50, + ticket: 30, + }, + { + scale: 0, + ticket: '', + }, + { + scale: 20, + ticket: 30, + }, + { + scale: 10, + ticket: 30, + }, + { + scale: 0, + ticket: '', + }, + ], + serviceFee:0, + transactionDate: pre_order_date, + shippingDate:'', + remark:'', + async getElevatorPrice(idx){ + const spec = this.elevators[idx].specifications + const person = this.elevators[idx].person + const stop = this.elevators[idx].stop + const open_converted = this.elevators[idx].open_converted + const speed = this.elevators[idx].speed + const model = spec + '-' + person + '*' + stop + '-' + open_converted + speed; + try{ + const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model}}) + console.log(res.data); + if(res.data.id == null || res.data.id == ""){ + console.log("公司並無提供此規格!!"); + } + this.elevators[idx].price = res.data.price + this.elevators[idx].facility_id = res.data.id + }catch (error) { + console.error("Error fetching elevator price:", error); + } + + }, + async getModalElevatorPrice(){ + let model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed; + try{ + const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model}}) + console.log(res.data); + if(res.data.id == null || res.data.id == ""){ + console.log("公司並無提供此規格!!"); + } + this.modalElevatorInfo.price = res.data.price + this.modalElevatorInfo.facility_id = res.data.id + }catch (error) { + console.error("Error fetching elevator price:", error); + } + }, + initButtons(kind) { + if (kind == 'A') { + this.buttons = [ + { name: '車廂意匠', type: 'A1' } + ] + } else if (kind == 'B') { + this.buttons = [ + { name: '天井', type: 'B1' }, + { name: '地板', type: 'B2' }, + { name: '操縱盤', type: 'B3' }, + { name: '扶手', type: 'B4' }, + { name: '車廂門與層門(轎門/層門)', type: 'B5' }, + { name: '轎壁(車廂側板)', type: 'B6' }, + { name: '其他車廂內裝配件', type: 'B7' }, + ] + } else if (kind == 'C') { + this.buttons = [ + { name: '框', type: 'C1' }, + { name: '乘場指示器', type: 'C2' }, + { name: '燈', type: 'C3' }, + { name: '方式與門', type: 'C4' }, + ] + } else if (kind == 'D') { + this.buttons = [ + { name: '功能與配置', type: 'D1' }, + { name: 'OH與樓高', type: 'D2' }, + ] + } else if (kind == 'E') { + this.buttons = [ + { name: '平台梯', type: 'E1' }, + ] + } else if (kind == 'F') { + this.buttons = [ + { name: '汰改', type: 'F1' }, + ] + } else if (kind == 1) { + this.buttons = [] + } + }, + optionSubCategory: 1, + initOptinos(){ + this.options.forEach(option=>{ + option.isShow = 1; + }) + }, + searchOptions(kind=this.kind, subkind=this.subkind){ + if(kind!=null) this.kind = kind; + if(subkind!=null) this.subkind = subkind; + this.initOptinos(); + this.initButtons(kind); + this.options.forEach(option=>{ + if(option.kind != this.kind && this.kind != 1){ + option.isShow = 0; + }else{ + if(option.subkind != this.subkind && this.subkind != 1){ + option.isShow = 0; + } + } + if(option.isShow == 1){ + if(option.group_name == null) option.group_name = '' + if(option.spec == null) option.spec = '' + if(option.memo == null) option.memo = '' + if(option.price == null) option.price = 0 + if(option.unit == null) option.unit = '' + if(String(option.id).includes(this.searchtext) || option.group_name.includes(this.searchtext) || option.memo.toLowerCase().includes(this.searchtext) || option.spec.toLowerCase().includes(this.searchtext) || option.unit.includes(this.searchtext) || String(option.price).includes(this.searchtext)){ + option.isShow = 1 + }else{ + option.isShow = 0 + } + } + }) + }, + selectOption(idx, id, name, price, memo){ + this.options[idx].selected = this.options[idx].selected==1 ? 0 : 1; + + if(this.modalSelectedOptions.hasOwnProperty(idx)){ + delete this.modalSelectedOptions[idx]; + }else{ + //this.optionKey => 已選option 流水號, idx:option表內的流水號, id:option 資料庫的ID + this.modalSelectedOptions[idx] = {key:this.optionKey, 'idx':idx, 'id': id, 'name': name, 'price': price, qty:1, 'memo': memo, 'toElevator':[] } + } + this.optionKey ++; + }, + initModalSelectedOptions(){ + this.modalSelectedOptions = {} + this.options.forEach(option=>{ + option.selected = 0 + }) + this.$refs.optionsModal.style.display = "block" + body.style.overflow = 'hidden' + }, + chkOptions(){ + Object.keys(this.modalSelectedOptions).forEach(option=>{ + this.selectedOptions.push(this.modalSelectedOptions[option]) + }) + console.log(this.modalSelectedOptions); + console.log(this.selectedOptions); + this.hideOptionsModal(); + }, + hideOptionsModal(){ + this.$refs.optionsModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + hideToElevatorModal(){ + this.$refs.toElevatorModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + hideToOtherOptionElevatorModal(){ + this.$refs.toOtherOptionElevatorModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + hideToMaintainOptionElevatorModal(){ + this.$refs.toMaintainOptionElevatorModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + hideCreateElevatorModal(){ + this.$refs.createElevatorModal.style.display = 'none'; + body.style.overflow = 'auto' + this.modalElevatorInfo = { + spec:'', + person:'', + stop:'', + speed:'', + open:'CO', + num: 1, + price:'', + sale_price:'', + }; + }, + hideCreateOtherOptionModal(){ + this.$refs.createOtherOptionModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + hideCreateMaintainModal(){ + this.$refs.createMaintainModal.style.display = 'none'; + body.style.overflow = 'auto' + }, + openCreateElevatorModal(){ + this.$refs.createElevatorModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, + openCreateOtherOptionFn(){ + this.$refs.createOtherOptionModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, + openCreateMaintainModal(){ + this.$refs.createMaintainModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, + totalElevatorsPrice(){ + return this.elevators.reduce((total, elevator) => { + return total + (elevator.spec_num * elevator.price); + }, 0); + }, + totalElevatorsNum(){ + return this.elevators.reduce((total, elevator) => { + return total + Number(elevator.spec_num); + }, 0) + }, + totalElevatorsSalePrice(){ + return this.elevators.reduce((total, elevator) => { + return total + (elevator.spec_num * elevator.spec_price); + }, 0); + }, + totalOptionsPrice(){ + return this.selectedOptions.reduce((total, option) => { + return total + (option.qty * option.price); + }, 0); + }, + openAddElevatorFn(){ + + }, + createElevatorFn(){ + if(this.modalElevatorInfo.spec == '') return alert("請選擇電梯規格"); + if(this.modalElevatorInfo.stop == '') return alert("請填入停數"); + if(this.modalElevatorInfo.speed == '') return alert("請選擇速度"); + if(this.modalElevatorInfo.open == '') return alert("請選擇開梯方式"); + if(this.modalElevatorInfo.person == '') return alert("請填入人乘/載重"); + if(this.modalElevatorInfo.num == '') return alert("請填入數量"); + if(this.modalElevatorInfo.sale_price == '') return alert("請填入售價"); + this.total_spec ++; + this.elevators.push({ + id: this.total_spec, + specifications: this.modalElevatorInfo.spec, + person: this.modalElevatorInfo.person, + stop: this.modalElevatorInfo.stop, + speed: this.modalElevatorInfo.speed, + open_converted: this.modalElevatorInfo.open, + spec_price: this.modalElevatorInfo.sale_price, + price: this.modalElevatorInfo.price, + open:'', + spec_num: this.modalElevatorInfo.num, + facility_id: this.modalElevatorInfo.facility_id, + }); + console.log(this.elevators); + this.hideCreateElevatorModal(); + }, + copyElevator(idx){ + const spec = this.elevators[idx].specifications + const person = this.elevators[idx].person + const stop = this.elevators[idx].stop + const open_converted = this.elevators[idx].open_converted + const speed = this.elevators[idx].speed + const spec_price = this.elevators[idx].spec_price + const open = this.elevators[idx].open + const spec_num = this.elevators[idx].spec_num + const price = this.elevators[idx].price + const facility_id = this.elevators[idx].facility_id + + this.total_spec ++; + this.elevators.push({ + id: this.total_spec, + specifications: spec, + person: person, + stop: stop, + speed: speed, + open_converted: open_converted, + spec_price: spec_price, + price: price, + open: open, + spec_num: spec_num, + facility_id: facility_id, + }); + console.log(this.elevators); + }, + addOptionToElevator(key){ + this.currentOptionKey = key; + this.toElevators = []; + this.toElevatorNo = ""; + const matchElevators = this.selectedOptions.filter(option=> option.key == key)[0].toElevator.map(elevator=> elevator.id) + console.log(matchElevators); + this.toElevatorNo = matchElevators[0] + this.elevators.forEach(elevator=>{ + if(elevator.price > 0){ + this.toElevators.push({ + id: elevator.id, + model: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, + checked: matchElevators.includes(elevator.id) ? 1: 0, + }) + } + }) + this.$refs.toElevatorModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, + addOtherOptionToElevator(id){ + this.currentOtherOptionKey = id; + this.toElevators = []; + this.toElevatorNo = ""; + const matchElevators = this.otherOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id) + this.toElevatorNo = matchElevators[0] + this.elevators.forEach(elevator=>{ + if(elevator.price > 0){ + this.toElevators.push({ + id: elevator.id, + model: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, + checked: matchElevators.includes(elevator.id) ? 1: 0, + }) + } + }) + this.$refs.toOtherOptionElevatorModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, + chkOptionToElevators(){ + const checkedOptions = []; + // this.toElevators.forEach(elevator=>{ + // if(elevator.checked){ + // checkedOptions.push({ + // id: elevator.id, + // model: elevator.model, + // }); + // } + // }) + const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] + checkedOptions.push({ + id: this.toElevatorNo, + model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], + }) + this.selectedOptions.forEach(option=>{ + if(option.key == this.currentOptionKey){ + option.toElevator = []; + option.toElevator.push(...checkedOptions) + } + }) + this.currentOptionKey = '' + this.hideToElevatorModal(); + }, + chkOtherOptionToElevators(){ + const checkedOptions = []; + // this.toElevators.forEach(elevator=>{ + // if(elevator.checked){ + // checkedOptions.push({ + // id: elevator.id, + // model: elevator.model, + // }); + // } + // }) + const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] + checkedOptions.push({ + id: this.toElevatorNo, + model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], + }) + this.otherOptions.forEach(option=>{ + if(option.id == this.currentOtherOptionKey){ + option.toElevator = []; + option.toElevator.push(...checkedOptions) + } + }) + + this.currentOtherOptionKey = '' + + this.hideToOtherOptionElevatorModal(); + }, + removeElevator(id){ + if(!confirm("確定刪除嗎?")) return; + this.elevators = this.elevators.filter(elevator=> elevator.id != id) + const issetElevators = []; + this.elevators.forEach(elevator=>{ + issetElevators.push(elevator.id); + }) + + this.selectedOptions.forEach(option=>{ + option.toElevator = option.toElevator.filter(el=>{ + return issetElevators.includes(el.id) + }) + }) + console.log(this.selectedOptions); + }, + removeOption(key){ + console.log(this.selectedOptions); + this.selectedOptions = this.selectedOptions.filter(option=> option.key != key) + }, + removeOtherOption(id){ + this.otherOptions = this.otherOptions.filter(option=> option.id != id) + }, + createOtherOptionFn(){ + this.otherOptions.push({ + id: this.otherOptionKey, + pr_no: this.modalOtherOptionInfo.pr_no, + name: this.modalOtherOptionInfo.name, + price: this.modalOtherOptionInfo.price, + num: this.modalOtherOptionInfo.num, + toElevator:[], + }) + this.modalOtherOptionInfo = { + pr_no: '', + name: '', + price: 0, + num: '', + } + this.otherOptionKey ++; + this.hideCreateOtherOptionModal(); + }, + totalOtherOptionsPrice(){ + return this.otherOptions.reduce((total, option) => { + return total + (Number(option.num) * Number(option.price)); + }, 0); + }, + totalOtherOptionsNum(){ + return this.otherOptions.reduce((total, option) => { + return total + Number(option.num); + }, 0); + }, + createMaintainOptionFn(){ + this.maintainOptions.push({ + id: this.maintainOptionKey, + price: this.modalMaintainInfo.price, + num: this.modalMaintainInfo.num, + memo: this.modalMaintainInfo.memo, + toElevator:[], + }) + this.modalMaintainInfo = { + price:0, + num:"", + memo:"", + } + this.maintainOptionKey ++; + this.hideCreateMaintainModal(); + }, + totalMaintainOptionsPrice(){ + return this.maintainOptions.reduce((total, option) => { + return total + (Number(option.num) * Number(option.price)); + }, 0); + }, + totalMaintainOptionsNum(){ + return this.maintainOptions.reduce((total, option) => { + return total + Number(option.num); + }, 0); + }, + chkMaintainOptionToElevators(){ + const checkedOptions = []; + // this.toElevators.forEach(elevator=>{ + // if(elevator.checked){ + // checkedOptions.push({ + // id: elevator.id, + // model: elevator.model, + // }); + // } + // }) + const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] + checkedOptions.push({ + id: this.toElevatorNo, + model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], + }) + this.maintainOptions.forEach(option=>{ + if(option.id == this.currentMaintainOptionKey){ + option.toElevator = []; + option.toElevator.push(...checkedOptions) + } + }) + this.currentMaintainOptionKey = '' + this.hideToMaintainOptionElevatorModal(); + }, + addMaintainOptionToElevator(id){ + this.currentMaintainOptionKey = id; + this.toElevators = []; + this.toElevatorNo = ""; + const matchElevators = this.maintainOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id) + this.toElevatorNo = matchElevators[0] + this.elevators.forEach(elevator=>{ + if(elevator.price > 0){ + this.toElevators.push({ + id: elevator.id, + model: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, + checked: matchElevators.includes(elevator.id) ? 1: 0, + }) + } + }) + + this.$refs.toMaintainOptionElevatorModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, + removeMaintainOption(id){ + this.maintainOptions = this.maintainOptions.filter(option=> option.id != id) + }, + totalPrice(){ + return this.totalElevatorsPrice() + this.totalOptionsPrice() + this.totalOtherOptionsPrice() + this.totalMaintainOptionsPrice(); + }, + totalSalePrice(){ + return this.elevators.reduce((total, elevator) => { + return total + (elevator.spec_num * elevator.spec_price); + }, 0); + }, + scalePrice(scale){ + if(scale === '') return 0; + return this.totalSalePrice() * scale / 100; + }, + totalScale(){ + let total = 0; + Object.keys(this.paymentRatio).forEach(pay=>{ + if(this.paymentRatio[pay].scale != '' && this.paymentRatio[pay].scale > 0){ + total += Number(this.paymentRatio[pay].scale) + } + }) + + return total; + }, + customerInfo:{ + contractno: contractno, + company: customer, + manager: manager, + address: address, + case_name: case_name, + uscc: uscc, + person: salesman, + }, + penalty:"", + deposit_rate:0, + keep_rate:0, + warranty_rate:0, + error: [], + submit(){ + this.error = [] + for(let i=0;i 0){ + let errortext = ''; + this.error.forEach(err=>{ + errortext += err+'\n'; + }) + alert(errortext) + return; + } + + const form = new FormData(); + form.append('contractno', contractno); + form.append('ekind', "新梯"); + form.append('person', this.customerInfo.person); + form.append('company', this.customerInfo.company); + form.append('case_name', this.customerInfo.case_name); + form.append('address', this.customerInfo.address); + form.append('price_lowest', this.totalPrice()); + form.append('price_total', this.totalSalePrice()); + form.append('price_rate', Math.round(this.totalSalePrice() / this.totalPrice() * 100 *10) / 10); + form.append('special_fee', this.serviceFee); + form.append('predeal_date', this.transactionDate); + form.append('facilitok_date', this.shippingDate); + form.append('penalty', this.penalty); + form.append('deposit_rate', this.deposit_rate); + form.append('keep_rate', this.keep_rate); + form.append('warranty_rate', this.warranty_rate); + form.append('memo', this.remark); + form.append('status', "YS"); + form.append('attatch1', ""); + form.append('attatch2', ""); + + + form.append('elevators', JSON.stringify(this.elevators)); + + form.append('options', JSON.stringify(this.selectedOptions)); + form.append('otherOptions', JSON.stringify(this.otherOptions)); + form.append('maintainOptions', JSON.stringify(this.maintainOptions)); + + form.append('paymentRatio', JSON.stringify(this.paymentRatio)); + + axios.post('./api/postNewElevatorPricereview.php', form).then(res=>{ + console.log(res.data); + if(res.data == "success"){ + alert("送審成功!"); + window.location.href = './pricereview-index.php?' + token_link; + } + }).catch(err=>{ + console.error(err); + }) + }, + + } +} + + +const pricereviewCheck = ()=>{ + return { + init(){ + this.elevators = items.filter(item=> item.item_group =='A'); + this.elevators.forEach(el=>{ + el.options = [] + el.optionsTotalPrice = 0; + el.otherOptions = [] + el.otherOptionsTotalPrice = 0; + el.maintainOptions = [] + el.maintainOptionsTotalPrice = 0; + }) + this.options = options; + this.otherOptions = items.filter(item=> item.item_group =='E'); + this.maintainOptions = items.filter(item=> item.item_group =='D'); + console.log(this.options); + + this.elevators.forEach((elevator, idx)=>{ + + this.options.forEach(option=>{ + if(option.option_relate_spec == elevator.item_no){ + elevator.optionsTotalPrice += option.option_mi * option.item_qty + this.elevators[idx].options.push({ + 'id': option.id, //&lt;br&gt;() + 'item_spec': option.item_spec.trim().replaceAll('&', '').replaceAll('lt;', '').replaceAll('br', '').replaceAll('gt;', '').replaceAll('()', ''), + 'item_unit_price': option.item_unit_price, + 'item_qty': option.item_qty, + 'mi': Math.round(option.option_mi), + }) + } + }) + + this.otherOptions.forEach(option=>{ + if(option.option_relate_spec == elevator.item_no){ + elevator.otherOptionsTotalPrice += option.item_unit_price * option.item_qty + this.elevators[idx].otherOptions.push({ + 'id': option.id, + 'item_spec': option.item_spec.trim(), + 'item_unit_price': option.item_unit_price, + 'item_qty': option.item_qty, + 'mi': Math.round(option.item_unit_price), + }) + } + }) + + this.maintainOptions.forEach(option=>{ + if(option.option_relate_spec == elevator.item_no){ + elevator.maintainOptionsTotalPrice += option.item_unit_price * option.item_qty + this.elevators[idx].maintainOptions.push({ + 'id': option.id, + 'item_spec': option.item_spe.trim(), + 'item_unit_price': option.item_unit_price, + 'item_qty': option.item_qty, + 'mi': Math.round(option.item_unit_price), + }) + } + }) + this.qty += Number(elevator.item_qty); + this.elevators_total_price += Number(elevator.item_qty) * Number(elevator.item_unit_price); + //MAE100-15*24-CO105 + const model = elevator.item_spec; + let spec = model.split('-')[0]; + let person = model.split('-')[1].split('*')[0]; + let stop = model.split('-')[1].split('*')[1].split('-')[0]; + let open = model.split('-')[2]; + let speed = ''; + for(let i=0;i',res.data); + if(res.data){ + this.elevators[idx].mi = res.data + this.elevators[idx].totalMi = res.data['equipment_fee'] + res.data['customs_shipping_fee'] + res.data['free1y_fee'] + res.data['install_fee'] + res.data['other_fee'] + res.data['transport_site_fee'] + res.data['unloading_fee']; + }else{ + this.isNotfoundMi = true; + this.elevators[idx].mi = { + 'equipment_fee': 0, + 'customs_shipping_fee': 0, + 'free1y_fee': 0, + 'install_fee': 0, + 'other_fee': 0, + 'transport_site_fee': 0, + 'unloading_fee': 0 + } + } + + + console.log(this.elevators[idx]); + + }catch (error) { + console.error("Error fetching elevator price:", error); + } + }, + isNotfoundMi:false, + openFn:[ + 'CO', '2S', '2U', '4PCO', '6PCO' + ], + sign1:'', + sign2:'', + sign3:'', + sign4:'', + is_renovate: false, + elevators_total_price: 0, + contractno: contractno, + person_name: person_name, + company: company, + case_name: case_name, + address: address, + price_lowest: price_lowest, + price_total: price_total, + special_fee: special_fee, + predeal_date: predeal_date, + facilitok_date: facilitok_date, + penalty: penalty, + deposit_rate: deposit_rate, + keep_rate: keep_rate, + warranty_rate: warranty_rate, + memo: memo, + qty: 0, + pays: pays, + elevators:[], + options: [], + otherOptions: [], + maintainOptions: [], + mid: mid, + user_id: user_id, + reviewcomment:'', + optionsTotalPrice(){ + return this.options.reduce((total, option) => { + return total + (option.item_qty * option.item_unit_price); + }, 0); + }, + otherOptionsTotalPrice(){ + return this.otherOptions.reduce((total, option) => { + return total + (option.item_qty * option.item_unit_price); + }, 0); + }, + maintainOptionsTotalPrice(){ + return this.maintainOptions.reduce((total, option) => { + return total + (option.item_qty * option.item_unit_price); + }, 0); + }, + totalScale(){ + return this.pays.reduce((total, option) => { + return total + Number(option.pay_scale ); + }, 0); + }, + check(sign, status){ + console.log(sign); + const form = new FormData(); + form.append('sign', sign); + form.append('mid', this.mid); + form.append('result', status); + form.append('user_id', this.user_id); + form.append('reviewcomment', this.reviewcomment); + axios.post('./api/postPricereviewSign.php', form).then(res=>{ + console.log(res.data); + if(res.data == 1){ + alert("簽核成功!"); + window.location.reload() + } + }) + }, + async getUsername(user_id){ + if(user_id == '') return '---' + const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}}) + return res.data ; + }, } } \ No newline at end of file diff --git a/wms/mkt/css/pricereview.css b/wms/mkt/css/pricereview.css index 13638fdf..5986f447 100644 --- a/wms/mkt/css/pricereview.css +++ b/wms/mkt/css/pricereview.css @@ -1,29 +1,51 @@ -#pricereviewCreate table, #pricereviewCreate th, #pricereviewCreate td { +#pricereviewCreate input[type=text], #pricereviewCreate input[type=number], #pricereviewCreate select { + margin: 1px; +} +#pricereviewCreate textarea { + resize: vertical; +} +#pricereviewCreate > .modal { + padding: 20px; +} +#pricereviewCreate > .modal table, #pricereviewCreate > .modal th, #pricereviewCreate > .modal td { + border: 1px #ccc solid; +} +#pricereviewCreate > .modal table > thead tr th { + color: #A52A2A; +} +#pricereviewCreate > .modal table > tbody .selected { + background-color: #E7FEFB; +} +#pricereviewCreate .container table, #pricereviewCreate .container th, #pricereviewCreate .container td { border: 1px #ccc solid; padding: 15px; } -#pricereviewCreate table thead th { +#pricereviewCreate .container table.noborder, #pricereviewCreate .container table .noborder th, #pricereviewCreate .container table .noborder td, #pricereviewCreate .container th.noborder, #pricereviewCreate .container th .noborder th, #pricereviewCreate .container th .noborder td, #pricereviewCreate .container td.noborder, #pricereviewCreate .container td .noborder th, #pricereviewCreate .container td .noborder td { + border: none; +} +#pricereviewCreate .container table thead th { background-color: #6D9EEB; } -#pricereviewCreate table tbody td input { +#pricereviewCreate .container table tbody td input { font-size: 14px; } -#pricereviewCreate table tbody th { +#pricereviewCreate .container table tbody th { background-color: #CCE4F8; font-size: 14px; padding: 15px 2px; min-width: 100px; text-align: center; } -#pricereviewCreate table input { +#pricereviewCreate .container table input { font-size: 13px; } -#pricereviewCreate .pricreviewmain { +#pricereviewCreate .container .pricreviewmain { background-color: #F2F2F2; padding: 20px; border-radius: 6px; + margin: 30px 0; } -#pricereviewCreate .pricreviewmain button { +#pricereviewCreate .container .pricreviewmain button { color: #fff; width: 55px; height: 30px; @@ -31,60 +53,244 @@ margin-left: 10px; font-size: 13px; } -#pricereviewCreate .pricreviewmain button.addbtn { +#pricereviewCreate .container .pricreviewmain button.addbtn { background-color: #337AB7; width: 30px; } -#pricereviewCreate .pricreviewmain button.deleteBtn { +#pricereviewCreate .container .pricreviewmain button.deleteBtn { background-color: #D9534F; color: #fff; font-size: 12px; width: 30px; } -#pricereviewCreate .pricreviewmain button.selectElevator { +#pricereviewCreate .container .pricreviewmain button.selectElevator { background-color: #D9534F; color: #fff; } -#pricereviewCreate .pricreviewmain > .divitem { +#pricereviewCreate .container .pricreviewmain > .divitem { border: 1px #ccc solid; padding: 10px; border-radius: 4px; } -#pricereviewCreate .pricreviewmain > .divitem .title { +#pricereviewCreate .container .pricreviewmain > .divitem .title { display: flex; align-items: center; border-bottom: 1px #ccc solid; padding: 10px 0; margin-bottom: 10px; } -#pricereviewCreate .pricreviewmain > .divitem .title h6 { +#pricereviewCreate .container .pricreviewmain > .divitem .title h6 { font-weight: 600; } -#pricereviewCreate .pricreviewmain > .divitem table, #pricereviewCreate .pricreviewmain > .divitem th, #pricereviewCreate .pricreviewmain > .divitem td { +#pricereviewCreate .container .pricreviewmain > .divitem table, #pricereviewCreate .container .pricreviewmain > .divitem th, #pricereviewCreate .container .pricreviewmain > .divitem td { font-size: 14px; background-color: transparent; } -#pricereviewCreate .pricreviewmain > .divitem table input, #pricereviewCreate .pricreviewmain > .divitem table select, #pricereviewCreate .pricreviewmain > .divitem table textarea, #pricereviewCreate .pricreviewmain > .divitem th input, #pricereviewCreate .pricreviewmain > .divitem th select, #pricereviewCreate .pricreviewmain > .divitem th textarea, #pricereviewCreate .pricreviewmain > .divitem td input, #pricereviewCreate .pricreviewmain > .divitem td select, #pricereviewCreate .pricreviewmain > .divitem td textarea { +#pricereviewCreate .container .pricreviewmain > .divitem table input, #pricereviewCreate .container .pricreviewmain > .divitem table select, #pricereviewCreate .container .pricreviewmain > .divitem table textarea, #pricereviewCreate .container .pricreviewmain > .divitem th input, #pricereviewCreate .container .pricreviewmain > .divitem th select, #pricereviewCreate .container .pricreviewmain > .divitem th textarea, #pricereviewCreate .container .pricreviewmain > .divitem td input, #pricereviewCreate .container .pricreviewmain > .divitem td select, #pricereviewCreate .container .pricreviewmain > .divitem td textarea { font-size: 13px; } -#pricereviewCreate .pricreviewmain > .divitem table input[type=number]::-webkit-outer-spin-button, -#pricereviewCreate .pricreviewmain > .divitem table input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .pricreviewmain > .divitem th input[type=number]::-webkit-outer-spin-button, -#pricereviewCreate .pricreviewmain > .divitem th input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .pricreviewmain > .divitem td input[type=number]::-webkit-outer-spin-button, -#pricereviewCreate .pricreviewmain > .divitem td input[type=number]::-webkit-inner-spin-button { +#pricereviewCreate .container .pricreviewmain > .divitem table input[type=number]::-webkit-outer-spin-button, +#pricereviewCreate .container .pricreviewmain > .divitem table input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .container .pricreviewmain > .divitem th input[type=number]::-webkit-outer-spin-button, +#pricereviewCreate .container .pricreviewmain > .divitem th input[type=number]::-webkit-inner-spin-button, #pricereviewCreate .container .pricreviewmain > .divitem td input[type=number]::-webkit-outer-spin-button, +#pricereviewCreate .container .pricreviewmain > .divitem td input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } -#pricereviewCreate .pricreviewmain > .divitem table tr:hover .deleteBtn { +#pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .deleteBtn, #pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .copyBtn { opacity: 1; } -#pricereviewCreate .pricreviewmain > .divitem table .saletd { +#pricereviewCreate .container .pricreviewmain > .divitem table .saletd { position: relative; } -#pricereviewCreate .pricreviewmain > .divitem table .saletd > .deleteBtn { +#pricereviewCreate .container .pricreviewmain > .divitem table .saletd > .deleteBtn { position: absolute; top: 50%; transform: translateY(-50%); right: 2px; opacity: 0; transition: 0.3s; +} +#pricereviewCreate .container .pricreviewmain > .divitem table .saletd > .copyBtn { + position: absolute; + top: 50%; + transform: translateY(-50%); + right: 38px; + opacity: 0; + transition: 0.3s; + width: 30px; + height: 30px; +} +#pricereviewCreate .container .pricreviewmain > .divitem table textarea { + height: auto; + min-height: 50px; +} +#pricereviewCreate .container .pricreviewmain > .filediv { + display: flex; + flex-direction: column; + margin-top: 20px; +} +#pricereviewCreate .container .pricreviewmain > .filediv label { + display: flex; + align-items: center; + margin: 10px 0; +} +#pricereviewCreate .container .pricreviewmain > .filediv label p { + width: 100px; + font-size: 15px; + font-weight: 600; +} +#pricereviewCreate .container .pricreviewmain > .filediv label input[type=file] { + width: 400px; +} +#pricereviewCreate .container .pricreviewmain > .filediv label button { + width: 90px; + height: 35px; + margin: 0; + margin-right: 15px; + margin-top: 20px; +} + +.container-fluid, .container { + max-width: 1400px !important; + width: 100%; +} +.container-fluid h4, .container h4 { + font-weight: 600; +} +.container-fluid .btn-secondary, .container .btn-secondary { + background-color: #6C757D; +} + +.window-modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100vh; + background-color: rgba(0, 0, 0, 0.5); + z-index: 9; + padding: 20px; + display: none; +} +@keyframes fade-in { + 0% { + transform: translate(-50%, -60%); + opacity: 0; + } + 100% { + transform: translate(-50%, -55%); + opacity: 1; + } +} +.window-modal table, .window-modal th, .window-modal td { + border: 1px #ccc solid; +} +.window-modal table > thead tr th { + color: #A52A2A; +} +.window-modal table > tbody .selected { + background-color: #E7FEFB; +} +.window-modal#optionModal .window-modal-content { + max-height: 80vh; +} +.window-modal#optionModal .window-modal-content .window-modal-body { + height: 400px; + overflow-y: scroll; +} +.window-modal#toElevatorModal .window-modal-content { + min-height: 270px; + height: auto; +} +.window-modal#toElevatorModal .window-modal-content .window-modal-body { + height: auto; +} +.window-modal .window-modal-content { + z-index: 9; + background-color: #fff; + border-radius: 10px; + position: absolute; + width: 1200px; + padding: 30px; + top: 50%; + left: 50%; + transform: translate(-50%, -55%); + box-shadow: 0 5px 5px #222; + animation: fade-in 0.2s linear; +} +.window-modal .window-modal-content.modal-xl { + width: 1200px; +} +.window-modal .window-modal-content.modal-lg { + width: 800px; +} +.window-modal .window-modal-content.modal-m { + width: 450px; +} +.window-modal .window-modal-content .window-modal-header { + display: flex; + flex-direction: column; +} +.window-modal .window-modal-content .window-modal-header button.btn-close { + position: absolute; + top: 10px; + right: 10px; + background-color: transparent; + border: none; + outline: none; + border-radius: 50%; +} +.window-modal .window-modal-content .window-modal-header > div > input { + width: 250px; +} +.window-modal .window-back { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: transparent; +} + +#pricereviewCheck > .container { + background-color: #F2F2F2; + border-radius: 15px; + padding: 20px; +} +#pricereviewCheck > .container textarea { + resize: vertical; +} +#pricereviewCheck > .container table, #pricereviewCheck > .container th, #pricereviewCheck > .container td { + border: 1px #ccc solid; +} +#pricereviewCheck > .container table.noborder { + border: none !important; +} +#pricereviewCheck > .container table.noborder th, #pricereviewCheck > .container table.noborder td { + border: none !important; +} +#pricereviewCheck > .container .customerinfo-table input { + background-color: #EEE5E5; +} +#pricereviewCheck > .container .mi-table th { + font-weight: 600; +} +#pricereviewCheck > .container .mi-table input[type=text] { + background-color: #EEEEEE; + cursor: not-allowed; + padding: 6px 12px; + font-size: 14px; +} +#pricereviewCheck > .container .mi-table .mi-info { + font-size: 14px; +} +#pricereviewCheck > .container .mi-table .mi-info span { + font-size: 15px; + font-weight: 600; +} +#pricereviewCheck > .container .mi-table .mi-info .line { + width: 100%; + height: 0.5px; + margin: 30px 0; + background-color: #ccc; }/*# sourceMappingURL=pricereview.css.map */ \ No newline at end of file diff --git a/wms/mkt/css/pricereview.css.map b/wms/mkt/css/pricereview.css.map index 24edcecf..d113f93f 100644 --- a/wms/mkt/css/pricereview.css.map +++ b/wms/mkt/css/pricereview.css.map @@ -1 +1 @@ -{"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,sBAAA;EACA,aAAA;ACAR;ADGQ;EACI,yBAAA;ACDZ;ADIY;EACI,eAAA;ACFhB;ADIY;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACFhB;ADKQ;EACI,eAAA;ACHZ;ADMI;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;ACJR;ADKQ;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,iBAAA;EACA,eAAA;ACHZ;ADIY;EACI,yBAAA;EACA,WAAA;ACFhB;ADIY;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACFhB;ADIY;EACI,yBAAA;EACA,WAAA;ACFhB;ADMQ;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACJZ;ADKY;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACHhB;ADIgB;EACI,gBAAA;ACFpB;ADMY;EACI,eAAA;EACA,6BAAA;ACJhB;ADKgB;EACI,eAAA;ACHpB;ADKgB;;;;EAEA,wBAAA;EACA,SAAA;ACDhB;ADKgB;EACI,UAAA;ACHpB;ADKgB;EACI,kBAAA;ACHpB;ADIoB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACFxB","file":"pricereview.css"} \ No newline at end of file +{"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,WAAA;ACAR;ADEI;EACI,gBAAA;ACAR;ADEI;EACI,aAAA;ACAR;ADCQ;EACI,sBAAA;ACCZ;ADCQ;EACI,cAAA;ACCZ;ADCQ;EACI,yBAAA;ACCZ;ADKQ;EACI,sBAAA;EACA,aAAA;ACHZ;ADIY;EACI,YAAA;ACFhB;ADMY;EACI,yBAAA;ACJhB;ADOgB;EACI,eAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACLpB;ADQY;EACI,eAAA;ACNhB;ADSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ACPZ;ADQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,iBAAA;EACA,eAAA;ACNhB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACPhB;ADQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACNpB;ADOoB;EACI,gBAAA;ACLxB;ADSgB;EACI,eAAA;EACA,6BAAA;ACPpB;ADQoB;EACI,eAAA;ACNxB;ADQoB;;;;EAEA,wBAAA;EACA,SAAA;ACJpB;ADQoB;EACI,UAAA;ACNxB;ADQoB;EACI,kBAAA;ACNxB;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACL5B;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ACL5B;ADQoB;EACI,YAAA;EACA,gBAAA;ACNxB;ADUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ACRhB;ADSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ACPpB;ADQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ACNxB;ADQoB;EACI,YAAA;ACNxB;ADQoB;EACI,WAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ACNxB;;ADcA;EACI,4BAAA;EACA,WAAA;ACXJ;ADYI;EACI,gBAAA;ACVR;ADYI;EACI,yBAAA;ACVR;;ADcA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;EACA,aAAA;ACXJ;ADYI;EACI;IACI,gCAAA;IACA,UAAA;ECVV;EDYM;IACI,gCAAA;IACA,UAAA;ECVV;AACF;ADYI;EACI,sBAAA;ACVR;ADYI;EACI,cAAA;ACVR;ADYI;EACI,yBAAA;ACVR;ADYI;EACI,gBAAA;ACVR;ADWQ;EACI,aAAA;EACA,kBAAA;ACTZ;ADYI;EACI,iBAAA;EACA,YAAA;ACVR;ADWQ;EACI,YAAA;ACTZ;ADYI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,aAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ACVR;ADWQ;EACI,aAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,aAAA;EACA,sBAAA;ACTZ;ADUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACRhB;ADUY;EACI,YAAA;ACRhB;ADYI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ACVR;;ADeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ACZR;ADaQ;EACI,gBAAA;ACXZ;ADaQ;EACI,sBAAA;ACXZ;ADaQ;EACI,uBAAA;ACXZ;ADYY;EACI,uBAAA;ACVhB;ADcY;EACI,yBAAA;ACZhB;ADgBY;EACI,gBAAA;ACdhB;ADgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ACdhB;ADgBY;EACI,eAAA;ACdhB;ADegB;EACI,eAAA;EACA,gBAAA;ACbpB;ADegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ACbpB","file":"pricereview.css"} \ No newline at end of file diff --git a/wms/mkt/css/pricereview.scss b/wms/mkt/css/pricereview.scss index e1b62d0b..ea3c48bc 100644 --- a/wms/mkt/css/pricereview.scss +++ b/wms/mkt/css/pricereview.scss @@ -1,98 +1,315 @@ #pricereviewCreate{ - table, th, td{ - border:1px #ccc solid; - padding: 15px; + input[type='text'], input[type='number'], select{ + margin: 1px; + } + textarea{ + resize: vertical; } - table{ - thead th{ - background-color: #6D9EEB; + >.modal{ + padding: 20px; + table, th, td{ + border:1px #ccc solid; } - tbody { - td input{ - font-size: 14px; + table > thead tr th{ + color:#A52A2A; + } + table > tbody .selected{ + background-color: #E7FEFB; + } + table > tbody .selected td{ + } + } + .container{ + table, th, td{ + border:1px #ccc solid; + padding: 15px; + &.noborder, .noborder th, .noborder td{ + border:none; } - th{ - background-color: #CCE4F8; - font-size: 14px; - padding: 15px 2px; - min-width: 100px; - text-align: center; + } + table{ + thead th{ + background-color: #6D9EEB; + } + tbody { + td input{ + font-size: 14px; + } + th{ + background-color: #CCE4F8; + font-size: 14px; + padding: 15px 2px; + min-width: 100px; + text-align: center; + } + } + input{ + font-size: 13px; + } + } + .pricreviewmain{ + background-color: #F2F2F2; + padding: 20px; + border-radius: 6px ; + margin:30px 0; + button{ + color:#fff; + width: 55px; + height: 30px; + padding: 0; + margin-left: 10px; + font-size: 13px; + &.addbtn{ + background-color: #337AB7; + width: 30px; + } + &.deleteBtn{ + background-color: #D9534F; + color:#fff; + font-size: 12px; + width: 30px; + } + &.selectElevator{ + background-color: #D9534F; + color:#fff; + } + } + + >.divitem{ + border:1px #ccc solid; + padding: 10px; + border-radius: 4px ; + .title{ + display: flex; + align-items: center; + border-bottom: 1px #ccc solid; + padding: 10px 0; + margin-bottom: 10px; + h6{ + font-weight: 600; + } + + } + table, th, td{ + font-size: 14px; + background-color: transparent; + input, select, textarea{ + font-size: 13px; + } + input[type=number]::-webkit-outer-spin-button, + input[type=number]::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + } + table { + tr:hover .deleteBtn ,tr:hover .copyBtn{ + opacity: 1; + } + .saletd{ + position: relative; + >.deleteBtn{ + position: absolute; + top: 50%; + transform: translateY(-50%); + right:2px; + opacity: 0; + transition: .3s; + } + >.copyBtn{ + position: absolute; + top: 50%; + transform: translateY(-50%); + right:38px; + opacity: 0; + transition: .3s; + width: 30px; + height: 30px; + } + } + textarea{ + height: auto; + min-height: 50px; + } + } + } + >.filediv{ + display: flex; + flex-direction: column; + margin-top: 20px; + label{ + display: flex; + align-items: center; + margin:10px 0; + p{ + width:100px; + font-size: 15px; + font-weight: 600; + } + input[type="file"]{ + width:400px + } + button{ + width:90px; + height: 35px; + margin:0; + margin-right: 15px; + margin-top: 20px; + } + } } } - input{ - font-size: 13px; + } +} + +.container-fluid, .container{ + max-width:1400px !important; + width: 100%; + h4{ + font-weight: 600; + } + .btn-secondary{ + background-color: #6C757D; + } +} + +.window-modal{ + position: fixed; + top: 0; + left:0; + width: 100%; + height: 100vh; + background-color: rgba(0, 0, 0, 0.5); + z-index: 9; + padding: 20px; + display: none; + @keyframes fade-in { + 0%{ + transform: translate(-50%, -60%); + opacity: 0; + } + 100%{ + transform: translate(-50%, -55%); + opacity: 1; + } + } + table, th, td{ + border:1px #ccc solid; + } + table > thead tr th{ + color:#A52A2A; + } + table > tbody .selected{ + background-color: #E7FEFB; + } + &#optionModal .window-modal-content{ + max-height: 80vh; + .window-modal-body{ + height: 400px; + overflow-y: scroll; + } + } + &#toElevatorModal .window-modal-content{ + min-height: 270px; + height: auto; + .window-modal-body{ + height: auto; + } + } + .window-modal-content{ + z-index: 9; + background-color: #fff; + border-radius: 10px; + position: absolute; + width:1200px; + padding: 30px; + top: 50%; + left:50%; + transform: translate(-50%, -55%); + box-shadow: 0 5px 5px #222; + animation: fade-in .2s linear; + &.modal-xl{ + width:1200px; + } + &.modal-lg{ + width:800px; + } + &.modal-m{ + width:450px; + } + .window-modal-header{ + display: flex; + flex-direction: column; + button.btn-close{ + position: absolute; + top: 10px; + right:10px; + background-color: transparent; + border:none; + outline: none; + border-radius: 50%; + } + >div > input{ + width: 250px; + } } } - .pricreviewmain{ + .window-back{ + position: absolute; + top: 0; + left:0; + width: 100%; + height: 100%; + background-color: transparent; + } +} + +#pricereviewCheck{ + >.container{ background-color: #F2F2F2; + border-radius: 15px; padding: 20px; - border-radius: 6px ; - button{ - color:#fff; - width: 55px; - height: 30px; - padding: 0; - margin-left: 10px; - font-size: 13px; - &.addbtn{ - background-color: #337AB7; - width: 30px; - } - &.deleteBtn{ - background-color: #D9534F; - color:#fff; - font-size: 12px; - width: 30px; + textarea{ + resize: vertical; + } + table, th, td{ + border:1px #ccc solid; + } + table.noborder{ + border:none !important; + th ,td{ + border:none !important; } - &.selectElevator{ - background-color: #D9534F; - color:#fff; + } + .customerinfo-table{ + input{ + background-color: #EEE5E5; } } - - >.divitem{ - border:1px #ccc solid; - padding: 10px; - border-radius: 4px ; - .title{ - display: flex; - align-items: center; - border-bottom: 1px #ccc solid; - padding: 10px 0; - margin-bottom: 10px; - h6{ - font-weight: 600; - } - + .mi-table{ + th{ + font-weight: 600; } - table, th, td{ + input[type=text]{ + background-color: #EEEEEE; + cursor: not-allowed; + padding: 6px 12px; font-size: 14px; - background-color: transparent; - input, select, textarea{ - font-size: 13px; - } - input[type=number]::-webkit-outer-spin-button, - input[type=number]::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; - } } - table { - tr:hover .deleteBtn{ - opacity: 1; + .mi-info{ + font-size: 14px; + span{ + font-size: 15px; + font-weight: 600; } - .saletd{ - position: relative; - >.deleteBtn{ - position: absolute; - top: 50%; - transform: translateY(-50%); - right:2px; - opacity: 0; - transition: .3s; - } + .line{ + width: 100%; + height: .5px; + margin:30px 0; + background-color: #ccc; } } } } + } \ No newline at end of file diff --git a/wms/mkt/pricereview-check.php b/wms/mkt/pricereview-check.php index 6795979a..4bdd0c85 100644 --- a/wms/mkt/pricereview-check.php +++ b/wms/mkt/pricereview-check.php @@ -587,16 +587,16 @@ foreach ($res as $data) { foreach ($item_arr as $item_no => $val) { $item_amt_A_all += $val["item_price_bp"]; if ($viewmi) { - for ($i = 0; $i < $val["item_qty"]; $i++) { + // for ($i = 0; $i < $val["item_qty"]; $i++) { ?> "> [規調] "> - - + "> + "> " disabled> - "> + "> @@ -609,7 +609,7 @@ foreach ($res as $data) { diff --git a/wms/mkt/pricereview-index.php b/wms/mkt/pricereview-index.php index 07bff8b2..1021a118 100644 --- a/wms/mkt/pricereview-index.php +++ b/wms/mkt/pricereview-index.php @@ -1,6 +1,6 @@ - " target="_blank" class="btn btn-warning btn-sm">檢視 + " target="_blank" class="btn btn-warning btn-sm">檢視 @@ -520,14 +520,14 @@ if ($data) : if ($ss_arr["sign_st"] == 1 && in_array($user_id, $ss_arr["sign_nt"]) && $data["status"] == "YS" || $user_id == 'TEST04') { $str = ""; $str = "待簽核"; - $str = "" . $str . ""; + $str = "" . $str . ""; } else $str = "--"; } echo $str; /* if ($sign_st==1 && $sign_nt==$user_id) { $str = ""; - $str = "".$str.""; + $str = "".$str.""; } else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程 list($uperson, $ustatus, $udtte) = explode(",", $sign1); if ($ustatus == "Y") $str = ""; @@ -545,7 +545,7 @@ if ($data) : $str = ""; } if (!$oneself) { - $str = "".$str.""; + $str = "".$str.""; $str .= "
".$data["checker_1"]."
".$data["checker_1_dt"]; } else { if ($data["checker_1_result"]) { @@ -577,7 +577,7 @@ if ($data) : if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 2) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST02') { $str = ""; $str = "待簽核"; - $str = "" . $str . ""; + $str = "" . $str . ""; } else $str = "--"; } echo $str; @@ -585,7 +585,7 @@ if ($data) : /* if ($sign_st==2 && $sign_nt==$user_id) { $str = ""; - $str = "".$str.""; + $str = "".$str.""; } else if ($sign_st > 2 || $data['last_check_result']) { list($uperson, $ustatus, $udtte) = explode(",", $sign2); if ($ustatus == "Y") $str = ""; @@ -603,7 +603,7 @@ if ($data) : $str = ""; } if (!$oneself) { - $str = "".$str.""; + $str = "".$str.""; $str .= "
".$data["checker_2"]."
".$data["checker_2_dt"]; } else { if ($data["checker_2_result"]) { @@ -631,7 +631,7 @@ if ($data) : if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 3) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST03') { $str = ""; $str = "待簽核"; - $str = "" . $str . ""; + $str = "" . $str . ""; } else $str = "--"; } echo $str; @@ -639,7 +639,7 @@ if ($data) : $str = ""; if ($sign_st==3 && $sign_nt==$user_id) { $str = ""; - $str = "".$str.""; + $str = "".$str.""; } else $str = "--"; */ @@ -652,7 +652,7 @@ if ($data) : $str = ""; } if (!$oneself) { - $str = "".$str.""; + $str = "".$str.""; $str .= "
".$data["checker_3"]."
".$data["checker_3_dt"]; } else { if ($data["checker_3_result"]) { @@ -677,7 +677,7 @@ if ($data) : if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 4) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST05') { $str = ""; $str = "待簽核"; - $str = "" . $str . ""; + $str = "" . $str . ""; } else $str = "--"; } echo $str; diff --git a/wms/mkt/pricereviewCheck.php b/wms/mkt/pricereviewCheck.php new file mode 100644 index 00000000..657c07af --- /dev/null +++ b/wms/mkt/pricereviewCheck.php @@ -0,0 +1,747 @@ +prepare($sql_str); +$stmt->bindParam(':id', $id); +$stmt->execute(); +$contract = $stmt->fetch(PDO::FETCH_ASSOC); + +if(!$contract){ + echo "找不到此紀錄!"; + exit; +} + +$sql_str = "SELECT * FROM pricereview_pay WHERE mid = :mid ORDER BY pay_kind ASC"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':mid', $id); +$stmt->execute(); +$pays = $stmt->fetchAll(PDO::FETCH_ASSOC); + +$sql_str = "SELECT pricereview_item.*, option_mi.price AS option_mi, option_price.group_name AS option_name, option_price.memo AS option_memo, option_price.spec AS option_spec + FROM pricereview_item + LEFT JOIN option_mi ON option_mi.option_price_id = pricereview_item.price_id + LEFT JOIN option_price ON option_price.id = pricereview_item.price_id + WHERE pricereview_item.mid = :mid AND option_mi.open_kind = 'CO' ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':mid', $id); +$stmt->execute(); +$options = $stmt->fetchAll(PDO::FETCH_ASSOC); + + +$sql_str = "SELECT * FROM pricereview_item + WHERE pricereview_item.mid = :mid ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':mid', $id); +$stmt->execute(); +$items = $stmt->fetchAll(PDO::FETCH_ASSOC); + +$sql_str = "SELECT * FROM pricereview_sign WHERE mid = :mid"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':mid', $id); +$stmt->execute(); +$sign = $stmt->fetch(PDO::FETCH_ASSOC); + +$currentSigner = ''; +$currentSign = 0; +// Y:已同意 N:不同意 W:待簽 +// sign1 => 處長, sign2 => 業務承辦人, sign3 => 協理, sign4 => 總經理 +if($sign['sign1'] == NULL || $sign['sign1'] ==''){ + $sign1 = NULL; +}else{ + if( explode(",", $sign['sign1'])[1] != ''){ + $sign1 = explode(",", $sign['sign1'])[1] == 'Y' ? 'Y' : 'N'; + }else{ + $sign1 = 'W'; + } +} + + +if($sign['sign2'] == NULL || $sign['sign2'] ==''){ + $sign2 = NULL; +}else{ + if( explode(",", $sign['sign2'])[1] != ''){ + $sign2 = explode(",", $sign['sign2'])[1] == 'Y' ? 'Y' : 'N'; + }else{ + $sign2 = 'W'; + } +} + +if($sign['sign3'] == NULL || $sign['sign3'] ==''){ + $sign3 = NULL; +}else{ + if( explode(",", $sign['sign3'])[1] != ''){ + // $sign3 = explode(",", $sign['sign3'])[1] == 'Y' ? 'Y' : 'N'; + if(explode(",", $sign['sign3'])[1] == 'YY') $sign3 = 'YY'; + if(explode(",", $sign['sign3'])[1] == 'Y') $sign3 = 'Y'; + }else{ + $sign3 = 'W'; + } +} +if($sign['sign4'] == NULL || $sign['sign4'] ==''){ + $sign4 = NULL; +}else{ + if( explode(",", $sign['sign4'])[1] != ''){ + // $sign4 = explode(",", $sign['sign4'])[1] == 'Y' ? 'Y' : 'N'; + if(explode(",", $sign['sign4'])[1] == 'YY') $sign4 = 'YY'; + if(explode(",", $sign['sign4'])[1] == 'Y') $sign4 = 'Y'; + }else{ + $sign4 = 'W'; + } +} + +if($sign1 == 'W'){ + $currentSigner = explode(",", $sign['sign1'])[0]; + $currentSign = 1; +}elseif($sign2 == 'W'){ + $currentSigner = explode(",", $sign['sign2'])[0]; + $currentSign = 2; +}elseif($sign3 == 'W'){ + $currentSigner = explode(",", $sign['sign3'])[0]; + $currentSign = 3; +}elseif($sign4 == 'W'){ + $currentSigner = explode(",", $sign['sign4'])[0]; + $currentSign = 4; +} + +// $sql_str = "SELECT * FROM account WHERE accountid = :accountid"; +// $stmt = $conn->prepare($sql_str); +// $stmt->bindParam(':accountid', $sign['sign']); +// $stmt->execute(); +// $account = $stmt->fetch(PDO::FETCH_ASSOC); + + + +// $sql_str = "SELECT * FROM account WHERE accountid = :accountid"; +// $stmt = $conn->prepare($sql_str); +// $stmt->bindParam(':accountid', $account['manager']); +// $stmt->execute(); +// $manager = $stmt->fetch(PDO::FETCH_ASSOC); + + +$permissions = false; +//開啟業務部權限 +if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){ + $permissions = true; +} + +?> + + + + + +
+
+ + + + + + + + + + + + + + + + + + + +
卷號營業員客戶名稱牌價總額(A)售價總額(B)破價總額(B-A)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
整機單價業務部作業區
項次規格單價數量複價業務部MI售價利潤利潤率(%)
小計
+ + + + + + + + + + + + + + + + + + + + + + + + +
OPTION 加價
項次OPTION ID名稱單價數量複價備註所屬電梯項次
小計 + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
除外項目
項次詢價單號名稱單價數量複價所屬電梯項次
小計 + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
保固延長
項次規格單價數量(月)複價備註所屬電梯項次
小計 + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
付款辦法款別比例(%)金額票期
材料1.訂金 + +
2.二次款 + +
3.貨到工地款 + +
4.其他 + +
材料5.安裝完畢款 + +
6.驗收款 + +
7.尾款 + +
合計
備註
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
卷號營業員客戶名稱案件名稱地址
牌價總額(A)售價總額(B)破價總額(B-A)總台數服務費(介紹費)價率%(B/A)
預定成交日預訂出貨日
罰則訂金保證金(函)%履約保證金(函)%保固保證金(函)%
特記事項
+ +
+
  • 營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    審核審核人結果意見時間
    區經理 + +
    業務承辦人 + +
    業務部協理 + +
    總經理 + +
    + + + + + + + + + + + + + +
    審核意見批示售價
    + + + +
    +
    + + + + + + + + + + + + +
    +
    + +
    + + \ No newline at end of file diff --git a/wms/mkt/pricereviewCreate.php b/wms/mkt/pricereviewCreate.php index 80c17a97..e1a303d8 100644 --- a/wms/mkt/pricereviewCreate.php +++ b/wms/mkt/pricereviewCreate.php @@ -1,15 +1,637 @@ prepare($sql_str); +$stmt->execute(); +$options = $stmt->fetchAll(PDO::FETCH_ASSOC); +foreach ($options as $key => $option) { + $options[$key]['isShow'] = 1; + $options[$key]['selected'] = 0; +} +$vol_no = $_GET['vol_no']; +$hope_status = [ + 'A'=>'有望簽約(已報價)', + 'B'=>'觀望考慮(等待時機報價)', + 'C'=>'在途合約', + 'D'=>'已簽約', + 'N'=>'無望簽約', +]; +//有望客戶基本資料 +$sql_str = "SELECT hope_elevator_customer.*, code.content AS source_content, account.name AS salesman_name FROM hope_elevator_customer + LEFT JOIN code ON code.code_name = hope_elevator_customer.source + LEFT JOIN account ON account.accountid = hope_elevator_customer.salesman + WHERE hope_elevator_customer.vol_no = :vol_no AND code.field_name = 'customer_source'"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':vol_no', $vol_no); +$stmt->execute(); +$hope_customer = $stmt->fetch(PDO::FETCH_ASSOC); + +//獲取有望客戶電梯規格 +$sql_str = "SELECT +hope_project_elevator_spec.specifications, +hope_project_elevator_spec.person, +hope_project_elevator_spec.stop, +hope_project_elevator_spec.speed, +hope_project_elevator_spec.open, +hope_project_elevator_spec.spec_price, +hope_project_elevator_spec.spec_num, +fp.price AS price, +fp.id AS facility_id, +CASE hope_project_elevator_spec.open + WHEN 4 THEN '2U' + WHEN 5 THEN '4PCO' + WHEN 7 THEN '6PCO' + WHEN 8 THEN '2S' + WHEN 9 THEN 'CO' + ELSE hope_project_elevator_spec.open +END AS open_converted +FROM hope_project_elevator_spec +LEFT JOIN ( +SELECT *, + ROW_NUMBER() OVER (PARTITION BY model ORDER BY create_dt DESC) as rn +FROM facility_price +) fp ON fp.model = CONCAT(hope_project_elevator_spec.specifications, '-', hope_project_elevator_spec.person, '*', hope_project_elevator_spec.stop, '-', CASE hope_project_elevator_spec.open + WHEN 4 THEN '2U' + WHEN 5 THEN '4PCO' + WHEN 7 THEN '6PCO' + WHEN 8 THEN '2S' + WHEN 9 THEN 'CO' + ELSE hope_project_elevator_spec.open +END, hope_project_elevator_spec.speed) +AND fp.rn = 1 +WHERE hope_project_elevator_spec.vol_no = :vol_no +ORDER BY hope_project_elevator_spec.seq ASC;"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(':vol_no', $vol_no); +$stmt->execute(); +$hope_elevators = $stmt->fetchAll(PDO::FETCH_ASSOC); +$total_spec = 0; +foreach ($hope_elevators as $key => $elevator) { + $hope_elevators[$key]['id'] = $key+1; + $total_spec ++; +} + + +function convertDateTimeFormat($dateTimeStr) { + // 使用 DateTime::createFromFormat 解析给定格式的日期时间 + $date = DateTime::createFromFormat('Y-m-d H:i:s', $dateTimeStr); + + // 如果解析成功,则使用 DateTime::format 转换格式 + if ($date) { + return $date->format('Y-m-d'); + } else { + // 如果解析失败,返回原始字符串或错误信息 + return $dateTimeStr; // 或者返回错误信息 + } +} ?> - + - + + -
    + +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    + @@ -19,39 +641,39 @@ require_once("./conn.php"); - + - + - + - + - + - + - + - + - + - + - + - + - + - +
    卷號 客戶名稱 負責人 客戶來源
    地址 案件名稱 統編/身份證 業主方聯係人
    市話/手機 營業員 台數 預定成交日
    有望客戶狀態 汰改
    @@ -65,12 +687,12 @@ require_once("./conn.php"); - + - +
    +
    -
    整機單價
    - +

    整機單價

    +
    - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + +
    電梯人乘/載重停數速度(m/min)開門方式規格單價數量複價售價 項次電梯人乘/
    載重
    停數速度(m/min)開門方式規格公司發布價(台)數量公司發布價(總價)售價(台)售價(總價)
    - - - - - - - - - - - - - - -
    小計
    -
    Option加價
    - +

    Option加價

    +
    - + - - - - - - - + + + + + + + + - - - - - - - - - - - - + + + + @@ -237,11 +885,11 @@ require_once("./conn.php");
    -
    除外項目
    - +

    除外項目

    +
    選配規格單價數量複價備註所屬電梯功能ID選配規格單價數量複價備註所屬電梯功能
    MAE100-6*7-CO45 -
    - - -
    -
    小計
    小計
    - + @@ -253,24 +901,30 @@ require_once("./conn.php"); - - - - - - - - - - + + - - + + @@ -278,16 +932,12 @@ require_once("./conn.php");
    -
    保固延長
    - +

    保固延長

    +
    詢價單號 名稱
    MAE100-6*7-CO45 -
    - - -
    -
    小計
    - + - - - - @@ -297,67 +947,29 @@ require_once("./conn.php"); - - - - - - - - - - - - - - - - + + + + + @@ -378,10 +990,10 @@ require_once("./conn.php"); - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -511,6 +1123,103 @@ require_once("./conn.php");
    電梯人乘/載重停數速度 單價 數量(月) 複價
    - - - - - - - - MAE100-6*7-CO45 -
    - - -
    -
    小計
    小計
    材料 1.訂金 - @@ -395,10 +1007,10 @@ require_once("./conn.php");
    2.二次款 - @@ -406,16 +1018,16 @@ require_once("./conn.php"); - +
    3.貨到工地款 - @@ -423,16 +1035,16 @@ require_once("./conn.php"); - +
    4.其他 - @@ -440,17 +1052,17 @@ require_once("./conn.php"); - +
    安裝 5.安裝完畢款 - @@ -458,16 +1070,16 @@ require_once("./conn.php"); - +
    6.驗收款 - @@ -475,16 +1087,16 @@ require_once("./conn.php"); - +
    7.其他 - @@ -492,14 +1104,14 @@ require_once("./conn.php"); - +
    合計
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    牌價總額(A)售價總額(B)破價總額(B-A)價率%(B/A)總台數服務費(介紹費)
    預定成交日預定出貨日
    罰則訂金保證金(函)%履約保證金(函)%保固保證金(函)%
    特記事項
    + +
    + +
    +
    + + + + +
    -
    \ No newline at end of file + + + + + \ No newline at end of file diff --git a/wms/mkt/pricereview_renovate-edit.php b/wms/mkt/pricereview_renovate-edit.php index b79985f5..39fdf44c 100644 --- a/wms/mkt/pricereview_renovate-edit.php +++ b/wms/mkt/pricereview_renovate-edit.php @@ -2127,7 +2127,7 @@ foreach ($res as $data) { X

      - + diff --git a/wms/mkt/specsurvey-create.php b/wms/mkt/specsurvey-create.php index 64f57e36..c9804847 100644 --- a/wms/mkt/specsurvey-create.php +++ b/wms/mkt/specsurvey-create.php @@ -596,6 +596,7 @@ C:當天第3版,依次類推……" readonly> +