feat: 지정판매소 판매대장 크기(리터)별 품목 필터
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -115,6 +115,15 @@ $excelUrl = mgmt_url('reports/sales-ledger?' . http_build_query($exportParams));
|
||||
<?= esc($catLabels[$ck] ?? $ck) ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
<span class="inline-flex items-center gap-1 ml-2 pl-3 border-l border-gray-200">
|
||||
<span class="text-xs text-gray-600">크기</span>
|
||||
<select name="size" class="border border-gray-300 rounded px-2 py-1 text-sm">
|
||||
<option value="">전체</option>
|
||||
<?php foreach (($sizeOptions ?? []) as $sz): ?>
|
||||
<option value="<?= esc($sz, 'attr') ?>" <?= ($size ?? '') === $sz ? 'selected' : '' ?>><?= esc($sz) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user