feat: improve bag price and packaging unit management

This commit is contained in:
taekyoungc
2026-04-08 00:21:53 +09:00
parent c2dc2fd38a
commit b5eed31b94
16 changed files with 362 additions and 160 deletions

View File

@@ -0,0 +1,37 @@
<div class="space-y-4">
<p class="text-sm text-gray-600">
<a href="<?= base_url('bag/basic-info') ?>" class="text-blue-600 hover:underline">&larr; 기본정보관리</a>
<span class="mx-2 text-gray-300">|</span>
<a href="<?= base_url('bag/prices') ?>" class="text-blue-600 hover:underline">봉투 단가</a>
</p>
<section>
<div class="flex items-center justify-between mb-2 border-b pb-1">
<h3 class="text-base font-bold text-gray-700">포장 단위</h3>
<a href="<?= base_url('bag/packaging-units/manage') ?>" class="text-blue-600 hover:underline text-sm">관리 &rarr;</a>
</div>
<table class="data-table">
<thead><tr>
<th class="w-16">번호</th><th>봉투코드</th><th>봉투명</th><th>박스당 </th><th>팩당 낱장 </th><th>1박스 낱장</th><th>적용시작</th><th>적용종료</th><th>상태</th>
</tr></thead>
<tbody>
<?php if (! empty($packagingUnits)): ?>
<?php foreach ($packagingUnits as $i => $row): ?>
<tr>
<td class="text-center"><?= $i + 1 ?></td>
<td class="text-center"><?= esc($row->pu_bag_code) ?></td>
<td><?= esc($row->pu_bag_name ?? '') ?></td>
<td class="text-right"><?= number_format((int) ($row->pu_box_per_pack ?? 0)) ?></td>
<td class="text-right"><?= number_format((int) ($row->pu_pack_per_sheet ?? 0)) ?></td>
<td class="text-right"><?= number_format((int) ($row->pu_total_per_box ?? 0)) ?></td>
<td class="text-center"><?= esc($row->pu_start_date ?? '') ?></td>
<td class="text-center"><?= ($row->pu_end_date ?? '') !== '' && $row->pu_end_date !== null ? esc((string) $row->pu_end_date) : '현재' ?></td>
<td class="text-center"><?= (int) ($row->pu_state ?? 1) === 1 ? '사용' : '만료' ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td colspan="9" class="text-center text-gray-400 py-4">등록된 포장 단위가 없습니다.</td></tr>
<?php endif; ?>
</tbody>
</table>
</section>
</div>

144
app/Views/bag/prices.php Normal file
View File

@@ -0,0 +1,144 @@
<?php
$_ph = ['printTitle' => '봉투 단가 조회', 'printExtraLines' => $printExtraLines ?? []];
if (($printLgName ?? '') !== '') {
$_ph['printLgName'] = $printLgName;
}
echo view('components/print_header', $_ph);
unset($_ph);
?>
<style>
@media print {
.no-print { display: none !important; }
}
</style>
<div class="space-y-4">
<p class="text-sm text-gray-600 no-print">
<a href="<?= base_url('bag/basic-info') ?>" class="text-blue-600 hover:underline">&larr; 기본정보관리</a>
<span class="mx-2 text-gray-300">|</span>
<a href="<?= base_url('bag/packaging-units') ?>" class="text-blue-600 hover:underline">포장 단위</a>
<span class="mx-2 text-gray-300">|</span>
<a href="<?= base_url('bag/bag-prices') ?>" class="text-blue-600 hover:underline">단가 관리(CRUD)</a>
</p>
<?php if (($lgIdx ?? null) === null): ?>
<p class="text-sm text-amber-800 bg-amber-50 border border-amber-200 rounded p-3">작업 지자체가 선택되지 않았습니다. 관리자는 지자체 선택 후 단가를 조회할 수 있습니다.</p>
<?php endif; ?>
<section class="no-print border border-gray-200 rounded-lg bg-white p-3">
<form method="post" action="<?= site_url('bag/prices') ?>" class="flex flex-wrap items-end gap-3" autocomplete="off">
<?= csrf_field() ?>
<div class="flex flex-col gap-0.5">
<label class="text-xs text-gray-500">봉투구분</label>
<select name="bag_kind_e" class="border border-gray-300 rounded px-2 py-1.5 text-sm min-w-[9rem]">
<option value="">전체</option>
<?php foreach ($bag_kind_options ?? [] as $cd): ?>
<option value="<?= esc($cd->cd_code) ?>" <?= (string) ($cd->cd_code ?? '') === (string) ($bag_kind_e ?? '') ? 'selected' : '' ?>>
<?= esc($cd->cd_name) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="flex flex-col gap-0.5">
<label class="text-xs text-gray-500">봉투코드</label>
<select name="bag_code" class="border border-gray-300 rounded px-2 py-1.5 text-sm min-w-[11rem]">
<option value="">전체</option>
<?php foreach ($bag_codes ?? [] as $cd): ?>
<option value="<?= esc($cd->cd_code) ?>" <?= (string) ($cd->cd_code ?? '') === (string) ($bag_code ?? '') ? 'selected' : '' ?>>
<?= esc($cd->cd_code) ?> — <?= esc($cd->cd_name) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="flex flex-col gap-0.5">
<label class="text-xs text-gray-500">조회 기간 (적용기간 겹침)</label>
<?php
$sp = $startParts ?? ['y' => '', 'm' => '', 'd' => ''];
$ep = $endParts ?? ['y' => '', 'm' => '', 'd' => ''];
$ymin = (int) ($dateYearMin ?? ((int) date('Y') - 12));
$ymax = (int) ($dateYearMax ?? ((int) date('Y') + 2));
?>
<div class="flex flex-wrap items-center gap-1">
<span class="text-xs text-gray-500 mr-0.5">시작</span>
<select name="start_y" class="border border-gray-300 rounded px-1.5 py-1.5 text-sm min-w-[4.5rem]" title="시작 연도">
<option value="">연도</option>
<?php for ($yy = $ymin; $yy <= $ymax; $yy++): ?>
<option value="<?= $yy ?>" <?= (string) ($sp['y'] ?? '') === (string) $yy ? 'selected' : '' ?>><?= $yy ?></option>
<?php endfor; ?>
</select>
<select name="start_m" class="border border-gray-300 rounded px-1.5 py-1.5 text-sm min-w-[3.75rem]" title="시작 월">
<option value="">월</option>
<?php for ($mi = 1; $mi <= 12; $mi++): ?>
<option value="<?= $mi ?>" <?= isset($sp['m']) && (int) $sp['m'] === $mi ? 'selected' : '' ?>><?= $mi ?>월</option>
<?php endfor; ?>
</select>
<select name="start_d" class="border border-gray-300 rounded px-1.5 py-1.5 text-sm min-w-[3.75rem]" title="시작 일">
<option value="">일</option>
<?php for ($di = 1; $di <= 31; $di++): ?>
<option value="<?= $di ?>" <?= isset($sp['d']) && (int) $sp['d'] === $di ? 'selected' : '' ?>><?= $di ?>일</option>
<?php endfor; ?>
</select>
<span class="text-sm text-gray-500 mx-0.5">~</span>
<span class="text-xs text-gray-500 mr-0.5">종료</span>
<select name="end_y" class="border border-gray-300 rounded px-1.5 py-1.5 text-sm min-w-[4.5rem]" title="종료 연도">
<option value="">연도</option>
<?php for ($yy = $ymin; $yy <= $ymax; $yy++): ?>
<option value="<?= $yy ?>" <?= (string) ($ep['y'] ?? '') === (string) $yy ? 'selected' : '' ?>><?= $yy ?></option>
<?php endfor; ?>
</select>
<select name="end_m" class="border border-gray-300 rounded px-1.5 py-1.5 text-sm min-w-[3.75rem]" title="종료 월">
<option value="">월</option>
<?php for ($mi = 1; $mi <= 12; $mi++): ?>
<option value="<?= $mi ?>" <?= isset($ep['m']) && (int) $ep['m'] === $mi ? 'selected' : '' ?>><?= $mi ?>월</option>
<?php endfor; ?>
</select>
<select name="end_d" class="border border-gray-300 rounded px-1.5 py-1.5 text-sm min-w-[3.75rem]" title="종료 일">
<option value="">일</option>
<?php for ($di = 1; $di <= 31; $di++): ?>
<option value="<?= $di ?>" <?= isset($ep['d']) && (int) $ep['d'] === $di ? 'selected' : '' ?>><?= $di ?>일</option>
<?php endfor; ?>
</select>
</div>
</div>
<div class="flex items-center gap-2 pb-0.5">
<button type="submit" class="bg-btn-search text-white px-4 py-1.5 rounded-sm text-sm">조회</button>
<a href="<?= base_url('bag/prices') ?>" class="text-sm text-gray-500 hover:underline">초기화</a>
<button type="button" onclick="window.print()" class="border border-gray-300 text-gray-700 px-3 py-1.5 rounded-sm text-sm hover:bg-gray-50">인쇄</button>
</div>
</form>
</section>
<section>
<div class="flex items-center justify-between mb-2 border-b pb-1">
<h3 class="text-base font-bold text-gray-700">봉투 단가</h3>
</div>
<div class="overflow-auto border border-gray-200">
<table class="data-table w-full">
<thead><tr>
<th class="w-16">번호</th><th>봉투코드</th><th>봉투명</th><th>발주단가</th><th>도매가</th><th>소비자가</th><th>적용시작</th><th>적용종료</th><th>상태</th>
</tr></thead>
<tbody>
<?php if (! empty($bagPrices)): ?>
<?php foreach ($bagPrices as $row): ?>
<tr>
<td class="text-center"><?= esc($row->bp_idx) ?></td>
<td class="text-center font-mono"><?= esc($row->bp_bag_code) ?></td>
<td class="text-left"><?= esc($row->bp_bag_name ?? '') ?></td>
<td class="text-right"><?= number_format((float) ($row->bp_order_price ?? 0)) ?></td>
<td class="text-right"><?= number_format((float) ($row->bp_wholesale ?? 0)) ?></td>
<td class="text-right"><?= number_format((float) ($row->bp_consumer ?? 0)) ?></td>
<td class="text-center"><?= esc($row->bp_start_date ?? '') ?></td>
<td class="text-center"><?= ($row->bp_end_date ?? '') !== '' && $row->bp_end_date !== null ? esc((string) $row->bp_end_date) : '현재' ?></td>
<td class="text-center"><?= (int) ($row->bp_state ?? 1) === 1 ? '사용' : '만료' ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td colspan="9" class="text-center text-gray-400 py-4">등록된 단가 정보가 없습니다.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
<?php if (! empty($pager)): ?>
<div class="mt-3 no-print"><?= $pager->links() ?></div>
<?php endif; ?>
</section>
</div>