From a1e7dcafd9caed221ae522f15bb8acdef31912ea Mon Sep 17 00:00:00 2001 From: 10994015 Date: Tue, 30 Jan 2024 10:54:30 +0800 Subject: [PATCH 1/5] merge --- wms/contract-repair/prviewPdf.php | 2 +- wms/contract/prviewPdf.php | 2 +- wms/fun_global.php | 4 ++-- wms/mkt/assets/js/alpine.js | 6 +++--- wms/mkt/price_option-index.php | 4 ++-- wms/mkt/price_option-select.php | 4 ++-- wms/mkt/pricereview-check.php | 2 +- wms/mkt/pricereview-create.php | 5 +++-- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/wms/contract-repair/prviewPdf.php b/wms/contract-repair/prviewPdf.php index 91adc475..82d476b0 100644 --- a/wms/contract-repair/prviewPdf.php +++ b/wms/contract-repair/prviewPdf.php @@ -509,7 +509,7 @@ if ($_POST['list']) { -  臺北市中山區敬業一路128巷39號3樓之1 +  桃園市觀音區崙坪村8鄰140號

 

diff --git a/wms/contract/prviewPdf.php b/wms/contract/prviewPdf.php index 1d311b0a..3ee604cb 100644 --- a/wms/contract/prviewPdf.php +++ b/wms/contract/prviewPdf.php @@ -495,7 +495,7 @@ if($_POST['list']){ -  臺北市中山區敬業一路128巷39號3樓之1 +  桃園市觀音區崙坪村8鄰140號

 

diff --git a/wms/fun_global.php b/wms/fun_global.php index cd4271b2..d9f9e98d 100644 --- a/wms/fun_global.php +++ b/wms/fun_global.php @@ -102,7 +102,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0) // 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。 if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) { $ret[1] = $user_id . ",,"; - $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) + // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) $ret[3] = "M0060,,"; // 業務協理 if ($rate < 80 || $special_fee > 0) { $ret[4] = "M0006,,"; // 總經理 @@ -123,7 +123,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0) } } else { - $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) + // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) $ret[3] = "M0060,,"; // 業務協理 if ($rate < 80 || $special_fee > 0) { $ret[4] = "M0006,,"; // 總經理 diff --git a/wms/mkt/assets/js/alpine.js b/wms/mkt/assets/js/alpine.js index 85f3c5a4..05a190ee 100644 --- a/wms/mkt/assets/js/alpine.js +++ b/wms/mkt/assets/js/alpine.js @@ -84,7 +84,7 @@ const priceOptionIndex = () => { if (item.spec == null) item.spec = '' if (item.memo == null) item.memo = '' if (item.price == null) item.price = 0 - return (item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase())); + return (item.id.includes(text.toLowerCase()) ||item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase())); } }).slice((Number(this.currentpage) - 1) * Number(this.pageLength), (Number(this.currentpage) - 1) * Number(this.pageLength) + Number(this.pageLength)) this.dataLangth = this.options.length @@ -165,7 +165,7 @@ const priceOptionSelect = () => { if (item.spec == null) item.spec = '' if (item.memo == null) item.memo = '' if (item.price == null) item.price = 0 - return (item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase())); + return (item.id.includes(text.toLowerCase()) || item.group_name.toLowerCase().includes(text.toLowerCase()) || item.spec.toLowerCase().includes(text.toLowerCase()) || item.memo.toLowerCase().includes(text.toLowerCase()) || String(item.price).includes(text.toLowerCase())); }).slice((Number(this.currentpage) - 1) * Number(this.pageLength), (Number(this.currentpage) - 1) * Number(this.pageLength) + Number(this.pageLength)) this.dataLangth = this.options.length } else { @@ -304,7 +304,7 @@ const pricereviewOptionSelect = () => { if(option.memo == null) option.memo = '' if(option.price == null) option.price = 0 if(option.unit == null) option.unit = '' - if(option.group_name.includes(val) || option.memo.toLowerCase().includes(val) || option.spec.toLowerCase().includes(val) || option.unit.includes(val) || String(option.price).includes(val)){ + if(option.id.includes(val) || option.group_name.includes(val) || option.memo.toLowerCase().includes(val) || option.spec.toLowerCase().includes(val) || option.unit.includes(val) || String(option.price).includes(val)){ option.status = "Y" }else{ option.status = "N" diff --git a/wms/mkt/price_option-index.php b/wms/mkt/price_option-index.php index ecf0afa6..e133f221 100644 --- a/wms/mkt/price_option-index.php +++ b/wms/mkt/price_option-index.php @@ -74,7 +74,7 @@ $optional_arr = [1 => '標', 2 => '選']; 配置 單位 定價 - + MI @@ -96,7 +96,7 @@ $optional_arr = [1 => '標', 2 => '選']; - + diff --git a/wms/mkt/price_option-select.php b/wms/mkt/price_option-select.php index a352c5ea..ed48efb2 100644 --- a/wms/mkt/price_option-select.php +++ b/wms/mkt/price_option-select.php @@ -58,7 +58,7 @@ $optional_arr = [1 => '標配', 2 => '選配',3=>'加價']; 配置 單位 定價 - + MI @@ -80,7 +80,7 @@ $optional_arr = [1 => '標配', 2 => '選配',3=>'加價']; - + diff --git a/wms/mkt/pricereview-check.php b/wms/mkt/pricereview-check.php index 64db1e44..18aa89e3 100644 --- a/wms/mkt/pricereview-check.php +++ b/wms/mkt/pricereview-check.php @@ -662,7 +662,7 @@ foreach ($res as $data) { ?> - + "> "> "> "> diff --git a/wms/mkt/pricereview-create.php b/wms/mkt/pricereview-create.php index ae64948b..cc95eadf 100644 --- a/wms/mkt/pricereview-create.php +++ b/wms/mkt/pricereview-create.php @@ -2556,12 +2556,13 @@ include "../footer.php"; // console.log(pobj.find('input[name=optionID]').val()); // console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html())); console.log(pobj.find('td').eq(0).html()); - jobj.html(pobj.find('td').eq(1).html() + " " + pobj.find('td').eq(2).html() + '
(' + pobj.find('td').eq(3).html() + ')'); + let sepc = pobj.find('td').eq(2).html() + '
(' + pobj.find('td').eq(3).html() + ')'; + sepc = sepc.replace("()", "") + jobj.html(pobj.find('td').eq(1).html() + " " ); jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(6).html()); jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(6).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, ""))); jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('td').eq(0).html()); $("#optionModal").modal('hide'); - } function checkSubmit(){ const price_total = document.getElementById('price_total') From 4648ac465f24d9115976e8713603ab9f68f67408 Mon Sep 17 00:00:00 2001 From: Ellin Date: Tue, 30 Jan 2024 15:13:07 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=87=89=E6=94=B6=E5=B8=B3=E6=AC=BE(?= =?UTF-8?q?=E6=B1=B0=E6=94=B9)=20=E5=88=9D=E7=89=88=E4=B8=8A=E7=B7=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/account-receivable-renovate-excel.php | 42 ++ wms/account-receivable-renovate-index.php | 812 +++++++--------------- wms/account-receivable-renovate.xlsx | Bin 0 -> 243700 bytes 3 files changed, 310 insertions(+), 544 deletions(-) create mode 100644 wms/account-receivable-renovate-excel.php create mode 100644 wms/account-receivable-renovate.xlsx diff --git a/wms/account-receivable-renovate-excel.php b/wms/account-receivable-renovate-excel.php new file mode 100644 index 00000000..77341d5a --- /dev/null +++ b/wms/account-receivable-renovate-excel.php @@ -0,0 +1,42 @@ +getActiveSheet(); +// file_put_contents('account-receivable.txt', json_encode($Bill)); + +$colomnHeader = [ + '合約號', '作番號', '部門編號', '部門名稱', '主管工號','主管名稱', '營業員工號', '營業員名稱', '客戶名稱', '抬頭', '統編', '通訊地址', + '收款階段名稱', '應收日期','是否應收', '應收金額', '已開金額','未開金額', '已收金額','催收金額', '催收次數' +]; +$sheet->fromArray($colomnHeader, NULL, 'A1'); +$rowIndex = 2; +foreach ($Bill as $key => $value) { + + $sheet->fromArray($value, NULL, 'A' . $rowIndex); + $column = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S','T' + ]; + foreach ($column as $col) { + $sheet->getColumnDimension($col)->setAutoSize(true); + } + $rowIndex++; +} +$writer = new Xlsx($spreadsheet); +$excelFileName = 'account-receivable-renovate.xlsx'; +$writer->save($excelFileName); + +echo $excelFileName; +?> + \ No newline at end of file diff --git a/wms/account-receivable-renovate-index.php b/wms/account-receivable-renovate-index.php index 08777c0a..63c1f588 100644 --- a/wms/account-receivable-renovate-index.php +++ b/wms/account-receivable-renovate-index.php @@ -25,11 +25,12 @@ $sql_contractNumber = "SELECT Distinct BillNo FROM salSalesOrder WHERE ModeId = // T8發票 (有專案的發票) $sql_invoice = "SELECT DISTINCT a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, -b.ProjectId +b.FromSalSalesOrder FROM arSellInvoice as a -LEFT JOIN arSellInvoiceMaterial as b +LEFT JOIN (SELECT CH.FromSalSalesOrder, SE.* FROM arSellInvoiceMaterial AS SE +LEFT JOIN arCheckBillDetail AS CH ON SE.FromBillNo=CH.BillNo) as b ON a.BillNo=b.BillNo -WHERE DATALENGTH(b.ProjectId)>0 +WHERE DATALENGTH(b.FromSalSalesOrder)>0 ORDER BY InvoiceTime ASC"; // T8核銷 @@ -61,11 +62,9 @@ SELECT * FROM account_received "; // 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的 if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210')))) { } else { - $sql_contract .= "AND (s.PersonId = '$user_id'"; // $sql_received .= " AND (PersonId = '$user_id'"; $sql_opening .= " OR person_id = '$user_id'"; $sql_contractNumber .= " AND (PersonId = '$user_id'"; - $sql_contract_budget .= " AND (PersonId = '$user_id'"; if (count($follower) > 0) { $column_str = "('$user_id'" . ",'"; $column_str .= implode("','", $follower); @@ -76,7 +75,6 @@ if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepart $sql_opening .= " OR person_id IN $column_str)"; // $sql_contract_budget .= " OR PersonId IN $column_str )ORDER BY BillNo, CU_MaterialId"; } else { - $sql_contract .= ")"; // $sql_received .= ")"; $sql_opening .= ")"; $sql_contractNumber .= ")"; @@ -128,19 +126,25 @@ FROM department ON d.department_id = tmp2.department_id"; //T8 銷售訂單 階段收款計畫 -$sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, +$sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, s.DeptId, s.DeptName, c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a -LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo -LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId -WHERE s.BillNo IN $str_numbers "; +LEFT JOIN (SELECT O.*, DE.DeptName FROM salSalesOrder AS O LEFT JOIN comDepartment AS DE ON O.DeptId=DE.DeptId) AS s on a.BillNo = s.BillNo +LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId "; +if (isset($str_numbers)) { + $sql_contract .= "WHERE s.BillNo IN $str_numbers "; +} + // T8 銷售訂單 作番金額 $sql_contract_budget = "SELECT A.BillNo,A.MaterialId, A.OAmountWithTax,A.CU_MaterialId FROM salSalesOrderDetail AS A LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo -WHERE B.ModeId='T' AND A.ItemType=1 AND A.BillNo IN $str_numbers "; - +WHERE B.ModeId='T' AND A.ItemType=1 "; +if (isset($str_numbers)) { + $sql_contract_budget .= "AND A.BillNo IN $str_numbers "; +} $contract = $conn->query($sql_contract); $contract_data = array(); +$manager_list = array(); // 將T8合約收款階段資料依據款別分類放進arraData裡 foreach ($contract as $cont) { $BillNo = $cont['BillNo']; @@ -153,6 +157,11 @@ foreach ($contract as $cont) { $TaxNo = $cont['TaxNo']; $ContactAddress = $cont['ContactAddress']; $RowNo = $cont['RowNo']; + $salesId = $cont['PersonId']; + if (!in_array($salesId, $manager_list)) { + array_push($manager_list, $salesId); + } + //['type'] A:比照新梯、B:純分期、C:其他 //['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期 @@ -161,6 +170,9 @@ foreach ($contract as $cont) { if (!(isset($arrayData[$BillNo]))) { // 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號 $arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + $arrayData[$BillNo][0] = $cont['DeptId']; + $arrayData[$BillNo][1] = $cont['DeptName']; + $arrayData[$BillNo][3] = $salesId; $arrayData[$BillNo][5] = $partnerName; $arrayData[$BillNo][6] = $EnterpriseName; $arrayData[$BillNo][7] = $TaxNo; @@ -197,11 +209,26 @@ $opening_data = mysqli_query($link, $sql_opening); $invoice_data = $conn->query($sql_invoice); $contract_budget_data = $conn->query($sql_contract_budget); +// 查WMS 契約員主管 +$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A +LEFT JOIN account AS B ON A.manager = B.accountid "; +$managers = mysqli_query($link, $sql_manager); + +$find_manager = array(); +foreach ($managers as $manager) { + $find_manager[$manager['accountid']] = $manager; +} // 將T8銷售訂單明細 每個作番金額存入arrayData $contract_budget = array(); foreach ($contract_budget_data as $cont) { $BillNo = $cont['BillNo']; if (isset($arrayData[$BillNo])) { + $salesid = $arrayData[$BillNo][3]; + if (isset($find_manager[$salesid])) { + $arrayData[$BillNo][2] = $find_manager[$salesid]['manager_name']; + $arrayData[$BillNo][4] = $find_manager[$salesid]['name']; + $arrayData[$BillNo][11] = $find_manager[$salesid]['manager']; + } $arrayData[$BillNo]['total_budget'] += $cont['OAmountWithTax']; $arrayData[$BillNo][$cont['MaterialId']] += $cont['OAmountWithTax']; if (isset($arrayData[$BillNo]['facility'][$cont['CU_MaterialId']])) { @@ -273,11 +300,11 @@ foreach ($wipwhole_array as $wip) { //[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 if (isset($arrayData[$wip['contractno']])) { // 整理合約資料 - $arrayData[$wip['contractno']][0] = $wip['department_id'];; - $arrayData[$wip['contractno']][1] = $wip['depart_name']; - $arrayData[$wip['contractno']][2] = $wip['manager_name']; - $arrayData[$wip['contractno']][3] = $wip['salesid']; - $arrayData[$wip['contractno']][4] = $wip['name']; + // $arrayData[$wip['contractno']][0] = $wip['department_id'];; + // $arrayData[$wip['contractno']][1] = $wip['depart_name']; + // $arrayData[$wip['contractno']][2] = $wip['manager_name']; + // $arrayData[$wip['contractno']][3] = $wip['salesid']; + // $arrayData[$wip['contractno']][4] = $wip['name']; $arrayData[$wip['contractno']][10] = $wip['contractno']; $arrayData[$wip['contractno']]['A40001'] = (isset($contract_budget[$wip['contractno']]['A40001']) && !is_null($contract_budget[$wip['contractno']]['A40001'])) ? $contract_budget[$wip['contractno']]['A40001'] : 0; $arrayData[$wip['contractno']]['A40008'] = (isset($contract_budget[$wip['contractno']]['A40008']) && !is_null($contract_budget[$wip['contractno']]['A40008'])) ? $contract_budget[$wip['contractno']]['A40008'] : 0; @@ -299,120 +326,122 @@ $sign_array = ['訂金', '簽約', '合約']; // 將所有facility的paystage放入一個array以便計算順序 $allPayStages = []; foreach ($arrayData as &$value) { - if (is_iterable($value['facility'])) { + if (isset($value['facility']) && is_iterable($value['facility'])) { foreach ($value['facility'] as $fakey => &$facility) { - $ratio = get_contract_ratio($fakey, $contract_budget[$value[10]]); - for ($stage = 1; $stage < (count($value['PayStage']) + 1); $stage++) { - $facility['PayStage'][$stage] = $value['PayStage'][$stage]; - $facility['PayStage'][$stage]['facilityno'] = $fakey; - //算每個作番的金額 - $facility['PayStage'][$stage]['PayAmount'] = $value['PayStage'][$stage]['PayAmount'] * $ratio; - //算每個作番每個收款階段的收款時間 - switch ($facility['PayStage'][$stage]['type']) { - case "A": - switch ($facility['PayStage'][$stage]['name']) { - case (stristr($facility['PayStage'][$stage]['name'], '試車')): - if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['tryrun_end_date'])); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '完工')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '尾款')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '交車')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '驗收')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '安裝')): - if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['install_end_date'])); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): - if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_arrival_date'])); - } elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date'])); - } - break; - default: - break; - }; - - case "B": - - break; - case "C": - switch ($facility['PayStage'][$stage]['name']) { - case (stristr($facility['PayStage'][$stage]['name'], '試車')): - if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['tryrun_end_date']))); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '完工')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '尾款')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '交車')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '驗收')): - if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '安裝')): - if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['install_end_date']))); - } - break; - case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): - if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_arrival_date']))); - } elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { - $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); - $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date']))); - } - break; - default: - break; - }; - default: - break; + if (isset($contract_budget[$value[10]])) { + $ratio = get_contract_ratio($fakey, $contract_budget[$value[10]]); + for ($stage = 1; $stage < (count($value['PayStage']) + 1); $stage++) { + $facility['PayStage'][$stage] = $value['PayStage'][$stage]; + $facility['PayStage'][$stage]['facilityno'] = $fakey; + //算每個作番的金額 + $facility['PayStage'][$stage]['PayAmount'] = $value['PayStage'][$stage]['PayAmount'] * $ratio; + //算每個作番每個收款階段的收款時間 + switch ($facility['PayStage'][$stage]['type']) { + case "A": + switch ($facility['PayStage'][$stage]['name']) { + case (stristr($facility['PayStage'][$stage]['name'], '試車')): + if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['tryrun_end_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '完工')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '尾款')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '交車')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '驗收')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '安裝')): + if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['install_end_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): + if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_arrival_date'])); + } elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date'])); + } + break; + default: + break; + }; + + case "B": + + break; + case "C": + switch ($facility['PayStage'][$stage]['name']) { + case (stristr($facility['PayStage'][$stage]['name'], '試車')): + if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['tryrun_end_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '完工')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '尾款')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '交車')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '驗收')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '安裝')): + if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['install_end_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): + if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_arrival_date']))); + } elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { + $haveNumber = (int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT); + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date']))); + } + break; + default: + break; + }; + default: + break; + } + } + if (isset($allPayStages[$value[10]])) { + $allPayStages[$value[10]] = array_merge($allPayStages[$value[10]], $facility['PayStage']); + } else { + $allPayStages[$value[10]] = $facility['PayStage']; } - } - if (isset($allPayStages[$value[10]])) { - $allPayStages[$value[10]] = array_merge($allPayStages[$value[10]], $facility['PayStage']); - } else { - $allPayStages[$value[10]] = $facility['PayStage']; } } } @@ -440,9 +469,9 @@ foreach ($allPayStages as $key => &$payStage) { // [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號] foreach ($invoice_data as $invoice) { - if (isset($arrayData[$invoice['ProjectId']])) { - $arrayData[$invoice['ProjectId']]['invoice_budget'] += intval($invoice['OAmountWithTax']); - $arrayData[$invoice['ProjectId']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; + if (isset($arrayData[$invoice['FromSalSalesOrder']])) { + $arrayData[$invoice['FromSalSalesOrder']]['invoice_budget'] += intval($invoice['OAmountWithTax']); + $arrayData[$invoice['FromSalSalesOrder']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; } } @@ -457,34 +486,34 @@ foreach ($received_array as $received) { } } // $final_paystage ['type'] ['PlanPayDate'] ['PayAmount'] ['facilityno'] ['sequenceNumber'] ['name'] ['InvoiceAmount'] ['receivedAmount'] -foreach($final_paystage as $key => &$payStage){ - if(isset($arrayData[$key]['invoice_budget']) && isset($arrayData[$key]['received_budget'])){ +foreach ($final_paystage as $key => &$payStage) { + if (isset($arrayData[$key]['invoice_budget']) && isset($arrayData[$key]['received_budget'])) { $tmpInvoice = $arrayData[$key]['invoice_budget']; $tmpReceived = $arrayData[$key]['received_budget']; - for($sequence = 1; $sequence <= count($payStage); $sequence++){ + for ($sequence = 1; $sequence <= count($payStage); $sequence++) { $collect_month = collect_month(strtotime($payStage[$sequence]['PlanPayDate'])); - if($tmpInvoice >$payStage[$sequence]['PayAmount']){ + if ($tmpInvoice > $payStage[$sequence]['PayAmount']) { $payStage[$sequence]['InvoiceAmount'] = $payStage[$sequence]['PayAmount']; $tmpInvoice -= $payStage[$sequence]['PayAmount']; - }else{ + } else { $payStage[$sequence]['InvoiceAmount'] = $tmpInvoice; $tmpInvoice = 0; } - if($tmpReceived >$payStage[$sequence]['PayAmount']){ + if ($tmpReceived > $payStage[$sequence]['PayAmount']) { $payStage[$sequence]['receivedAmount'] = $payStage[$sequence]['PayAmount']; $tmpReceived -= $payStage[$sequence]['PayAmount']; - }else{ + } else { $payStage[$sequence]['receivedAmount'] = $tmpReceived; $tmpReceived = 0; } - if($collect_month>0){ + if ($collect_month > 0) { // $arrayData[$key]['facility'][$payStage[$sequence]['facilityno']]['receivable_budget']+=$payStage[$sequence]['PayAmount']; } - if($collect_month>0 && $payStage[$sequence]['PayAmount']>$payStage[$sequence]['receivedAmount']){ + if ($collect_month > 0 && $payStage[$sequence]['PayAmount'] > $payStage[$sequence]['receivedAmount']) { $payStage[$sequence]['collect_month'] = $collect_month; - }else{ + } else { $payStage[$sequence]['collect_month'] = 0; } } @@ -499,164 +528,71 @@ foreach($final_paystage as $key => &$payStage){ // echo "---------------------
"; // } -foreach ($arrayData as &$value) { - // if (is_iterable($value['facility'])) { - // foreach ($value['facility'] as $fakey => &$facility) { - // // foreach ($facility['PayStage'] as $index => &$payStage) { - // // // $payStage['sequenceNumber'] = $allPayStages[$value[10]][$index]['sequenceNumber']; - // // echo $index." => "; - // // print_r($payStage); - // // echo "
"; - // // } - // echo $fakey." => "; - // print_r($facility); - // echo "
"; - // } - // } - print_r($value); - echo "---------------------
"; -} -exit(); -//========================================================================================================================================================= - - -//產生excel的array +// foreach ($arrayData as &$value) { +// if (is_iterable($value['facility'])) { +// foreach ($value['facility'] as $fakey => &$facility) { +// // foreach ($facility['PayStage'] as $index => &$payStage) { +// // // $payStage['sequenceNumber'] = $allPayStages[$value[10]][$index]['sequenceNumber']; +// // echo $index." => "; +// // print_r($payStage); +// // echo "
"; +// // } +// echo $fakey." => "; +// print_r($facility); +// echo "
"; +// } +// } +// print_r($value); +// echo "---------------------
"; +// } +// foreach ($final_paystage as $key => $payStage) { +// echo $key . "
"; +// for ($sequence = 1; $sequence <= count($payStage); $sequence++) { +// print_r($payStage[$sequence]); +// echo "
"; +// } +// echo "---------------------
"; +// } +// exit(); +// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號 +// 0 合約號 1 作番號 2 部門id 3 部門名稱 4 經理名稱 5 營業員id 6 營業員名稱 7 客戶名稱 8 抬頭 9 統編 10 通訊地址 +// 11 收款階段名稱 12 應收日期 13 收款金額 14 已開金額 15 已收金額 16 催收次數 $excel_aray = array(); -$boga_array = array(); -$exclude_boga_array = array(); -$facility_array = array(); -$facility_boga_array = array(); -$facility_exclude_boga_array = array(); +$today = strtotime(date('Ymt')); foreach ($arrayData as $key => $value) { - $sum_A40001 += isset($value['A40001']) ? $value['A40001'] : 0; - $sum_A40008 += isset($value['A40008']) ? $value['A40008'] : 0; - $sum_total_budget += $value['total_budget']; - $sum_facility += $value['total_facility_num']; - $value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0; - $value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0; - $value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0; - $value['install'][3] = (isset($value['install'][3])) ? $value['install'][3] : 0; - $value['tryrun'][3] = (isset($value['tryrun'][3])) ? $value['tryrun'][3] : 0; - $value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0; - $value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0; - $value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0; - $value[9] = (isset($value[9])) ? Date('Ymd', strtotime($value[9])) : 0; - $contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); - foreach ($contractstage as $i) { - $value[$i]['max'] = (empty($value[$i]['max']) || is_null($value[$i]['max'])) ? 0 : $value[$i]['max']; - $value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min']; - $value[$i][4] = (isset($value[$i][4])) ? $value[$i][4] : 0; - $value[$i][5] = (isset($value[$i][5])) ? $value[$i][5] : 0; - $value['A40001'] = (isset($value['A40001'])) ? $value['A40001'] : 0; - $value['A40008'] = (isset($value['A40008'])) ? $value['A40008'] : 0; - }; - - if (isset($value['sign'][0]) && $value['sign'][0] == "寶佳出貨前30天") { - $boga_array[$key] = [ - $value[9], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], - number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'], - number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'], - number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'], - number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'], - number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'], - number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'], - number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'], - number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'], - number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('
', '; ', $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 催收次數 - if (isset($value['facility'])) { - foreach ($value['facility'] as $valkey => $val) { - foreach ($contractstage as $stage) { - $val[$stage][0] = (!(isset($val[$stage][0])) || is_null($val[$stage][0])) ? "-" : $val[$stage][0]; - $val[$stage][1] = (!(isset($val[$stage][1])) || is_null($val[$stage][1])) ? 0 : $val[$stage][1]; - $val[$stage][2] = (!(isset($val[$stage][2])) || is_null($val[$stage][2])) ? "-" : $val[$stage][2]; - $val[$stage][3] = (!(isset($val[$stage][3])) || is_null($val[$stage][3])) ? 0 : $val[$stage][3]; - $val[$stage][4] = (!(isset($val[$stage][4])) || is_null($val[$stage][4])) ? 0 : $val[$stage][4]; - $val[$stage][5] = (!(isset($val[$stage][5])) || is_null($val[$stage][5])) ? 0 : $val[$stage][5]; - $val[$stage][6] = (!(isset($val[$stage][6])) || is_null($val[$stage][6])) ? 0 : $val[$stage][6]; + if (isset($final_paystage[$key])) { + for ($sequence = 1; $sequence <= count($final_paystage[$key]); $sequence++) { + $keyname = $key . $final_paystage[$key][$sequence]['sequenceNumber']; + $value[4] = (isset($value[4]) && !empty($value[4])) ? $value[4] : '--'; + $value[5] = (isset($value[5]) && !empty($value[5])) ? $value[5] : '--'; + $value[6] = (isset($value[6]) && !empty($value[6])) ? $value[6] : '--'; + $value[7] = (isset($value[7]) && !empty($value[7])) ? $value[7] : '--'; + $value[8] = (isset($value[8]) && !empty($value[8])) ? $value[8] : '--'; + $value[11] = (isset($value[11]) && !empty($value[11])) ? $value[11] : '--'; + $value[12] = (isset($value[12]) && !empty($value[12])) ? date('Y/m/d', strtotime($value[12])) : '--'; + $thisPayStage = $final_paystage[$key][$sequence]; + $havetopay = ($today >= $thisPayStage['PlanPayDate']) ? "V" : "--"; + switch ($havetopay) { + case "V": + $unInvoiceAmount = $thisPayStage['PayAmount'] - $thisPayStage['InvoiceAmount']; + $unReceivedAmount = $thisPayStage['PayAmount'] - $thisPayStage['receivedAmount']; + break; + default: + break; } - $facility_array[$valkey] = [ - $value[9], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], - $val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), number_format(round($val['sign'][6])), - $val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), number_format(round($val['second'][6])), - $val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), number_format(round($val['arrive'][6])), - $val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), number_format(round($val['install'][6])), - $val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), number_format(round($val['tryrun'][6])), - $val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), number_format(round($val['check'][6])), - $val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), number_format(round($val['delivery'][6])), - $val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), number_format(round($val['final'][6])), - str_replace('
', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget'])) + $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'])) + ]; - if ($value['sign'][0] == "寶佳出貨前30天") { - $facility_boga_array[$valkey] = [ - $value[9], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], - $val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), number_format(round($val['sign'][6])), - $val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), number_format(round($val['second'][6])), - $val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), number_format(round($val['arrive'][6])), - $val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), number_format(round($val['install'][6])), - $val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), number_format(round($val['tryrun'][6])), - $val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), number_format(round($val['check'][6])), - $val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), number_format(round($val['delivery'][6])), - $val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), number_format(round($val['final'][6])), - str_replace('
', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget'])) - ]; - } else { - $facility_exclude_boga_array[$valkey] = [ - $value[9], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], - $val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), number_format(round($val['sign'][6])), - $val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), number_format(round($val['second'][6])), - $val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), number_format(round($val['arrive'][6])), - $val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), number_format(round($val['install'][6])), - $val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), number_format(round($val['tryrun'][6])), - $val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), number_format(round($val['check'][6])), - $val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), number_format(round($val['delivery'][6])), - $val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), number_format(round($val['final'][6])), - str_replace('
', '; ', $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); ?>
@@ -647,9 +619,15 @@ $total_data = json_encode($excel_aray);

合約 (汰改)統整資訊

- -
- + +
+ + +
+
+
@@ -670,8 +648,8 @@ $total_data = json_encode($excel_aray); - - + $row) { ?> + @@ -694,6 +672,21 @@ $total_data = json_encode($excel_aray); \ No newline at end of file diff --git a/wms/rib02-create.php b/wms/rib02-create.php index 5b06c718..93d74484 100644 --- a/wms/rib02-create.php +++ b/wms/rib02-create.php @@ -157,7 +157,7 @@ $materials = $conn->query($sql_Material);
- +
diff --git a/wms/rib02-edit.php b/wms/rib02-edit.php index 7892870a..8b490e75 100644 --- a/wms/rib02-edit.php +++ b/wms/rib02-edit.php @@ -96,7 +96,7 @@ $materials = $conn->query($sql_Material);
- +
From 1fd320683b14938de9877bd72adb50566b58571f Mon Sep 17 00:00:00 2001 From: 10994015 Date: Wed, 31 Jan 2024 18:03:29 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=8E=BB=E9=AB=98=E9=9B=84=E5=9B=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/contract/js/alpine.js | 2 +- wms/contract/mi/mi7.xlsx | Bin 0 -> 10028 bytes wms/mkt/assets/js/alpinejs/cdn.min.js | 5 + wms/mkt/assets/js/pricereviewAlpine.js | 7 + wms/mkt/conn.php | 10 +- wms/mkt/css/pricereview.css | 90 +++++ wms/mkt/css/pricereview.css.map | 1 + wms/mkt/css/pricereview.scss | 98 +++++ wms/mkt/pricereview-check.php | 1 + wms/mkt/pricereview-index.php | 12 +- wms/mkt/pricereviewCreate.php | 516 +++++++++++++++++++++++++ wms/mkt/pricereview_mi-api.php | 5 + wms/schedule-index.php | 44 ++- 13 files changed, 756 insertions(+), 35 deletions(-) create mode 100644 wms/contract/mi/mi7.xlsx create mode 100644 wms/mkt/assets/js/alpinejs/cdn.min.js create mode 100644 wms/mkt/assets/js/pricereviewAlpine.js create mode 100644 wms/mkt/css/pricereview.css create mode 100644 wms/mkt/css/pricereview.css.map create mode 100644 wms/mkt/css/pricereview.scss create mode 100644 wms/mkt/pricereviewCreate.php diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index 35f81f58..0f8b39d2 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -948,7 +948,7 @@ const contractInput = () => { }, cities: [], data: { - contractno: 'B23100060', + contractno: 'B24010030', total_price: '', //合約總價 vat: '', //統一編號 mtype: 'A', //維修型態 diff --git a/wms/contract/mi/mi7.xlsx b/wms/contract/mi/mi7.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..efb0213a354f75eb133867dcac053450594abe8c GIT binary patch literal 10028 zcmeHtg-O?O4g*}=ur{-=*m#(S1W>AbD#9gCG)1s zS6}wlXu-9RM;+8Va|cFwSaZ!dAEPGDq@)P#Z+#D-^%qMT#0e;Q(HDF!t$-VmU{`Xr z5l2am-v5k4%L>dB+~!^&0r_6n#&MV^k6#^VO)c(?i)9GSSjl257I~*jv?;~UsIO^( z*59WnLBKeI0z|j+pGl!9k$PBt`%QQ)D=@aeRPeE^S2OKG2ky2Xg7WYHZrn34b@yku z2aS7j)x!;ha1*+ioFqXAHxmadG3~t`im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6Pn`)Tm34hA16ux9h_xcMbSJ^I5CjVYfPd9OLwo!GDIsjh{yg5r zwb|lx{H!K-^q+U92Qq;?^m9NH2;s7FUX)E$5h2sHd)rJa+V%FLt6028+#0JKDT|up ziYuKqW_P29c4ozF=OxVi&t{PgA})(TNS^qXyLE~6vrR%?bdk@#TG_W5(_yD{<@??} zD^Uwi=`~`TY2TFJ3ttuQw|1Qo&#c(fwh*@r;8oNmN$VzULjP7OrF`7P!cKdD<`Z?Q zEl3(U>M%NbpElKY;(h7r6pmRuxl5eEB`TQjYp00L$EndYOXe)EB-Q0?#p%{JCYCI( zq+Y}Q)xNL05iVJ^uP3lkdMmjWKE3ieIV(RWNG*2%^~?DNMq%-8iUK@xT8vEMB0I8p zYF7^Rv2&5;+pEis^XWtRO5v$c`#JuoeFY&(QeIx0JuGQ#LM1ewqzB({2GQ|u5!{85 zD2SyO7{b>e>fMHxzWWjPPpWZm0z!;WhOU$^>22EyfWp=%)gPw>WVOEIMw5vUPH?e5 zZCEmCKxpZ@%GtEbX}RCO=sUeJdfv=@=s&Xi&-GvS z8L24zox$I?J^Y98$2AWIkiTq#_?__gR`4&vsmfrxm{#M3DSs@GHsqo%Ht*=NBn2 z`5&ae2Ry%X_&sL$#o-aGVFX*tzeNzgQ~%v5|Dpu|kYO>|KV0{var Ze=!1,Qe=!1,H=[],et=-1;function zt(e){En(e)}function En(e){H.includes(e)||H.push(e),vn()}function we(e){let t=H.indexOf(e);t!==-1&&t>et&&H.splice(t,1)}function vn(){!Qe&&!Ze&&(Ze=!0,queueMicrotask(Sn))}function Sn(){Ze=!1,Qe=!0;for(let e=0;ee.effect(t,{scheduler:r=>{tt?zt(r):r()}}),rt=e.raw}function nt(e){I=e}function qt(e){let t=()=>{};return[n=>{let i=I(n);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),L(i))},i},()=>{t()}]}function q(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}function O(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>O(i,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)O(n,t,!1),n=n.nextElementSibling}function v(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var Ut=!1;function Wt(){Ut&&v("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),Ut=!0,document.body||v("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's ` + +
+
+
合約號
" . $row[3]; ?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
有望客戶基本資料
卷號客戶名稱負責人客戶來源
地址案件名稱統編/身份證業主方聯係人
市話/手機營業員台數預定成交日
有望客戶狀態汰改
+ + + + + + + + + + + + +
洽商進度
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
電梯規格訊息
序號規格人乘/載重停數開門方式速度(m/min)數量單價
+
+
+
+
整機單價
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
電梯人乘/載重停數速度(m/min)開門方式規格單價數量複價售價
+ + + + + + + + + + + + + + +
小計
+
+
+
+
Option加價
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
選配規格單價數量複價備註所屬電梯功能
MAE100-6*7-CO45 +
+ + +
+
小計
+
+
+
+
除外項目
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
詢價單號名稱單價數量複價所屬電梯功能
MAE100-6*7-CO45 +
+ + +
+
小計
+
+
+
+
保固延長
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
電梯人乘/載重停數速度單價數量(月)複價備註所屬電梯功能
+ + + + + + + + MAE100-6*7-CO45 +
+ + +
+
小計
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
付款辦法款別比例(%)金額票期
材料1.訂金 + +
2.二次款 + +
3.貨到工地款 + +
4.其他 + +
安裝5.安裝完畢款 + +
6.驗收款 + +
7.其他 + +
合計
備註 + +
+
+
+
+ \ No newline at end of file diff --git a/wms/mkt/pricereview_mi-api.php b/wms/mkt/pricereview_mi-api.php index 3784957b..db7221fa 100644 --- a/wms/mkt/pricereview_mi-api.php +++ b/wms/mkt/pricereview_mi-api.php @@ -106,6 +106,7 @@ try { $opt_elev_arr[$row[0]]["item_qty"] = $row[3]; $tmp_arr = explode(",", $row[4]); $opt_elev_arr[$row[0]]["elev_no"] = $tmp_arr; + if (!empty($opt_elev_arr[$row[0]]["elev_no"][0])) { foreach ($tmp_arr as $v) { $elev_arr[$v]["option"][] = $row[0]; @@ -125,6 +126,7 @@ try { } */ } + mysqli_free_result($res); $opt_nosel_id_arr = array_diff(array_keys($opt_elev_arr), $opt_sel_id_arr); @@ -337,6 +339,7 @@ try { AND option_mi.open_kind = '" . $v["item_op"] . "'"; $res_om = mysqli_query($link, $sql4); + if ($row_om = mysqli_fetch_assoc($res_om)) { $row_om['price'] = (int)ceil($row_om['price']); $plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"]) * $row_om["base_floor_plus"] : 0; @@ -488,6 +491,8 @@ try { } } // $rarr["content"][] = $exceptArr; + print_r($rarr["content"]); + exit; foreach($rarr["content"] as $idx=>&$item){ $newTotal = 0; $item[16] = []; diff --git a/wms/schedule-index.php b/wms/schedule-index.php index d4cb5a0c..0aec06c1 100644 --- a/wms/schedule-index.php +++ b/wms/schedule-index.php @@ -24,7 +24,7 @@ $data = array(); // sql語法存在變數中 $page_close = 0; $sql_cmd2 = ""; -$sql_cmd = sql_myself($user_id, "repairedid"); +$sql_cmd = sql_myself($user_id, "repairerid"); if ($user_department_id == "501" || $user_department_id == "322" || $user_id == "M0012" || $user_id == "M0105") $sql_cmd = ""; if (in_array($user_department_id . $user_role_id, $dr_arr)) $sql_cmd = ""; //if (empty($sql_cmd)) $sql_cmd = "where "; @@ -177,17 +177,17 @@ if ($data) : 保養人員姓名 應保養日期 實際保養日期 - 保養項目編號 - 保養項目內容 + 保養結果 - 上傳照片 + 保養照片/保養品質 說明 - 客戶評價登入帳號 + 客戶姓名 - 評價/保養品質 - 評價/服務態度 - 內容 - 簽名檔 + + 建檔人 建檔時間 @@ -208,16 +208,22 @@ if ($data) : - - - - 瀏覽"; + + + + 查看明細 + + + 瀏覽 + 瀏覽"; } ?> - + - + + From ea503fbee65cc2bb5ce9442e618db9c6878a09cb Mon Sep 17 00:00:00 2001 From: Ellin Date: Thu, 1 Feb 2024 17:47:21 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A7=A3=E6=B1=BA=E8=B2=BB=E7=94=A8?= =?UTF-8?q?=E5=A0=B1=E9=8A=B7=E5=96=AEbug;=20=E6=96=B0=E5=A2=9E=E6=B1=B0?= =?UTF-8?q?=E6=94=B9=E6=87=89=E6=94=B6=E5=B8=B3=E6=AC=BEing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ve-submit.php => T8-purReceive-submit.php} | 176 ++-- ...hase-submit.php => T8-purchase-submit.php} | 176 ++-- wms/T8_Authorization.php | 8 +- wms/T8_Authorization_from_bpm.php | 6 +- wms/WriteOff.xlsx | Bin 8774 -> 8779 bytes wms/account-receivable-renovate-index-ing.php | 773 ++++++++++++++++++ wms/account-receivable-renovate-index.php | 11 +- wms/rib01-check.php | 3 +- wms/rib01-edit.php | 22 +- wms/rib01-index.php | 150 ++-- wms/rib02-edit.php | 107 ++- wms/rib02-submit.php | 18 +- 12 files changed, 1122 insertions(+), 328 deletions(-) rename wms/{rib02-purReceive-submit.php => T8-purReceive-submit.php} (96%) rename wms/{rib02-purchase-submit.php => T8-purchase-submit.php} (97%) create mode 100644 wms/account-receivable-renovate-index-ing.php diff --git a/wms/rib02-purReceive-submit.php b/wms/T8-purReceive-submit.php similarity index 96% rename from wms/rib02-purReceive-submit.php rename to wms/T8-purReceive-submit.php index ba87bc27..aa917201 100644 --- a/wms/rib02-purReceive-submit.php +++ b/wms/T8-purReceive-submit.php @@ -1,89 +1,89 @@ - - \ No newline at end of file diff --git a/wms/rib02-purchase-submit.php b/wms/T8-purchase-submit.php similarity index 97% rename from wms/rib02-purchase-submit.php rename to wms/T8-purchase-submit.php index 13f042fa..216b4906 100644 --- a/wms/rib02-purchase-submit.php +++ b/wms/T8-purchase-submit.php @@ -1,89 +1,89 @@ - - \ No newline at end of file diff --git a/wms/T8_Authorization.php b/wms/T8_Authorization.php index a1a756ce..dce65c91 100644 --- a/wms/T8_Authorization.php +++ b/wms/T8_Authorization.php @@ -14,12 +14,13 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); var validation = ""; // var corsurl = 'http://cors-anywhere.herokuapp.com/'; // var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; - var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth' + // var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth' headerParam = { UserId: 'M0000', Pwd: 'M012290493119', TimestampUTC: , - Sign: '' + Sign: '', + GroupId: 'TEST', }; obj = { type: 'get', @@ -30,7 +31,7 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); success: function(res) { validation = res.Data['CHI_Authorization']; console.log(validation); - // console.log(res); + console.log(res); // console.log() // window.parent.postMessage(validation,'http://localhost:3000'); // window.parent.postMessage(validation,'https://masada.com.tw'); @@ -40,4 +41,5 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); jQuery.ajax(obj); // return jQuery.ajax(obj); } + get_Auth(); \ No newline at end of file diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php index 3e8708b2..7c206023 100644 --- a/wms/T8_Authorization_from_bpm.php +++ b/wms/T8_Authorization_from_bpm.php @@ -24,11 +24,13 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119") // $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; + //GroupId : TEST測試區 ; MASADA正式區 $headerParam = [ "UserId: $user_id", "Pwd: $user_password", "TimestampUTC: $now", - "Sign: $sign" + "Sign: $sign", + "GroupId: TEST" ]; $ch = curl_init(); @@ -51,4 +53,4 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119") curl_close($ch); } // $data = []; -// get_Auth(); +get_Auth(); diff --git a/wms/WriteOff.xlsx b/wms/WriteOff.xlsx index 614072914604d42981872e8404de724932e0c9ac..6bb1cd8270b10a3d868964cda5509a0bb1db6346 100644 GIT binary patch delta 2825 zcmZvec{J2tAIE1bF=Qx9wlQQhmO?V3h%|O%8AM_F8RRFV3>izlLX5@ zYE=qN05csxc`g`wL^TYsBN}3CJECmn*dtP5nPcWSP)wAl!|@CtP$Wr~0|s;%(KUER zdMqRB@0@Cm=C$C}|2wFlt}69G)LD51b|On4cn+G!ipXE%YD7q$EG^K`Z;~<9YY&dO z`h11hBIg+t5x&5BzAlBZSVJbv7!mKPod|Q$7i@{U6T*Is2`c>+?;({#LBE#E80)E@ z7VUHJ(u+n~NW6P!#&r?-NFLA>bjX$tzh{aupslLjjFg55Fvm%0IktN!q{pJFFvZJ~ z3D>72cr19%otV|SN^C+-C3iMjpf?9pmUP ztaDJpB;QZ@3CjyOESj&};1!y+!;#+YWPRp+TgPHWMF1=qta>dR79PY; zKG7^7HYYKZAiJCH#8#ms=KE!vQ`3Z}C05i(>bp7kdt_k$09Y0W@@?QqqcPm8@(4^8 zkV{VlZU)zvk6BxtV)`<|@b(l{ccV3T2u>gHdmy!@O4}awh~y}=#I^fBJu~^9Zto&b z%&M6oI%oNWu2lkMK!U6RzBZro>x~1O&KAO0!O=I-5vsuG>^5dl*6KC9RAydSy0}(a zcg?y+O3R@d{nf2*0B`!Ur1LSVaKa!Rmx5d9{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WUcFvhdc=- za@a6tH-k&BUs6jge_UM;&$3BG3r8zck@8-!>lltl`P3?23vOSVT&I(H0as{j{7RY5 zZ&*(o-N#vsNjaz)D55a<{HfJSBe~qdVFbIDLwQp1xXsZfRo5YpN>;I!=oNQZ-oesD zn-+;MS&7Nm3PdUnJm<+b!qGbdQK%b+94nt8ta@sSReTu-o=KOKe5vR9NetqaLE$48 zMboFSgf!WkU?={#A+92Ga1RxxF#K}5k#94sAunj!H8 zy4wGKE9(IeUoPH>Ezj57ez3{oE*Mr)n{mio)4Zop0`Ii^z;A0t!TlV=-OI08V8A&bR2dZ{wV(;HPNh0$(O zjbJ%+iQ=EzW=e#QTs@56;nko}7MbiS>6mt>p!CmGmwKdBP?jon>wl z3CtUu8XuAkg%3A>rw#kmCrwOL+~k}1@Thge;~mx^0Vrn|_R^dyD^k-oo8eEzxMknZ=S!9~TWBmp0^{d*1$-?;)OF8Zt)jN< z_4Mx_GX1+R?-0r)HviX+gaXOXV*mp6j=>oSJq98Wb_}yXo!=Ue?lCxm^#1S1R|@*= zngxk6JtZ(e;>SvHuqcxmK^rUy`loIsXgX!7hXV diff --git a/wms/account-receivable-renovate-index-ing.php b/wms/account-receivable-renovate-index-ing.php new file mode 100644 index 00000000..dc2ba4ae --- /dev/null +++ b/wms/account-receivable-renovate-index-ing.php @@ -0,0 +1,773 @@ +0 +ORDER BY InvoiceTime ASC"; + +// 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"; + + +// 期初收款資訊 +$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']); + $str_numbers = "('" . implode("','", $contractNumbers) . "')"; +} +//作番大日程 +$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='B' +)AS tmp2 +left join ( +SELECT DISTINCT + department_id, + name +FROM department + +) AS d +ON d.department_id = tmp2.department_id"; + +//T8 銷售訂單 階段收款計畫 +$sql_contract = "SELECT a.BillNo,s.BillDate, a.RowNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, s.DeptId, s.DeptName, +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 "; +} + + +// 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 "; +} +$contract = $conn->query($sql_contract); +$contract_data = array(); +// 將T8合約收款階段資料依據款別分類放進arraData裡 +foreach ($contract as $cont) { + $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']; + $RowNo = $cont['RowNo']; + $salesId = $cont['PersonId']; + + //['type'] A:比照新梯、B:純分期、C:其他 + //['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單據日期 10 合約號 + $arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + $arrayData[$BillNo][0] = $cont['DeptId']; + $arrayData[$BillNo][1] = $cont['DeptName']; + $arrayData[$BillNo][3] = $salesId; + $arrayData[$BillNo][5] = $partnerName; + $arrayData[$BillNo][6] = $EnterpriseName; + $arrayData[$BillNo][7] = $TaxNo; + $arrayData[$BillNo][8] = $ContactAddress; + $arrayData[$BillNo][9] = $BillDate; + $arrayData[$BillNo][10] = $BillNo; + $arrayData[$BillNo]['total_budget'] = 0; + $arrayData[$BillNo]['invoice'] = array(); + $arrayData[$BillNo]['received_budget'] = 0; + $arrayData[$BillNo]['invoice_budget'] = 0; + $arrayData[$BillNo]['A40002'] = $arrayData[$BillNo]['A40009'] = $arrayData[$BillNo]['A40010'] = 0; + $arrayData[$BillNo]['total_facility_num'] = 0; + } + $arrayData[$BillNo]['PayStage'][$RowNo]['type'] = 0; + $arrayData[$BillNo]['PayStage'][$RowNo]['name'] = $PayStage; + $arrayData[$BillNo]['PayStage'][$RowNo]['PlanPayDate'] = $PlanPayDate; + $arrayData[$BillNo]['PayStage'][$RowNo]['PayAmount'] = $PayAmount; + // 判斷type + $wipStage = ['簽約', '訂金', '貨抵工地', '完工', '試車', '安裝', '驗收', '完工', '交車', '尾款', '合約']; + foreach ($wipStage as $wipstage) { + if (strpos($PayStage, $wipstage) !== false) { + $arrayData[$BillNo]['PayStage'][$RowNo]['type'] = "A"; + } + } + $haveNumber = (int) filter_var(str_replace('-', '', $PayStage), FILTER_SANITIZE_NUMBER_INT); + if ($haveNumber > 0 && $arrayData[$BillNo]['PayStage'][$RowNo]['type'] === 0) { + $arrayData[$BillNo]['PayStage'][$RowNo]['type'] = "B"; + } elseif ($haveNumber > 0 && $arrayData[$BillNo]['PayStage'][$RowNo]['type'] == 'A') { + $arrayData[$BillNo]['PayStage'][$RowNo]['type'] = "C"; + } +} +$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); + +// 查WMS 契約員主管 +$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A +LEFT JOIN account AS B ON A.manager = B.accountid "; +$managers = mysqli_query($link, $sql_manager); + +$find_manager = array(); +foreach ($managers as $manager) { + $find_manager[$manager['accountid']] = $manager; +} +// 將T8銷售訂單明細 每個作番金額存入arrayData +$contract_budget = array(); +foreach ($contract_budget_data as $cont) { + $BillNo = $cont['BillNo']; + if (isset($arrayData[$BillNo])) { + $salesid = $arrayData[$BillNo][3]; + if (isset($find_manager[$salesid])) { + $arrayData[$BillNo][2] = $find_manager[$salesid]['manager_name']; + $arrayData[$BillNo][4] = $find_manager[$salesid]['name']; + $arrayData[$BillNo][11] = $find_manager[$salesid]['manager']; + } + $arrayData[$BillNo]['total_budget'] += $cont['OAmountWithTax']; + $sum_total_budget += $cont['OAmountWithTax']; + $arrayData[$BillNo][$cont['MaterialId']] += $cont['OAmountWithTax']; + switch ($cont['MaterialId']) { + case "A40002": + $sum_A40002 += $cont['OAmountWithTax']; + break; + case "A40009": + $sum_A40009 += $cont['OAmountWithTax']; + break; + case "A40010": + $sum_A40010 += $cont['OAmountWithTax']; + break; + } + if (isset($arrayData[$BillNo]['facility'][$cont['CU_MaterialId']])) { + $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['total_budget'] += $cont['OAmountWithTax']; + $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] += $cont['OAmountWithTax']; + } else { + $sum_facility += 1; + $arrayData[$BillNo]['total_facility_num'] += 1; + $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['total_budget'] = $cont['OAmountWithTax']; + $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['A40002'] = $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['A40009'] = $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']]['A40010'] = 0; + $arrayData[$BillNo]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] = $cont['OAmountWithTax']; + } + } + 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['MaterialId']])) { + $contract_budget[$cont['BillNo']][$cont['MaterialId']] += $cont['OAmountWithTax']; + } else { + $contract_budget[$cont['BillNo']][$cont['MaterialId']] = $cont['OAmountWithTax']; + } + + if (isset($contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']])) { + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['total'] += $cont['OAmountWithTax']; + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] += $cont['OAmountWithTax']; + } else { + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['total'] = $cont['OAmountWithTax']; + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['A40002'] = 0; + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['A40009'] = 0; + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']]['A40010'] = 0; + $contract_budget[$cont['BillNo']]['facility'][$cont['CU_MaterialId']][$cont['MaterialId']] = $cont['OAmountWithTax']; + }; +} + +/*計算作番佔合約的金額比例 +@param $facility_no string => 作番號 +@param $contract_budget_billno array => $contract_budget[合約號] +return float */ +function get_contract_ratio($facility_no, $contract_budget_billno) +{ + $ratio = 0; + if (isset($contract_budget_billno['facility'][$facility_no])) { + if (empty($contract_budget_billno['total'])) { + } else { + + $ratio += $contract_budget_billno['facility'][$facility_no]['total'] / $contract_budget_billno['total']; + } + } + return $ratio; +} + +/* 比較應收日期 +@param $a array +@param $b array +return int */ +function comparePlanPayDate($a, $b) +{ + return strtotime($a['PlanPayDate']) - strtotime($b['PlanPayDate']); +} + +//取作番大日程作番與時程 進arrayData +// real_contract_arrival_date 預計出貨日 +// real_arrival_date 實際出貨日 +$today = strtotime(date('Ymd')); +$wipwhole_array = mysqli_query($link, $sql); +$wipwhole_status = array(); +foreach ($wipwhole_array as $wip) { + //[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 + if (isset($arrayData[$wip['contractno']])) { + // 整理合約資料 + // $arrayData[$wip['contractno']][0] = $wip['department_id'];; + // $arrayData[$wip['contractno']][1] = $wip['depart_name']; + // $arrayData[$wip['contractno']][2] = $wip['manager_name']; + // $arrayData[$wip['contractno']][3] = $wip['salesid']; + // $arrayData[$wip['contractno']][4] = $wip['name']; + $arrayData[$wip['contractno']][10] = $wip['contractno']; + $arrayData[$wip['contractno']]['A40002'] = (isset($contract_budget[$wip['contractno']]['A40002']) && !is_null($contract_budget[$wip['contractno']]['A40002'])) ? $contract_budget[$wip['contractno']]['A40002'] : 0; + $arrayData[$wip['contractno']]['A40009'] = (isset($contract_budget[$wip['contractno']]['A40009']) && !is_null($contract_budget[$wip['contractno']]['A40009'])) ? $contract_budget[$wip['contractno']]['A40009'] : 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']]['A40009'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40009']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40009'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40009'] : 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; + } + $wipwhole_status[$wip['facilityno']] = $wip; +} + +// 整理arrayData[合約]['PayStage']進 (新增) arrayData[合約]['facility'][作番號][PayStage] +$sign_array = ['訂金', '簽約', '合約']; +// 將所有facility的paystage放入一個array以便計算順序 +$allPayStages = []; +foreach ($arrayData as &$value) { + if (isset($value['facility']) && is_iterable($value['facility'])) { + foreach ($value['facility'] as $fakey => &$facility) { + if (isset($contract_budget[$value[10]])) { + $ratio = get_contract_ratio($fakey, $contract_budget[$value[10]]); + for ($stage = 1; $stage < (count($value['PayStage']) + 1); $stage++) { + $facility['PayStage'][$stage] = $value['PayStage'][$stage]; + $facility['PayStage'][$stage]['facilityno'] = $fakey; + //算每個作番的金額 + $facility['PayStage'][$stage]['PayAmount'] = $value['PayStage'][$stage]['PayAmount'] * $ratio; + //算每個作番每個收款階段的收款時間 + switch ($facility['PayStage'][$stage]['type']) { + case "A": + switch ($facility['PayStage'][$stage]['name']) { + case (stristr($facility['PayStage'][$stage]['name'], '試車')): + if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['tryrun_end_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '完工')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '尾款')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '交車')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '驗收')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['delivery_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '安裝')): + if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['install_end_date'])); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): + if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_arrival_date'])); + } elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date'])); + } + break; + default: + break; + }; + + case "B": + + break; + case "C": + switch ($facility['PayStage'][$stage]['name']) { + case (stristr($facility['PayStage'][$stage]['name'], '試車')): + if (isset($wipwhole_status[$fakey]['tryrun_end_date']) && $wipwhole_status[$fakey]['tryrun_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['tryrun_end_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['tryrun_end_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '完工')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '尾款')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '交車')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '驗收')): + if (isset($wipwhole_status[$fakey]['delivery_date']) && $wipwhole_status[$fakey]['delivery_date'] !== NULL && !empty($wipwhole_status[$fakey]['delivery_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['delivery_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '安裝')): + if (isset($wipwhole_status[$fakey]['install_end_date']) && $wipwhole_status[$fakey]['install_end_date'] !== NULL && !empty($wipwhole_status[$fakey]['install_end_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['install_end_date']))); + } + break; + case (stristr($facility['PayStage'][$stage]['name'], '貨抵工地')): + if (isset($wipwhole_status[$fakey]['real_arrival_date']) && $wipwhole_status[$fakey]['real_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_arrival_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_arrival_date']))); + } elseif (isset($wipwhole_status[$fakey]['real_contract_arrival_date']) && $wipwhole_status[$fakey]['real_contract_arrival_date'] !== NULL && !empty($wipwhole_status[$fakey]['real_contract_arrival_date'])) { + $haveNumber = ((int) filter_var(str_replace('-', '', $facility['PayStage'][$stage]['name']), FILTER_SANITIZE_NUMBER_INT)) - 1; + $facility['PayStage'][$stage]['PlanPayDate'] = date("Ymd", strtotime("+ $haveNumber months", strtotime($wipwhole_status[$fakey]['real_contract_arrival_date']))); + } + break; + default: + break; + }; + default: + break; + } + } + if (isset($allPayStages[$value[10]])) { + $allPayStages[$value[10]] = array_merge($allPayStages[$value[10]], $facility['PayStage']); + } else { + $allPayStages[$value[10]] = $facility['PayStage']; + } + } + } + } +} +foreach ($allPayStages as $paykey => $pay) { + uasort($allPayStages[$paykey], 'comparePlanPayDate'); +} + +foreach ($allPayStages as &$payStage) { + $sequenceNumber = 1; + foreach ($payStage as $tk => &$pstage) { + $pstage['sequenceNumber'] = $sequenceNumber; + $sequenceNumber += 1; + } +} +// 整理好的收款階段 +$final_paystage = array(); +foreach ($allPayStages as $key => &$payStage) { + if (is_iterable($payStage)) { + foreach ($payStage as $key2 => $pstage) { + $final_paystage[$key][$pstage['sequenceNumber']] = $pstage; + } + } +} + +// [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']]; + } +} + +// 把核銷單的內容補到發票資料中 +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']); + } + } +} +// $final_paystage ['type'] ['PlanPayDate'] ['PayAmount'] ['facilityno'] ['sequenceNumber'] ['name'] ['InvoiceAmount'] ['receivedAmount'] +foreach ($final_paystage as $key => &$payStage) { + if (isset($arrayData[$key]['invoice_budget']) && isset($arrayData[$key]['received_budget'])) { + $tmpInvoice = $arrayData[$key]['invoice_budget']; + $tmpReceived = $arrayData[$key]['received_budget']; + for ($sequence = 1; $sequence <= count($payStage); $sequence++) { + $collect_month = collect_month(strtotime($payStage[$sequence]['PlanPayDate'])); + if ($tmpInvoice > $payStage[$sequence]['PayAmount']) { + $payStage[$sequence]['InvoiceAmount'] = $payStage[$sequence]['PayAmount']; + $tmpInvoice -= $payStage[$sequence]['PayAmount']; + } else { + $payStage[$sequence]['InvoiceAmount'] = $tmpInvoice; + $tmpInvoice = 0; + } + + if ($tmpReceived > $payStage[$sequence]['PayAmount']) { + + $payStage[$sequence]['receivedAmount'] = $payStage[$sequence]['PayAmount']; + $tmpReceived -= $payStage[$sequence]['PayAmount']; + } else { + $payStage[$sequence]['receivedAmount'] = $tmpReceived; + $tmpReceived = 0; + } + if ($collect_month > 0) { + // $arrayData[$key]['facility'][$payStage[$sequence]['facilityno']]['receivable_budget']+=$payStage[$sequence]['PayAmount']; + } + if ($collect_month > 0 && $payStage[$sequence]['PayAmount'] > $payStage[$sequence]['receivedAmount']) { + $payStage[$sequence]['collect_month'] = $collect_month; + } else { + $payStage[$sequence]['collect_month'] = 0; + } + } + } +} + +// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 9 T8單據日期 10 合約號 +// 0 合約號 1 作番號 2 部門id 3 部門名稱 4 經理名稱 5 營業員id 6 營業員名稱 7 客戶名稱 8 抬頭 9 統編 10 通訊地址 +// 11 收款階段名稱 12 應收日期 13 收款金額 14 已開金額 15 已收金額 16 催收次數 +$excel_aray = array(); +$today = strtotime(date('Ymt')); +foreach ($arrayData as $key => $value) { + if (isset($final_paystage[$key])) { + for ($sequence = 1; $sequence <= count($final_paystage[$key]); $sequence++) { + $value[4] = (isset($value[4]) && !empty($value[4])) ? $value[4] : '--'; + $value[5] = (isset($value[5]) && !empty($value[5])) ? $value[5] : '--'; + $value[6] = (isset($value[6]) && !empty($value[6])) ? $value[6] : '--'; + $value[7] = (isset($value[7]) && !empty($value[7])) ? $value[7] : '--'; + $value[8] = (isset($value[8]) && !empty($value[8])) ? $value[8] : '--'; + $value[11] = (isset($value[11]) && !empty($value[11])) ? $value[11] : '--'; + $value[12] = (isset($value[12]) && !empty($value[12])) ? date('Y/m/d', strtotime($value[12])) : '--'; + $thisPayStage = $final_paystage[$key][$sequence]; + $keyname = $key . "/" . $final_paystage[$key][$sequence]['facilityno'] . "/" . $value[5]; + $havetopay = ($today >= strtotime($thisPayStage['PlanPayDate'])) ? "V" : "--"; + switch ($havetopay) { + case "V": + $unInvoiceAmount = $thisPayStage['PayAmount'] - $thisPayStage['InvoiceAmount']; + $unReceivedAmount = $thisPayStage['PayAmount'] - $thisPayStage['receivedAmount']; + break; + default: + $unInvoiceAmount = 0; + $unReceivedAmount = 0; + break; + } + $excel_aray[$keyname] = [ + $value[10], $thisPayStage['facilityno'], $value[0], $value[1], $value[11], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], + $thisPayStage['name'], $thisPayStage['PlanPayDate'], $havetopay, + number_format(round($thisPayStage['PayAmount'])), + number_format(round($thisPayStage['InvoiceAmount'])), number_format(round($unInvoiceAmount)), + number_format(round($thisPayStage['receivedAmount'])), number_format(round($unReceivedAmount)), + number_format(round($thisPayStage['collect_month'])) + + ]; + } + } +} +$total_data = json_encode($excel_aray); +//計算總作番數、金額、A40002、A40009、A40010金額與平均 +$average_budget = round($sum_total_budget / $sum_facility); +$average_A40002 = round($sum_A40002 / $sum_facility); +$average_A40009 = round($sum_A40009 / $sum_facility); +$average_A40010 = round($sum_A40010 / $sum_facility); + +foreach($arrayData as $key=> $data){ + echo $key."
"; + print_r($data); + echo "
-----------------------------
"; +} +exit(); +?> + + +
+
+ +
+
+
+
+

合約 (汰改)統整資訊

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + $row) { ?> + + + + + + + + + + + + + + + + + + + +
合約號作番號部門主管契約員客戶名稱收款階段應收日期是否應收應收金額已開金額未開金額已收金額催收金額催收次數
" . $row[3]; ?>" . $row[5]; ?>" . $row[7]; ?>
+
+ + \ No newline at end of file diff --git a/wms/account-receivable-renovate-index.php b/wms/account-receivable-renovate-index.php index 5b2929dd..a4f2f82e 100644 --- a/wms/account-receivable-renovate-index.php +++ b/wms/account-receivable-renovate-index.php @@ -53,16 +53,12 @@ ON a.BillNo=c.BillNo WHERE DATALENGTH(c.OrderBillNo) >0"; - -//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')))) { } else { - // $sql_received .= " AND (PersonId = '$user_id'"; $sql_opening .= " OR person_id = '$user_id'"; $sql_contractNumber .= " AND (PersonId = '$user_id'"; if (count($follower) > 0) { @@ -70,15 +66,10 @@ if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepart $column_str .= implode("','", $follower); $column_str .= "')"; $sql_contractNumber .= " OR PersonId IN $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_contract_budget .= " OR PersonId IN $column_str )ORDER BY BillNo, CU_MaterialId"; } else { - // $sql_received .= ")"; $sql_opening .= ")"; $sql_contractNumber .= ")"; - // $sql_contract_budget .= ")"; }; } @@ -626,7 +617,7 @@ include "./footer.php"; -
+
diff --git a/wms/rib01-check.php b/wms/rib01-check.php index 6ef49006..9332ec24 100644 --- a/wms/rib01-check.php +++ b/wms/rib01-check.php @@ -358,7 +358,8 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC); - + diff --git a/wms/rib01-edit.php b/wms/rib01-edit.php index e916daaf..cb02acf0 100644 --- a/wms/rib01-edit.php +++ b/wms/rib01-edit.php @@ -159,11 +159,13 @@ if ($pay_data) { @@ -187,12 +189,14 @@ if ($pay_data) { echo "disabled"; } ?>> $value) { + if (is_iterable($member)) { + foreach ($member as $key => $value) { ?> - - + + diff --git a/wms/rib01-index.php b/wms/rib01-index.php index c4dd0f49..517ec992 100644 --- a/wms/rib01-index.php +++ b/wms/rib01-index.php @@ -105,81 +105,87 @@ if ($data) : - - - - - - - - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + +

+ + +
- -

- - - - - - - - + +

+ +

+ + + - - - - - - - - - - - - - - - - - - - - -

-
diff --git a/wms/rib02-edit.php b/wms/rib02-edit.php index 8b490e75..43ba5fdd 100644 --- a/wms/rib02-edit.php +++ b/wms/rib02-edit.php @@ -17,10 +17,12 @@ $member = array(); $sql_mydept = "SELECT UserId, Username FROM capMembership"; $deptmem = $conn->query($sql_mydept); -foreach ($deptmem as $mem) { - $userid = $mem['UserId']; - $username = $mem['Username']; - $member["$userid"] = [$username]; +if (is_iterable($deptmem)) { + foreach ($deptmem as $mem) { + $userid = $mem['UserId']; + $username = $mem['Username']; + $member["$userid"] = [$username]; + } }; $sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'"; $allpeople = $conn->query($sql_dept); @@ -61,10 +63,11 @@ $rib_id = $ribsub['rib_id']; $sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id !== $rib_id"; $invoiceNo = mysqli_query($link, $sql_invoiceNo); $invoiceNo_array = array(); -foreach ($invoiceNo as $invoice) { - array_push($invoiceNo_array, $invoice['InvoiceNo']); +if (is_iterable($invoiceNo)) { + foreach ($invoiceNo as $invoice) { + array_push($invoiceNo_array, $invoice['InvoiceNo']); + } } - $BizJSON = json_encode($BusinessPartner); $InvoiceJSON = json_encode($invoiceNo_array); $sql_Project = "SELECT * FROM comProject"; @@ -105,11 +108,13 @@ $materials = $conn->query($sql_Material);
@@ -171,11 +176,13 @@ $materials = $conn->query($sql_Material); @@ -188,12 +195,14 @@ $materials = $conn->query($sql_Material); @@ -207,11 +216,13 @@ $materials = $conn->query($sql_Material); @@ -224,12 +235,14 @@ $materials = $conn->query($sql_Material); @@ -240,12 +253,14 @@ $materials = $conn->query($sql_Material); @@ -285,11 +300,13 @@ $materials = $conn->query($sql_Material); @@ -694,11 +711,13 @@ $materials = $conn->query($sql_Material); window.open('rib02-invoice.php', '新視窗的名稱', config = 'height=600, width=600'); } - function checkInvoice(){ + + function checkInvoice() { var invoiceArray = ; - if($.inArray($("#InvoiceNo").val().replace("-", ""),invoiceArray) !== -1) { + if ($.inArray($("#InvoiceNo").val().replace("-", ""), invoiceArray) !== -1) { alert("此發票已報銷過"); - $("#InvoiceNo").val('');} + $("#InvoiceNo").val(''); + } } function changeWriteOffId(SelectedDept) { diff --git a/wms/rib02-submit.php b/wms/rib02-submit.php index c561cd61..ba23422b 100644 --- a/wms/rib02-submit.php +++ b/wms/rib02-submit.php @@ -50,7 +50,7 @@ $OAmount = $CurrId == "TWD" ? round($_POST['OAmount']) : round($_POST['OAmount'] $TaxId = $_POST['TaxId']; $IsCounteract = $_POST['IsCounteract']; $InvoiceId = $_POST['InvoiceId']; -$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount']; +$VoucherCount = isset($_POST['VoucherCount']) ? $_POST['VoucherCount']:0; $VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0; $InvoiceNo = empty($_POST['InvoiceNo']) ? " " : (in_array(str_replace("-", "", $_POST['InvoiceNo']), $invoiceNo_array) ? " " : str_replace("-", "", $_POST['InvoiceNo'])); @@ -106,12 +106,11 @@ if ($submit == "add") { $SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`, `BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`, `Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`OTax`,`LTax`, - `OAmountUnWithTax`,`LAmountUnWithTax`,`LAmount`"; + `OAmountUnWithTax`,`LAmountUnWithTax`,`LAmount`,`VoucherCount`"; $SQL1 .= isset($CurrLAmount) ? ",`CurrentLAmount`" : ""; $SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`"; $SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : ""; $SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`"; - $SQL1 .= empty($VoucherCount) ? "" : ",`VoucherCount`"; $SQL1 .= isset($VoucherType) ? ",`VoucherType`" : ""; $SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`"; $SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`"; @@ -120,12 +119,11 @@ if ($submit == "add") { $SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2, '1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity, $Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$OTax,$LTax, - $OAmountUnWithTax,$LAmountUnWithTax,$LAmount"; + $OAmountUnWithTax,$LAmountUnWithTax,$LAmount,$VoucherCount"; $SQL2 .= isset($CurrLAmount) ? "," . $CurrLAmount : ""; $SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'"; $SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : ""; $SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'"; - $SQL2 .= empty($VoucherCount) ? "" : "," . $VoucherCount; $SQL2 .= isset($VoucherType) ? "," . $VoucherType : ""; $SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'"; $SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'"; @@ -134,11 +132,10 @@ if ($submit == "add") { } else { $SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`, `BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`, - `Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`"; + `Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`VoucherCount`"; $SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`"; $SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : ""; $SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`"; - $SQL1 .= empty($VoucherCount) ? "" : ",`VoucherCount`"; $SQL1 .= isset($VoucherType) ? ",`VoucherType`" : ""; $SQL1 .= empty($InvoiceNo) ? "" : ",`InvoiceNo`"; $SQL1 .= empty($comSupplierName) ? "" : ",`comSupplierName`"; @@ -146,11 +143,10 @@ if ($submit == "add") { $SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2, '1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity, - $Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo'"; + $Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$VoucherCount"; $SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'"; $SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : ""; $SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'"; - $SQL2 .= empty($VoucherCount) ? "" : "," . $VoucherCount; $SQL2 .= isset($VoucherType) ? "," . $VoucherType : ""; $SQL2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'"; $SQL2 .= empty($comSupplierName) ? "" : ",'" . $comSupplierName . "'"; @@ -177,11 +173,11 @@ if ($submit == "add") {