From b8148923529c68280c36562bde41aaf535166bb8 Mon Sep 17 00:00:00 2001 From: taekyoungc Date: Tue, 14 Jul 2026 11:35:13 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A7=9E=EC=B6=A4=20=EC=A7=91=EA=B3=84?= =?UTF-8?q?=ED=91=9C=20=EC=97=91=EC=85=80=20=EB=8B=A4=EC=9A=B4=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 조회 폼에 '엑셀저장' 버튼(현재 컬럼·필터·제목·집계방식 그대로 반영) - Excel 2003 XML로 제목·기간·품목구분 머리행 + 선택 컬럼 + 합계행 출력 Co-Authored-By: Claude Opus 4.8 --- app/Controllers/Admin/SalesReport.php | 32 +++++++++++++++++++ .../admin/sales_report/custom_report.php | 4 ++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Admin/SalesReport.php b/app/Controllers/Admin/SalesReport.php index 3292f0f..5d314cd 100644 --- a/app/Controllers/Admin/SalesReport.php +++ b/app/Controllers/Admin/SalesReport.php @@ -3556,6 +3556,38 @@ class SalesReport extends BaseController } } + // 엑셀 다운로드 — 현재 컬럼·필터·제목 그대로 + if ((string) ($this->request->getGet('export') ?? '') === '1') { + $headers = array_map(static fn ($k) => self::CUSTOM_REPORT_COLUMNS[$k]['label'], $selected); + $exportRows = []; + foreach ($rows as $row) { + $line = []; + foreach ($selected as $key) { + $isNum = (self::CUSTOM_REPORT_COLUMNS[$key]['type'] ?? '') === 'num'; + $line[] = $isNum ? number_format((int) ($row[$key] ?? 0)) : (string) ($row[$key] ?? ''); + } + $exportRows[] = $line; + } + // 합계 행 + $totalLine = []; + foreach ($selected as $i => $key) { + $isNum = (self::CUSTOM_REPORT_COLUMNS[$key]['type'] ?? '') === 'num'; + if ($i === 0) { + $totalLine[] = '합계'; + } else { + $totalLine[] = $isNum ? number_format((int) ($totals[$key] ?? 0)) : ''; + } + } + $exportRows[] = $totalLine; + + $fileTitle = $title !== '' ? $title : '맞춤집계표'; + $topRows = [ + [$fileTitle], + ['조회기간: ' . $startDate . ' ~ ' . $endDate . ' / 품목구분: ' . $this->customReportCategoryLabel($category)], + ]; + export_excel_2003_xml($fileTitle . '_' . $startDate . '_' . $endDate, mb_substr($fileTitle, 0, 31), $headers, $exportRows, $topRows); + } + return $this->renderWorkPage('맞춤 집계표', 'admin/sales_report/custom_report', [ 'columnCatalog' => self::CUSTOM_REPORT_COLUMNS, 'selected' => $selected, diff --git a/app/Views/admin/sales_report/custom_report.php b/app/Views/admin/sales_report/custom_report.php index acbdf1c..a57d240 100644 --- a/app/Views/admin/sales_report/custom_report.php +++ b/app/Views/admin/sales_report/custom_report.php @@ -32,6 +32,7 @@ $nf = static fn ($n): string => number_format((int) $n);
+
@@ -60,7 +61,8 @@ $nf = static fn ($n): string => number_format((int) $n);
- + +