<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
// $routes->get('/', 'Home::index');

//추가 Custom RULE 만들때 : ex)UUID형식
$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
//authFilter는 추가적인 작업이 필요
//1. app/Filters/AuthFilter.php
//2. Config/Filters.php -> $aliases = ['authFilter' => AuthFilter::class]
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
  $routes->cli('billing', 'Payment::billing');
  $routes->group('migration', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
    $routes->cli('client', 'SourceDB::client');
    $routes->cli('servercode', 'SourceDB::servercode');
    $routes->cli('switchcode', 'SourceDB::switchcode');
  });
});
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
  $routes->get('/', 'Home::index');
  $routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) {
    $routes->get('login', 'LocalController::create_form');
    $routes->post('login', 'LocalController::create');
    $routes->get('google_login', 'GoogleController::create');
    $routes->get('logout', 'LocalController::logout');
  });
});
//Admin 관련
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
  $routes->get('/', 'Home::index');
  $routes->group('user', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
    $routes->get('/', 'UserController::index', ['filter' => 'authFilter:master']);
    $routes->get('create', 'UserController::create_form', ['filter' => 'authFilter:master']);
    $routes->post('create', 'UserController::create', ['filter' => 'authFilter:master']);
    $routes->get('modify/(:num)', 'UserController::modify_form/$1', ['filter' => 'authFilter:master']);
    $routes->post('modify/(:num)', 'UserController::modify/$1', ['filter' => 'authFilter:master']);
    $routes->get('view/(:num)', 'UserController::view/$1', ['filter' => 'authFilter:manager']);
    $routes->get('delete/(:num)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
    $routes->get('toggle/(:num)/(:any)', 'UserController::toggle/$1/$2', ['filter' => 'authFilter:master']);
    $routes->post('batchjob', 'UserController::batchjob', ['filter' => 'authFilter:master']);
    $routes->post('batchjob_delete', 'UserController::batchjob_delete', ['filter' => 'authFilter:master']);
    $routes->get('download/(:alpha)', 'UserController::download/$1', ['filter' => 'authFilter:master']);
    $routes->get('profile_modify/(:num)', 'UserController::profile_modify_form/$1', ['filter' => 'authFilter:manager']);
    $routes->post('profile_modify/(:num)', 'UserController::profile_modify/$1', ['filter' => 'authFilter:manager']);
  });
  $routes->group('mylog', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
    $routes->get('/', 'MyLogController::index');
    $routes->get('view/(:num)', 'MyLogController::view/$1');
  });
  $routes->group('search', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
    $routes->get('/', 'SearchController::index');
  });
  //Customer 관련
  $routes->group('customer', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
    $routes->group('client', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'ClientController::index');
      $routes->get('create', 'ClientController::create_form');
      $routes->post('create', 'ClientController::create');
      $routes->get('modify/(:num)', 'ClientController::modify_form/$1');
      $routes->post('modify/(:num)', 'ClientController::modify/$1');
      $routes->get('view/(:num)', 'ClientController::view/$1');
      $routes->get('delete/(:num)', 'ClientController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'ClientController::toggle/$1/$2');
      $routes->post('batchjob', 'ClientController::batchjob');
      $routes->post('batchjob_delete', 'ClientController::batchjob_delete');
      $routes->get('download/(:alpha)', 'ClientController::download/$1');
    });
    $routes->group('account', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'AccountController::index');
      $routes->get('create', 'AccountController::create_form');
      $routes->post('create', 'AccountController::create');
      $routes->get('modify/(:num)', 'AccountController::modify_form/$1');
      $routes->post('modify/(:num)', 'AccountController::modify/$1');
      $routes->get('view/(:num)', 'AccountController::view/$1');
      $routes->get('delete/(:num)', 'AccountController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'AccountController::toggle/$1/$2');
      $routes->post('batchjob', 'AccountController::batchjob');
      $routes->post('batchjob_delete', 'AccountController::batchjob_delete');
      $routes->get('download/(:alpha)', 'AccountController::download/$1');
    });
    $routes->group('coupon', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'CouponController::index');
      $routes->get('create', 'CouponController::create_form');
      $routes->post('create', 'CouponController::create');
      $routes->get('modify/(:num)', 'CouponController::modify_form/$1');
      $routes->post('modify/(:num)', 'CouponController::modify/$1');
      $routes->get('view/(:num)', 'CouponController::view/$1');
      $routes->get('delete/(:num)', 'CouponController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'CouponController::toggle/$1/$2');
      $routes->post('batchjob', 'CouponController::batchjob');
      $routes->post('batchjob_delete', 'CouponController::batchjob_delete');
      $routes->get('download/(:alpha)', 'CouponController::download/$1');
    });
    $routes->group('point', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'PointController::index');
      $routes->get('create', 'PointController::create_form');
      $routes->post('create', 'PointController::create');
      $routes->get('modify/(:num)', 'PointController::modify_form/$1');
      $routes->post('modify/(:num)', 'PointController::modify/$1');
      $routes->get('view/(:num)', 'PointController::view/$1');
      $routes->get('delete/(:num)', 'PointController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'PointController::toggle/$1/$2');
      $routes->post('batchjob', 'PointController::batchjob');
      $routes->post('batchjob_delete', 'PointController::batchjob_delete');
      $routes->get('download/(:alpha)', 'PointController::download/$1');
    });
    $routes->group('service', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'ServiceController::index');
      $routes->get('create', 'ServiceController::create_form');
      $routes->post('create', 'ServiceController::create');
      $routes->get('modify/(:num)', 'ServiceController::modify_form/$1');
      $routes->post('modify/(:num)', 'ServiceController::modify/$1');
      $routes->get('view/(:num)', 'ServiceController::view/$1');
      $routes->get('delete/(:num)', 'ServiceController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'ServiceController::toggle/$1/$2');
      $routes->post('batchjob', 'ServiceController::batchjob');
      $routes->post('batchjob_delete', 'ServiceController::batchjob_delete');
      $routes->get('download/(:alpha)', 'ServiceController::download/$1');
    });
    $routes->group('serviceitem', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'ServiceItemController::index');
      $routes->get('create', 'ServiceItemController::create_form');
      $routes->post('create', 'ServiceItemController::create');
      $routes->get('modify/(:num)', 'ServiceItemController::modify_form/$1');
      $routes->post('modify/(:num)', 'ServiceItemController::modify/$1');
      $routes->get('view/(:num)', 'ServiceItemController::view/$1');
      $routes->get('delete/(:num)', 'ServiceItemController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'ServiceItemController::toggle/$1/$2');
      $routes->post('batchjob', 'ServiceItemController::batchjob');
      $routes->post('batchjob_delete', 'ServiceItemController::batchjob_delete');
      $routes->get('download/(:alpha)', 'ServiceItemController::download/$1');
    });
    $routes->group('payment', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
      $routes->get('/', 'PaymentController::index');
      $routes->get('create', 'PaymentController::create_form');
      $routes->post('create', 'PaymentController::create');
      $routes->get('modify/(:num)', 'PaymentController::modify_form/$1');
      $routes->post('modify/(:num)', 'PaymentController::modify/$1');
      $routes->get('view/(:num)', 'PaymentController::view/$1');
      $routes->get('delete/(:num)', 'PaymentController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'PaymentController::toggle/$1/$2');
      $routes->post('batchjob', 'PaymentController::batchjob');
      $routes->post('batchjob_delete', 'PaymentController::batchjob_delete');
      $routes->get('download/(:alpha)', 'PaymentController::download/$1');
      $routes->post('invoice', 'PaymentController::invoice', []);
    });
  });
  //Customer 관련
  //Equipment 관련
  $routes->group('equipment', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
    $routes->group('switch', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'SwitchController::index');
      $routes->get('create', 'SwitchController::create_form');
      $routes->post('create', 'SwitchController::create');
      $routes->get('modify/(:alphanum)', 'SwitchController::modify_form/$1');
      $routes->post('modify/(:alphanum)', 'SwitchController::modify/$1');
      $routes->get('view/(:alphanum)', 'SwitchController::view/$1');
      $routes->get('delete/(:alphanum)', 'SwitchController::delete/$1');
      $routes->get('toggle/(:alphanum)/(:any)', 'SwitchController::toggle/$1/$2');
      $routes->post('batchjob', 'SwitchController::batchjob');
      $routes->post('batchjob_delete', 'SwitchController::batchjob_delete');
      $routes->get('download/(:alpha)', 'SwitchController::download/$1');
    });
    $routes->group('server', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'ServerController::index');
      $routes->get('create', 'ServerController::create_form');
      $routes->post('create', 'ServerController::create');
      $routes->get('modify/(:num)', 'ServerController::modify_form/$1');
      $routes->post('modify/(:num)', 'ServerController::modify/$1');
      $routes->get('view/(:num)', 'ServerController::view/$1');
      $routes->get('delete/(:num)', 'ServerController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'ServerController::toggle/$1/$2');
      $routes->post('batchjob', 'ServerController::batchjob');
      $routes->post('batchjob_delete', 'ServerController::batchjob_delete');
      $routes->get('download/(:alpha)', 'ServerController::download/$1');
    });
    $routes->group('line', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'LineController::index');
      $routes->get('create', 'LineController::create_form');
      $routes->post('create', 'LineController::create');
      $routes->get('modify/(:num)', 'LineController::modify_form/$1');
      $routes->post('modify/(:num)', 'LineController::modify/$1');
      $routes->get('view/(:num)', 'LineController::view/$1');
      $routes->get('delete/(:num)', 'LineController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'LineController::toggle/$1/$2');
      $routes->post('batchjob', 'LineController::batchjob');
      $routes->post('batchjob_delete', 'LineController::batchjob_delete');
      $routes->get('download/(:alpha)', 'LineController::download/$1');
    });
    $routes->group('ip', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'IpController::index');
      $routes->get('create', 'IpController::create_form');
      $routes->post('create', 'IpController::create');
      $routes->get('modify/(:num)', 'IpController::modify_form/$1');
      $routes->post('modify/(:num)', 'IpController::modify/$1');
      $routes->get('view/(:num)', 'IpController::view/$1');
      $routes->get('delete/(:num)', 'IpController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'IpController::toggle/$1/$2');
      $routes->post('batchjob', 'IpController::batchjob');
      $routes->post('batchjob_delete', 'IpController::batchjob_delete');
      $routes->get('download/(:alpha)', 'IpController::download/$1');
    });
    $routes->group('cs', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'CSController::index');
      $routes->get('create', 'CSController::create_form');
      $routes->post('create', 'CSController::create');
      $routes->get('modify/(:num)', 'CSController::modify_form/$1');
      $routes->post('modify/(:num)', 'CSController::modify/$1');
      $routes->get('view/(:num)', 'CSController::view/$1');
      $routes->get('delete/(:num)', 'CSController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'CSController::toggle/$1/$2');
      $routes->post('batchjob', 'CSController::batchjob');
      $routes->post('batchjob_delete', 'CSController::batchjob_delete');
      $routes->get('download/(:alpha)', 'CSController::download/$1');
    });
    $routes->group('part', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'PartController::index');
      $routes->get('create', 'PartController::create_form');
      $routes->post('create', 'PartController::create');
      $routes->get('modify/(:num)', 'PartController::modify_form/$1');
      $routes->post('modify/(:num)', 'PartController::modify/$1');
      $routes->get('view/(:num)', 'PartController::view/$1');
      $routes->get('delete/(:num)', 'PartController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'PartController::toggle/$1/$2');
      $routes->post('batchjob', 'PartController::batchjob');
      $routes->post('batchjob_delete', 'PartController::batchjob_delete');
      $routes->get('download/(:alpha)', 'PartController::download/$1');
    });
    $routes->group('cs', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'OnetimeController::index');
      $routes->get('create', 'OnetimeController::create_form');
      $routes->post('create', 'OnetimeController::create');
      $routes->get('modify/(:num)', 'OnetimeController::modify_form/$1');
      $routes->post('modify/(:num)', 'OnetimeController::modify/$1');
      $routes->get('view/(:num)', 'OnetimeController::view/$1');
      $routes->get('delete/(:num)', 'OnetimeController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'OnetimeController::toggle/$1/$2');
      $routes->post('batchjob', 'OnetimeController::batchjob');
      $routes->post('batchjob_delete', 'OnetimeController::batchjob_delete');
      $routes->get('download/(:alpha)', 'OnetimeController::download/$1');
    });
  });
  //Equipment 관련
});
