<?php

namespace App\Controllers\Admin;

use App\Controllers\BaseController;
use App\Models\BagInventoryModel;

class BagInventory extends BaseController
{
    public function index()
    {
        helper('admin');
        $lgIdx = admin_effective_lg_idx();
        if (!$lgIdx) return redirect()->to(site_url('admin'))->with('error', '지자체를 선택해 주세요.');

        $list = model(BagInventoryModel::class)->where('bi_lg_idx', $lgIdx)->orderBy('bi_bag_code', 'ASC')->findAll();

        return view('admin/layout', [
            'title'   => '재고 현황',
            'content' => view('admin/bag_inventory/index', ['list' => $list]),
        ]);
    }
}
