Quitado todo lo referente a planilla de cantidades de transporte
This commit is contained in:
parent
9fcdc5a52a
commit
d02505a70b
4 changed files with 0 additions and 59 deletions
|
@ -250,53 +250,4 @@ class GrupoDeCompra extends Model
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function totalesParaTransportePorBarrio() {
|
||||
return DB::table('grupos_de_compra')
|
||||
->leftJoin('subpedidos', 'grupos_de_compra.id', '=', 'subpedidos.grupo_de_compra_id')
|
||||
->leftJoin('producto_subpedido', 'subpedidos.id', '=', 'producto_subpedido.subpedido_id')
|
||||
->leftJoin('productos', 'producto_subpedido.producto_id', '=', 'productos.id')
|
||||
->where(function ($query) {
|
||||
$query->whereNull('productos.categoria')
|
||||
->orWhere('productos.categoria', 'not like', '%SUBSIDIADO%');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereNull('productos.bono')
|
||||
->orWhere('productos.bono', 0);
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereNull('subpedidos.aprobado')
|
||||
->orWhere('subpedidos.aprobado', 1);
|
||||
})
|
||||
->select(
|
||||
'grupos_de_compra.id as id',
|
||||
'grupos_de_compra.nombre as barrio',
|
||||
DB::raw('COALESCE(SUM(producto_subpedido.cantidad * productos.precio), 0) as total')
|
||||
)
|
||||
->groupBy('grupos_de_compra.id')
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
static public function planillaTransporte() {
|
||||
$totalesPorBarrio = self::totalesParaTransportePorBarrio();
|
||||
$barrios = [];
|
||||
$bonosDeTransporte = [];
|
||||
|
||||
foreach ($totalesPorBarrio as $totalBarrio) {
|
||||
$barrios[] = $totalBarrio->barrio;
|
||||
$bonosDeTransporte[] = ceil($totalBarrio->total / 500);
|
||||
}
|
||||
|
||||
$planilla = [];
|
||||
$planilla[] = array_merge(['Barrio'], $barrios);
|
||||
$planilla[] = array_merge(['Cant. bonos de transporte'], $bonosDeTransporte);
|
||||
|
||||
try {
|
||||
$writer = Writer::createFromPath(resource_path('csv/exports/transporte-por-barrio.csv'), 'w');
|
||||
$writer->insertAll($planilla);
|
||||
} catch (CannotInsertRecord $e) {
|
||||
var_export($e->getRecords());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,6 @@ class ComprasController
|
|||
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');
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
<a href="/compras/pedidos/notas" class="dropdown-item">
|
||||
Notas por barrio
|
||||
</a>
|
||||
<a href="/compras/pedidos/transporte" class="dropdown-item">
|
||||
Transporte por barrio
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -82,7 +82,6 @@ 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');
|
||||
Route::post('/compras/canasta', 'ComprasController@cargarCanasta')->name('compras.canasta');
|
||||
Route::get('/compras/canasta/ejemplo', 'ComprasController@descargarCanastaEjemplo')->name('compras.canasta.ejemplo');
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue