재고 조정(실사) 기능 추가 + 수불 관리 바로가기 버튼
- /bag/inventory/adjust: 재고 수량 조정 (실사 설정/증가/감소) - 재고 관리 페이지에 "재고 조정" 버튼 추가 - 봉투 수불 관리에 입고/판매/불출 바로가기 버튼 추가 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,8 @@ $routes->get('bag/window', 'Bag::window');
|
|||||||
$routes->get('bag/help', 'Bag::help');
|
$routes->get('bag/help', 'Bag::help');
|
||||||
|
|
||||||
// 사이트 메뉴 CRUD (사이트 레이아웃)
|
// 사이트 메뉴 CRUD (사이트 레이아웃)
|
||||||
|
$routes->get('bag/inventory/adjust', 'Bag::inventoryAdjust');
|
||||||
|
$routes->post('bag/inventory/adjust', 'Bag::inventoryAdjustStore');
|
||||||
$routes->get('bag/issue/create', 'Bag::issueCreate');
|
$routes->get('bag/issue/create', 'Bag::issueCreate');
|
||||||
$routes->post('bag/issue/store', 'Bag::issueStore');
|
$routes->post('bag/issue/store', 'Bag::issueStore');
|
||||||
$routes->post('bag/issue/cancel/(:num)', 'Bag::issueCancel/$1');
|
$routes->post('bag/issue/cancel/(:num)', 'Bag::issueCancel/$1');
|
||||||
|
|||||||
@@ -249,6 +249,55 @@ class Bag extends BaseController
|
|||||||
return $this->render('도움말', 'bag/help', []);
|
return $this->render('도움말', 'bag/help', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ──────────────────────────────────────────────
|
||||||
|
// 재고 조정 (실사)
|
||||||
|
// ──────────────────────────────────────────────
|
||||||
|
public function inventoryAdjust(): string
|
||||||
|
{
|
||||||
|
$lgIdx = $this->lgIdx();
|
||||||
|
$inventory = $lgIdx ? model(BagInventoryModel::class)->where('bi_lg_idx', $lgIdx)->orderBy('bi_bag_code')->findAll() : [];
|
||||||
|
return $this->render('재고 조정', 'bag/inventory_adjust', compact('inventory'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function inventoryAdjustStore()
|
||||||
|
{
|
||||||
|
helper('admin');
|
||||||
|
$lgIdx = $this->lgIdx();
|
||||||
|
if (! $lgIdx) {
|
||||||
|
return redirect()->to(site_url('bag/inventory'))->with('error', '지자체를 선택해 주세요.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'bag_code' => 'required|max_length[50]',
|
||||||
|
'adjust_type' => 'required|in_list[set,add,sub]',
|
||||||
|
'qty' => 'required|is_natural',
|
||||||
|
];
|
||||||
|
if (! $this->validate($rules)) {
|
||||||
|
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
$bagCode = $this->request->getPost('bag_code');
|
||||||
|
$type = $this->request->getPost('adjust_type');
|
||||||
|
$qty = (int) $this->request->getPost('qty');
|
||||||
|
|
||||||
|
$invModel = model(BagInventoryModel::class);
|
||||||
|
$existing = $invModel->where('bi_lg_idx', $lgIdx)->where('bi_bag_code', $bagCode)->first();
|
||||||
|
|
||||||
|
if ($type === 'set') {
|
||||||
|
if ($existing) {
|
||||||
|
$invModel->update($existing->bi_idx, ['bi_qty' => $qty, 'bi_updated_at' => date('Y-m-d H:i:s')]);
|
||||||
|
}
|
||||||
|
} elseif ($type === 'add') {
|
||||||
|
$bagName = $existing ? $existing->bi_bag_name : '';
|
||||||
|
$invModel->adjustQty($lgIdx, $bagCode, $bagName, $qty);
|
||||||
|
} elseif ($type === 'sub') {
|
||||||
|
$bagName = $existing ? $existing->bi_bag_name : '';
|
||||||
|
$invModel->adjustQty($lgIdx, $bagCode, $bagName, -$qty);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->to(site_url('bag/inventory'))->with('success', '재고가 조정되었습니다.');
|
||||||
|
}
|
||||||
|
|
||||||
// ══════════════════════════════════════════════
|
// ══════════════════════════════════════════════
|
||||||
// CRUD — 사이트 레이아웃으로 등록/처리 폼 제공
|
// CRUD — 사이트 레이아웃으로 등록/처리 폼 제공
|
||||||
// ══════════════════════════════════════════════
|
// ══════════════════════════════════════════════
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
<button type="submit" class="bg-btn-search text-white px-4 py-1.5 rounded-sm text-sm">조회</button>
|
<button type="submit" class="bg-btn-search text-white px-4 py-1.5 rounded-sm text-sm">조회</button>
|
||||||
<a href="<?= base_url('bag/flow') ?>" class="text-sm text-gray-500 hover:text-gray-700">초기화</a>
|
<a href="<?= base_url('bag/flow') ?>" class="text-sm text-gray-500 hover:text-gray-700">초기화</a>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="flex gap-2 mb-2">
|
||||||
|
<a href="<?= base_url('bag/receiving/create') ?>" class="bg-btn-search text-white px-3 py-1.5 rounded-sm text-sm">입고 처리</a>
|
||||||
|
<a href="<?= base_url('bag/sale/create') ?>" class="bg-white text-blue-600 border border-blue-300 px-3 py-1.5 rounded-sm text-sm">판매 등록</a>
|
||||||
|
<a href="<?= base_url('bag/issue/create') ?>" class="bg-white text-blue-600 border border-blue-300 px-3 py-1.5 rounded-sm text-sm">불출 처리</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 수불 요약 -->
|
<!-- 수불 요약 -->
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th class="w-16">번호</th><th>봉투코드</th><th>봉투명</th><th>현재재고(낱장)</th><th>최종갱신</th>
|
<th class="w-16">번호</th><th>봉투코드</th><th>봉투명</th><th>현재재고(낱장)</th><th>최종갱신</th>
|
||||||
@@ -9,8 +15,8 @@
|
|||||||
<td class="text-center"><?= $i + 1 ?></td>
|
<td class="text-center"><?= $i + 1 ?></td>
|
||||||
<td class="text-center"><?= esc($row->bi_bag_code ?? '') ?></td>
|
<td class="text-center"><?= esc($row->bi_bag_code ?? '') ?></td>
|
||||||
<td><?= esc($row->bi_bag_name ?? '') ?></td>
|
<td><?= esc($row->bi_bag_name ?? '') ?></td>
|
||||||
<td class="text-right"><?= number_format((int)($row->bi_qty_sheet ?? 0)) ?></td>
|
<td class="text-right"><?= number_format((int)($row->bi_qty ?? 0)) ?></td>
|
||||||
<td class="text-center"><?= esc($row->bi_updated_at ?? $row->updated_at ?? '') ?></td>
|
<td class="text-center"><?= esc($row->bi_updated_at ?? '') ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
@@ -18,3 +24,4 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|||||||
43
app/Views/bag/inventory_adjust.php
Normal file
43
app/Views/bag/inventory_adjust.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<div class="max-w-lg">
|
||||||
|
<div class="flex items-center justify-between mb-4">
|
||||||
|
<h3 class="text-base font-bold text-gray-700">재고 수량 조정 (실사)</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form action="<?= base_url('bag/inventory/adjust') ?>" method="POST" class="space-y-4">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-bold text-gray-700 mb-1">봉투코드 <span class="text-red-500">*</span></label>
|
||||||
|
<select name="bag_code" required class="w-full border border-gray-300 rounded px-3 py-2 text-sm">
|
||||||
|
<option value="">선택</option>
|
||||||
|
<?php foreach ($inventory as $item): ?>
|
||||||
|
<option value="<?= esc($item->bi_bag_code) ?>"><?= esc($item->bi_bag_code) ?> — <?= esc($item->bi_bag_name) ?> (현재: <?= number_format((int)$item->bi_qty) ?>)</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-bold text-gray-700 mb-1">조정 유형 <span class="text-red-500">*</span></label>
|
||||||
|
<select name="adjust_type" required class="w-full border border-gray-300 rounded px-3 py-2 text-sm">
|
||||||
|
<option value="set">실사 수량으로 설정</option>
|
||||||
|
<option value="add">증가 (+)</option>
|
||||||
|
<option value="sub">감소 (-)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-bold text-gray-700 mb-1">수량 <span class="text-red-500">*</span></label>
|
||||||
|
<input type="number" name="qty" required min="0" value="0" class="w-full border border-gray-300 rounded px-3 py-2 text-sm"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-bold text-gray-700 mb-1">사유</label>
|
||||||
|
<input type="text" name="reason" placeholder="실사 조정, 오류 수정 등" class="w-full border border-gray-300 rounded px-3 py-2 text-sm"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-2 pt-2">
|
||||||
|
<button type="submit" class="bg-btn-search text-white px-6 py-2 rounded-sm text-sm">조정</button>
|
||||||
|
<a href="<?= base_url('bag/inventory') ?>" class="bg-gray-200 text-gray-700 px-6 py-2 rounded-sm text-sm">취소</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user