<?php

use App\Http\Controllers\ChoferController;
use App\Http\Controllers\CuentaBancariaController;
use App\Http\Controllers\DeudaController;
use App\Http\Controllers\InicioController;
use App\Http\Controllers\ItemController;
use App\Http\Controllers\MantenimientoController;
use App\Http\Controllers\MarcasController;
use App\Http\Controllers\ModelosController;
use App\Http\Controllers\PagosController;
use App\Http\Controllers\ParametrosController;
use App\Http\Controllers\SocioController;
use App\Http\Controllers\SuspencionesController;
use App\Http\Controllers\VehiculoController;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Route;

Route::get('/', [InicioController::class, 'Index']); //->name('login');

Route::get('/password/reset', [InicioController::class, 'IndexRecuperaClave']); //->name('login');
Route::get('/crearsocio', [SocioController::class, 'CrearSocioIndex'])->name('admin.crearsocio');
Route::get('/socio/cargarExcel', [SocioController::class, 'CargarSocioIndex'])->name('socio.cargarExcel');
Route::post('/grabarSocioExcel', [SocioController::class, 'GrabarSocioExcelIndex']);

//VEHICULOS
Route::get('/mantenimiento', [VehiculoController::class, 'Mantenimiento'])->name('mantenimiento');
Route::post('/admin/crearvehiculo', [VehiculoController::class, 'CreateVehiculo']);

Route::post('/admin/listarModelos', [VehiculoController::class, 'CargarModelos']);
Route::post('/admin/listarModelosCatalogo', [VehiculoController::class, 'CargarModelosPorDetCatalogo']);
Route::get('/buscarVehiculos', [VehiculoController::class, 'ConsultarVehiculos'])->name('buscarVehiculos');
Route::get('/buscarSocios', [SocioController::class, 'ConsultarChoferes'])->name('buscarSocios');
Route::get('/informeVehiculos', [VehiculoController::class, 'InformeVehiculoIndex'])->name('informeVehiculos');
Route::post('/consultaInfoVehi', [VehiculoController::class, 'ConsultaInformeVehiculos']);
Route::get('create-pdf-Vehiculos', [VehiculoController::class, 'VehiculosVerPdf']);

//CHOFER
Route::post('/api/crearChofer', [VehiculoController::class, 'crearChofer']);

//MARCAS
Route::get('/mantenimientoMarcas', [MarcasController::class, 'MantenimientoMarcas'])->name('mantenimientoMarcas');
Route::get('/listarMarcas', [MarcasController::class, 'listarMarcas'])->name('listarMarcas');
Route::get('/vehiculo/CargarMarcas', [MarcasController::class, 'CargarMarcas'])->name('/vehiculo/CargarMarcas');
Route::post('/admin/createMarcas', [MarcasController::class, 'crearMarcas']);

//MODELOS
Route::get('/mantenimientoModelos', [ModelosController::class, 'MantenimientoModelos'])->name('mantenimientoModelos');
Route::get('/listarModelos', [ModelosController::class, 'listarModelos'])->name('listarModelos');
Route::post('/admin/createModelos', [ModelosController::class, 'crearModelos']);

//ITEMA
Route::get('/mantenimientoServicios', [ItemController::class, 'MantenimientoServicios'])->name('mantenimientoServicios');
Route::get('/mantenimientoRepuestos', [ItemController::class, 'MantenimientoRepuestos'])->name('mantenimientoRepuestos');
Route::post('/admin/crearItems', [ItemController::class, 'crearItems']);
Route::get('/listarServicios', [ItemController::class, 'listarItemsServicios'])->name('listarServicios');
Route::get('/listarReparacion', [ItemController::class, 'listarItemsReparacion'])->name('listarReparacion');

Route::post('/mantenimiento/crearsocio', [SocioController::class, 'CreateSocio']);
Route::post('/mantenimiento/crearUsuario', [SocioController::class, 'GrabaUsuario']);
Route::get('/mantenimiento/listarUsuarios', [SocioController::class, 'ListarUsuarios']);
Route::get('/socios/listaSociosActivos', [SocioController::class, 'MuestraSociosActivo']);
Route::get('/socios/listaSociosTodos', [SocioController::class, 'MuestraTodosSocios']);
Route::get('/admin/crearUsuario', [SocioController::class, 'CrearUsuarioIndex'])->name('crearusuario');

Route::get('/cuentaBancaria', [CuentaBancariaController::class, 'CrearCuentaIndex'])->name('cuentaBancaria');
Route::post('/admin/createcuenta', [CuentaBancariaController::class, 'CrearCuentaBancaria']);
Route::get('/listarCuentas', [CuentaBancariaController::class, 'ListarCuentas'])->name('listarCuentas');

Route::get('/parametros', [ParametrosController::class, 'ParametrosIndex'])->name('parametros');
Route::get('/informe', [SocioController::class, 'InformeSocioIndex'])->name('informe');
Route::post('/admin/crearparametros', [ParametrosController::class, 'ModificarParametros']);
Route::post('/admin/consultaSocio', [SocioController::class, 'ConsultaInformeSocio']);

//RUTAS PARA VISUALIZAR ARCHIVOS SOCIOS Y VEHICULOS
Route::get('/mostrarArchivo/{idarchivo}/{tipodoc}', [SocioController::class, 'VerPdfSocios'])->name('mostrarArchivo');
Route::get('/mostrarArchivoVehiculo/{idarchivo}/{tipodoc}', [VehiculoController::class, 'VerPdfVehiculos'])->name('mostrarArchivoVehiculo');


Route::get('/pagopdf/{idpago}/{iddeuda}', [PagosController::class, 'PagosPdf'])->name('pagopdf');
Route::get('/create-pdf-deuda', [DeudaController::class, 'DeudaPdf']);
Route::get('/create-pdf-pagos', [PagosController::class, 'InfPagosPdf']);
// Route::get('/Reimpresion-pdf-pago', [DeudaController::class, 'ReimpresionDocumentosPdf']); 

Route::get('create-pdf-socio', [SocioController::class, 'SocioVerPdf']);
//DEUDAD
Route::get('/deuda', [DeudaController::class, 'Index']);
Route::get('/deudas', [DeudaController::class, 'IndexMantenimientoDeuda'])->name('deudas');
Route::get('/consultarRubrosActivos', [DeudaController::class, 'ConsultarRubrosActivos'])->name('consultarRubrosActivos');
Route::post('/deudas/GrabarDeuda', [DeudaController::class, 'GrabarDeuda']);
Route::get('/deudas/consultarDeudas', [DeudaController::class, 'ConsultarDeudas'])->name('/deudas/consultarDeudas');
Route::post('/deudas/consultarSociosDeudas', [DeudaController::class, 'ConsultarSociosDeudas']);
Route::post('/deudas/consultarRubrosDeudas', [DeudaController::class, 'ConsultarRubrosDeudas']);
Route::post('/deudas/procesarSociosCuotas', [DeudaController::class, 'procesarSociosCuotas']);
Route::post('/deudas/ReimpresionDocumento', [DeudaController::class, 'BuscaExistenciaDocumento']);
Route::get('/reimprecion/{tipodoc}/{numerodoc}', [DeudaController::class, 'ReimpresionDocumentosPdf'])->name('reimprecion');
Route::get('/tablamortizacion/{numerodoc}', [DeudaController::class, 'BuscarTablaMortizacion'])->name('tablamortizacion');
Route::post('/deudas/exitedocumento', [DeudaController::class, 'ExisteDocumento']);
Route::get('/deudas/ConsultarFactSocios', [DeudaController::class, 'ConsultarFactSocios'])->name('/deudas/ConsultarFactSocios');
//PAGOS
Route::get('/pagos', [PagosController::class, 'IndexMantenimientoPagos'])->name('pagos');
Route::get('/Informe-Deudas', [DeudaController::class, 'InfDeudaIndex'])->name('admin.infdeuda');
Route::get('/Re-impresion', [DeudaController::class, 'ReimpresionIndex'])->name('admin.reimpresion');
Route::get('/Tabla-Amortizacion', [DeudaController::class, 'TablaMortizacionIndex'])->name('admin.tablamortiza');
Route::get('/Informe-Pagos', [PagosController::class, 'InfPagoIndex'])->name('admin.infpagos');
Route::get('/Index-Suspenciones', [SuspencionesController::class, 'IndexSuspenciones'])->name('admin.suspenciones');
Route::get('/Index-Mantenimiento', [MantenimientoController::class, 'IndexMantenimiento'])->name('admin.mantenimiento');
Route::get('/Index-Asignaciones', [MantenimientoController::class, 'IndexAsignaciones'])->name('admin.asignaciones');

Route::get('/pagos/consultarSocios', [PagosController::class, 'ConsultarSocios'])->name('/pagos/consultarSocios');
Route::get('/generarmotrizacion/{numerodoc}', [DeudaController::class, 'BuscarTablaMortizacion'])->name('generarmotrizacion');
//Route::post('/consultarFacturasSocios', [PagosController::class, 'ConsultarFacturasSocios']); 
Route::get('/consultarFacturasSocios', [PagosController::class, 'ConsultarFacturasSocios'])->name('consultarFacturasSocios');
Route::post('/pagos/consultarCuotasSocios', [PagosController::class, 'ConsultarCuotasSocios']);
Route::post('/pagos/procesarPagoSocio', [PagosController::class, 'ProcesarPagoSocio']);
Route::post('/pagos/RegistrarDatosBancarios', [PagosController::class, 'RegistrarDatosBancarios']);
Route::post('/deudas/buscarinformes', [DeudaController::class, 'BuscarInformeDeuda']);
Route::post('/pagos/buscarinformes', [PagosController::class, 'BuscarInformePagos']);
Route::post('/mantenimiento/buscarinformes', [MantenimientoController::class, 'BucaListaMantenimiento']);
Route::post('/asignacion/buscarinformes', [MantenimientoController::class, 'BuscaAsignaciones']);
Route::get('image/{filename}', [ParametrosController::class, 'displayImage'])->name('image.displayImage');

//bancos
Route::post('/bancos/CrearBancos', [CuentaBancariaController::class, 'CrearBancos']);
Route::get('/bancos/ListarBancos', [CuentaBancariaController::class, 'ListarBancos'])->name('/bancos/ListarBancos');

Route::get('/suspeciones/listasuspenciones', [SuspencionesController::class, 'ListarSuspenciones'])->name('/suspeciones/listasuspenciones');
//PDF REPORTES
Route::get('/pdf-recibopdf/{id_factura}', [DeudaController::class, 'ReciboPdf']);

Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
    Route::get('/home', [InicioController::class, 'Index'])->name('home');
});
Route::get('/buscarMortizacionGet/{numerodoc}', [DeudaController::class, 'BuscarTablaMortizacionInformacion'])->name('buscarMortizacionGet');


Route::get('/key-generate', function () {
    Artisan::call('key:generate');
    return "Application key set successfully.";
});

Route::get('/config-cache', function () {
    Artisan::call('config:cache');
    return "Configuration cache cleared!";
});

Route::get('/cache-clear', function () {
    Artisan::call('cache:clear');
    return "Application cache cleared!";
});
