<?php

use App\Controllers\DashboardController;
use App\Controllers\ErrorController;
use App\Controllers\ClientController;
use App\Controllers\ArticleController;
use App\Controllers\MaintenanceController;
use App\Controllers\StockController;
use App\Controllers\DevisController;
use App\Controllers\BonLivraisonController;
use App\Controllers\FactureController;
use App\Controllers\EncaissementController;
use App\Controllers\DocumentController;
use App\Controllers\TarifClientController;
use App\Controllers\AvoirController;
use App\Controllers\ParametreController;
use App\Controllers\FournisseurController;
use App\Controllers\CommandeFournisseurController;
use App\Controllers\FactureFournisseurController;
use App\Controllers\UtilisateurController;
use App\Controllers\AuthController;
use App\Controllers\DocumentCenterController;
use App\Controllers\DocumentCycleController;
use App\Controllers\MailTemplateController;

/*************************************************
 * AUTHENTIFICATION
 *************************************************/

$router->get('login',AuthController::class,'login');
$router->post('login_store',AuthController::class,'authenticate');
$router->post('logout',AuthController::class,'logout');

$router->get('', DashboardController::class, 'index');
$router->get('dashboard', DashboardController::class, 'index');
$router->get('dashboard_commercial', DashboardController::class, 'commercial');
$router->get('document_cycle', DocumentCycleController::class, 'index');
$router->get('devis_analysis', DashboardController::class, 'devisAnalysis');
$router->get('factures_clients_suivi', DashboardController::class, 'facturesClients');
$router->get('articles_sales_analysis', DashboardController::class, 'articlesSalesAnalysis');
$router->get('clients_analysis', DashboardController::class, 'clientsAnalysis');
$router->get('commercial_actions', DashboardController::class, 'commercialActions');

$router->get('clients', ClientController::class, 'index');
$router->get('clients_create', ClientController::class, 'create');
$router->post('clients_store', ClientController::class, 'store');
$router->get('clients_show', ClientController::class, 'show');
$router->get('clients_edit', ClientController::class, 'edit');
$router->post('clients_update', ClientController::class, 'update');
$router->post('clients_deactivate', ClientController::class, 'deactivate');
$router->get('clients_import', ClientController::class, 'import');
$router->post('clients_import_preview', ClientController::class, 'importPreview');
$router->post('clients_import_execute', ClientController::class, 'importExecute');
$router->post('clients_tarifs_store', TarifClientController::class, 'store');
$router->post('clients_tarifs_delete', TarifClientController::class, 'delete');

$router->get('fournisseurs', FournisseurController::class, 'index');
$router->get('fournisseurs_create', FournisseurController::class, 'create');
$router->post('fournisseurs_store', FournisseurController::class, 'store');
$router->get('fournisseurs_show', FournisseurController::class, 'show');
$router->get('fournisseurs_edit', FournisseurController::class, 'edit');
$router->post('fournisseurs_update', FournisseurController::class, 'update');
$router->post('fournisseurs_deactivate', FournisseurController::class, 'deactivate');
$router->post('fournisseurs_activate', FournisseurController::class, 'activate');

$router->get('commandes_fournisseurs', CommandeFournisseurController::class, 'index');
$router->get('commandes_fournisseurs_dashboard', CommandeFournisseurController::class, 'dashboard');
$router->get('commandes_fournisseurs_finalisation', CommandeFournisseurController::class, 'finalisation');
$router->get('commandes_fournisseurs_historique', CommandeFournisseurController::class, 'historique');
$router->get('commandes_fournisseurs_analyse', CommandeFournisseurController::class, 'analyse');
$router->get('commandes_fournisseurs_create', CommandeFournisseurController::class, 'create');
$router->post('commandes_fournisseurs_store', CommandeFournisseurController::class, 'store');
$router->get('commandes_fournisseurs_show', CommandeFournisseurController::class, 'show');
$router->get('commandes_fournisseurs_edit', CommandeFournisseurController::class, 'edit');
$router->post('commandes_fournisseurs_update', CommandeFournisseurController::class, 'update');
$router->get('commandes_fournisseurs_receive', CommandeFournisseurController::class, 'receive');
$router->post('commandes_fournisseurs_receive_store', CommandeFournisseurController::class, 'storeReceive');
$router->get('receptions_fournisseurs', CommandeFournisseurController::class, 'receptions');
$router->post('receptions_fournisseurs_cancel', CommandeFournisseurController::class, 'cancelReception');
$router->post('commandes_fournisseurs_deactivate', CommandeFournisseurController::class, 'deactivate');
$router->post('commandes_fournisseurs_activate', CommandeFournisseurController::class, 'activate');

$router->get('factures_fournisseurs', FactureFournisseurController::class, 'index');
$router->get('factures_fournisseurs_dashboard', FactureFournisseurController::class, 'dashboard');
$router->get('factures_fournisseurs_finalisation', FactureFournisseurController::class, 'finalisation');
$router->get('factures_fournisseurs_echeancier', FactureFournisseurController::class, 'echeancier');
$router->get('factures_fournisseurs_create', FactureFournisseurController::class, 'createFromCommande');
$router->post('factures_fournisseurs_store', FactureFournisseurController::class, 'store');
$router->get('factures_fournisseurs_show', FactureFournisseurController::class, 'show');
$router->get('factures_fournisseurs_edit', FactureFournisseurController::class, 'edit');
$router->post('factures_fournisseurs_update', FactureFournisseurController::class, 'update');
$router->get('factures_fournisseurs_justificatif', FactureFournisseurController::class, 'justificatif');
$router->get('factures_fournisseurs_reglement', FactureFournisseurController::class, 'reglement');
$router->post('factures_fournisseurs_reglement_store', FactureFournisseurController::class, 'storeReglement');
$router->get('reglements_fournisseurs', FactureFournisseurController::class, 'reglements');
$router->post('reglements_fournisseurs_annuler', FactureFournisseurController::class, 'annulerReglement');
$router->post('factures_fournisseurs_deactivate', FactureFournisseurController::class, 'deactivate');
$router->post('factures_fournisseurs_reactivate', FactureFournisseurController::class, 'reactivate');

$router->get('articles', ArticleController::class, 'index');
$router->get('articles_create', ArticleController::class, 'create');
$router->post('articles_store', ArticleController::class, 'store');
$router->get('articles_edit', ArticleController::class, 'edit');
$router->post('articles_update', ArticleController::class, 'update');
$router->get('articles_duplicate', ArticleController::class, 'duplicate');
$router->post('articles_toggle_active', ArticleController::class, 'toggleActive');
$router->get('articles_achats', ArticleController::class, 'achats');
$router->post('articles_achats_update', ArticleController::class, 'updateAchats');
$router->get('articles_import', ArticleController::class, 'import');
$router->post('articles_import_preview', ArticleController::class, 'previewImport');
$router->post('articles_import_confirm', ArticleController::class, 'confirmImport');


$router->get('stock', StockController::class, 'index');
$router->get('stock_dashboard', StockController::class, 'dashboard');
$router->get('stock_finalisation', StockController::class, 'finalisation');
$router->get('stock_inventory', StockController::class, 'inventory');
$router->get('stock_valuation', StockController::class, 'valuation');
$router->post('stock_inventory_store', StockController::class, 'storeInventory');
$router->get('stock_inventory_show', StockController::class, 'inventoryShow');
$router->get('stock_show', StockController::class, 'show');
$router->get('stock_entry', StockController::class, 'entry');
$router->post('stock_store_entry', StockController::class, 'storeEntry');
$router->get('stock_adjust', StockController::class, 'adjust');
$router->get('stock_alerts', StockController::class, 'alerts');
$router->post('stock_minimum_store', StockController::class, 'storeMinimum');
$router->get('stock_history', StockController::class, 'history');
$router->post('stock_store_adjust', StockController::class, 'storeAdjust');


$router->get('devis', DevisController::class, 'index');
$router->get('devis_create', DevisController::class, 'create');
$router->post('devis_store', DevisController::class, 'store');
$router->get('devis_edit', DevisController::class, 'edit');
$router->post('devis_update', DevisController::class, 'update');
$router->get('devis_show', DevisController::class, 'show');
$router->get('devis_pdf', DevisController::class, 'pdf');
$router->post('devis_duplicate', DevisController::class, 'duplicate');
$router->post('devis_transform_bl', BonLivraisonController::class, 'createFromDevis');

$router->get('bons_livraison', BonLivraisonController::class, 'index');
$router->get('bons_livraison_show', BonLivraisonController::class, 'show');
$router->get('bons_livraison_pdf', BonLivraisonController::class, 'pdf');
$router->post('bons_livraison_mark_delivered', BonLivraisonController::class, 'markDelivered');

$router->get('factures', FactureController::class, 'index');
$router->get('factures_show', FactureController::class, 'show');
$router->get('factures_edit', FactureController::class, 'edit');
$router->get('factures_pdf', FactureController::class, 'pdf');
$router->post('factures_from_bl', FactureController::class, 'createFromBonLivraison');
$router->post('factures_from_devis', FactureController::class, 'createFromDevis');



$router->get('documents', DocumentController::class, 'index');
$router->get('documents_create', DocumentController::class, 'create');
$router->get('documents_sources', DocumentController::class, 'sources');
$router->post('documents_store', DocumentController::class, 'store');
$router->get('documents_show', DocumentController::class, 'show');
$router->get('documents_pdf', DocumentController::class, 'pdf');
$router->get('documents_edit', DocumentController::class, 'edit');
$router->post('documents_update', DocumentController::class, 'update');
$router->post('documents_transform', DocumentController::class, 'transform');


$router->get('avoirs', AvoirController::class, 'index');
$router->get('avoirs_create', AvoirController::class, 'create');
$router->get('avoirs_pdf', AvoirController::class, 'pdf');
$router->post('avoirs_store', AvoirController::class, 'store');

$router->get('encaissements', EncaissementController::class, 'index');
$router->get('encaissements_create', EncaissementController::class, 'create');
$router->post('encaissements_store', EncaissementController::class, 'store');
$router->get('encaissements_edit', EncaissementController::class, 'edit');
$router->post('encaissements_update', EncaissementController::class, 'update');
$router->post('encaissements_cancel', EncaissementController::class, 'cancel');
$router->get('encaissements_receipt', EncaissementController::class, 'receipt');
$router->get('encaissements_statement', EncaissementController::class, 'statement');
$router->get('encaissements_export', EncaissementController::class, 'exportCsv');

$router->get('maintenance', MaintenanceController::class, 'index');
$router->post('maintenance_backup', MaintenanceController::class, 'backup');
$router->get('maintenance_backup_download', MaintenanceController::class,'downloadBackup');
$router->post('maintenance_backup_delete', MaintenanceController::class, 'deleteBackup');
$router->post('maintenance_backup_restore', MaintenanceController::class, 'restoreBackup');

$router->post('maintenance_backup_complete',MaintenanceController::class,'completeBackup');

/*************************************************
 * UTILISATEURS
 *************************************************/

/*************************************************
 * UTILISATEURS
 *************************************************/

$router->get('utilisateurs',UtilisateurController::class,'index');
$router->get('utilisateurs_create',UtilisateurController::class,'create');
$router->post('utilisateurs_store',UtilisateurController::class,'store');
$router->get('utilisateurs_show',UtilisateurController::class,'show');
$router->get('utilisateurs_edit',UtilisateurController::class,'edit');
$router->post('utilisateurs_update',UtilisateurController::class,'update');
$router->get('utilisateurs_password',UtilisateurController::class,'password');
$router->post('utilisateurs_password_update',UtilisateurController::class,'updatePassword');
$router->post('utilisateurs_deactivate',UtilisateurController::class,'deactivate');

$router->get('parametres_societe', ParametreController::class, 'societe');
$router->post('parametres_societe_save', ParametreController::class, 'saveSociete');
$router->get('parametres_types_clients', ParametreController::class, 'typesClients');
$router->post('parametres_types_clients_store', ParametreController::class, 'storeTypeClient');
$router->post('parametres_types_clients_update', ParametreController::class, 'updateTypeClient');
$router->post('parametres_types_clients_delete', ParametreController::class, 'deleteTypeClient');
$router->get('parametres', ParametreController::class, 'index');
$router->get('parametres_familles_articles', ParametreController::class,'famillesArticles');
$router->post('parametres_familles_articles_store', ParametreController::class, 'storeFamilleArticle');
$router->post('parametres_familles_articles_update', ParametreController::class, 'updateFamilleArticle');
$router->post('parametres_familles_articles_delete', ParametreController::class, 'deleteFamilleArticle');

$router->get('parametres_marques_articles', ParametreController::class, 'marquesArticles');
$router->post('parametres_marques_articles_store', ParametreController::class, 'storeMarqueArticle');
$router->post('parametres_marques_articles_update', ParametreController::class, 'updateMarqueArticle');
$router->post('parametres_marques_articles_delete', ParametreController::class, 'deleteMarqueArticle');

$router->get('parametres_unites_articles', ParametreController::class, 'unitesArticles');
$router->post('parametres_unites_articles_store', ParametreController::class, 'storeUniteArticle');
$router->post('parametres_unites_articles_update', ParametreController::class, 'updateUniteArticle');
$router->post('parametres_unites_articles_delete', ParametreController::class, 'deleteUniteArticle');

$router->get('parametres_taux_tva', ParametreController::class, 'tauxTva');
$router->post('parametres_taux_tva_store', ParametreController::class, 'storeTauxTva');
$router->post('parametres_taux_tva_update', ParametreController::class, 'updateTauxTva');
$router->post('parametres_taux_tva_default', ParametreController::class, 'setDefaultTauxTva');
$router->post('parametres_taux_tva_delete', ParametreController::class, 'deleteTauxTva');

$router->get('parametres_modes_reglement',ParametreController::class,'modesReglement');
$router->post('parametres_modes_reglement_store',ParametreController::class,'storeModeReglement');
$router->post('parametres_modes_reglement_update',ParametreController::class,'updateModeReglement');
$router->post('parametres_modes_reglement_delete',ParametreController::class,'deleteModeReglement');

$router->get('parametres_numerotation',ParametreController::class,'numerotation');
$router->post('parametres_numerotation_update',ParametreController::class,'updateNumerotation');
$router->get('parametres_documents', ParametreController::class, 'documents');
$router->post('parametres_documents_save', ParametreController::class,'saveDocuments');
$router->post('parametres_documents_logo_delete',ParametreController::class,'removeDocumentLogo');

$router->get('maintenance_cleanup', MaintenanceController::class,'cleanup');
$router->post('maintenance_cleanup_run', MaintenanceController::class,'runCleanup');
$router->get('maintenance_logs', MaintenanceController::class, 'logs');
$router->post('maintenance_logs_clear', MaintenanceController::class, 'clearLog');
$router->get('maintenance_logs_download', MaintenanceController::class, 'downloadLog');
$router->get('maintenance_system', MaintenanceController::class, 'system');
$router->get('maintenance_version', MaintenanceController::class, 'version');


/*************************************************
 * DOCUMENT CENTER
 *************************************************/
$router->get('document_center_devis_prepare', DocumentCenterController::class, 'prepareDevis');
$router->post('document_center_devis_send', DocumentCenterController::class, 'sendDevis');
$router->get('parametres_mail_templates', MailTemplateController::class, 'index');
$router->post('parametres_mail_templates_save', MailTemplateController::class, 'save');

$router->get('404', ErrorController::class, 'notFound');
