feat: 기본코드 bag 목록과 관리자 CRUD 분리
- /bag/code-kinds, /bag/code-details/{ck_idx} 조회 (LoginAuthFilter, Roles::canManageCodeMaster)
- admin에서는 종류·세부 목록 제거, 등록·수정·삭제만 유지 후 bag으로 리다이렉트
- 사이트 메뉴·기본코드 링크 SQL, CSV 동기화 스크립트·README 보강
- 관리자 대시보드: 발주·판매 테이블 미존재 시 통계 비활성화
- 회원 로그인 잠금(mb_login_fail_count, mb_locked_until) 및 관리자 잠금 해제
Made-with: Cursor
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\CodeKindModel;
|
||||
use App\Models\CodeDetailModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use Config\Roles;
|
||||
|
||||
class CodeDetail extends BaseController
|
||||
{
|
||||
@@ -17,31 +21,30 @@ class CodeDetail extends BaseController
|
||||
$this->detailModel = model(CodeDetailModel::class);
|
||||
}
|
||||
|
||||
public function index(int $ckIdx)
|
||||
private function redirectIfCannotManageCodeMaster(): ?RedirectResponse
|
||||
{
|
||||
$kind = $this->kindModel->find($ckIdx);
|
||||
if ($kind === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
if (! Roles::canManageCodeMaster((int) session()->get('mb_level'))) {
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 관리 권한이 없습니다.');
|
||||
}
|
||||
|
||||
$list = $this->detailModel->where('cd_ck_idx', $ckIdx)->orderBy('cd_sort', 'ASC')->paginate(20);
|
||||
$pager = $this->detailModel->pager;
|
||||
return null;
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '세부코드 관리 — ' . $kind->ck_name . ' (' . $kind->ck_code . ')',
|
||||
'content' => view('admin/code_detail/index', [
|
||||
'kind' => $kind,
|
||||
'list' => $list,
|
||||
'pager' => $pager,
|
||||
]),
|
||||
]);
|
||||
/** @deprecated 사이트 URL 유지용 — 세부 목록은 /bag/code-details/{ck_idx} */
|
||||
public function index(int $ckIdx): RedirectResponse
|
||||
{
|
||||
return redirect()->to(site_url('bag/code-details/' . $ckIdx));
|
||||
}
|
||||
|
||||
public function create(int $ckIdx)
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$kind = $this->kindModel->find($ckIdx);
|
||||
if ($kind === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
@@ -52,6 +55,10 @@ class CodeDetail extends BaseController
|
||||
|
||||
public function store()
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$rules = [
|
||||
'cd_ck_idx' => 'required|is_natural_no_zero',
|
||||
'cd_code' => 'required|max_length[50]',
|
||||
@@ -74,14 +81,18 @@ class CodeDetail extends BaseController
|
||||
'cd_regdate' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/code-details/' . $ckIdx))->with('success', '세부코드가 등록되었습니다.');
|
||||
return redirect()->to(site_url('bag/code-details/' . $ckIdx))->with('success', '세부코드가 등록되었습니다.');
|
||||
}
|
||||
|
||||
public function edit(int $id)
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$item = $this->detailModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '세부코드를 찾을 수 없습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '세부코드를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$kind = $this->kindModel->find($item->cd_ck_idx);
|
||||
@@ -97,9 +108,13 @@ class CodeDetail extends BaseController
|
||||
|
||||
public function update(int $id)
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$item = $this->detailModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '세부코드를 찾을 수 없습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '세부코드를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$rules = [
|
||||
@@ -118,19 +133,23 @@ class CodeDetail extends BaseController
|
||||
'cd_state' => (int) $this->request->getPost('cd_state'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/code-details/' . $item->cd_ck_idx))->with('success', '세부코드가 수정되었습니다.');
|
||||
return redirect()->to(site_url('bag/code-details/' . $item->cd_ck_idx))->with('success', '세부코드가 수정되었습니다.');
|
||||
}
|
||||
|
||||
public function delete(int $id)
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$item = $this->detailModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '세부코드를 찾을 수 없습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '세부코드를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$ckIdx = $item->cd_ck_idx;
|
||||
$this->detailModel->delete($id);
|
||||
|
||||
return redirect()->to(site_url('admin/code-details/' . $ckIdx))->with('success', '세부코드가 삭제되었습니다.');
|
||||
return redirect()->to(site_url('bag/code-details/' . $ckIdx))->with('success', '세부코드가 삭제되었습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\CodeKindModel;
|
||||
use App\Models\CodeDetailModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use Config\Roles;
|
||||
|
||||
class CodeKind extends BaseController
|
||||
@@ -16,30 +19,21 @@ class CodeKind extends BaseController
|
||||
$this->kindModel = model(CodeKindModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
private function redirectIfCannotManageCodeMaster(): ?RedirectResponse
|
||||
{
|
||||
$list = $this->kindModel->orderBy('ck_code', 'ASC')->paginate(20);
|
||||
$pager = $this->kindModel->pager;
|
||||
|
||||
// 세부코드 수 매핑
|
||||
$detailModel = model(CodeDetailModel::class);
|
||||
$countMap = [];
|
||||
foreach ($list as $row) {
|
||||
$countMap[$row->ck_idx] = $detailModel->where('cd_ck_idx', $row->ck_idx)->countAllResults(false);
|
||||
if (! Roles::canManageCodeMaster((int) session()->get('mb_level'))) {
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 관리 권한이 없습니다.');
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '기본코드 종류 관리',
|
||||
'content' => view('admin/code_kind/index', [
|
||||
'list' => $list,
|
||||
'countMap' => $countMap,
|
||||
'pager' => $pager,
|
||||
]),
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '기본코드 종류 등록',
|
||||
'content' => view('admin/code_kind/create'),
|
||||
@@ -48,6 +42,10 @@ class CodeKind extends BaseController
|
||||
|
||||
public function store()
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$rules = [
|
||||
'ck_code' => 'required|max_length[20]|is_unique[code_kind.ck_code]',
|
||||
'ck_name' => 'required|max_length[100]',
|
||||
@@ -64,14 +62,18 @@ class CodeKind extends BaseController
|
||||
'ck_regdate' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('success', '코드 종류가 등록되었습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('success', '코드 종류가 등록되었습니다.');
|
||||
}
|
||||
|
||||
public function edit(int $id)
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$item = $this->kindModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
@@ -82,9 +84,13 @@ class CodeKind extends BaseController
|
||||
|
||||
public function update(int $id)
|
||||
{
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$item = $this->kindModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$rules = [
|
||||
@@ -101,24 +107,28 @@ class CodeKind extends BaseController
|
||||
'ck_state' => (int) $this->request->getPost('ck_state'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('success', '코드 종류가 수정되었습니다.');
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('success', '코드 종류가 수정되었습니다.');
|
||||
}
|
||||
|
||||
public function delete(int $id)
|
||||
{
|
||||
$item = $this->kindModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
if ($r = $this->redirectIfCannotManageCodeMaster()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
$item = $this->kindModel->find($id);
|
||||
if ($item === null) {
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
// 세부코드가 있으면 삭제 불가
|
||||
$detailCount = model(CodeDetailModel::class)->where('cd_ck_idx', $id)->countAllResults();
|
||||
if ($detailCount > 0) {
|
||||
return redirect()->to(site_url('admin/code-kinds'))
|
||||
return redirect()->to(site_url('bag/code-kinds'))
|
||||
->with('error', '세부코드가 ' . $detailCount . '개 존재하여 삭제할 수 없습니다. 먼저 세부코드를 삭제해 주세요.');
|
||||
}
|
||||
|
||||
$this->kindModel->delete($id);
|
||||
return redirect()->to(site_url('admin/code-kinds'))->with('success', '코드 종류가 삭제되었습니다.');
|
||||
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('success', '코드 종류가 삭제되었습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
|
||||
class Dashboard extends BaseController
|
||||
{
|
||||
@@ -22,65 +23,71 @@ class Dashboard extends BaseController
|
||||
'issue_count_month'=> 0,
|
||||
'recent_orders' => [],
|
||||
'recent_sales' => [],
|
||||
'stats_unavailable'=> false,
|
||||
];
|
||||
|
||||
if ($lgIdx) {
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 총 발주 건수/금액
|
||||
$orderStats = $db->query("
|
||||
SELECT COUNT(*) as cnt,
|
||||
COALESCE(SUM(sub.total_amt), 0) as total_amount
|
||||
FROM bag_order bo
|
||||
LEFT JOIN (
|
||||
SELECT boi_bo_idx, SUM(boi_amount) as total_amt
|
||||
FROM bag_order_item GROUP BY boi_bo_idx
|
||||
) sub ON sub.boi_bo_idx = bo.bo_idx
|
||||
WHERE bo.bo_lg_idx = ? AND bo.bo_status = 'normal'
|
||||
", [$lgIdx])->getRow();
|
||||
$stats['order_count'] = (int) ($orderStats->cnt ?? 0);
|
||||
$stats['order_amount'] = (int) ($orderStats->total_amount ?? 0);
|
||||
try {
|
||||
// 총 발주 건수/금액
|
||||
$orderStats = $db->query("
|
||||
SELECT COUNT(*) as cnt,
|
||||
COALESCE(SUM(sub.total_amt), 0) as total_amount
|
||||
FROM bag_order bo
|
||||
LEFT JOIN (
|
||||
SELECT boi_bo_idx, SUM(boi_amount) as total_amt
|
||||
FROM bag_order_item GROUP BY boi_bo_idx
|
||||
) sub ON sub.boi_bo_idx = bo.bo_idx
|
||||
WHERE bo.bo_lg_idx = ? AND bo.bo_status = 'normal'
|
||||
", [$lgIdx])->getRow();
|
||||
$stats['order_count'] = (int) ($orderStats->cnt ?? 0);
|
||||
$stats['order_amount'] = (int) ($orderStats->total_amount ?? 0);
|
||||
|
||||
// 총 판매 건수/금액
|
||||
$saleStats = $db->query("
|
||||
SELECT COUNT(*) as cnt, COALESCE(SUM(bs_amount), 0) as total_amount
|
||||
FROM bag_sale
|
||||
WHERE bs_lg_idx = ? AND bs_type = 'sale'
|
||||
", [$lgIdx])->getRow();
|
||||
$stats['sale_count'] = (int) ($saleStats->cnt ?? 0);
|
||||
$stats['sale_amount'] = (int) ($saleStats->total_amount ?? 0);
|
||||
// 총 판매 건수/금액
|
||||
$saleStats = $db->query("
|
||||
SELECT COUNT(*) as cnt, COALESCE(SUM(bs_amount), 0) as total_amount
|
||||
FROM bag_sale
|
||||
WHERE bs_lg_idx = ? AND bs_type = 'sale'
|
||||
", [$lgIdx])->getRow();
|
||||
$stats['sale_count'] = (int) ($saleStats->cnt ?? 0);
|
||||
$stats['sale_amount'] = (int) ($saleStats->total_amount ?? 0);
|
||||
|
||||
// 현재 재고 품목 수
|
||||
$invCount = $db->query("
|
||||
SELECT COUNT(*) as cnt FROM bag_inventory WHERE bi_lg_idx = ? AND bi_qty > 0
|
||||
", [$lgIdx])->getRow();
|
||||
$stats['inventory_count'] = (int) ($invCount->cnt ?? 0);
|
||||
// 현재 재고 품목 수
|
||||
$invCount = $db->query("
|
||||
SELECT COUNT(*) as cnt FROM bag_inventory WHERE bi_lg_idx = ? AND bi_qty > 0
|
||||
", [$lgIdx])->getRow();
|
||||
$stats['inventory_count'] = (int) ($invCount->cnt ?? 0);
|
||||
|
||||
// 이번 달 불출 건수
|
||||
$monthStart = date('Y-m-01');
|
||||
$issueCount = $db->query("
|
||||
SELECT COUNT(*) as cnt FROM bag_issue
|
||||
WHERE bi2_lg_idx = ? AND bi2_status = 'normal' AND bi2_issue_date >= ?
|
||||
", [$lgIdx, $monthStart])->getRow();
|
||||
$stats['issue_count_month'] = (int) ($issueCount->cnt ?? 0);
|
||||
// 이번 달 불출 건수
|
||||
$monthStart = date('Y-m-01');
|
||||
$issueCount = $db->query("
|
||||
SELECT COUNT(*) as cnt FROM bag_issue
|
||||
WHERE bi2_lg_idx = ? AND bi2_status = 'normal' AND bi2_issue_date >= ?
|
||||
", [$lgIdx, $monthStart])->getRow();
|
||||
$stats['issue_count_month'] = (int) ($issueCount->cnt ?? 0);
|
||||
|
||||
// 최근 발주 5건
|
||||
$stats['recent_orders'] = $db->query("
|
||||
SELECT bo_idx, bo_lot_no, bo_order_date, bo_status
|
||||
FROM bag_order
|
||||
WHERE bo_lg_idx = ?
|
||||
ORDER BY bo_order_date DESC, bo_idx DESC
|
||||
LIMIT 5
|
||||
", [$lgIdx])->getResult();
|
||||
// 최근 발주 5건
|
||||
$stats['recent_orders'] = $db->query("
|
||||
SELECT bo_idx, bo_lot_no, bo_order_date, bo_status
|
||||
FROM bag_order
|
||||
WHERE bo_lg_idx = ?
|
||||
ORDER BY bo_order_date DESC, bo_idx DESC
|
||||
LIMIT 5
|
||||
", [$lgIdx])->getResult();
|
||||
|
||||
// 최근 판매 5건
|
||||
$stats['recent_sales'] = $db->query("
|
||||
SELECT bs_idx, bs_ds_name, bs_bag_name, bs_qty, bs_amount, bs_sale_date, bs_type
|
||||
FROM bag_sale
|
||||
WHERE bs_lg_idx = ?
|
||||
ORDER BY bs_sale_date DESC, bs_idx DESC
|
||||
LIMIT 5
|
||||
", [$lgIdx])->getResult();
|
||||
// 최근 판매 5건
|
||||
$stats['recent_sales'] = $db->query("
|
||||
SELECT bs_idx, bs_ds_name, bs_bag_name, bs_qty, bs_amount, bs_sale_date, bs_type
|
||||
FROM bag_sale
|
||||
WHERE bs_lg_idx = ?
|
||||
ORDER BY bs_sale_date DESC, bs_idx DESC
|
||||
LIMIT 5
|
||||
", [$lgIdx])->getResult();
|
||||
} catch (DatabaseException $e) {
|
||||
$stats['stats_unavailable'] = true;
|
||||
log_message('error', '[Dashboard] 통계 조회 실패(테이블 미생성 등): ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
|
||||
@@ -177,6 +177,23 @@ class User extends BaseController
|
||||
return redirect()->to(site_url('admin/users'))->with('success', '회원 정보가 수정되었습니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그인 실패 누적 잠금(mb_locked_until) 해제 — 비밀번호는 그대로 두고 재시도만 가능하게 함
|
||||
*/
|
||||
public function unlockLogin(int $id)
|
||||
{
|
||||
$member = $this->memberModel->find($id);
|
||||
if (! $member) {
|
||||
return redirect()->to(site_url('admin/users'))->with('error', '회원을 찾을 수 없습니다.');
|
||||
}
|
||||
$this->memberModel->update($id, [
|
||||
'mb_login_fail_count' => 0,
|
||||
'mb_locked_until' => null,
|
||||
]);
|
||||
|
||||
return redirect()->back()->with('success', '로그인 잠금이 해제되었습니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 로그인한 관리자가 부여 가능한 역할 목록.
|
||||
* super/본부만 4·5 부여 가능, 지자체 관리자는 1~3만.
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
use App\Models\BagInventoryModel;
|
||||
use App\Models\BagIssueModel;
|
||||
use App\Models\BagOrderModel;
|
||||
@@ -18,6 +19,7 @@ use App\Models\PackagingUnitModel;
|
||||
use App\Models\SalesAgencyModel;
|
||||
use App\Models\ShopOrderModel;
|
||||
use App\Models\DesignatedShopModel;
|
||||
use Config\Roles;
|
||||
|
||||
class Bag extends BaseController
|
||||
{
|
||||
@@ -44,17 +46,74 @@ class Bag extends BaseController
|
||||
public function basicInfo(): string
|
||||
{
|
||||
$lgIdx = $this->lgIdx();
|
||||
$data = [];
|
||||
$data = [
|
||||
'bagPrices' => [],
|
||||
'packagingUnits' => [],
|
||||
];
|
||||
|
||||
if ($lgIdx) {
|
||||
$data['codeKinds'] = model(CodeKindModel::class)->orderBy('ck_code', 'ASC')->findAll();
|
||||
$data['bagPrices'] = model(BagPriceModel::class)->where('bp_lg_idx', $lgIdx)->orderBy('bp_bag_code', 'ASC')->findAll();
|
||||
$data['packagingUnits'] = model(PackagingUnitModel::class)->where('pu_lg_idx', $lgIdx)->orderBy('pu_bag_code', 'ASC')->findAll();
|
||||
try {
|
||||
$data['bagPrices'] = model(BagPriceModel::class)->where('bp_lg_idx', $lgIdx)->orderBy('bp_bag_code', 'ASC')->findAll();
|
||||
} catch (DatabaseException $e) {
|
||||
log_message('error', '[basicInfo] bag_price 조회 실패(테이블 미생성 등): ' . $e->getMessage());
|
||||
}
|
||||
try {
|
||||
$data['packagingUnits'] = model(PackagingUnitModel::class)->where('pu_lg_idx', $lgIdx)->orderBy('pu_bag_code', 'ASC')->findAll();
|
||||
} catch (DatabaseException $e) {
|
||||
log_message('error', '[basicInfo] packaging_unit 조회 실패: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('기본정보관리', 'bag/basic_info', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본코드 종류·세부코드 조회 전용 (사이트 메뉴 기본코드관리)
|
||||
*/
|
||||
public function codeKinds(): string
|
||||
{
|
||||
$kindModel = model(CodeKindModel::class);
|
||||
$detailModel = model(CodeDetailModel::class);
|
||||
$kinds = $kindModel->orderBy('ck_code', 'ASC')->findAll();
|
||||
$countMap = [];
|
||||
foreach ($kinds as $row) {
|
||||
// countAllResults() 기본값(true)으로 매번 빌더 초기화 — false 시 where 누적되어 2번째부터 0건으로 보임
|
||||
$countMap[$row->ck_idx] = (int) $detailModel->where('cd_ck_idx', $row->ck_idx)->countAllResults();
|
||||
}
|
||||
|
||||
return $this->render('기본코드관리', 'bag/code_kinds', [
|
||||
'codeKinds' => $kinds,
|
||||
'countMap' => $countMap,
|
||||
'canManage' => Roles::canManageCodeMaster((int) session()->get('mb_level')),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본코드 세부 목록 (사이트 레이아웃). 등록·수정·삭제 폼은 /admin/code-details/* 유지.
|
||||
*/
|
||||
public function codeDetails(int $ckIdx)
|
||||
{
|
||||
$kindModel = model(CodeKindModel::class);
|
||||
$detailModel = model(CodeDetailModel::class);
|
||||
$kind = $kindModel->find($ckIdx);
|
||||
if ($kind === null) {
|
||||
return redirect()->to(site_url('bag/code-kinds'))->with('error', '코드 종류를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$list = $detailModel->where('cd_ck_idx', $ckIdx)->orderBy('cd_sort', 'ASC')->orderBy('cd_idx', 'ASC')->paginate(20);
|
||||
$pager = $detailModel->pager;
|
||||
|
||||
$canManage = Roles::canManageCodeMaster((int) session()->get('mb_level'));
|
||||
$title = ($canManage ? '세부코드 관리' : '세부코드 조회') . ' — ' . $kind->ck_name . ' (' . $kind->ck_code . ')';
|
||||
|
||||
return $this->render($title, 'bag/code_details', [
|
||||
'kind' => $kind,
|
||||
'list' => $list,
|
||||
'pager' => $pager,
|
||||
'canManage' => $canManage,
|
||||
]);
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 발주 입고 관리
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user