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) {