<?php

namespace Config;

// Create a new instance of our RouteCollection class.
$routes = Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . "Config/Routes.php")) {
    require SYSTEMPATH . "Config/Routes.php";
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace("App\Controllers");
$routes->setDefaultController("Home");
$routes->setDefaultMethod("index");
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(false);

/*
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get("/", "Home::index");
$routes->get("landing_1", "Home::landing1");
$routes->get("landing_2", "Home::landing2");
$routes->get("landing_3", "Home::landing3");
$routes->get("landing_4", "Home::landing4");
$routes->get("landing_5", "Home::landing5");
$routes->get("landing_6", "Home::landing6");
$routes->get("logo-design-india", "Home::logoDesignIndia");
$routes->get("logo-redesign-india", "Home::logoRedesignIndia");
$routes->get("logo-redesign-scorecard", "Home::logoRedesignScorecard");
$routes->get("brand-guide", "BrandGuide::index");
$routes->get("brand-guide/(:segment)", "BrandGuide::show/$1");
$routes->get("industries", "IndustryPages::industries");
$routes->get("logo-design-for-(:segment)", "IndustryPages::show/$1");
$routes->get("sitemap", "IndustryPages::directory");
$routes->get("sitemap.xml", "IndustryPages::sitemap");
$routes->post("leads", "LeadController::store");

$routes->match(["get", "post"], "admin/setup", "Admin::setup");
$routes->match(["get", "post"], "admin/login", "Admin::login");
$routes->get("admin", "Admin::index");
$routes->group("admin", ["filter" => "adminauth"], function ($routes) {
    $routes->post("logout", "Admin::logout");
    $routes->get("leads", "Admin::leads");
    $routes->post("leads/(:num)/status", "Admin::updateLeadStatus/$1");
    $routes->get("clients", "Clients::index");
    $routes->match(["get", "post"], "clients/new", "Clients::create");
    $routes->get("clients/(:num)", "Clients::show/$1");
    $routes->match(["get", "post"], "clients/(:num)/edit", "Clients::edit/$1");
    $routes->post("clients/(:num)/delete", "Clients::delete/$1");
    $routes->get("quotations", "Quotations::index");
    $routes->match(["get", "post"], "quotations/new", "Quotations::create");
    $routes->get("quotations/(:num)", "Quotations::show/$1");
    $routes->match(
        ["get", "post"],
        "quotations/(:num)/edit",
        "Quotations::edit/$1",
    );
    $routes->get("quotations/(:num)/download", "Quotations::download/$1");
    $routes->post("quotations/(:num)/email-pdf", "Quotations::emailPdf/$1");
    $routes->post("quotations/(:num)/email", "Quotations::emailQuotation/$1");
    $routes->post("quotations/(:num)/delete", "Quotations::delete/$1");
    $routes->get("invoices", "Invoices::index");
    $routes->match(["get", "post"], "invoices/new", "Invoices::create");
    $routes->get("invoices/(:num)", "Invoices::show/$1");
    $routes->match(
        ["get", "post"],
        "invoices/(:num)/edit",
        "Invoices::edit/$1",
    );
    $routes->get("invoices/(:num)/download", "Invoices::download/$1");
    $routes->post("invoices/(:num)/email-pdf", "Invoices::emailPdf/$1");
    $routes->post("invoices/(:num)/email", "Invoices::emailInvoice/$1");
    $routes->post("invoices/(:num)/delete", "Invoices::delete/$1");
    $routes->get("industries", "Industries::index");
    $routes->match(["get", "post"], "industries/new", "Industries::create");
    $routes->get("industries/(:num)", "Industries::show/$1");
    $routes->match(
        ["get", "post"],
        "industries/(:num)/edit",
        "Industries::edit/$1",
    );
    $routes->get("articles", "Articles::index");
    $routes->match(["get", "post"], "articles/new", "Articles::create");
    $routes->get("articles/(:num)", "Articles::show/$1");
    $routes->match(
        ["get", "post"],
        "articles/(:num)/edit",
        "Articles::edit/$1",
    );
    $routes->post("articles/(:num)/delete", "Articles::delete/$1");
    $routes->get("email-templates", "EmailTemplates::index");
    $routes->match(
        ["get", "post"],
        "email-templates/(:segment)",
        "EmailTemplates::edit/$1",
    );
    $routes->get(
        "email-templates/(:segment)/preview",
        "EmailTemplates::preview/$1",
    );
    $routes->post(
        "email-templates/(:segment)/reset",
        "EmailTemplates::reset/$1",
    );
    $routes->match(["get", "post"], "settings", "Admin::settings");
});

/*
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH . "Config/" . ENVIRONMENT . "/Routes.php")) {
    require APPPATH . "Config/" . ENVIRONMENT . "/Routes.php";
}
