53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\GrupoDeCompra;
|
|
use App\Producto;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ComprasController
|
|
{
|
|
public function indexPedidos() {
|
|
return view('compras_pedidos');
|
|
}
|
|
|
|
public function descargarPedidos() {
|
|
Producto::planillaTotales();
|
|
$file = resource_path('csv/exports/pedidos-por-barrio.csv');
|
|
return response()->download($file);
|
|
}
|
|
|
|
public function descargarNotas() {
|
|
Producto::planillaNotas();
|
|
$file = resource_path('csv/exports/notas-por-barrio.csv');
|
|
return response()->download($file);
|
|
}
|
|
|
|
public function descargarTransporte() {
|
|
GrupoDeCompra::planillaTransporte();
|
|
$file = resource_path('csv/exports/transporte-por-barrio.csv');
|
|
return response()->download($file);
|
|
}
|
|
|
|
public function show()
|
|
{
|
|
return view('auth/compras_login');
|
|
}
|
|
|
|
public function cargarCanasta(Request $request)
|
|
{
|
|
$request->validate([
|
|
'data' => 'required|file|mimes:csv,txt|max:2048',
|
|
]);
|
|
|
|
$archivo = $request->file('data');
|
|
$path = resource_path('/csv/canastas/');
|
|
$archivo->move($path, $archivo->getClientOriginalName());
|
|
|
|
return response()->json([
|
|
'message' => 'Canasta cargada exitosamente',
|
|
], 200);
|
|
}
|
|
}
|