<?php

use App\EntradaMateriales;
use App\Http\Controllers\ComunasController;
use App\PeticionMaterial;
use App\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

use App\Http\Controllers\PersonalController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Estas son las rutas para acceder a los controladores y sus metodos

//ruta para acceder al inicio
Route::get('/', function () {
    return view('auth.login');
});

Route::middleware('auth')->group(function() 
{
    Route::get('UserInfo', 'UserController@verInfo')->name('informacion');
    
    Route::resource('Comunas', 'ComunasController');
    Route::resource('EmpresasMatriz', 'EmpresasMatrizController');
    Route::resource('Personal', 'PersonalController');
    Route::resource('Usuarios', 'UserController');
    Route::resource('Proveedores', 'ProveedoresController');
    Route::resource('EmpresasProyectos', 'EmpresasProyectosController');
    Route::resource('EmpProyectos', 'EmpProyectosController');
    Route::resource('ContinuacionProyectos', 'ContinuacionProyectosController');
    Route::resource('Actividades', 'ActividadesController');
    Route::resource('Materiales', 'MaterialesController');
    Route::resource('EntradaMateriales', 'EntradaMaterialesController');
    Route::resource('Rebajes', 'RebajesController');
    Route::resource('DetallePeticion', 'DetallePeticionController');
    Route::resource('DetalleVentas', 'DetalleVentasController');
    Route::resource('Vacaciones', 'VacacionesController');
    Route::get('ContProy/{id}', 'ContinuacionProyectosController@create');

    //RUTAS PEDIR MATERIAL
    Route::post('/materialDePeticion', 'PeticionMaterialController@agregarMaterialPeticion')->name('agregarMaterialPeticion');
    Route::delete('/materialDePeticion', 'PeticionMaterialController@quitarMaterialDePeticion')->name('quitarMaterialDePeticion');
    Route::post('/terminarOCancelarPeticion', 'PeticionMaterialController@terminarOCancelarPeticion')->name('terminarOCancelarPeticion');
    Route::get('PeticionMaterial/create', 'PeticionMaterialController@indexPeticion')->name('peticion.index');
    Route::get('PeticionMaterial', 'PeticionMaterialController@index')->name('listaPeticiones');    
    Route::delete('PeticionMaterial/{id}', 'PeticionMaterialController@destroy');

    Route::get('detallePeticion/{id}', 'DetallePeticionController@mostrarDetalles');

    //RUTAS VENDER MATERIAL
    Route::post('/materialDeVenta', 'VentasController@agregarMaterialVenta')->name('agregarMaterialVenta');
    Route::delete('/materialDeVenta', 'VentasController@quitarMaterialDeVenta')->name('quitarMaterialDeVenta');
    Route::post('/terminarOCancelarVenta', 'VentasController@terminarOCancelarVenta')->name('terminarOCancelarVenta');
    Route::get('VentaMaterial/create', 'VentasController@indexVenta')->name('venta.index');
    Route::get('VentaMaterial', 'VentasController@index')->name('listaVentas');
    
    Route::get('detalleVenta/{id}', 'DetalleVentasController@mostrarDetalles');
    
    //RUTAS REPORTES Y CONTRATOS
    Route::get('ReportePersonales', 'PersonalController@imprimir');
    Route::get('ReporteContratoPersonal/{id}', 'PersonalController@imprimirContrato');
    Route::get('CreateFiniquito/{id}', 'PersonalController@createFiniquito');
    Route::get('ContratoAdministrativoCP/{id}', 'PersonalController@contratoAdminCP');
    Route::get('ContratoAdministrativoSP/{id}', 'PersonalController@contratoAdminSP');
    Route::get('ContratoExtranjeroDefinitiva/{id}', 'PersonalController@contratoExtranjeroDefinitiva');
    Route::get('ContratoExtranjeroVisaSujeta/{id}', 'PersonalController@contratoExtranjeroVisaSujeta');

    //RUTA IMPRIMIR BARCODE
    Route::get('CodigoBarras/{id}', 'MaterialesController@imprimirBarcode');

    //LiveSearch Routes
    Route::get('/SearchConProy', 'ContinuacionProyectosController@search');
    Route::get('/SearchEmpMat', 'EmpresasMatrizController@search');
    Route::get('/SearchEmpProy', 'EmpresasProyectosController@search');
    Route::get('/SearchEmpresaProy', 'EmpProyectosController@search');
    Route::get('/SearchEntMat', 'EntradaMaterialesController@search');
    Route::get('/SearchProv', 'ProveedoresController@search');
    Route::get('/SearchMate', 'MaterialesController@search');
    Route::get('/SearchPetMat','PeticionMaterialController@search');
    Route::get('/SearchDetPet', 'DetallePeticionController@search');
    Route::get('/SearchRebaje', 'RebajesController@search');
    Route::get('/SearchDetVent', 'DetalleVentasController@search');
    Route::get('/SearchVenta', 'VentasController@search');
    Route::get('/SearchVacaciones', 'VacacionesController@search');
    Route::get('/SearchUser', 'UserController@search');

    Route::get('/home', 'HomeController@index')->name('home');//Ruta home despues de loguear
});

Auth::routes(['reset'=>false]);






