P2-05/06 포장 단위 관리 CRUD + 이력 + 기간별 조회
- packaging_unit, packaging_unit_history 테이블 생성 - PackagingUnitModel, PackagingUnitHistoryModel - PackagingUnit 컨트롤러 (목록/등록/수정/삭제/이력) - 박스당팩수 x 팩당낱장수 = 총낱장수 자동 계산 - 변경 시 자동 이력 기록 - E2E 테스트 3개 전체 통과 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,15 @@ $routes->group('admin', ['filter' => 'adminAuth'], static function ($routes): vo
|
||||
$routes->post('bag-prices/delete/(:num)', 'Admin\BagPrice::delete/$1');
|
||||
$routes->get('bag-prices/history/(:num)', 'Admin\BagPrice::history/$1');
|
||||
|
||||
// 포장 단위 관리 (P2-05/06)
|
||||
$routes->get('packaging-units', 'Admin\PackagingUnit::index');
|
||||
$routes->get('packaging-units/create', 'Admin\PackagingUnit::create');
|
||||
$routes->post('packaging-units/store', 'Admin\PackagingUnit::store');
|
||||
$routes->get('packaging-units/edit/(:num)', 'Admin\PackagingUnit::edit/$1');
|
||||
$routes->post('packaging-units/update/(:num)', 'Admin\PackagingUnit::update/$1');
|
||||
$routes->post('packaging-units/delete/(:num)', 'Admin\PackagingUnit::delete/$1');
|
||||
$routes->get('packaging-units/history/(:num)', 'Admin\PackagingUnit::history/$1');
|
||||
|
||||
$routes->get('designated-shops', 'Admin\DesignatedShop::index');
|
||||
$routes->get('designated-shops/create', 'Admin\DesignatedShop::create');
|
||||
$routes->post('designated-shops/store', 'Admin\DesignatedShop::store');
|
||||
|
||||
212
app/Controllers/Admin/PackagingUnit.php
Normal file
212
app/Controllers/Admin/PackagingUnit.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\PackagingUnitModel;
|
||||
use App\Models\PackagingUnitHistoryModel;
|
||||
use App\Models\CodeKindModel;
|
||||
use App\Models\CodeDetailModel;
|
||||
|
||||
class PackagingUnit extends BaseController
|
||||
{
|
||||
private PackagingUnitModel $unitModel;
|
||||
private PackagingUnitHistoryModel $historyModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->unitModel = model(PackagingUnitModel::class);
|
||||
$this->historyModel = model(PackagingUnitHistoryModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if (!$lgIdx) {
|
||||
return redirect()->to(site_url('admin'))->with('error', '지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$builder = $this->unitModel->where('pu_lg_idx', $lgIdx);
|
||||
|
||||
$startDate = $this->request->getGet('start_date');
|
||||
$endDate = $this->request->getGet('end_date');
|
||||
if ($startDate) {
|
||||
$builder->where('pu_start_date >=', $startDate);
|
||||
}
|
||||
if ($endDate) {
|
||||
$builder->groupStart()->where('pu_end_date IS NULL')->orWhere('pu_end_date <=', $endDate)->groupEnd();
|
||||
}
|
||||
|
||||
$list = $builder->orderBy('pu_bag_code', 'ASC')->orderBy('pu_start_date', 'DESC')->findAll();
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '포장 단위 관리',
|
||||
'content' => view('admin/packaging_unit/index', [
|
||||
'list' => $list, 'startDate' => $startDate, 'endDate' => $endDate,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
helper('admin');
|
||||
if (!admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('error', '지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
|
||||
$bagCodes = $kind ? model(CodeDetailModel::class)->getByKind((int) $kind->ck_idx, true) : [];
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '포장 단위 등록',
|
||||
'content' => view('admin/packaging_unit/create', ['bagCodes' => $bagCodes]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
|
||||
$rules = [
|
||||
'pu_bag_code' => 'required|max_length[50]',
|
||||
'pu_box_per_pack' => 'required|is_natural_no_zero',
|
||||
'pu_pack_per_sheet' => 'required|is_natural_no_zero',
|
||||
'pu_start_date' => 'required|valid_date[Y-m-d]',
|
||||
'pu_end_date' => 'permit_empty|valid_date[Y-m-d]',
|
||||
];
|
||||
|
||||
if (! $this->validate($rules)) {
|
||||
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$bagCode = $this->request->getPost('pu_bag_code');
|
||||
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
|
||||
$bagName = '';
|
||||
if ($kind) {
|
||||
$detail = model(CodeDetailModel::class)->where('cd_ck_idx', $kind->ck_idx)->where('cd_code', $bagCode)->first();
|
||||
$bagName = $detail ? $detail->cd_name : '';
|
||||
}
|
||||
|
||||
$boxPerPack = (int) $this->request->getPost('pu_box_per_pack');
|
||||
$packPerSheet = (int) $this->request->getPost('pu_pack_per_sheet');
|
||||
|
||||
$this->unitModel->insert([
|
||||
'pu_lg_idx' => $lgIdx,
|
||||
'pu_bag_code' => $bagCode,
|
||||
'pu_bag_name' => $bagName,
|
||||
'pu_box_per_pack' => $boxPerPack,
|
||||
'pu_pack_per_sheet' => $packPerSheet,
|
||||
'pu_total_per_box' => $boxPerPack * $packPerSheet,
|
||||
'pu_start_date' => $this->request->getPost('pu_start_date'),
|
||||
'pu_end_date' => $this->request->getPost('pu_end_date') ?: null,
|
||||
'pu_state' => 1,
|
||||
'pu_regdate' => date('Y-m-d H:i:s'),
|
||||
'pu_reg_mb_idx' => session()->get('mb_idx'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('success', '포장 단위가 등록되었습니다.');
|
||||
}
|
||||
|
||||
public function edit(int $id)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->unitModel->find($id);
|
||||
if (!$item || (int) $item->pu_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('error', '포장 단위를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
|
||||
$bagCodes = $kind ? model(CodeDetailModel::class)->getByKind((int) $kind->ck_idx, true) : [];
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '포장 단위 수정',
|
||||
'content' => view('admin/packaging_unit/edit', ['item' => $item, 'bagCodes' => $bagCodes]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(int $id)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->unitModel->find($id);
|
||||
if (!$item || (int) $item->pu_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('error', '포장 단위를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$rules = [
|
||||
'pu_box_per_pack' => 'required|is_natural_no_zero',
|
||||
'pu_pack_per_sheet' => 'required|is_natural_no_zero',
|
||||
'pu_start_date' => 'required|valid_date[Y-m-d]',
|
||||
'pu_end_date' => 'permit_empty|valid_date[Y-m-d]',
|
||||
'pu_state' => 'required|in_list[0,1]',
|
||||
];
|
||||
|
||||
if (! $this->validate($rules)) {
|
||||
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
|
||||
$trackFields = ['pu_box_per_pack', 'pu_pack_per_sheet'];
|
||||
foreach ($trackFields as $field) {
|
||||
$oldVal = (string) $item->$field;
|
||||
$newVal = (string) $this->request->getPost($field);
|
||||
if ($oldVal !== $newVal) {
|
||||
$this->historyModel->insert([
|
||||
'puh_pu_idx' => $id,
|
||||
'puh_field' => $field,
|
||||
'puh_old_value' => $oldVal,
|
||||
'puh_new_value' => $newVal,
|
||||
'puh_changed_at'=> date('Y-m-d H:i:s'),
|
||||
'puh_changed_by'=> session()->get('mb_idx'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$boxPerPack = (int) $this->request->getPost('pu_box_per_pack');
|
||||
$packPerSheet = (int) $this->request->getPost('pu_pack_per_sheet');
|
||||
|
||||
$this->unitModel->update($id, [
|
||||
'pu_box_per_pack' => $boxPerPack,
|
||||
'pu_pack_per_sheet' => $packPerSheet,
|
||||
'pu_total_per_box' => $boxPerPack * $packPerSheet,
|
||||
'pu_start_date' => $this->request->getPost('pu_start_date'),
|
||||
'pu_end_date' => $this->request->getPost('pu_end_date') ?: null,
|
||||
'pu_state' => (int) $this->request->getPost('pu_state'),
|
||||
'pu_moddate' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$db->transComplete();
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('success', '포장 단위가 수정되었습니다.');
|
||||
}
|
||||
|
||||
public function delete(int $id)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->unitModel->find($id);
|
||||
if (!$item || (int) $item->pu_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('error', '포장 단위를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$this->unitModel->delete($id);
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('success', '포장 단위가 삭제되었습니다.');
|
||||
}
|
||||
|
||||
public function history(int $puIdx)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->unitModel->find($puIdx);
|
||||
if (!$item || (int) $item->pu_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/packaging-units'))->with('error', '포장 단위를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$list = $this->historyModel->where('puh_pu_idx', $puIdx)->orderBy('puh_changed_at', 'DESC')->findAll();
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '포장 단위 변경 이력 — ' . $item->pu_bag_name,
|
||||
'content' => view('admin/packaging_unit/history', ['item' => $item, 'list' => $list]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
17
app/Models/PackagingUnitHistoryModel.php
Normal file
17
app/Models/PackagingUnitHistoryModel.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PackagingUnitHistoryModel extends Model
|
||||
{
|
||||
protected $table = 'packaging_unit_history';
|
||||
protected $primaryKey = 'puh_idx';
|
||||
protected $returnType = 'object';
|
||||
protected $useTimestamps = false;
|
||||
protected $allowedFields = [
|
||||
'puh_pu_idx', 'puh_field', 'puh_old_value', 'puh_new_value',
|
||||
'puh_changed_at', 'puh_changed_by',
|
||||
];
|
||||
}
|
||||
19
app/Models/PackagingUnitModel.php
Normal file
19
app/Models/PackagingUnitModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PackagingUnitModel extends Model
|
||||
{
|
||||
protected $table = 'packaging_unit';
|
||||
protected $primaryKey = 'pu_idx';
|
||||
protected $returnType = 'object';
|
||||
protected $useTimestamps = false;
|
||||
protected $allowedFields = [
|
||||
'pu_lg_idx', 'pu_bag_code', 'pu_bag_name',
|
||||
'pu_box_per_pack', 'pu_pack_per_sheet', 'pu_total_per_box',
|
||||
'pu_start_date', 'pu_end_date', 'pu_state',
|
||||
'pu_regdate', 'pu_moddate', 'pu_reg_mb_idx',
|
||||
];
|
||||
}
|
||||
48
app/Views/admin/packaging_unit/create.php
Normal file
48
app/Views/admin/packaging_unit/create.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
|
||||
<span class="text-sm font-bold text-gray-700">포장 단위 등록</span>
|
||||
</section>
|
||||
<div class="border border-gray-300 p-4 mt-2 bg-white max-w-3xl">
|
||||
<form action="<?= base_url('admin/packaging-units/store') ?>" method="POST" class="space-y-4">
|
||||
<?= csrf_field() ?>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">봉투 <span class="text-red-500">*</span></label>
|
||||
<select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-60" name="pu_bag_code" required>
|
||||
<option value="">선택</option>
|
||||
<?php foreach ($bagCodes as $cd): ?>
|
||||
<option value="<?= esc($cd->cd_code) ?>" <?= old('pu_bag_code') === $cd->cd_code ? 'selected' : '' ?>>
|
||||
<?= esc($cd->cd_code) ?> — <?= esc($cd->cd_name) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">박스당 팩 수 <span class="text-red-500">*</span></label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32 text-right" name="pu_box_per_pack" type="number" min="1" value="<?= esc(old('pu_box_per_pack', '1')) ?>" required/>
|
||||
<span class="text-sm text-gray-500">팩</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">팩당 낱장 수 <span class="text-red-500">*</span></label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32 text-right" name="pu_pack_per_sheet" type="number" min="1" value="<?= esc(old('pu_pack_per_sheet', '1')) ?>" required/>
|
||||
<span class="text-sm text-gray-500">장</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">적용시작일 <span class="text-red-500">*</span></label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="pu_start_date" type="date" value="<?= esc(old('pu_start_date', date('Y-m-d'))) ?>" required/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">적용종료일</label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="pu_end_date" type="date" value="<?= esc(old('pu_end_date')) ?>"/>
|
||||
<span class="text-sm text-gray-400">비워두면 현재 적용중</span>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 pt-2">
|
||||
<button type="submit" class="bg-btn-search text-white px-6 py-1.5 rounded-sm text-sm shadow hover:opacity-90 transition">등록</button>
|
||||
<a href="<?= base_url('admin/packaging-units') ?>" class="bg-gray-200 text-gray-700 px-6 py-1.5 rounded-sm text-sm hover:bg-gray-300 transition">취소</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
49
app/Views/admin/packaging_unit/edit.php
Normal file
49
app/Views/admin/packaging_unit/edit.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
|
||||
<span class="text-sm font-bold text-gray-700">포장 단위 수정</span>
|
||||
</section>
|
||||
<div class="border border-gray-300 p-4 mt-2 bg-white max-w-3xl">
|
||||
<form action="<?= base_url('admin/packaging-units/update/' . (int) $item->pu_idx) ?>" method="POST" class="space-y-4">
|
||||
<?= csrf_field() ?>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">봉투</label>
|
||||
<span class="text-sm font-mono"><?= esc($item->pu_bag_code) ?></span>
|
||||
<span class="text-sm text-gray-500"><?= esc($item->pu_bag_name) ?></span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">박스당 팩 수 <span class="text-red-500">*</span></label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32 text-right" name="pu_box_per_pack" type="number" min="1" value="<?= esc(old('pu_box_per_pack', $item->pu_box_per_pack)) ?>" required/>
|
||||
<span class="text-sm text-gray-500">팩</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">팩당 낱장 수 <span class="text-red-500">*</span></label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32 text-right" name="pu_pack_per_sheet" type="number" min="1" value="<?= esc(old('pu_pack_per_sheet', $item->pu_pack_per_sheet)) ?>" required/>
|
||||
<span class="text-sm text-gray-500">장</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">적용시작일 <span class="text-red-500">*</span></label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="pu_start_date" type="date" value="<?= esc(old('pu_start_date', $item->pu_start_date)) ?>" required/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">적용종료일</label>
|
||||
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="pu_end_date" type="date" value="<?= esc(old('pu_end_date', $item->pu_end_date)) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="block text-sm font-bold text-gray-700 w-32">상태 <span class="text-red-500">*</span></label>
|
||||
<select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32" name="pu_state" required>
|
||||
<option value="1" <?= (int) old('pu_state', $item->pu_state) === 1 ? 'selected' : '' ?>>사용</option>
|
||||
<option value="0" <?= (int) old('pu_state', $item->pu_state) === 0 ? 'selected' : '' ?>>미사용</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 pt-2">
|
||||
<button type="submit" class="bg-btn-search text-white px-6 py-1.5 rounded-sm text-sm shadow hover:opacity-90 transition">수정</button>
|
||||
<a href="<?= base_url('admin/packaging-units') ?>" class="bg-gray-200 text-gray-700 px-6 py-1.5 rounded-sm text-sm hover:bg-gray-300 transition">취소</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
34
app/Views/admin/packaging_unit/history.php
Normal file
34
app/Views/admin/packaging_unit/history.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="<?= base_url('admin/packaging-units') ?>" class="text-blue-600 hover:underline text-sm">← 포장 단위 목록</a>
|
||||
<span class="text-gray-400">|</span>
|
||||
<span class="text-sm font-bold text-gray-700">변경 이력 — <?= esc($item->pu_bag_name) ?> (<?= esc($item->pu_bag_code) ?>)</span>
|
||||
</div>
|
||||
</section>
|
||||
<div class="border border-gray-300 overflow-auto mt-2">
|
||||
<table class="w-full data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-16">번호</th>
|
||||
<th>변경 필드</th>
|
||||
<th>이전 값</th>
|
||||
<th>변경 값</th>
|
||||
<th>변경일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-right">
|
||||
<?php foreach ($list as $row): ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= esc($row->puh_idx) ?></td>
|
||||
<td class="text-left pl-2"><?= esc($row->puh_field) ?></td>
|
||||
<td><?= esc($row->puh_old_value) ?></td>
|
||||
<td><?= esc($row->puh_new_value) ?></td>
|
||||
<td class="text-center"><?= esc($row->puh_changed_at) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($list)): ?>
|
||||
<tr><td colspan="5" class="text-center text-gray-400 py-4">변경 이력이 없습니다.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
60
app/Views/admin/packaging_unit/index.php
Normal file
60
app/Views/admin/packaging_unit/index.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
|
||||
<div class="flex flex-wrap items-center justify-between gap-y-2">
|
||||
<span class="text-sm font-bold text-gray-700">포장 단위 관리</span>
|
||||
<a href="<?= base_url('admin/packaging-units/create') ?>" class="bg-btn-search text-white px-4 py-1.5 rounded-sm flex items-center gap-1 text-sm shadow hover:opacity-90 transition border border-transparent">포장 단위 등록</a>
|
||||
</div>
|
||||
</section>
|
||||
<section class="p-2 bg-white border-b border-gray-200">
|
||||
<form method="GET" action="<?= base_url('admin/packaging-units') ?>" class="flex flex-wrap items-center gap-2">
|
||||
<label class="text-sm text-gray-600">적용시작일</label>
|
||||
<input type="date" name="start_date" value="<?= esc($startDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
|
||||
<label class="text-sm text-gray-600">~</label>
|
||||
<input type="date" name="end_date" value="<?= esc($endDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
|
||||
<button type="submit" class="bg-btn-search text-white px-4 py-1 rounded-sm text-sm">조회</button>
|
||||
<a href="<?= base_url('admin/packaging-units') ?>" class="text-sm text-gray-500 hover:underline">초기화</a>
|
||||
</form>
|
||||
</section>
|
||||
<div class="border border-gray-300 overflow-auto mt-2">
|
||||
<table class="w-full 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 class="w-20">상태</th>
|
||||
<th class="w-36">작업</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-right">
|
||||
<?php foreach ($list as $row): ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= esc($row->pu_idx) ?></td>
|
||||
<td class="text-center font-mono"><?= esc($row->pu_bag_code) ?></td>
|
||||
<td class="text-left pl-2"><?= esc($row->pu_bag_name) ?></td>
|
||||
<td><?= number_format((int) $row->pu_box_per_pack) ?></td>
|
||||
<td><?= number_format((int) $row->pu_pack_per_sheet) ?></td>
|
||||
<td class="font-bold"><?= number_format((int) $row->pu_total_per_box) ?></td>
|
||||
<td class="text-center"><?= esc($row->pu_start_date) ?></td>
|
||||
<td class="text-center"><?= esc($row->pu_end_date ?? '현재') ?></td>
|
||||
<td class="text-center"><?= (int) $row->pu_state === 1 ? '사용' : '미사용' ?></td>
|
||||
<td class="text-center">
|
||||
<a href="<?= base_url('admin/packaging-units/history/' . (int) $row->pu_idx) ?>" class="text-green-600 hover:underline text-sm mr-1">이력</a>
|
||||
<a href="<?= base_url('admin/packaging-units/edit/' . (int) $row->pu_idx) ?>" class="text-blue-600 hover:underline text-sm mr-1">수정</a>
|
||||
<form action="<?= base_url('admin/packaging-units/delete/' . (int) $row->pu_idx) ?>" method="POST" class="inline" onsubmit="return confirm('삭제하시겠습니까?');">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit" class="text-red-600 hover:underline text-sm">삭제</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($list)): ?>
|
||||
<tr><td colspan="10" class="text-center text-gray-400 py-4">등록된 포장 단위가 없습니다.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
34
e2e/packaging-unit.spec.js
Normal file
34
e2e/packaging-unit.spec.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const { login } = require('./helpers/auth');
|
||||
|
||||
async function loginAsAdmin(page) {
|
||||
await login(page, 'admin');
|
||||
await page.locator('input[name="lg_idx"]').first().check();
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(url => !url.pathname.includes('select-local-government'), { timeout: 15000 });
|
||||
}
|
||||
|
||||
test.describe('P2-05/06: 포장 단위 관리', () => {
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await loginAsAdmin(page);
|
||||
});
|
||||
|
||||
test('포장 단위 목록 접근', async ({ page }) => {
|
||||
await page.goto('/admin/packaging-units');
|
||||
await expect(page).toHaveURL(/\/admin\/packaging-units/);
|
||||
});
|
||||
|
||||
test('포장 단위 등록 폼 표시', async ({ page }) => {
|
||||
await page.goto('/admin/packaging-units/create');
|
||||
await expect(page.locator('select[name="pu_bag_code"]')).toBeVisible();
|
||||
await expect(page.locator('input[name="pu_box_per_pack"]')).toBeVisible();
|
||||
await expect(page.locator('input[name="pu_pack_per_sheet"]')).toBeVisible();
|
||||
});
|
||||
|
||||
test('기간 필터 조회', async ({ page }) => {
|
||||
await page.goto('/admin/packaging-units?start_date=2026-01-01&end_date=2026-12-31');
|
||||
await expect(page).toHaveURL(/start_date/);
|
||||
});
|
||||
});
|
||||
34
writable/database/packaging_unit_tables.sql
Normal file
34
writable/database/packaging_unit_tables.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- ============================================
|
||||
-- 포장 단위 관리 테이블 (P2-05, P2-06)
|
||||
-- ============================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `packaging_unit` (
|
||||
`pu_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`pu_lg_idx` INT UNSIGNED NOT NULL COMMENT '지자체 FK',
|
||||
`pu_bag_code` VARCHAR(50) NOT NULL COMMENT '봉투코드(code_detail cd_code, ck=O)',
|
||||
`pu_bag_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '봉투명(스냅샷)',
|
||||
`pu_box_per_pack` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '박스당 팩 수',
|
||||
`pu_pack_per_sheet` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '팩당 낱장 수',
|
||||
`pu_total_per_box` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '1박스당 총 낱장 수',
|
||||
`pu_start_date` DATE NOT NULL,
|
||||
`pu_end_date` DATE NULL DEFAULT NULL,
|
||||
`pu_state` TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
`pu_regdate` DATETIME NOT NULL,
|
||||
`pu_moddate` DATETIME NULL DEFAULT NULL,
|
||||
`pu_reg_mb_idx` INT UNSIGNED NULL,
|
||||
PRIMARY KEY (`pu_idx`),
|
||||
KEY `idx_pu_lg_bag` (`pu_lg_idx`, `pu_bag_code`),
|
||||
KEY `idx_pu_dates` (`pu_start_date`, `pu_end_date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='포장 단위';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `packaging_unit_history` (
|
||||
`puh_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`puh_pu_idx` INT UNSIGNED NOT NULL,
|
||||
`puh_field` VARCHAR(30) NOT NULL,
|
||||
`puh_old_value` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`puh_new_value` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`puh_changed_at` DATETIME NOT NULL,
|
||||
`puh_changed_by` INT UNSIGNED NULL,
|
||||
PRIMARY KEY (`puh_idx`),
|
||||
KEY `idx_puh_pu_idx` (`puh_pu_idx`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='포장 단위 변경 이력';
|
||||
Reference in New Issue
Block a user