<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Home::index');
$routes->get('dashboard', 'Home::dashboard');
$routes->get('dashboard/classic-mock', 'Home::dashboardClassicMock');
$routes->get('dashboard/modern', 'Home::dashboardModern');
$routes->get('dashboard/dense', 'Home::dashboardDense');
$routes->get('dashboard/charts', 'Home::dashboardCharts');
$routes->get('bag/inventory-inquiry', 'Home::inventoryInquiry');
$routes->get('bag/waste-suibal-enterprise', 'Home::wasteSuibalEnterprise');

// 사이트 메뉴 (/bag/*)
$routes->get('bag/basic-info', 'Bag::basicInfo');
$routes->get('bag/purchase-inbound', 'Bag::purchaseInbound');
$routes->get('bag/issue', 'Bag::issue');
$routes->get('bag/inventory', 'Bag::inventory');
$routes->get('bag/sales', 'Bag::sales');
$routes->get('bag/sales-stats', 'Bag::salesStats');
$routes->get('bag/flow', 'Bag::flow');
$routes->get('bag/analytics', 'Bag::analytics');
$routes->get('bag/window', 'Bag::window');
$routes->get('bag/help', 'Bag::help');

// Auth
$routes->get('login', 'Auth::showLoginForm');
$routes->post('login', 'Auth::login');
$routes->get('logout', 'Auth::logout');
$routes->get('register', 'Auth::showRegisterForm');
$routes->post('register', 'Auth::register');

// Admin (adminAuth 필터 적용)
$routes->group('admin', ['filter' => 'adminAuth'], static function ($routes): void {
    $routes->get('select-local-government', 'Admin\SelectLocalGovernment::index');
    $routes->post('select-local-government', 'Admin\SelectLocalGovernment::store');
    $routes->get('/', 'Admin\Dashboard::index');
    $routes->get('users', 'Admin\User::index');
    $routes->get('users/create', 'Admin\User::create');
    $routes->post('users/store', 'Admin\User::store');
    $routes->get('users/edit/(:num)', 'Admin\User::edit/$1');
    $routes->post('users/update/(:num)', 'Admin\User::update/$1');
    $routes->post('users/delete/(:num)', 'Admin\User::delete/$1');
    $routes->get('access/login-history', 'Admin\Access::loginHistory');
    $routes->get('access/approvals', 'Admin\Access::approvals');
    $routes->post('access/approve/(:num)', 'Admin\Access::approve/$1');
    $routes->post('access/reject/(:num)', 'Admin\Access::reject/$1');
    $routes->get('roles', 'Admin\Role::index');
    $routes->get('menus', 'Admin\Menu::index');
    $routes->get('menus/list', 'Admin\Menu::list');
    $routes->post('menus/store', 'Admin\Menu::store');
    $routes->post('menus/update/(:num)', 'Admin\Menu::update/$1');
    $routes->post('menus/delete/(:num)', 'Admin\Menu::delete/$1');
    $routes->post('menus/move', 'Admin\Menu::move');

    // Local government & designated shop 관리
    $routes->get('local-governments', 'Admin\LocalGovernment::index');
    $routes->get('local-governments/create', 'Admin\LocalGovernment::create');
    $routes->post('local-governments/store', 'Admin\LocalGovernment::store');
    $routes->get('local-governments/edit/(:num)', 'Admin\LocalGovernment::edit/$1');
    $routes->post('local-governments/update/(:num)', 'Admin\LocalGovernment::update/$1');
    $routes->post('local-governments/delete/(:num)', 'Admin\LocalGovernment::delete/$1');

    // 비밀번호 변경 (P2-20)
    $routes->get('password-change', 'Admin\PasswordChange::index');
    $routes->post('password-change', 'Admin\PasswordChange::update');

    // 기본코드 종류 관리 (P2-01)
    $routes->get('code-kinds', 'Admin\CodeKind::index');
    $routes->get('code-kinds/create', 'Admin\CodeKind::create');
    $routes->post('code-kinds/store', 'Admin\CodeKind::store');
    $routes->get('code-kinds/edit/(:num)', 'Admin\CodeKind::edit/$1');
    $routes->post('code-kinds/update/(:num)', 'Admin\CodeKind::update/$1');
    $routes->post('code-kinds/delete/(:num)', 'Admin\CodeKind::delete/$1');

    // 세부코드 관리 (P2-02)
    $routes->get('code-details/(:num)', 'Admin\CodeDetail::index/$1');
    $routes->get('code-details/(:num)/create', 'Admin\CodeDetail::create/$1');
    $routes->post('code-details/store', 'Admin\CodeDetail::store');
    $routes->get('code-details/edit/(:num)', 'Admin\CodeDetail::edit/$1');
    $routes->post('code-details/update/(:num)', 'Admin\CodeDetail::update/$1');
    $routes->post('code-details/delete/(:num)', 'Admin\CodeDetail::delete/$1');

    // 봉투 단가 관리 (P2-03/04)
    $routes->get('bag-prices', 'Admin\BagPrice::index');
    $routes->get('bag-prices/create', 'Admin\BagPrice::create');
    $routes->post('bag-prices/store', 'Admin\BagPrice::store');
    $routes->get('bag-prices/edit/(:num)', 'Admin\BagPrice::edit/$1');
    $routes->post('bag-prices/update/(:num)', 'Admin\BagPrice::update/$1');
    $routes->post('bag-prices/delete/(:num)', 'Admin\BagPrice::delete/$1');
    $routes->get('bag-prices/history/(:num)', 'Admin\BagPrice::history/$1');

    // 발주 관리 (P3-01~05)
    $routes->get('bag-orders', 'Admin\BagOrder::index');
    $routes->get('bag-orders/create', 'Admin\BagOrder::create');
    $routes->post('bag-orders/store', 'Admin\BagOrder::store');
    $routes->get('bag-orders/detail/(:num)', 'Admin\BagOrder::detail/$1');
    $routes->post('bag-orders/cancel/(:num)', 'Admin\BagOrder::cancel/$1');
    $routes->post('bag-orders/delete/(:num)', 'Admin\BagOrder::delete/$1');

    // 입고 관리 (P3-06~09)
    $routes->get('bag-receivings', 'Admin\BagReceiving::index');
    $routes->get('bag-receivings/create', 'Admin\BagReceiving::create');
    $routes->post('bag-receivings/store', 'Admin\BagReceiving::store');

    // 재고 현황 (P3-10)
    $routes->get('bag-inventory', 'Admin\BagInventory::index');

    // 주문 접수 관리 (P4-01~03)
    $routes->get('shop-orders', 'Admin\ShopOrder::index');
    $routes->get('shop-orders/create', 'Admin\ShopOrder::create');
    $routes->post('shop-orders/store', 'Admin\ShopOrder::store');
    $routes->post('shop-orders/cancel/(:num)', 'Admin\ShopOrder::cancel/$1');

    // 판매/반품 관리 (P4-04~07)
    $routes->get('bag-sales', 'Admin\BagSale::index');
    $routes->get('bag-sales/create', 'Admin\BagSale::create');
    $routes->post('bag-sales/store', 'Admin\BagSale::store');

    // 무료용 불출 관리 (P4-08~10)
    $routes->get('bag-issues', 'Admin\BagIssue::index');
    $routes->get('bag-issues/create', 'Admin\BagIssue::create');
    $routes->post('bag-issues/store', 'Admin\BagIssue::store');
    $routes->post('bag-issues/cancel/(:num)', 'Admin\BagIssue::cancel/$1');

    // 포장 단위 관리 (P2-05/06)
    $routes->get('packaging-units', 'Admin\PackagingUnit::index');
    $routes->get('packaging-units/create', 'Admin\PackagingUnit::create');
    $routes->post('packaging-units/store', 'Admin\PackagingUnit::store');
    $routes->get('packaging-units/edit/(:num)', 'Admin\PackagingUnit::edit/$1');
    $routes->post('packaging-units/update/(:num)', 'Admin\PackagingUnit::update/$1');
    $routes->post('packaging-units/delete/(:num)', 'Admin\PackagingUnit::delete/$1');
    $routes->get('packaging-units/history/(:num)', 'Admin\PackagingUnit::history/$1');

    // 현황/리포트 (Phase 5)
    $routes->get('reports/sales-ledger', 'Admin\SalesReport::salesLedger');
    $routes->get('reports/daily-summary', 'Admin\SalesReport::dailySummary');
    $routes->get('reports/period-sales', 'Admin\SalesReport::periodSales');
    $routes->get('reports/supply-demand', 'Admin\SalesReport::supplyDemand');

    // 판매 대행소 관리 (P2-07/08)
    $routes->get('sales-agencies', 'Admin\SalesAgency::index');
    $routes->get('sales-agencies/create', 'Admin\SalesAgency::create');
    $routes->post('sales-agencies/store', 'Admin\SalesAgency::store');
    $routes->get('sales-agencies/edit/(:num)', 'Admin\SalesAgency::edit/$1');
    $routes->post('sales-agencies/update/(:num)', 'Admin\SalesAgency::update/$1');
    $routes->post('sales-agencies/delete/(:num)', 'Admin\SalesAgency::delete/$1');

    // 담당자 관리 (P2-09/10)
    $routes->get('managers', 'Admin\Manager::index');
    $routes->get('managers/create', 'Admin\Manager::create');
    $routes->post('managers/store', 'Admin\Manager::store');
    $routes->get('managers/edit/(:num)', 'Admin\Manager::edit/$1');
    $routes->post('managers/update/(:num)', 'Admin\Manager::update/$1');
    $routes->post('managers/delete/(:num)', 'Admin\Manager::delete/$1');

    // 업체 관리 (P2-11/12)
    $routes->get('companies', 'Admin\Company::index');
    $routes->get('companies/create', 'Admin\Company::create');
    $routes->post('companies/store', 'Admin\Company::store');
    $routes->get('companies/edit/(:num)', 'Admin\Company::edit/$1');
    $routes->post('companies/update/(:num)', 'Admin\Company::update/$1');
    $routes->post('companies/delete/(:num)', 'Admin\Company::delete/$1');

    // 무료용 대상자 관리 (P2-13/14)
    $routes->get('free-recipients', 'Admin\FreeRecipient::index');
    $routes->get('free-recipients/create', 'Admin\FreeRecipient::create');
    $routes->post('free-recipients/store', 'Admin\FreeRecipient::store');
    $routes->get('free-recipients/edit/(:num)', 'Admin\FreeRecipient::edit/$1');
    $routes->post('free-recipients/update/(:num)', 'Admin\FreeRecipient::update/$1');
    $routes->post('free-recipients/delete/(:num)', 'Admin\FreeRecipient::delete/$1');

    $routes->get('designated-shops', 'Admin\DesignatedShop::index');
    $routes->get('designated-shops/create', 'Admin\DesignatedShop::create');
    $routes->post('designated-shops/store', 'Admin\DesignatedShop::store');
    $routes->get('designated-shops/edit/(:num)', 'Admin\DesignatedShop::edit/$1');
    $routes->post('designated-shops/update/(:num)', 'Admin\DesignatedShop::update/$1');
    $routes->post('designated-shops/delete/(:num)', 'Admin\DesignatedShop::delete/$1');
});
