<?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('invoice', 'Invoice::execute');
  $routes->group('migration', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
    $routes->group('primeidc', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
      $routes->cli('client', 'PrimeidcSource::client');
      $routes->cli('line', 'PrimeidcSource::line');
      $routes->cli('servercode', 'PrimeidcSource::servercode');
      $routes->cli('switchcode', 'PrimeidcSource::switchcode');
    });
    $routes->group('itsolution', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
      $routes->cli('client', 'ItsolutionSource::client');
      $routes->cli('line', 'ItsolutionSource::line');
      $routes->cli('servercode', 'ItsolutionSource::servercode');
      $routes->cli('switchcode', 'ItsolutionSource::switchcode');
    });
    $routes->group('gdidc', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
      $routes->cli('client', 'GdidcSource::client');
      $routes->cli('line', 'GdidcSource::line');
      $routes->cli('servercode', 'GdidcSource::servercode');
      $routes->cli('switchcode', 'GdidcSource::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::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->group('user', function ($routes) {
    $routes->get('/', 'UserController::index');
    $routes->get('create', 'UserController::create_form');
    $routes->post('create', 'UserController::create');
    $routes->get('modify/(:num)', 'UserController::modify_form/$1');
    $routes->post('modify/(:num)', 'UserController::modify/$1');
    $routes->get('view/(:num)', 'UserController::view/$1');
    $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');
  });
  $routes->group('mylog', function ($routes) {
    $routes->get('/', 'MylogController::index');
    $routes->get('create', 'MylogController::create_form');
    $routes->post('create', 'MylogController::create');
    $routes->get('modify/(:num)', 'MylogController::modify_form/$1');
    $routes->post('modify/(:num)', 'MylogController::modify/$1');
    $routes->get('view/(:num)', 'MylogController::view/$1');
    $routes->get('delete/(:num)', 'MylogController::delete/$1');
    $routes->get('toggle/(:num)/(:any)', 'MylogController::toggle/$1/$2');
    $routes->post('batchjob', 'MylogController::batchjob');
    $routes->post('batchjob_delete', 'MylogController::batchjob_delete');
    $routes->get('download/(:alpha)', 'MylogController::download/$1');
  });
  $routes->group('search', function ($routes) {
    $routes->get('/', 'SearchController::index');
  });
  $routes->group('board', 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('latest/(:alpha)', 'BoardController::latest/$1');
  });
  $routes->group('payment', function ($routes) {
    $routes->get('/', 'PaymentController::index');
    $routes->get('onetime', 'PaymentController::onetime_form');
    $routes->post('onetime', 'PaymentController::create');
    $routes->get('prepayment', 'PaymentController::prepayment_form');
    $routes->post('prepayment', 'PaymentController::create');
    $routes->get('coupon', 'PaymentController::coupon_form');
    $routes->post('coupon', 'PaymentController::create');
    $routes->get('point', 'PaymentController::point_form');
    $routes->post('point', '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');
    $routes->get('paid/(:num)', 'PaymentController::paid/$1');
  });
  //Customer 관련
  $routes->group('customer', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
    $routes->group('client', 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('service', 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::alternative_create_form/$1');
      $routes->post('addServer/(:num)', 'ServiceController::alternative_create/$1');
      $routes->get('changeServer/(:num)', 'ServiceController::alternative_modify/$1');
      $routes->get('terminateServer/(:num)', 'ServiceController::alternative_delete/$1');
      $routes->post('history/(:num)', 'ServiceController::history/$1');
      $routes->post('billingat/(:num)', 'ServiceController::billingat/$1');
    });
    $routes->group('wallet', ['namespace' => 'App\Controllers\Admin\Customer\Wallet'], function ($routes) {
      $routes->group('account', 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', 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', 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');
      });
    });
  });
  //Customer 관련
  //Equipment 관련
  $routes->group('equipment', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
    $routes->group('line', 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', 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->get('console/(:num)', 'ServerController::console/$1');
    });
    $routes->group('serverpart', 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');
    });
    $routes->group('chassis', function ($routes) {
      $routes->get('/', 'CHASSISController::index');
      $routes->get('create', 'CHASSISController::create_form');
      $routes->post('create', 'CHASSISController::create');
      $routes->get('modify/(:num)', 'CHASSISController::modify_form/$1');
      $routes->post('modify/(:num)', 'CHASSISController::modify/$1');
      $routes->get('view/(:num)', 'CHASSISController::view/$1');
      $routes->get('delete/(:num)', 'CHASSISController::delete/$1');
      $routes->get('toggle/(:num)/(:any)', 'CHASSISController::toggle/$1/$2');
      $routes->post('batchjob', 'CHASSISController::batchjob');
      $routes->post('batchjob_delete', 'CHASSISController::batchjob_delete');
      $routes->get('download/(:alpha)', 'CHASSISController::download/$1');
    });
  });
  //Equipment 관련
  //Part 관련
  $routes->group('part', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
    $routes->group('switch', 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', 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', 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', 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', 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', 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', 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 관련
});
