diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..9dc6b4df --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,48 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9003 + }, + { + "name": "Launch currently open script", + "type": "php", + "request": "launch", + "program": "${file}", + "cwd": "${fileDirname}", + "port": 0, + "runtimeArgs": [ + "-dxdebug.start_with_request=yes" + ], + "env": { + "XDEBUG_MODE": "debug,develop", + "XDEBUG_CONFIG": "client_port=${port}" + } + }, + { + "name": "Launch Built-in web server", + "type": "php", + "request": "launch", + "runtimeArgs": [ + "-dxdebug.mode=debug", + "-dxdebug.start_with_request=yes", + "-S", + "localhost:0" + ], + "program": "", + "cwd": "${workspaceRoot}", + "port": 9003, + "serverReadyAction": { + "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + } + } + ] +} \ No newline at end of file diff --git a/wms/account-receivable-check.php b/wms/account-receivable-check.php new file mode 100644 index 00000000..727c015d --- /dev/null +++ b/wms/account-receivable-check.php @@ -0,0 +1,251 @@ + 0) { + foreach ($pay_received as $received) { + $had_received_amount += intval($received['received_amount']); + $had_invoice_amount += intval($received['invoice_amount']); + if(in_array(intval($received['status']),array(0,4,5,99))){ + $tem_status = intval(0); + }else{ + $tem_status = intval($received['status']); + } + if($status_summary < $tem_status){ + $status_summary = $tem_status; + } + } +} + +$unreceived_amount = intval($Bill[12]) - intval($had_received_amount); +$uninvoice_amount = intval($Bill[12]) - intval($had_invoice_amount); +$Bill[19] =$had_invoice_amount; +$Bill[20] =$had_received_amount; +$Bill[21] =$uninvoice_amount; +$Bill[22] =$unreceived_amount; +$Bill[23] =$status_summary; +$data = json_encode($Bill); +?> + +
+ +
+ + + +
+ +
+
+
+

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
目前應收已開發票金額未開發票金額已收金額未收金額
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
簽約款二次款貨抵工地款安裝款試車款官檢款交車款
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
發票日期發票金額發票號碼收款日期收款金額備註狀態功能
+ 進行中"; + break; + case 1: + echo "催收"; + break; + case 2: + echo "法務件 (發函)"; + break; + case 3: + echo "法務件 (訴訟)"; + break; + case 4: + echo "折讓"; + break; + case 5: + echo "壞帳"; + break; + case 99: + echo "完成"; + break; + } + ?> + + + +
+
+ \ No newline at end of file diff --git a/wms/account-receivable-index.php b/wms/account-receivable-index.php index b6d56bcf..e33f2b75 100644 --- a/wms/account-receivable-index.php +++ b/wms/account-receivable-index.php @@ -7,24 +7,58 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls; //use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; +$follower = find_follow($user_id); $arrayData = []; $receivable_array = []; +$received_array = []; //4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 //arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交 -// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態
"; +$sql_received = "SELECT * from account_received"; -// $T8_array = mysqli_fetch_all($T8_array, MYSQLI_ASSOC); - -// $sql_depid = "SELECT department_id, name from department"; -// $dept_query = mysqli_query($link, $sql_depid); -// $deptype = mysqli_fetch_all($dept_query, MYSQLI_ASSOC); - - -$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName FROM salOrderStagePay AS a +$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName, s.PersonId, +c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId -WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; +WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; +if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) { + $sql_contract .= "AND (s.PersonId = '$user_id'"; + $sql_received .= " WHERE person_id = '$user_id'"; + if (count($follower) > 0) { + $column_str = "('$user_id'" . ",'"; + $column_str .= implode("','", $follower); + $column_str .= "')"; + $sql_contract .= " OR s.PersonId IN $column_str)"; + $sql_received .= " OR person_id IN $column_str)"; + } else { + $sql_contract .= ")"; + }; +} + $contract = $conn->query($sql_contract); + +// 取收款資料 account_received +$received_data = mysqli_query($link, $sql_received); +foreach ($received_data as $received) { + if ($received['BillNo'] == 'SO20230801001') { + $BillNo = 'M230947'; + } elseif ($received['BillNo'] == 'SO20230801002') { + $BillNo = 'M231067'; + } else { + $BillNo = $received['BillNo']; + }; + if (isset($received_array[$BillNo])) { + $received_array[$BillNo][0] += $received['invoice_amount']; + $received_array[$BillNo][1] += $received['received_amount']; + $received['status'] = (intval($received['status']) < 4) ? intval($received['status']) : 0; + if ($received_array[$BillNo][2] < intval($received['status'])) { + $received_array[$BillNo][2] = intval($received['status']); + } + } else { + $received_array[$BillNo][0] = $received['invoice_amount']; + $received_array[$BillNo][1] = $received['received_amount']; + $received_array[$BillNo][2] = (intval($received['status']) < 4) ? intval($received['status']) : 0; + } +} foreach ($contract as $cont) { // print_r($cont); // echo "
"; @@ -38,6 +72,9 @@ foreach ($contract as $cont) { $PayStage = $cont['PayStage']; $PayAmount = $cont['PlanPayAmt']; $partnerName = $cont['BizPartnerName']; + $EnterpriseName = $cont['EnterpriseName']; + $TaxNo = $cont['TaxNo']; + $ContactAddress = $cont['ContactAddress']; //4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 if (isset($arrayData[$BillNo])) { if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) { @@ -60,6 +97,9 @@ foreach ($contract as $cont) { } else { $arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; $arrayData[$BillNo][3] = $partnerName; + $arrayData[$BillNo][13] = $EnterpriseName; + $arrayData[$BillNo][14] = $TaxNo; + $arrayData[$BillNo][15] = $ContactAddress; if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) { $arrayData[$BillNo][5] = $PayAmount; } elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) { @@ -124,79 +164,153 @@ ON d.department_id = tmp2.department_id"; $official_num = 0; $wipwhole_array = mysqli_query($link, $sql); foreach ($wipwhole_array as $wip) { - - $value[0] = $wip['depart_name']; $value[1] = $wip['manager_name']; $value[2] = $wip['name']; + $value[16] = isset($wip['department_id']) ? $wip['department_id'] : ''; + $value[17] = isset($wip['salesid']) ? $wip['salesid'] : ''; if ($wip['delivery_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交)
"; $total_facility_num += 1; $arrive_num += 1; $tryrun_num += 1; $official_num += 1; $delivery_num += 1; } elseif ($wip['official_check_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢)
"; $total_facility_num += 1; $arrive_num += 1; $tryrun_num += 1; $official_num += 1; } elseif ($wip['tryrun_end_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢)
"; $total_facility_num += 1; $arrive_num += 1; $tryrun_num += 1; } elseif ($wip['install_end_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢)
"; $total_facility_num += 1; $arrive_num += 1; } elseif ($wip['real_arrival_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地)
"; $total_facility_num += 1; $arrive_num += 1; } elseif ($wip['actual_tofactory_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日)
"; $total_facility_num += 1; } elseif ($wip['estimated_shipping_date'] != NULL) { - $facitities .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) , \n"; + $facitities .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港)
"; $total_facility_num += 1; } else { - $facitities .= $wip['facilityno'] . " (預計到港日待確認) , \n"; + $facitities .= $wip['facilityno'] . " (預計到港日待確認)
"; $total_facility_num += 1; } } + $receivable_budget = 0; //這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 //這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交 if ($total_facility_num > 0) { $receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) + ($value[7] + $value[8]) * ($tryrun_num / $total_facility_num) + ($value[9]) * ($official_num / $total_facility_num) + ($value[10]) * ($delivery_num / $total_facility_num); + $uninvoice_budget = $receivable_budget; + $unreceived_budget = $receivable_budget; + $received_invoice = 0; + $received_budget = 0; + if (isset($received_array[$key][0])) { + $uninvoice_budget = $receivable_budget - $received_array[$key][0]; + $received_invoice = $received_array[$key][0]; + } else { + $uninvoice_budget = $receivable_budget; + } + if (isset($received_array[$key][1])) { + $unreceived_budget = $receivable_budget - $received_array[$key][1]; + $received_budget = $received_array[$key][1]; + } else { + $unreceived_budget = $receivable_budget; + } + if (isset($received_array[$key][2])) { + $status = $received_array[$key][2]; + } else { + $status = 0; + } + } + + if (isset($key)) { + $receivable_array[$key] = [ + $key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9], + $value[10], $receivable_budget, $facitities, $value[13], $value[14], $value[15], $value[16], $value[17], $received_invoice, $received_budget, + $uninvoice_budget, $unreceived_budget, $status + ]; } - array_push($receivable_array, [$key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9], $value[10], $receivable_budget, $facitities]); - // echo $key . ";" . $value[0] . ";" . $value[1] . ";" . $value[2] . ";" . $value[3] . ";" . $value[4] . ";" . $value[5] . ";" . $value[6] . ";" . $value[7] . ";" . $value[8] . ";" . $value[9].";" . $value[10] . ";" . $receivable_budget . ";" . $total_facility_num . ";" . $arrive_num . ";". $tryrun_num . ";" .$official_num.";". $delivery_num . ";" . $facitities . "
"; + } -// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態
"; +$data = json_encode($receivable_array); +//0 合約號; 1 部門; 2 經理; 3 營業員; 4 客戶名稱; 5 簽約款; 6 二次款; 7 貨底工地款; 8 安裝款; 9 式車款; 10 官檢款; +//11 交車款; 12 目前應收; 13 作番狀態; 14 抬頭; 15 統一編號; 16 聯絡地址; 17 部門id; 18 營業員id; 19 已開發票金額; 20 已收金額; +//21 未開發票金額; 22 未收金額; 23 狀態 + ?> -
- + +
+
- - - - + + + + - - - - - - - - - + + + + + + + @@ -209,15 +323,28 @@ ON d.department_id = tmp2.department_id"; - - - - - - - - + + + + + +
合約號部門經理營業員合約號部門經理營業員 客戶名稱簽約款二次款貨抵工地款安裝款試車款官檢款交車款目前應收狀態目前應收未開發票金額未收金額作番狀態收款狀態操作
催收"; + } else { + echo "法務件"; + } + ?> +
+ \ No newline at end of file diff --git a/wms/account-receivable-received-create.php b/wms/account-receivable-received-create.php new file mode 100644 index 00000000..31537102 --- /dev/null +++ b/wms/account-receivable-received-create.php @@ -0,0 +1,124 @@ + +
+ +
+ +
+
+
+
+

+

新增收款資訊

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

+

編輯收款資訊

+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + + + +
+
+
+
+
+ +
+
+
+
+ + + + + \ No newline at end of file diff --git a/wms/account-receivable-received-submit.php b/wms/account-receivable-received-submit.php new file mode 100644 index 00000000..b9b18f0f --- /dev/null +++ b/wms/account-receivable-received-submit.php @@ -0,0 +1,96 @@ + + \ No newline at end of file diff --git a/wms/rib01-check.php b/wms/rib01-check.php index ebbda72e..2aad50ad 100644 --- a/wms/rib01-check.php +++ b/wms/rib01-check.php @@ -107,7 +107,7 @@ elseif ($state == 1 && ($user_id == "M0056" || $user_id == "M0209")) :