feat: 지정판매소 판매대장 크기(리터)별 품목 필터

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
taekyoungc
2026-06-25 14:31:29 +09:00
parent acce968f9c
commit 5b903c9aa6
2 changed files with 41 additions and 0 deletions

View File

@@ -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,