<?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->cli('partcode', 'SourceDB::partcode');
  });
});
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
  $routes->get('/', 'Home::index');
  $routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) {
    $routes->get('login', 'LocalController::login_form');
    $routes->post('login', 'LocalController::login');
    $routes->get('google_login', 'GoogleController::login');
    $routes->get('logout', 'LocalController::logout');
  });
});
//Admin 관련
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
  $routes->get('/', 'Home::index');
  $routes->get('/search', 'SearchController::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/(:num)', 'UserController::profile_form/$1', ['filter' => 'authFilter:manager']);
    $routes->post('profile/(:num)', 'UserController::profile/$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');
  });
  $routes->group('board', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
    $routes->get('/', 'BoardController::index');
    $routes->get('create', 'BoardController::create_form');
    $routes->post('create', 'BoardController::create');
    $routes->get('modify/(:num)', 'BoardController::modify_form/$1');
    $routes->post('modify/(:num)', 'BoardController::modify/$1');
    $routes->get('view/(:num)', 'BoardController::view/$1');
    $routes->get('delete/(:num)', 'BoardController::delete/$1');
    $routes->get('toggle/(:num)/(:any)', 'BoardController::toggle/$1/$2');
    $routes->post('batchjob', 'BoardController::batchjob');
    $routes->post('batchjob_delete', 'BoardController::batchjob_delete');
    $routes->get('download/(:alpha)', 'BoardController::download/$1');
    $routes->get('notice', 'BoardController::notice');
    $routes->get('reqeusttask', 'BoardController::reqeusttask');
  });
  //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->get('detail/(:num)', 'ClientController::detail/$1');
      $routes->post('history/(:num)', 'ClientController::history/$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->get('addServer/(:num)', 'ServiceController::addServer_form/$1');
      $routes->post('addServer/(:num)', 'ServiceController::addServer/$1');
      $routes->get('changeServer/(:num)', 'ServiceController::changeServer/$1');
      $routes->get('terminateServer/(:num)', 'ServiceController::terminateServer/$1');
      $routes->post('history/(:num)', 'ServiceController::history/$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('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('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)', 'ServerPartController::download/$1');
    });
    $routes->group('serverpart', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
      $routes->get('/', 'ServerPartController::index');
      $routes->get('create', 'ServerPartController::create_form');
      $routes->post('create', 'ServerPartController::create');
      $routes->get('modify/(:num)', 'ServerPartController::modify_form/$1');
      $routes->post('modify/(:num)', 'ServerPartController::modify/$1');
      $routes->get('view/(:num)', 'ServerPartController::view/$1');
      $routes->get('delete/(:num)', 'ServerPartController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'ServerPartController::toggle/$1/$2');
      $routes->post('batchjob', 'ServerPartController::batchjob');
      $routes->post('batchjob_delete', 'ServerPartController::batchjob_delete');
      $routes->get('download/(:alpha)', 'ServerPartController::download/$1');
    });
  });
  //Equipment 관련
  //Part 관련
  $routes->group('part', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
    $routes->group('switch', ['namespace' => 'App\Controllers\Admin\Part'], 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('ip', ['namespace' => 'App\Controllers\Admin\Part'], 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\Part'], 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('cpu', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
      $routes->get('/', 'CPUController::index');
      $routes->get('create', 'CPUController::create_form');
      $routes->post('create', 'CPUController::create');
      $routes->get('modify/(:num)', 'CPUController::modify_form/$1');
      $routes->post('modify/(:num)', 'CPUController::modify/$1');
      $routes->get('view/(:num)', 'CPUController::view/$1');
      $routes->get('delete/(:num)', 'CPUController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'CPUController::toggle/$1/$2');
      $routes->post('batchjob', 'CPUController::batchjob');
      $routes->post('batchjob_delete', 'CPUController::batchjob_delete');
      $routes->get('download/(:alpha)', 'CPUController::download/$1');
    });
    $routes->group('ram', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
      $routes->get('/', 'RAMController::index');
      $routes->get('create', 'RAMController::create_form');
      $routes->post('create', 'RAMController::create');
      $routes->get('modify/(:num)', 'RAMController::modify_form/$1');
      $routes->post('modify/(:num)', 'RAMController::modify/$1');
      $routes->get('view/(:num)', 'RAMController::view/$1');
      $routes->get('delete/(:num)', 'RAMController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'RAMController::toggle/$1/$2');
      $routes->post('batchjob', 'RAMController::batchjob');
      $routes->post('batchjob_delete', 'RAMController::batchjob_delete');
      $routes->get('download/(:alpha)', 'RAMController::download/$1');
    });
    $routes->group('disk', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
      $routes->get('/', 'DISKController::index');
      $routes->get('create', 'DISKController::create_form');
      $routes->post('create', 'DISKController::create');
      $routes->get('modify/(:num)', 'DISKController::modify_form/$1');
      $routes->post('modify/(:num)', 'DISKController::modify/$1');
      $routes->get('view/(:num)', 'DISKController::view/$1');
      $routes->get('delete/(:num)', 'DISKController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'DISKController::toggle/$1/$2');
      $routes->post('batchjob', 'DISKController::batchjob');
      $routes->post('batchjob_delete', 'DISKController::batchjob_delete');
      $routes->get('download/(:alpha)', 'DISKController::download/$1');
      $routes->get('complete/(:num)', 'DISKController::complete/$1');
    });
    $routes->group('software', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
      $routes->get('/', 'SOFTWAREController::index');
      $routes->get('create', 'SOFTWAREController::create_form');
      $routes->post('create', 'SOFTWAREController::create');
      $routes->get('modify/(:num)', 'SOFTWAREController::modify_form/$1');
      $routes->post('modify/(:num)', 'SOFTWAREController::modify/$1');
      $routes->get('view/(:num)', 'SOFTWAREController::view/$1');
      $routes->get('delete/(:num)', 'SOFTWAREController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'SOFTWAREController::toggle/$1/$2');
      $routes->post('batchjob', 'SOFTWAREController::batchjob');
      $routes->post('batchjob_delete', 'SOFTWAREController::batchjob_delete');
      $routes->get('download/(:alpha)', 'SOFTWAREController::download/$1');
    });
  });
  //Part 관련
});
