86 lines
		
	
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| use Illuminate\Support\Facades\Route;
 | |
| use Symfony\Component\HttpKernel\Exception\HttpException;
 | |
| /*
 | |
| |--------------------------------------------------------------------------
 | |
| | 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!
 | |
| |
 | |
| */
 | |
| 
 | |
| if (App::environment('production')) {
 | |
|     URL::forceScheme('https');
 | |
| }
 | |
| 
 | |
| Route::get('/', 'ProductoController@index')->name('productos');
 | |
| 
 | |
| Auth::routes(['register' => false]);
 | |
| 
 | |
| Route::get('/productos', 'ProductoController@index')->name('productos.index');
 | |
| 
 | |
| Route::get('/admin', 'AdminController@show')->name('admin_login.show');
 | |
| 
 | |
| Route::get('/admin/obtener_sesion', function() {
 | |
|     $sesion = [
 | |
|         'gdc' => session("admin_gdc")
 | |
|     ];
 | |
|     return $sesion;
 | |
| })->name('admin_obtener_sesion');
 | |
| 
 | |
| Route::middleware(['auth', 'admin'])->group( function () {
 | |
| 	Route::get('/admin/pedidos', 'AdminController@index')->name('admin_login.index');
 | |
| 
 | |
| 	Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPlanillasAPdf');
 | |
| 
 | |
| 	Route::get('/admin/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV');
 | |
| 
 | |
| 	Route::get('/admin/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV');
 | |
| });
 | |
| 
 | |
| Route::middleware('auth')->group( function() {
 | |
| 
 | |
| 	Route::name('subpedidos.')->prefix("subpedidos")->group( function() {
 | |
| 		Route::get('/', function() {
 | |
| 			return view('subpedidos_create');
 | |
| 		})->name('create');
 | |
| 
 | |
| 		Route::post('guardar_sesion', function() {
 | |
| 			$r = request();
 | |
| 			if (!isset($r["subpedido"])) {
 | |
| 	            throw new HttpException(400, "La request necesita un subpedido para guardar en sesión");
 | |
| 	        }
 | |
|             if (!isset($r["grupo_de_compra_id"])) {
 | |
|                 throw new HttpException(400, "La request necesita un grupo de compra para guardar en sesión");
 | |
|             }
 | |
| 	        session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
 | |
| 	        session(["subpedido_id" => $r["subpedido"]["id"]]);
 | |
| 	        session(["gdc" => $r["grupo_de_compra_id"]]);
 | |
| 	        return "Subpedido guardado en sesión";
 | |
| 		})->name('guardarSesion');
 | |
| 
 | |
| 		Route::get('obtener_sesion', function() {
 | |
| 			$sesion = [
 | |
| 				'subpedido' => [
 | |
| 					'nombre' => session("subpedido_nombre"),
 | |
| 					'id' => session("subpedido_id")
 | |
| 				],
 | |
|                 'gdc' => session("gdc")
 | |
| 			];
 | |
| 	        return $sesion;
 | |
| 		})->name('obtenerSesion');
 | |
| 	});
 | |
| });
 | |
| 
 | |
| Route::get('/compras', 'ComprasController@show')->name('compras_login.show');
 | |
| 
 | |
| Route::middleware(['compras'])->group( function() {
 | |
|     Route::get('/compras/pedidos', 'ComprasController@indexPedidos')->name('compras.pedidos');
 | |
|     Route::get('/compras/pedidos/descargar', 'ComprasController@descargarPedidos')->name('compras.pedidos.descargar');
 | |
|     Route::get('/compras/pedidos/notas', 'ComprasController@descargarNotas')->name('compras.pedidos.descargar');
 | |
|     Route::get('/compras/pedidos/transporte', 'ComprasController@descargarTransporte')->name('compras.pedidos.descargar');
 | |
| });
 |