From 4ac711958c26f1a21dbd2100097652064332cb7a Mon Sep 17 00:00:00 2001 From: "IA2301\\IA_2301" Date: Mon, 26 Feb 2024 19:23:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A4=A7=E6=97=A5=E7=A8=8B=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=20area=5Fno=20=E5=88=A4=E6=96=B7=E5=88=86=E5=8D=80=202.?= =?UTF-8?q?=E5=AE=89=E8=A3=9D=E5=A4=A7=E6=97=A5=E7=A8=8B=20index=20?= =?UTF-8?q?=E5=B7=A5=E5=8B=98=E4=BA=BA=E5=93=A1=E6=94=B9=E6=8A=93=20wareho?= =?UTF-8?q?useid=203.=E5=A4=A7=E6=97=A5=E7=A8=8B=20submit=20=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=20post=20=E7=9A=84=E7=A8=8B=E5=BC=8F=E7=A2=BC?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .vscode/launch.json | 4 +- wms/gary.php | 2 +- wms/ship_run_chart-model.php | 238 ++++++++++++++- wms/ship_run_chart.php | 45 ++- wms/wipwhole-index-export-excel.php | 8 +- wms/wipwhole-index-function.php | 27 +- wms/wipwhole-rec-invoice-edit-fileupload.php | 18 +- wms/wipwhole-rec-invoice-edit-submit.php | 273 +++++++++--------- wms/wipwhole-rec-invoice-edit.php | 4 + wms/wipwhole-renovate-index-export-excel.php | 8 +- wms/wipwhole-renovate-index-function.php | 27 +- ...whole-renovate-rec-invoice-edit-submit.php | 253 ++++++++-------- wms/wipwhole-renovate-rec-invoice-edit.php | 10 +- wms/wipwholeinstall-index-export-excel.php | 13 +- wms/wipwholeinstall-index-function.php | 41 ++- wms/wipwholeinstall-index-table-html.php | 4 +- ...oleinstall-renovate-index-export-excel.php | 12 +- ...ipwholeinstall-renovate-index-function.php | 39 ++- ...wholeinstall-renovate-index-table-html.php | 4 +- 20 files changed, 682 insertions(+), 349 deletions(-) diff --git a/.gitignore b/.gitignore index 39bef4b0..4e1c1487 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ wms/test.php app/account_log/ wms/gary2.php wms/chinese.php +phpinfo.php diff --git a/.vscode/launch.json b/.vscode/launch.json index 9dc6b4df..22c9965b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Listen for Xdebug", "type": "php", "request": "launch", - "port": 9003 + "port": 9004 }, { "name": "Launch currently open script", @@ -37,7 +37,7 @@ ], "program": "", "cwd": "${workspaceRoot}", - "port": 9003, + "port": 9004, "serverReadyAction": { "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", "uriFormat": "http://localhost:%s", diff --git a/wms/gary.php b/wms/gary.php index c8143ea5..efabf743 100644 --- a/wms/gary.php +++ b/wms/gary.php @@ -16,7 +16,7 @@ function getUserIP() { // 获取用户的 IP 地址 $user_ip = getUserIP(); - +echo $test = "123"; // 输出用户的 IP 地址 echo "用户的 IP 地址是:$user_ip"; exit; diff --git a/wms/ship_run_chart-model.php b/wms/ship_run_chart-model.php index 167b099b..2d5f064f 100644 --- a/wms/ship_run_chart-model.php +++ b/wms/ship_run_chart-model.php @@ -1,31 +1,66 @@ $row) { + foreach ($row as $field => $value) { + if ($value === null) { + $data[$key][$field] = ''; + } + } + } + return $data; } // 出貨台數 @@ -51,7 +86,7 @@ function getShipping($type, $mtype, $year, $month) $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; $result = mysqli_query($link, $sql); $data = mysqli_fetch_all($result, MYSQLI_ASSOC); - return json_encode($data, JSON_UNESCAPED_UNICODE); + return json_encode(fixDataNull($data), JSON_UNESCAPED_UNICODE); } // 在裝台數 @@ -77,7 +112,7 @@ function getInstalling($type, $mtype, $year, $month) $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; $result = mysqli_query($link, $sql); $data = mysqli_fetch_all($result, MYSQLI_ASSOC); - return json_encode($data, JSON_UNESCAPED_UNICODE); + return json_encode(fixDataNull($data), JSON_UNESCAPED_UNICODE); } // 完工台數 @@ -99,7 +134,7 @@ function getInstalling2($type, $mtype, $year, $month) $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; $result = mysqli_query($link, $sql); $data = mysqli_fetch_all($result, MYSQLI_ASSOC); - return json_encode($data, JSON_UNESCAPED_UNICODE); + return json_encode(fixDataNull($data), JSON_UNESCAPED_UNICODE); } // QC台數 @@ -121,7 +156,7 @@ function getQCing($type, $mtype, $year, $month) $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; $result = mysqli_query($link, $sql); $data = mysqli_fetch_all($result, MYSQLI_ASSOC); - return json_encode($data, JSON_UNESCAPED_UNICODE); + return json_encode(fixDataNull($data), JSON_UNESCAPED_UNICODE); } // 移交台數 @@ -143,5 +178,180 @@ function getDeliverying($type, $mtype, $year, $month) $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; $result = mysqli_query($link, $sql); $data = mysqli_fetch_all($result, MYSQLI_ASSOC); - return json_encode($data, JSON_UNESCAPED_UNICODE); + return json_encode(fixDataNull($data), JSON_UNESCAPED_UNICODE); +} + + + + +// 出貨台數 產生excel +function getShipping_makeExcel($type, $mtype, $year, $month) +{ + global $link; + $sql = " + SELECT + * + FROM wipwholestatus + WHERE status = '1' + AND ( + real_arrival_date IS NOT NULL + AND real_arrival_date != '' + ) + "; + if (!empty($month)) { + $sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; + } else { + $sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; + } + $sql .= !empty($type) ? " AND contract_type = '$type'" : ""; + $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; + $result = mysqli_query($link, $sql); + return mysqli_fetch_all($result, MYSQLI_ASSOC); +} + +// 在裝台數 產生excel +function getInstalling_makeExcel($type, $mtype, $year, $month) +{ + global $link; + $sql = " + SELECT + * + FROM wipwholestatus + WHERE status = '1' + AND ( + tryrun_end_date = '' + OR tryrun_end_date IS NULL + ) + "; + if (!empty($month)) { + $sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; + } else { + $sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; + } + $sql .= !empty($type) ? " AND contract_type = '$type'" : ""; + $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; + $result = mysqli_query($link, $sql); + return mysqli_fetch_all($result, MYSQLI_ASSOC); +} + +// 完工台數 產生excel +function getInstalling2_makeExcel($type, $mtype, $year, $month) +{ + global $link; + $sql = " + SELECT + * + FROM wipwholestatus + WHERE status = '1' + "; + if (!empty($month)) { + $sql .= " AND tryrun_end_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; + } else { + $sql .= " AND tryrun_end_date BETWEEN '$year-01-01' AND '$year-12-31'"; + } + $sql .= !empty($type) ? " AND contract_type = '$type'" : ""; + $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; + $result = mysqli_query($link, $sql); + return mysqli_fetch_all($result, MYSQLI_ASSOC); +} + +// QC台數 產生excel +function getQCing_makeExcel($type, $mtype, $year, $month) +{ + global $link; + $sql = " + SELECT + * + FROM wipwholestatus + WHERE status = '1' + "; + if (!empty($month)) { + $sql .= " AND end_qc_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; + } else { + $sql .= " AND end_qc_date BETWEEN '$year-01-01' AND '$year-12-31'"; + } + $sql .= !empty($type) ? " AND contract_type = '$type'" : ""; + $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; + $result = mysqli_query($link, $sql); + return mysqli_fetch_all($result, MYSQLI_ASSOC); +} + +// 移交台數 產生excel +function getDeliverying_makeExcel($type, $mtype, $year, $month) +{ + + global $link; + // 建立一個新的 Spreadsheet 物件 + $sql = " + SELECT + * + FROM wipwholestatus + WHERE status = '1' + "; + if (!empty($month)) { + $sql .= " AND delivery_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; + } else { + $sql .= " AND delivery_date BETWEEN '$year-01-01' AND '$year-12-31'"; + } + $sql .= !empty($type) ? " AND contract_type = '$type'" : ""; + $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; + $result = mysqli_query($link, $sql); + return mysqli_fetch_all($result, MYSQLI_ASSOC); +} + + +function downloadExcel($data) +{ + + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $colArr = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + ]; + $colTitleArr = [ + '合約號', + '作番號', + '客戶名稱', + '預計出貨日', + '試車完工日', + 'QC合格日', + '官檢日', + '移交日', + ]; + $sheet->setTitle('出貨完工推移表'); + for ($i = 0; $i < count($colArr); $i++) + $sheet->setCellValue($colArr[$i] . '1', $colTitleArr[$i]); + + $i = 2; + foreach ($data as $row) { + $colContentArr = [ + $row['contractno'], + $row['facilityno'], + $row['custom'], + $row['real_arrival_date'], + $row['tryrun_end_date'], + $row['end_qc_date'], + $row['official_check_date'], + $row['delivery_date'] + ]; + for ($j = 0; $j < count($colContentArr); $j++) + $sheet->setCellValue($colArr[$j] . $i, $colContentArr[$j]); + $i++; + } + + // 調整欄位大小 + foreach ($sheet->getColumnIterator() as $column) { + $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); + } + + $writer = new Xlsx($spreadsheet); + $file_path = dirname(__DIR__) . '/wms/excel/' . 'gary_test.xlsx'; + try { + $writer->save($file_path); + // 回傳檔案路徑給 JavaScript + echo $file_path; + } catch (Exception $e) { + echo 'Error: ' . $e->getMessage(); + } + exit(); } diff --git a/wms/ship_run_chart.php b/wms/ship_run_chart.php index 2ed7d112..5f1b0e83 100644 --- a/wms/ship_run_chart.php +++ b/wms/ship_run_chart.php @@ -132,6 +132,11 @@ foreach ($contract_type as $c_val => $c_key) {