<?php

/**
 * Sale module routes (Sales & CRM workspace).
 * @var \CodeIgniter\Router\RouteCollection $routes
 */
$routes->group('sale', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\SaleDashboardController::index', ['filter' => 'permission:sale.view']);
});

$routes->group('sale/leads', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\LeadController::index', ['filter' => 'permission:leads.view']);
    $routes->get('create', '\Modules\Sale\Controllers\LeadController::createForm', ['filter' => 'permission:leads.create']);
    $routes->post('/', '\Modules\Sale\Controllers\LeadController::store', ['filter' => 'permission:leads.create']);
    $routes->get('(:num)', '\Modules\Sale\Controllers\LeadController::show/$1', ['filter' => 'permission:leads.view']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\LeadController::editForm/$1', ['filter' => 'permission:leads.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\LeadController::update/$1', ['filter' => 'permission:leads.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\LeadController::destroy/$1', ['filter' => 'permission:leads.delete']);
});

$routes->group('sale/lead-sources', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\LeadSourceController::index', ['filter' => 'permission:lead_sources.view']);
    $routes->get('create', '\Modules\Sale\Controllers\LeadSourceController::createForm', ['filter' => 'permission:lead_sources.create']);
    $routes->post('/', '\Modules\Sale\Controllers\LeadSourceController::store', ['filter' => 'permission:lead_sources.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\LeadSourceController::editForm/$1', ['filter' => 'permission:lead_sources.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\LeadSourceController::update/$1', ['filter' => 'permission:lead_sources.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\LeadSourceController::activate/$1', ['filter' => 'permission:lead_sources.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\LeadSourceController::deactivate/$1', ['filter' => 'permission:lead_sources.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\LeadSourceController::destroy/$1', ['filter' => 'permission:lead_sources.delete']);
});

$routes->group('sale/lead-assignment', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\LeadAssignmentController::index', ['filter' => 'permission:lead_assignment.view']);
    $routes->get('create', '\Modules\Sale\Controllers\LeadAssignmentController::createForm', ['filter' => 'permission:lead_assignment.edit']);
    $routes->post('/', '\Modules\Sale\Controllers\LeadAssignmentController::store', ['filter' => 'permission:lead_assignment.edit']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\LeadAssignmentController::editForm/$1', ['filter' => 'permission:lead_assignment.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\LeadAssignmentController::update/$1', ['filter' => 'permission:lead_assignment.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\LeadAssignmentController::activate/$1', ['filter' => 'permission:lead_assignment.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\LeadAssignmentController::deactivate/$1', ['filter' => 'permission:lead_assignment.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\LeadAssignmentController::destroy/$1', ['filter' => 'permission:lead_assignment.edit']);
    $routes->post('assign-unassigned', '\Modules\Sale\Controllers\LeadAssignmentController::assignUnassigned', ['filter' => 'permission:lead_assignment.edit']);
});

$routes->group('sale/lead-scoring', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\LeadScoringController::index', ['filter' => 'permission:lead_scoring.view']);
    $routes->get('create', '\Modules\Sale\Controllers\LeadScoringController::createForm', ['filter' => 'permission:lead_scoring.create']);
    $routes->post('/', '\Modules\Sale\Controllers\LeadScoringController::store', ['filter' => 'permission:lead_scoring.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\LeadScoringController::editForm/$1', ['filter' => 'permission:lead_scoring.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\LeadScoringController::update/$1', ['filter' => 'permission:lead_scoring.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\LeadScoringController::activate/$1', ['filter' => 'permission:lead_scoring.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\LeadScoringController::deactivate/$1', ['filter' => 'permission:lead_scoring.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\LeadScoringController::destroy/$1', ['filter' => 'permission:lead_scoring.delete']);
    $routes->post('recalculate', '\Modules\Sale\Controllers\LeadScoringController::recalculate', ['filter' => 'permission:lead_scoring.edit']);
});

$routes->group('sale/lead-conversion', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\LeadConversionController::index', ['filter' => 'permission:lead_conversion.view']);
    $routes->post('(:num)/convert', '\Modules\Sale\Controllers\LeadConversionController::convert/$1', ['filter' => 'permission:lead_conversion.convert']);
});

$routes->group('sale/companies', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CompanyController::index', ['filter' => 'permission:companies.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CompanyController::createForm', ['filter' => 'permission:companies.view']);
    $routes->get('(:num)', '\Modules\Sale\Controllers\CompanyController::show/$1', ['filter' => 'permission:companies.view']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\CompanyController::editForm/$1', ['filter' => 'permission:companies.view']);
});

$routes->group('sale/contacts', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\ContactController::index', ['filter' => 'permission:contacts.view']);
    $routes->get('create', '\Modules\Sale\Controllers\ContactController::createForm', ['filter' => 'permission:contacts.create']);
    $routes->post('/', '\Modules\Sale\Controllers\ContactController::store', ['filter' => 'permission:contacts.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\ContactController::editForm/$1', ['filter' => 'permission:contacts.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\ContactController::update/$1', ['filter' => 'permission:contacts.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\ContactController::activate/$1', ['filter' => 'permission:contacts.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\ContactController::deactivate/$1', ['filter' => 'permission:contacts.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\ContactController::destroy/$1', ['filter' => 'permission:contacts.delete']);
});

$routes->group('sale/customer-groups', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CustomerGroupController::index', ['filter' => 'permission:customer_groups.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CustomerGroupController::createForm', ['filter' => 'permission:customer_groups.create']);
    $routes->post('/', '\Modules\Sale\Controllers\CustomerGroupController::store', ['filter' => 'permission:customer_groups.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\CustomerGroupController::editForm/$1', ['filter' => 'permission:customer_groups.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\CustomerGroupController::update/$1', ['filter' => 'permission:customer_groups.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\CustomerGroupController::activate/$1', ['filter' => 'permission:customer_groups.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\CustomerGroupController::deactivate/$1', ['filter' => 'permission:customer_groups.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\CustomerGroupController::destroy/$1', ['filter' => 'permission:customer_groups.delete']);
});

$routes->group('sale/customer-history', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CustomerHistoryController::index', ['filter' => 'permission:customer_history.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CustomerHistoryController::createForm', ['filter' => 'permission:customer_history.create']);
    $routes->post('/', '\Modules\Sale\Controllers\CustomerHistoryController::store', ['filter' => 'permission:customer_history.create']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\CustomerHistoryController::destroy/$1', ['filter' => 'permission:customer_history.delete']);
});

$routes->group('sale/customer-documents', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CustomerDocumentController::index', ['filter' => 'permission:customer_documents.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CustomerDocumentController::createForm', ['filter' => 'permission:customer_documents.create']);
    $routes->post('/', '\Modules\Sale\Controllers\CustomerDocumentController::store', ['filter' => 'permission:customer_documents.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\CustomerDocumentController::editForm/$1', ['filter' => 'permission:customer_documents.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\CustomerDocumentController::update/$1', ['filter' => 'permission:customer_documents.edit']);
    $routes->post('(:num)/archive', '\Modules\Sale\Controllers\CustomerDocumentController::archive/$1', ['filter' => 'permission:customer_documents.edit']);
    $routes->post('(:num)/restore', '\Modules\Sale\Controllers\CustomerDocumentController::restore/$1', ['filter' => 'permission:customer_documents.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\CustomerDocumentController::destroy/$1', ['filter' => 'permission:customer_documents.delete']);
});

$routes->group('sale/opportunities', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\OpportunityController::index', ['filter' => 'permission:opportunities.view']);
    $routes->get('create', '\Modules\Sale\Controllers\OpportunityController::createForm', ['filter' => 'permission:opportunities.create']);
    $routes->post('/', '\Modules\Sale\Controllers\OpportunityController::store', ['filter' => 'permission:opportunities.create']);
    $routes->get('(:num)', '\Modules\Sale\Controllers\OpportunityController::show/$1', ['filter' => 'permission:opportunities.view']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\OpportunityController::editForm/$1', ['filter' => 'permission:opportunities.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\OpportunityController::update/$1', ['filter' => 'permission:opportunities.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\OpportunityController::destroy/$1', ['filter' => 'permission:opportunities.delete']);
});

$routes->group('sale/sales-stages', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\SalesStageController::index', ['filter' => 'permission:sales_stages.view']);
    $routes->get('create', '\Modules\Sale\Controllers\SalesStageController::createForm', ['filter' => 'permission:sales_stages.create']);
    $routes->post('/', '\Modules\Sale\Controllers\SalesStageController::store', ['filter' => 'permission:sales_stages.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\SalesStageController::editForm/$1', ['filter' => 'permission:sales_stages.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\SalesStageController::update/$1', ['filter' => 'permission:sales_stages.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\SalesStageController::activate/$1', ['filter' => 'permission:sales_stages.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\SalesStageController::deactivate/$1', ['filter' => 'permission:sales_stages.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\SalesStageController::destroy/$1', ['filter' => 'permission:sales_stages.delete']);
});

$routes->group('sale/expected-revenue', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\ExpectedRevenueController::index', ['filter' => 'permission:expected_revenue.view']);
});

$routes->group('sale/probability', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\ProbabilityController::index', ['filter' => 'permission:probability.view']);
    $routes->post('(:num)/update-probability', '\Modules\Sale\Controllers\ProbabilityController::updateProbability/$1', ['filter' => 'permission:probability.edit']);
});

$routes->group('sale/competitors', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CompetitorController::index', ['filter' => 'permission:competitors.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CompetitorController::createForm', ['filter' => 'permission:competitors.create']);
    $routes->post('/', '\Modules\Sale\Controllers\CompetitorController::store', ['filter' => 'permission:competitors.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\CompetitorController::editForm/$1', ['filter' => 'permission:competitors.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\CompetitorController::update/$1', ['filter' => 'permission:competitors.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\CompetitorController::activate/$1', ['filter' => 'permission:competitors.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\CompetitorController::deactivate/$1', ['filter' => 'permission:competitors.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\CompetitorController::destroy/$1', ['filter' => 'permission:competitors.delete']);
});

$routes->group('sale/calls', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CallController::index', ['filter' => 'permission:calls.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CallController::createForm', ['filter' => 'permission:calls.create']);
    $routes->post('/', '\Modules\Sale\Controllers\CallController::store', ['filter' => 'permission:calls.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\CallController::editForm/$1', ['filter' => 'permission:calls.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\CallController::update/$1', ['filter' => 'permission:calls.edit']);
    $routes->post('(:num)/complete', '\Modules\Sale\Controllers\CallController::complete/$1', ['filter' => 'permission:calls.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\CallController::cancel/$1', ['filter' => 'permission:calls.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\CallController::destroy/$1', ['filter' => 'permission:calls.delete']);
});

$routes->group('sale/emails', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\EmailController::index', ['filter' => 'permission:emails.view']);
    $routes->get('create', '\Modules\Sale\Controllers\EmailController::createForm', ['filter' => 'permission:emails.create']);
    $routes->post('/', '\Modules\Sale\Controllers\EmailController::store', ['filter' => 'permission:emails.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\EmailController::editForm/$1', ['filter' => 'permission:emails.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\EmailController::update/$1', ['filter' => 'permission:emails.edit']);
    $routes->post('(:num)/complete', '\Modules\Sale\Controllers\EmailController::complete/$1', ['filter' => 'permission:emails.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\EmailController::cancel/$1', ['filter' => 'permission:emails.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\EmailController::destroy/$1', ['filter' => 'permission:emails.delete']);
});

$routes->group('sale/meetings', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\MeetingController::index', ['filter' => 'permission:meetings.view']);
    $routes->get('create', '\Modules\Sale\Controllers\MeetingController::createForm', ['filter' => 'permission:meetings.create']);
    $routes->post('/', '\Modules\Sale\Controllers\MeetingController::store', ['filter' => 'permission:meetings.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\MeetingController::editForm/$1', ['filter' => 'permission:meetings.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\MeetingController::update/$1', ['filter' => 'permission:meetings.edit']);
    $routes->post('(:num)/complete', '\Modules\Sale\Controllers\MeetingController::complete/$1', ['filter' => 'permission:meetings.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\MeetingController::cancel/$1', ['filter' => 'permission:meetings.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\MeetingController::destroy/$1', ['filter' => 'permission:meetings.delete']);
});

$routes->group('sale/tasks', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\TaskController::index', ['filter' => 'permission:tasks.view']);
    $routes->get('create', '\Modules\Sale\Controllers\TaskController::createForm', ['filter' => 'permission:tasks.create']);
    $routes->post('/', '\Modules\Sale\Controllers\TaskController::store', ['filter' => 'permission:tasks.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\TaskController::editForm/$1', ['filter' => 'permission:tasks.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\TaskController::update/$1', ['filter' => 'permission:tasks.edit']);
    $routes->post('(:num)/complete', '\Modules\Sale\Controllers\TaskController::complete/$1', ['filter' => 'permission:tasks.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\TaskController::cancel/$1', ['filter' => 'permission:tasks.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\TaskController::destroy/$1', ['filter' => 'permission:tasks.delete']);
});

$routes->group('sale/follow-ups', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\FollowUpController::index', ['filter' => 'permission:follow_ups.view']);
    $routes->get('create', '\Modules\Sale\Controllers\FollowUpController::createForm', ['filter' => 'permission:follow_ups.create']);
    $routes->post('/', '\Modules\Sale\Controllers\FollowUpController::store', ['filter' => 'permission:follow_ups.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\FollowUpController::editForm/$1', ['filter' => 'permission:follow_ups.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\FollowUpController::update/$1', ['filter' => 'permission:follow_ups.edit']);
    $routes->post('(:num)/complete', '\Modules\Sale\Controllers\FollowUpController::complete/$1', ['filter' => 'permission:follow_ups.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\FollowUpController::cancel/$1', ['filter' => 'permission:follow_ups.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\FollowUpController::destroy/$1', ['filter' => 'permission:follow_ups.delete']);
});

// Quotations
$routes->group('sale/quotations', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\QuotationController::index', ['filter' => 'permission:quotations.view']);
    $routes->get('create', '\Modules\Sale\Controllers\QuotationController::createForm', ['filter' => 'permission:quotations.create']);
    $routes->post('/', '\Modules\Sale\Controllers\QuotationController::store', ['filter' => 'permission:quotations.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\QuotationController::editForm/$1', ['filter' => 'permission:quotations.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\QuotationController::update/$1', ['filter' => 'permission:quotations.edit']);
    $routes->post('(:num)/submit', '\Modules\Sale\Controllers\QuotationController::submit/$1', ['filter' => 'permission:quotations.edit']);
    $routes->post('(:num)/mark-sent', '\Modules\Sale\Controllers\QuotationController::markSent/$1', ['filter' => 'permission:quotations.edit']);
    $routes->post('(:num)/convert', '\Modules\Sale\Controllers\QuotationController::convert/$1', ['filter' => 'permission:sales_orders.create']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\QuotationController::cancel/$1', ['filter' => 'permission:quotations.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\QuotationController::destroy/$1', ['filter' => 'permission:quotations.delete']);
});

$routes->group('sale/quotation-approval', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\QuotationApprovalController::index', ['filter' => 'permission:quotations.approve']);
    $routes->post('(:num)/approve', '\Modules\Sale\Controllers\QuotationApprovalController::approve/$1', ['filter' => 'permission:quotations.approve']);
    $routes->post('(:num)/reject', '\Modules\Sale\Controllers\QuotationApprovalController::reject/$1', ['filter' => 'permission:quotations.approve']);
});

$routes->group('sale/price-lists', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\PriceListController::index', ['filter' => 'permission:price_lists.view']);
    $routes->get('create', '\Modules\Sale\Controllers\PriceListController::createForm', ['filter' => 'permission:price_lists.create']);
    $routes->post('/', '\Modules\Sale\Controllers\PriceListController::store', ['filter' => 'permission:price_lists.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\PriceListController::editForm/$1', ['filter' => 'permission:price_lists.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\PriceListController::update/$1', ['filter' => 'permission:price_lists.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\PriceListController::activate/$1', ['filter' => 'permission:price_lists.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\PriceListController::deactivate/$1', ['filter' => 'permission:price_lists.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\PriceListController::destroy/$1', ['filter' => 'permission:price_lists.delete']);
});

$routes->group('sale/quotation-templates', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\QuotationTemplateController::index', ['filter' => 'permission:quotation_templates.view']);
    $routes->get('create', '\Modules\Sale\Controllers\QuotationTemplateController::createForm', ['filter' => 'permission:quotation_templates.create']);
    $routes->post('/', '\Modules\Sale\Controllers\QuotationTemplateController::store', ['filter' => 'permission:quotation_templates.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\QuotationTemplateController::editForm/$1', ['filter' => 'permission:quotation_templates.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\QuotationTemplateController::update/$1', ['filter' => 'permission:quotation_templates.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\QuotationTemplateController::activate/$1', ['filter' => 'permission:quotation_templates.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\QuotationTemplateController::deactivate/$1', ['filter' => 'permission:quotation_templates.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\QuotationTemplateController::destroy/$1', ['filter' => 'permission:quotation_templates.delete']);
});

// Sales Orders
$routes->group('sale/orders', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\SalesOrderController::index', ['filter' => 'permission:sales_orders.view']);
    $routes->get('create', '\Modules\Sale\Controllers\SalesOrderController::createForm', ['filter' => 'permission:sales_orders.create']);
    $routes->post('/', '\Modules\Sale\Controllers\SalesOrderController::store', ['filter' => 'permission:sales_orders.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\SalesOrderController::editForm/$1', ['filter' => 'permission:sales_orders.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\SalesOrderController::update/$1', ['filter' => 'permission:sales_orders.edit']);
    $routes->post('(:num)/submit', '\Modules\Sale\Controllers\SalesOrderController::submit/$1', ['filter' => 'permission:sales_orders.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\SalesOrderController::destroy/$1', ['filter' => 'permission:sales_orders.delete']);
});

$routes->group('sale/order-approval', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\OrderApprovalController::index', ['filter' => 'permission:sales_orders.approve']);
    $routes->post('(:num)/approve', '\Modules\Sale\Controllers\OrderApprovalController::approve/$1', ['filter' => 'permission:sales_orders.approve']);
    $routes->post('(:num)/reject', '\Modules\Sale\Controllers\OrderApprovalController::reject/$1', ['filter' => 'permission:sales_orders.approve']);
});

$routes->group('sale/order-tracking', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\OrderTrackingController::index', ['filter' => 'permission:sales_orders.view']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\OrderTrackingController::update/$1', ['filter' => 'permission:sales_orders.edit']);
});

// Deliveries
$routes->group('sale/delivery-notes', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\DeliveryNoteController::index', ['filter' => 'permission:deliveries.view']);
    $routes->get('create', '\Modules\Sale\Controllers\DeliveryNoteController::createForm', ['filter' => 'permission:deliveries.create']);
    $routes->post('/', '\Modules\Sale\Controllers\DeliveryNoteController::store', ['filter' => 'permission:deliveries.create']);
    $routes->post('from-order/(:num)', '\Modules\Sale\Controllers\DeliveryNoteController::createFromOrder/$1', ['filter' => 'permission:deliveries.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\DeliveryNoteController::editForm/$1', ['filter' => 'permission:deliveries.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\DeliveryNoteController::update/$1', ['filter' => 'permission:deliveries.edit']);
    $routes->post('(:num)/ready', '\Modules\Sale\Controllers\DeliveryNoteController::markReady/$1', ['filter' => 'permission:deliveries.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\DeliveryNoteController::destroy/$1', ['filter' => 'permission:deliveries.delete']);
});

$routes->group('sale/dispatch', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\DispatchController::index', ['filter' => 'permission:deliveries.dispatch']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\DispatchController::dispatch/$1', ['filter' => 'permission:deliveries.dispatch']);
});

$routes->group('sale/delivery-tracking', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\DeliveryTrackingController::index', ['filter' => 'permission:deliveries.view']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\DeliveryTrackingController::update/$1', ['filter' => 'permission:deliveries.edit']);
});

// Invoices
$routes->group('sale/invoices', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\InvoiceController::index', ['filter' => 'permission:invoices.view']);
    $routes->get('create', '\Modules\Sale\Controllers\InvoiceController::createForm', ['filter' => 'permission:invoices.create']);
    $routes->post('/', '\Modules\Sale\Controllers\InvoiceController::store', ['filter' => 'permission:invoices.create']);
    $routes->post('from-order/(:num)', '\Modules\Sale\Controllers\InvoiceController::createFromOrder/$1', ['filter' => 'permission:invoices.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\InvoiceController::editForm/$1', ['filter' => 'permission:invoices.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\InvoiceController::update/$1', ['filter' => 'permission:invoices.edit']);
    $routes->post('(:num)/issue', '\Modules\Sale\Controllers\InvoiceController::issue/$1', ['filter' => 'permission:invoices.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\InvoiceController::cancel/$1', ['filter' => 'permission:invoices.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\InvoiceController::destroy/$1', ['filter' => 'permission:invoices.delete']);
});

$routes->group('sale/payment-status', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\PaymentStatusController::index', ['filter' => 'permission:invoices.view']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\PaymentStatusController::update/$1', ['filter' => 'permission:invoices.edit']);
});

$routes->group('sale/outstanding-payments', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\OutstandingPaymentController::index', ['filter' => 'permission:invoices.view']);
});

// Returns
$routes->group('sale/sales-returns', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\SalesReturnController::index', ['filter' => 'permission:sales_returns.view']);
    $routes->get('create', '\Modules\Sale\Controllers\SalesReturnController::createForm', ['filter' => 'permission:sales_returns.create']);
    $routes->post('/', '\Modules\Sale\Controllers\SalesReturnController::store', ['filter' => 'permission:sales_returns.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\SalesReturnController::editForm/$1', ['filter' => 'permission:sales_returns.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\SalesReturnController::update/$1', ['filter' => 'permission:sales_returns.edit']);
    $routes->post('(:num)/submit', '\Modules\Sale\Controllers\SalesReturnController::submit/$1', ['filter' => 'permission:sales_returns.edit']);
    $routes->post('(:num)/approve', '\Modules\Sale\Controllers\SalesReturnController::approve/$1', ['filter' => 'permission:sales_returns.edit']);
    $routes->post('(:num)/complete', '\Modules\Sale\Controllers\SalesReturnController::complete/$1', ['filter' => 'permission:sales_returns.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\SalesReturnController::cancel/$1', ['filter' => 'permission:sales_returns.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\SalesReturnController::destroy/$1', ['filter' => 'permission:sales_returns.delete']);
});

$routes->group('sale/refunds', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\RefundController::index', ['filter' => 'permission:refunds.view']);
    $routes->get('create', '\Modules\Sale\Controllers\RefundController::createForm', ['filter' => 'permission:refunds.create']);
    $routes->post('/', '\Modules\Sale\Controllers\RefundController::store', ['filter' => 'permission:refunds.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\RefundController::editForm/$1', ['filter' => 'permission:refunds.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\RefundController::update/$1', ['filter' => 'permission:refunds.edit']);
    $routes->post('(:num)/submit', '\Modules\Sale\Controllers\RefundController::submit/$1', ['filter' => 'permission:refunds.edit']);
    $routes->post('(:num)/process', '\Modules\Sale\Controllers\RefundController::process/$1', ['filter' => 'permission:refunds.edit']);
    $routes->post('(:num)/cancel', '\Modules\Sale\Controllers\RefundController::cancel/$1', ['filter' => 'permission:refunds.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\RefundController::destroy/$1', ['filter' => 'permission:refunds.delete']);
});

// Sales Team
$routes->group('sale/sales-representatives', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\SalesRepresentativeController::index', ['filter' => 'permission:sales_team.view']);
    $routes->get('create', '\Modules\Sale\Controllers\SalesRepresentativeController::createForm', ['filter' => 'permission:sales_team.create']);
    $routes->post('/', '\Modules\Sale\Controllers\SalesRepresentativeController::store', ['filter' => 'permission:sales_team.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\SalesRepresentativeController::editForm/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\SalesRepresentativeController::update/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\SalesRepresentativeController::activate/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\SalesRepresentativeController::deactivate/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\SalesRepresentativeController::destroy/$1', ['filter' => 'permission:sales_team.delete']);
});

$routes->group('sale/targets', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\TargetController::index', ['filter' => 'permission:sales_team.view']);
    $routes->get('create', '\Modules\Sale\Controllers\TargetController::createForm', ['filter' => 'permission:sales_team.create']);
    $routes->post('/', '\Modules\Sale\Controllers\TargetController::store', ['filter' => 'permission:sales_team.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\TargetController::editForm/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\TargetController::update/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\TargetController::destroy/$1', ['filter' => 'permission:sales_team.delete']);
});

$routes->group('sale/commissions', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\CommissionController::index', ['filter' => 'permission:sales_team.view']);
    $routes->get('create', '\Modules\Sale\Controllers\CommissionController::createForm', ['filter' => 'permission:sales_team.create']);
    $routes->post('/', '\Modules\Sale\Controllers\CommissionController::store', ['filter' => 'permission:sales_team.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\CommissionController::editForm/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\CommissionController::update/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/approve', '\Modules\Sale\Controllers\CommissionController::approve/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/mark-paid', '\Modules\Sale\Controllers\CommissionController::markPaid/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\CommissionController::destroy/$1', ['filter' => 'permission:sales_team.delete']);
});

$routes->group('sale/territories', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Sale\Controllers\TerritoryController::index', ['filter' => 'permission:sales_team.view']);
    $routes->get('create', '\Modules\Sale\Controllers\TerritoryController::createForm', ['filter' => 'permission:sales_team.create']);
    $routes->post('/', '\Modules\Sale\Controllers\TerritoryController::store', ['filter' => 'permission:sales_team.create']);
    $routes->get('(:num)/edit', '\Modules\Sale\Controllers\TerritoryController::editForm/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)', '\Modules\Sale\Controllers\TerritoryController::update/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/activate', '\Modules\Sale\Controllers\TerritoryController::activate/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Sale\Controllers\TerritoryController::deactivate/$1', ['filter' => 'permission:sales_team.edit']);
    $routes->post('(:num)/delete', '\Modules\Sale\Controllers\TerritoryController::destroy/$1', ['filter' => 'permission:sales_team.delete']);
});

// Reports
$routes->group('sale/reports', ['filter' => 'auth'], static function ($routes) {
    $routes->get('sales-performance', '\Modules\Sale\Controllers\SaleReportController::salesPerformance', ['filter' => 'permission:sale_reports.view']);
    $routes->get('lead-conversion', '\Modules\Sale\Controllers\SaleReportController::leadConversion', ['filter' => 'permission:sale_reports.view']);
    $routes->get('revenue-forecast', '\Modules\Sale\Controllers\SaleReportController::revenueForecast', ['filter' => 'permission:sale_reports.view']);
    $routes->get('customer-analysis', '\Modules\Sale\Controllers\SaleReportController::customerAnalysis', ['filter' => 'permission:sale_reports.view']);
    $routes->get('sales-reports', '\Modules\Sale\Controllers\SaleReportController::salesReports', ['filter' => 'permission:sale_reports.view']);
});
