Compare commits
No commits in common. "be945b0eee99e03274617ffa2041b5bf8e435356" and "1e443ea2ca17c381fc3f8bcda4a6a68d86fc0984" have entirely different histories.
be945b0eee
...
1e443ea2ca
5 changed files with 4 additions and 51 deletions
|
@ -236,30 +236,4 @@ class GrupoDeCompra extends Model
|
|||
var_export($e->getRecords());
|
||||
}
|
||||
}
|
||||
|
||||
public static function exportarProductosConNotasEnCSV() {
|
||||
$gdcs = GrupoDeCompra::all();
|
||||
foreach ($gdcs as $i => $gdc) {
|
||||
$productos_en_pedido = DB::table('pedidos_aprobados')->where('grupo_de_compra_id', $gdc->id)->get()->keyBy('producto_id');
|
||||
$pedidos = $gdc->pedidosAprobados();
|
||||
foreach ($productos_en_pedido as $id => $producto_pedido) {
|
||||
foreach ($pedidos as $pedido) {
|
||||
$producto = $pedido->productos()->find($id);
|
||||
if ($producto != null && $producto->requiere_notas) {
|
||||
$planilla[$i+1][0] = $gdc->nombre;
|
||||
$planilla[$i+1][1] = $producto->nombre;
|
||||
$planilla[$i+1][2] = $producto->pivot->cantidad;
|
||||
$planilla[$i+1][3] = $producto->pivot->notas;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Guardar en un archivo .csv
|
||||
try {
|
||||
$writer = Writer::createFromPath(resource_path('csv/exports/pedidos-notas.csv'), 'w');
|
||||
$writer->insertAll($planilla);
|
||||
} catch (CannotInsertRecord $e) {
|
||||
var_export($e->getRecords());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,6 @@ class ComprasController
|
|||
return response()->download($file);
|
||||
}
|
||||
|
||||
public function descargarNotas() {
|
||||
GrupoDeCompra::exportarProductosConNotasEnCSV();
|
||||
$file = resource_path('csv/exports/pedidos-notas.csv');
|
||||
return response()->download($file);
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
return view('auth/compras_login');
|
||||
|
|
|
@ -11,16 +11,6 @@
|
|||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="control">
|
||||
<a href="/compras/pedidos/notas" class="button">
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-sticky-note"></i>
|
||||
</span>
|
||||
<span>Descargar planilla de notas</span>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -27,13 +27,9 @@
|
|||
|
||||
@foreach($subpedido->productos as $producto)
|
||||
@if(!$producto->bono)
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
{{ $producto->nombre }}
|
||||
@if($producto->pivot->notas)
|
||||
<br /><b>Talle/Color:</b> {{ $producto->pivot->notas }}
|
||||
@endif
|
||||
</td>
|
||||
<td style="text-align: center">
|
||||
{{ $producto->pivot->cantidad }}
|
||||
|
|
|
@ -81,5 +81,4 @@ 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');
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue