58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\GrupoDeCompra;
|
|
use App\Helpers\CanastaHelper;
|
|
use App\Producto;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ComprasController
|
|
{
|
|
const CANASTAS_PATH = 'csv/canastas/';
|
|
|
|
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',
|
|
]);
|
|
|
|
$data = $request->file('data');
|
|
$nombre = $data->getClientOriginalName();
|
|
|
|
$data->move(resource_path(self::CANASTAS_PATH), $nombre);
|
|
CanastaHelper::cargarCanasta(self::CANASTAS_PATH . $nombre);
|
|
|
|
return response()->json([
|
|
'message' => 'Canasta cargada exitosamente',
|
|
], 200);
|
|
}
|
|
}
|