사이트 메뉴 CRUD를 /bag/* 경로로 통합 — 관리자 레이아웃 혼용 해결

- Bag 컨트롤러에 create/store 메서드 추가 (불출/발주/입고/판매/주문)
- bag용 create 뷰 5개 생성 (form action을 /bag/*로 변경)
- 모든 등록/취소 버튼을 /admin/* → /bag/*로 변경
- 사이트 레이아웃이 CRUD 전체에서 유지됨
- playwright.production.config.js 추가 (도메인 테스트용)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
javamon1174
2026-03-26 16:13:07 +09:00
parent f6a64e07b8
commit 39ee71cc80
11 changed files with 500 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ use App\Models\CompanyModel;
use App\Models\PackagingUnitModel;
use App\Models\SalesAgencyModel;
use App\Models\ShopOrderModel;
use App\Models\DesignatedShopModel;
class Bag extends BaseController
{
@@ -247,4 +248,124 @@ class Bag extends BaseController
{
return $this->render('도움말', 'bag/help', []);
}
// ══════════════════════════════════════════════
// CRUD — 사이트 레이아웃으로 등록/처리 폼 제공
// ══════════════════════════════════════════════
// --- 불출 등록 ---
public function issueCreate(): string
{
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
$bagCodes = $kind ? model(CodeDetailModel::class)->where('cd_ck_idx', $kind->ck_idx)->where('cd_state', 1)->orderBy('cd_sort')->findAll() : [];
return $this->render('불출 처리', 'bag/create_bag_issue', compact('bagCodes'));
}
public function issueStore()
{
$admin = new \App\Controllers\Admin\BagIssue();
$admin->initController($this->request, $this->response, service('logger'));
$result = $admin->store();
if ($result instanceof \CodeIgniter\HTTP\RedirectResponse) {
$to = (string) $result->getHeaderLine('Location');
$to = str_replace('/admin/bag-issues', '/bag/issue', $to);
return redirect()->to($to)->with('success', session()->getFlashdata('success'))->with('errors', session()->getFlashdata('errors'));
}
return redirect()->to(site_url('bag/issue'))->with('success', '불출 처리되었습니다.');
}
public function issueCancel(int $id)
{
$admin = new \App\Controllers\Admin\BagIssue();
$admin->initController($this->request, $this->response, service('logger'));
$admin->cancel($id);
return redirect()->to(site_url('bag/issue'))->with('success', session()->getFlashdata('success') ?? '취소되었습니다.');
}
// --- 발주 등록 ---
public function orderCreate(): string
{
helper('admin');
$lgIdx = $this->lgIdx();
$companies = $lgIdx ? model(CompanyModel::class)->where('cp_lg_idx', $lgIdx)->where('cp_type', 'manufacturer')->where('cp_state', 1)->findAll() : [];
$agencies = $lgIdx ? model(SalesAgencyModel::class)->where('sa_lg_idx', $lgIdx)->where('sa_state', 1)->findAll() : [];
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
$bagCodes = $kind ? model(CodeDetailModel::class)->where('cd_ck_idx', $kind->ck_idx)->where('cd_state', 1)->orderBy('cd_sort')->findAll() : [];
return $this->render('발주 등록', 'bag/create_bag_order', compact('companies', 'agencies', 'bagCodes'));
}
public function orderStore()
{
$admin = new \App\Controllers\Admin\BagOrder();
$admin->initController($this->request, $this->response, service('logger'));
$result = $admin->store();
if ($result instanceof \CodeIgniter\HTTP\RedirectResponse) {
return redirect()->to(site_url('bag/purchase-inbound'))->with('success', session()->getFlashdata('success'))->with('errors', session()->getFlashdata('errors'));
}
return redirect()->to(site_url('bag/purchase-inbound'))->with('success', '발주 등록되었습니다.');
}
// --- 입고 처리 ---
public function receivingCreate(): string
{
helper('admin');
$lgIdx = $this->lgIdx();
$orders = $lgIdx ? model(BagOrderModel::class)->where('bo_lg_idx', $lgIdx)->where('bo_status', 'normal')->orderBy('bo_order_date', 'DESC')->findAll() : [];
return $this->render('입고 처리', 'bag/create_bag_receiving', compact('orders'));
}
public function receivingStore()
{
$admin = new \App\Controllers\Admin\BagReceiving();
$admin->initController($this->request, $this->response, service('logger'));
$result = $admin->store();
if ($result instanceof \CodeIgniter\HTTP\RedirectResponse) {
return redirect()->to(site_url('bag/purchase-inbound'))->with('success', session()->getFlashdata('success'))->with('errors', session()->getFlashdata('errors'));
}
return redirect()->to(site_url('bag/purchase-inbound'))->with('success', '입고 처리되었습니다.');
}
// --- 판매 등록 ---
public function saleCreate(): string
{
helper('admin');
$lgIdx = $this->lgIdx();
$shops = $lgIdx ? model(DesignatedShopModel::class)->where('ds_lg_idx', $lgIdx)->where('ds_state', 1)->findAll() : [];
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
$bagCodes = $kind ? model(CodeDetailModel::class)->where('cd_ck_idx', $kind->ck_idx)->where('cd_state', 1)->orderBy('cd_sort')->findAll() : [];
return $this->render('판매 등록', 'bag/create_bag_sale', compact('shops', 'bagCodes'));
}
public function saleStore()
{
$admin = new \App\Controllers\Admin\BagSale();
$admin->initController($this->request, $this->response, service('logger'));
$result = $admin->store();
if ($result instanceof \CodeIgniter\HTTP\RedirectResponse) {
return redirect()->to(site_url('bag/sales'))->with('success', session()->getFlashdata('success'))->with('errors', session()->getFlashdata('errors'));
}
return redirect()->to(site_url('bag/sales'))->with('success', '판매 등록되었습니다.');
}
// --- 주문 접수 ---
public function shopOrderCreate(): string
{
helper('admin');
$lgIdx = $this->lgIdx();
$shops = $lgIdx ? model(DesignatedShopModel::class)->where('ds_lg_idx', $lgIdx)->where('ds_state', 1)->findAll() : [];
$kind = model(CodeKindModel::class)->where('ck_code', 'O')->first();
$bagCodes = $kind ? model(CodeDetailModel::class)->where('cd_ck_idx', $kind->ck_idx)->where('cd_state', 1)->orderBy('cd_sort')->findAll() : [];
return $this->render('주문 접수', 'bag/create_shop_order', compact('shops', 'bagCodes'));
}
public function shopOrderStore()
{
$admin = new \App\Controllers\Admin\ShopOrder();
$admin->initController($this->request, $this->response, service('logger'));
$result = $admin->store();
if ($result instanceof \CodeIgniter\HTTP\RedirectResponse) {
return redirect()->to(site_url('bag/sales'))->with('success', session()->getFlashdata('success'))->with('errors', session()->getFlashdata('errors'));
}
return redirect()->to(site_url('bag/sales'))->with('success', '주문 접수되었습니다.');
}
}