feat: 판매대장 하단에 용량별·품목별 통계 표시

- 현재 필터(기간·판매소·대행소·카테고리·크기) 적용 결과 기준 집계
- 용량별(리터별): 크기 오름차순, 판매량·판매금액 합계
- 품목별: 봉투/음식물/폐기물 3분류, 판매량·판매금액 합계

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
taekyoungc
2026-07-06 18:39:06 +09:00
parent a61e7887ea
commit 952ca3e3e7
2 changed files with 142 additions and 0 deletions

View File

@@ -250,6 +250,80 @@ $excelUrl = mgmt_url('reports/sales-ledger?' . http_build_query($exportParams));
</table>
</div>
<p class="text-sm text-gray-700 mt-2 mb-0 no-print">판매건수(상세 행): <?= number_format((int) ($saleLineCount ?? 0)) ?>건</p>
<?php
$sizeStats = $sizeStats ?? [];
$catStats = $catStats ?? [];
$sizeTotQty = array_sum(array_map(static fn ($r) => (int) $r['qty'], $sizeStats));
$sizeTotAmt = array_sum(array_map(static fn ($r) => (int) $r['amount'], $sizeStats));
$catTotQty = array_sum(array_map(static fn ($r) => (int) $r['qty'], $catStats));
$catTotAmt = array_sum(array_map(static fn ($r) => (int) $r['amount'], $catStats));
?>
<div class="mt-4 grid grid-cols-1 lg:grid-cols-2 gap-4">
<!-- 용량별(리터별) 통계 -->
<div>
<div class="text-sm font-bold text-gray-700 mb-1">용량별(리터별) 통계</div>
<table class="w-full data-table text-sm">
<thead>
<tr class="bg-gray-50">
<th class="text-left px-2 py-1">용량</th>
<th class="text-right px-2 py-1">판매량(매)</th>
<th class="text-right px-2 py-1">판매금액(원)</th>
</tr>
</thead>
<tbody>
<?php if ($sizeStats === []): ?>
<tr><td colspan="3" class="text-center text-gray-400 py-4">데이터 없음</td></tr>
<?php else: ?>
<?php foreach ($sizeStats as $r): ?>
<tr>
<td class="text-left px-2 py-1"><?= esc($r['label']) ?></td>
<td class="text-right px-2 py-1"><?= number_format((int) $r['qty']) ?></td>
<td class="text-right px-2 py-1"><?= number_format((int) $r['amount']) ?></td>
</tr>
<?php endforeach; ?>
<tr class="bg-amber-50 font-bold">
<td class="text-left px-2 py-1">합계</td>
<td class="text-right px-2 py-1"><?= number_format((int) $sizeTotQty) ?></td>
<td class="text-right px-2 py-1"><?= number_format((int) $sizeTotAmt) ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<!-- 품목별(봉투/음식물/폐기물) 통계 -->
<div>
<div class="text-sm font-bold text-gray-700 mb-1">품목별(봉투·음식물·폐기물) 통계</div>
<table class="w-full data-table text-sm">
<thead>
<tr class="bg-gray-50">
<th class="text-left px-2 py-1">품목</th>
<th class="text-right px-2 py-1">판매량(매)</th>
<th class="text-right px-2 py-1">판매금액(원)</th>
</tr>
</thead>
<tbody>
<?php if ($catStats === []): ?>
<tr><td colspan="3" class="text-center text-gray-400 py-4">데이터 없음</td></tr>
<?php else: ?>
<?php foreach ($catStats as $r): ?>
<tr>
<td class="text-left px-2 py-1"><?= esc($r['label']) ?></td>
<td class="text-right px-2 py-1"><?= number_format((int) $r['qty']) ?></td>
<td class="text-right px-2 py-1"><?= number_format((int) $r['amount']) ?></td>
</tr>
<?php endforeach; ?>
<tr class="bg-amber-50 font-bold">
<td class="text-left px-2 py-1">합계</td>
<td class="text-right px-2 py-1"><?= number_format((int) $catTotQty) ?></td>
<td class="text-right px-2 py-1"><?= number_format((int) $catTotAmt) ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</section>
<script>