diff --git a/app/Controllers/Admin/SalesReport.php b/app/Controllers/Admin/SalesReport.php index 8cb6239..518297f 100644 --- a/app/Controllers/Admin/SalesReport.php +++ b/app/Controllers/Admin/SalesReport.php @@ -77,6 +77,36 @@ class SalesReport extends BaseController } } + // 크기별(리터/금액) 조회 — 품목명에서 크기 토큰 추출(예: 10L, 1000원) + $sizeOf = static function (string $name): string { + if (preg_match('/(\d+)\s*[lL]/u', $name, $m) === 1) { + return $m[1] . 'L'; + } + if (preg_match('/([\d,]+)\s*원/u', $name, $m) === 1) { + return str_replace(',', '', $m[1]) . '원'; + } + return ''; + }; + // 현재(카테고리 필터까지 적용된) 결과에서 선택 가능한 크기 목록 구성 + $sizeOptions = []; + foreach ($filtered as $row) { + $sz = $sizeOf((string) ($row->bs_bag_name ?? '')); + if ($sz !== '') { + $sizeOptions[$sz] = true; + } + } + $sizeOptions = array_keys($sizeOptions); + usort($sizeOptions, static function (string $a, string $b): int { + $na = (int) preg_replace('/\D/', '', $a); + $nb = (int) preg_replace('/\D/', '', $b); + return $na <=> $nb; + }); + + $size = trim((string) ($this->request->getGet('size') ?? '')); + if ($size !== '') { + $filtered = array_values(array_filter($filtered, static fn ($row): bool => $sizeOf((string) ($row->bs_bag_name ?? '')) === $size)); + } + if ($mode === 'daily') { $built = $this->buildDailyLedgerPresentation($filtered, $hasBsFee); } else { @@ -169,6 +199,8 @@ class SalesReport extends BaseController 'dsIdx' => $dsIdx, 'saIdx' => $saIdx, 'cats' => $cats, + 'sizeOptions' => $sizeOptions, + 'size' => $size, 'shops' => $shops, 'agencies' => $agencies, 'lgName' => $lgName, diff --git a/app/Views/admin/sales_report/sales_ledger.php b/app/Views/admin/sales_report/sales_ledger.php index d047e00..96318be 100644 --- a/app/Views/admin/sales_report/sales_ledger.php +++ b/app/Views/admin/sales_report/sales_ledger.php @@ -115,6 +115,15 @@ $excelUrl = mgmt_url('reports/sales-ledger?' . http_build_query($exportParams)); = esc($catLabels[$ck] ?? $ck) ?> + + 크기 + +