<?php

/**
 * Procurement workspace routes (Phase 1 + Phase 2).
 * @var \CodeIgniter\Router\RouteCollection $routes
 */

$routes->group('procurement', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\ProcurementDashboardController::index', ['filter' => 'permission:procurement.view']);
});

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

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

$routes->group('procurement/purchase-requests', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\PurchaseRequestController::index', ['filter' => 'permission:purchase_requests.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\PurchaseRequestController::createForm', ['filter' => 'permission:purchase_requests.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\PurchaseRequestController::store', ['filter' => 'permission:purchase_requests.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\PurchaseRequestController::editForm/$1', ['filter' => 'permission:purchase_requests.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\PurchaseRequestController::update/$1', ['filter' => 'permission:purchase_requests.edit']);
    $routes->post('(:num)/submit', '\Modules\Procurement\Controllers\PurchaseRequestController::submit/$1', ['filter' => 'permission:purchase_requests.edit']);
    $routes->post('(:num)/approve', '\Modules\Procurement\Controllers\PurchaseRequestController::approve/$1', ['filter' => 'permission:purchase_requests.approve']);
    $routes->post('(:num)/reject', '\Modules\Procurement\Controllers\PurchaseRequestController::reject/$1', ['filter' => 'permission:purchase_requests.approve']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\PurchaseRequestController::cancel/$1', ['filter' => 'permission:purchase_requests.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\PurchaseRequestController::destroy/$1', ['filter' => 'permission:purchase_requests.delete']);
});

$routes->group('procurement/rfqs', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\RfqController::index', ['filter' => 'permission:rfqs.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\RfqController::createForm', ['filter' => 'permission:rfqs.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\RfqController::store', ['filter' => 'permission:rfqs.create']);
    $routes->post('from-request/(:num)', '\Modules\Procurement\Controllers\RfqController::fromRequest/$1', ['filter' => 'permission:rfqs.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\RfqController::editForm/$1', ['filter' => 'permission:rfqs.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\RfqController::update/$1', ['filter' => 'permission:rfqs.edit']);
    $routes->post('(:num)/submit', '\Modules\Procurement\Controllers\RfqController::submit/$1', ['filter' => 'permission:rfqs.edit']);
    $routes->post('(:num)/approve', '\Modules\Procurement\Controllers\RfqController::approve/$1', ['filter' => 'permission:rfqs.approve']);
    $routes->post('(:num)/reject', '\Modules\Procurement\Controllers\RfqController::reject/$1', ['filter' => 'permission:rfqs.approve']);
    $routes->post('(:num)/mark-sent', '\Modules\Procurement\Controllers\RfqController::markSent/$1', ['filter' => 'permission:rfqs.edit']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\RfqController::cancel/$1', ['filter' => 'permission:rfqs.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\RfqController::destroy/$1', ['filter' => 'permission:rfqs.delete']);
});

$routes->group('procurement/supplier-quotations', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\SupplierQuotationController::index', ['filter' => 'permission:supplier_quotations.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\SupplierQuotationController::createForm', ['filter' => 'permission:supplier_quotations.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\SupplierQuotationController::store', ['filter' => 'permission:supplier_quotations.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\SupplierQuotationController::editForm/$1', ['filter' => 'permission:supplier_quotations.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\SupplierQuotationController::update/$1', ['filter' => 'permission:supplier_quotations.edit']);
    $routes->post('(:num)/submit', '\Modules\Procurement\Controllers\SupplierQuotationController::submit/$1', ['filter' => 'permission:supplier_quotations.edit']);
    $routes->post('(:num)/approve', '\Modules\Procurement\Controllers\SupplierQuotationController::approve/$1', ['filter' => 'permission:supplier_quotations.approve']);
    $routes->post('(:num)/reject', '\Modules\Procurement\Controllers\SupplierQuotationController::reject/$1', ['filter' => 'permission:supplier_quotations.approve']);
    $routes->post('(:num)/convert', '\Modules\Procurement\Controllers\SupplierQuotationController::convert/$1', ['filter' => 'permission:supplier_quotations.edit']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\SupplierQuotationController::cancel/$1', ['filter' => 'permission:supplier_quotations.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\SupplierQuotationController::destroy/$1', ['filter' => 'permission:supplier_quotations.delete']);
});

$routes->group('procurement/purchase-orders', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\PurchaseOrderController::index', ['filter' => 'permission:purchase_orders.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\PurchaseOrderController::createForm', ['filter' => 'permission:purchase_orders.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\PurchaseOrderController::store', ['filter' => 'permission:purchase_orders.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\PurchaseOrderController::editForm/$1', ['filter' => 'permission:purchase_orders.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\PurchaseOrderController::update/$1', ['filter' => 'permission:purchase_orders.edit']);
    $routes->post('(:num)/submit', '\Modules\Procurement\Controllers\PurchaseOrderController::submit/$1', ['filter' => 'permission:purchase_orders.edit']);
    $routes->post('(:num)/approve', '\Modules\Procurement\Controllers\PurchaseOrderController::approve/$1', ['filter' => 'permission:purchase_orders.approve']);
    $routes->post('(:num)/reject', '\Modules\Procurement\Controllers\PurchaseOrderController::reject/$1', ['filter' => 'permission:purchase_orders.approve']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\PurchaseOrderController::cancel/$1', ['filter' => 'permission:purchase_orders.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\PurchaseOrderController::destroy/$1', ['filter' => 'permission:purchase_orders.delete']);
});

$routes->group('procurement/goods-receipts', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\GoodsReceiptController::index', ['filter' => 'permission:goods_receipts.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\GoodsReceiptController::createForm', ['filter' => 'permission:goods_receipts.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\GoodsReceiptController::store', ['filter' => 'permission:goods_receipts.create']);
    $routes->post('from-order/(:num)', '\Modules\Procurement\Controllers\GoodsReceiptController::fromOrder/$1', ['filter' => 'permission:goods_receipts.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\GoodsReceiptController::editForm/$1', ['filter' => 'permission:goods_receipts.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\GoodsReceiptController::update/$1', ['filter' => 'permission:goods_receipts.edit']);
    $routes->post('(:num)/post', '\Modules\Procurement\Controllers\GoodsReceiptController::post/$1', ['filter' => 'permission:goods_receipts.edit']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\GoodsReceiptController::cancel/$1', ['filter' => 'permission:goods_receipts.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\GoodsReceiptController::destroy/$1', ['filter' => 'permission:goods_receipts.delete']);
});

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

$routes->group('procurement/vendor-bills', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\VendorBillController::index', ['filter' => 'permission:vendor_bills.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\VendorBillController::createForm', ['filter' => 'permission:vendor_bills.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\VendorBillController::store', ['filter' => 'permission:vendor_bills.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\VendorBillController::editForm/$1', ['filter' => 'permission:vendor_bills.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\VendorBillController::update/$1', ['filter' => 'permission:vendor_bills.edit']);
    $routes->post('(:num)/issue', '\Modules\Procurement\Controllers\VendorBillController::issue/$1', ['filter' => 'permission:vendor_bills.edit']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\VendorBillController::cancel/$1', ['filter' => 'permission:vendor_bills.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\VendorBillController::destroy/$1', ['filter' => 'permission:vendor_bills.delete']);
});

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

$routes->group('procurement/supplier-contracts', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\SupplierContractController::index', ['filter' => 'permission:supplier_contracts.view']);
    $routes->get('create', '\Modules\Procurement\Controllers\SupplierContractController::createForm', ['filter' => 'permission:supplier_contracts.create']);
    $routes->post('/', '\Modules\Procurement\Controllers\SupplierContractController::store', ['filter' => 'permission:supplier_contracts.create']);
    $routes->get('(:num)/edit', '\Modules\Procurement\Controllers\SupplierContractController::editForm/$1', ['filter' => 'permission:supplier_contracts.edit']);
    $routes->post('(:num)', '\Modules\Procurement\Controllers\SupplierContractController::update/$1', ['filter' => 'permission:supplier_contracts.edit']);
    $routes->post('(:num)/activate', '\Modules\Procurement\Controllers\SupplierContractController::activate/$1', ['filter' => 'permission:supplier_contracts.edit']);
    $routes->post('(:num)/terminate', '\Modules\Procurement\Controllers\SupplierContractController::terminate/$1', ['filter' => 'permission:supplier_contracts.edit']);
    $routes->post('(:num)/cancel', '\Modules\Procurement\Controllers\SupplierContractController::cancel/$1', ['filter' => 'permission:supplier_contracts.edit']);
    $routes->post('(:num)/delete', '\Modules\Procurement\Controllers\SupplierContractController::destroy/$1', ['filter' => 'permission:supplier_contracts.delete']);
});

$routes->group('procurement/approval-queue', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\ApprovalQueueController::index', ['filter' => 'permission:procurement.approve']);
    $routes->post('approve', '\Modules\Procurement\Controllers\ApprovalQueueController::approve', ['filter' => 'permission:procurement.approve']);
    $routes->post('reject', '\Modules\Procurement\Controllers\ApprovalQueueController::reject', ['filter' => 'permission:procurement.approve']);
});

$routes->group('procurement/reports', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Procurement\Controllers\ProcurementReportController::index', ['filter' => 'permission:procurement.reports']);
});
