사이트·관리자 봉투 물류 기능(수불·통계·레포트·재고·발주)과 DB·메뉴·E2E를 운영 반영한다.
통계 분석(전년대비·월별·계절별), 수급계획·LOT 수불, 지정판매소·실사·메뉴 링크 등을 포함한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,27 +1,122 @@
|
||||
<div class="space-y-1">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<span></span>
|
||||
<a href="<?= base_url('bag/inventory/adjust') ?>" class="bg-btn-search text-white px-3 py-1.5 rounded-sm text-sm">재고 조정</a>
|
||||
<?= view('components/print_header', [
|
||||
'printTitle' => '재고 현황',
|
||||
'printDate' => (string) ($baseDate ?? date('Y-m-d')),
|
||||
'printExtraLines' => [
|
||||
'기준일자: ' . (string) ($baseDate ?? date('Y-m-d')),
|
||||
],
|
||||
]) ?>
|
||||
<?php
|
||||
$baseDate = (string) ($baseDate ?? date('Y-m-d'));
|
||||
$agencyIdx = (int) ($agencyIdx ?? 0);
|
||||
$rows = is_array($rows ?? null) ? $rows : [];
|
||||
$subtotals = is_array($subtotals ?? null) ? $subtotals : [];
|
||||
$grandTotals = is_array($grandTotals ?? null) ? $grandTotals : ['total' => 0, 'gugun' => 0, 'agency' => 0];
|
||||
$agencyOptions = is_array($agencyOptions ?? null) ? $agencyOptions : [];
|
||||
$subtotalByGroup = [];
|
||||
foreach ($subtotals as $subtotal) {
|
||||
$group = (string) ($subtotal['group'] ?? '');
|
||||
if ($group !== '') {
|
||||
$subtotalByGroup[$group] = $subtotal;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
|
||||
<form method="get" class="flex flex-wrap items-end justify-between gap-2">
|
||||
<div class="flex flex-wrap items-end gap-2 text-sm">
|
||||
<label class="font-bold text-gray-700">기준일자</label>
|
||||
<input type="date" name="base_date" value="<?= esc($baseDate) ?>" class="border border-gray-300 rounded px-2 py-1 min-w-[10rem]">
|
||||
|
||||
<label class="font-bold text-gray-700">대행소</label>
|
||||
<select name="agency_idx" class="border border-gray-300 rounded px-2 py-1 min-w-[12rem]">
|
||||
<option value="0">전체</option>
|
||||
<?php foreach ($agencyOptions as $agency): ?>
|
||||
<?php $idx = (int) ($agency->sa_idx ?? 0); ?>
|
||||
<option value="<?= esc((string) $idx) ?>" <?= $agencyIdx === $idx ? 'selected' : '' ?>>
|
||||
<?= esc((string) ($agency->sa_name ?? '')) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button type="submit" class="bg-btn-search text-white px-4 py-1 rounded-sm text-sm">조회</button>
|
||||
<a href="<?= base_url('bag/inventory/export?' . http_build_query(['base_date' => $baseDate, 'agency_idx' => $agencyIdx])) ?>" class="no-print border border-btn-excel-border text-btn-excel-text px-3 py-1 rounded-sm text-sm hover:bg-green-50 transition">엑셀저장</a>
|
||||
<button type="button" onclick="window.print()" class="no-print border border-btn-print-border text-gray-600 px-3 py-1 rounded-sm text-sm hover:bg-gray-50 transition">인쇄</button>
|
||||
<a href="<?= base_url('bag/inventory/inspection-select') ?>" class="no-print border border-blue-300 text-blue-700 px-3 py-1 rounded-sm text-sm hover:bg-blue-50 transition">실사 선별 조회</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="mt-2 border border-gray-300 bg-white p-2 print:p-0 print:border-0">
|
||||
<div class="overflow-auto">
|
||||
<table class="w-full data-table text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-36">품 목 구 분</th>
|
||||
<th>봉투/스티커 종류</th>
|
||||
<th class="w-32">계</th>
|
||||
<th class="w-32">시군구 재고</th>
|
||||
<th class="w-32">대행소 재고</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($rows !== []): ?>
|
||||
<?php
|
||||
$groupRowCount = [];
|
||||
foreach ($rows as $row) {
|
||||
$group = (string) ($row['group'] ?? '');
|
||||
if (! isset($groupRowCount[$group])) {
|
||||
$groupRowCount[$group] = 0;
|
||||
}
|
||||
$groupRowCount[$group]++;
|
||||
}
|
||||
$printedGroupCount = [];
|
||||
?>
|
||||
<?php foreach ($rows as $row): ?>
|
||||
<?php
|
||||
$group = (string) ($row['group'] ?? '');
|
||||
if (! isset($printedGroupCount[$group])) {
|
||||
$printedGroupCount[$group] = 0;
|
||||
}
|
||||
$printedGroupCount[$group]++;
|
||||
$isFirst = $printedGroupCount[$group] === 1;
|
||||
$isLast = $printedGroupCount[$group] === (int) ($groupRowCount[$group] ?? 0);
|
||||
?>
|
||||
<tr>
|
||||
<?php if ($isFirst): ?>
|
||||
<td class="text-center font-semibold bg-gray-50" rowspan="<?= esc((string) ($groupRowCount[$group] ?? 1)) ?>"><?= esc($group) ?></td>
|
||||
<?php endif; ?>
|
||||
<td class="pl-2"><?= esc((string) ($row['name'] ?? '')) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($row['total_qty'] ?? 0)) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($row['gugun_qty'] ?? 0)) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($row['agency_qty'] ?? 0)) ?></td>
|
||||
</tr>
|
||||
<?php if ($isLast && isset($subtotalByGroup[$group])): ?>
|
||||
<?php $s = $subtotalByGroup[$group]; ?>
|
||||
<tr class="bg-blue-50 font-semibold">
|
||||
<td class="text-center">소계</td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($s['total_qty'] ?? 0)) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($s['gugun_qty'] ?? 0)) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($s['agency_qty'] ?? 0)) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr><td colspan="5" class="text-center text-gray-400 py-4">조회 결과가 없습니다.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="bg-gray-100 font-bold">
|
||||
<td class="text-center" colspan="2">합계</td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($grandTotals['total'] ?? 0)) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($grandTotals['gugun'] ?? 0)) ?></td>
|
||||
<td class="text-right pr-2"><?= number_format((int) ($grandTotals['agency'] ?? 0)) ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table class="data-table">
|
||||
<thead><tr>
|
||||
<th class="w-16">번호</th><th>봉투코드</th><th>봉투명</th><th>현재재고(낱장)</th><th>최종갱신</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<?php if (! empty($list)): ?>
|
||||
<?php foreach ($list as $i => $row): ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $i + 1 ?></td>
|
||||
<td class="text-center"><?= esc($row->bi_bag_code ?? '') ?></td>
|
||||
<td><?= esc($row->bi_bag_name ?? '') ?></td>
|
||||
<td class="text-right"><?= number_format((int)($row->bi_qty ?? 0)) ?></td>
|
||||
<td class="text-center"><?= esc($row->bi_updated_at ?? '') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr><td colspan="5" class="text-center text-gray-400 py-4">재고 데이터가 없습니다.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="mt-2 text-xs text-gray-500">
|
||||
※ 기준일자까지 갱신된 재고를 집계합니다. 대행소 재고는 별도 재고 연계 전까지 0으로 표시됩니다.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user