From 35561b414b1d61ae6a828188c91083018589c637 Mon Sep 17 00:00:00 2001 From: javamon1174 Date: Thu, 26 Mar 2026 16:20:35 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=AC=EA=B3=A0=20=EC=A1=B0=EC=A0=95(?= =?UTF-8?q?=EC=8B=A4=EC=82=AC)=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20+=20=EC=88=98=EB=B6=88=20=EA=B4=80=EB=A6=AC=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=EA=B0=80=EA=B8=B0=20=EB=B2=84=ED=8A=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /bag/inventory/adjust: 재고 수량 조정 (실사 설정/증가/감소) - 재고 관리 페이지에 "재고 조정" 버튼 추가 - 봉투 수불 관리에 입고/판매/불출 바로가기 버튼 추가 Co-Authored-By: Claude Opus 4.6 (1M context) --- app/Config/Routes.php | 2 ++ app/Controllers/Bag.php | 49 ++++++++++++++++++++++++++++++ app/Views/bag/flow.php | 5 +++ app/Views/bag/inventory.php | 47 ++++++++++++++++------------ app/Views/bag/inventory_adjust.php | 43 ++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 app/Views/bag/inventory_adjust.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6f6538e..eb31589 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -28,6 +28,8 @@ $routes->get('bag/window', 'Bag::window'); $routes->get('bag/help', 'Bag::help'); // 사이트 메뉴 CRUD (사이트 레이아웃) +$routes->get('bag/inventory/adjust', 'Bag::inventoryAdjust'); +$routes->post('bag/inventory/adjust', 'Bag::inventoryAdjustStore'); $routes->get('bag/issue/create', 'Bag::issueCreate'); $routes->post('bag/issue/store', 'Bag::issueStore'); $routes->post('bag/issue/cancel/(:num)', 'Bag::issueCancel/$1'); diff --git a/app/Controllers/Bag.php b/app/Controllers/Bag.php index f6bee95..ab091b5 100644 --- a/app/Controllers/Bag.php +++ b/app/Controllers/Bag.php @@ -249,6 +249,55 @@ class Bag extends BaseController 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 — 사이트 레이아웃으로 등록/처리 폼 제공 // ══════════════════════════════════════════════ diff --git a/app/Views/bag/flow.php b/app/Views/bag/flow.php index 265a898..9c24425 100644 --- a/app/Views/bag/flow.php +++ b/app/Views/bag/flow.php @@ -7,6 +7,11 @@ 초기화 + diff --git a/app/Views/bag/inventory.php b/app/Views/bag/inventory.php index a7bc3e3..ca3164f 100644 --- a/app/Views/bag/inventory.php +++ b/app/Views/bag/inventory.php @@ -1,20 +1,27 @@ -
- - - - - - $row): ?> - - - - - - - - - - - - -
번호봉투코드봉투명현재재고(낱장)최종갱신
bi_bag_code ?? '') ?>bi_bag_name ?? '') ?>bi_qty_sheet ?? 0)) ?>bi_updated_at ?? $row->updated_at ?? '') ?>
재고 데이터가 없습니다.
+
+ + + + + + + + + $row): ?> + + + + + + + + + + + + +
번호봉투코드봉투명현재재고(낱장)최종갱신
bi_bag_code ?? '') ?>bi_bag_name ?? '') ?>bi_qty ?? 0)) ?>bi_updated_at ?? '') ?>
재고 데이터가 없습니다.
+
diff --git a/app/Views/bag/inventory_adjust.php b/app/Views/bag/inventory_adjust.php new file mode 100644 index 0000000..13622f6 --- /dev/null +++ b/app/Views/bag/inventory_adjust.php @@ -0,0 +1,43 @@ +
+
+

재고 수량 조정 (실사)

+
+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + 취소 +
+
+