Añadidas lineas de presupuesto ByN y Color al presupuesto. Cambios esteticos

This commit is contained in:
imnavajas
2024-01-18 21:50:52 +01:00
parent bbea1465af
commit 7fc32a7840
6 changed files with 89 additions and 44 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace App\Models\Presupuestos;
class PresupuestoLineaModel extends \App\Models\GoBaseModel
@ -307,17 +308,18 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
return $result;
}
public function createForPresupuesto($presupuesto_id){
public function createForPresupuesto($presupuesto_id)
{
$tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color'];
foreach($tipos as $tipo){
$tipos = ['bn', 'bnhq', 'color', 'colorhq', 'cubierta', 'sobrecubierta', 'rot_bn', 'rot_color'];
foreach ($tipos as $tipo) {
$builder = $this->db
->table($this->table . " t1");
->table($this->table . " t1");
$data = [
'presupuesto_id' => $presupuesto_id,
'tipo' => $tipo,
'presupuesto_id' => $presupuesto_id,
'tipo' => $tipo,
];
$builder->insert($data);
}
}
@ -330,30 +332,58 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
"*"
)
->where("t1.presupuesto_id", $presupuesto_id);
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
}
public function deleteLineasPresupuesto($presupuesto_id){
public function deleteLineasPresupuesto($presupuesto_id)
{
$this->db
->table($this->table . " t1")
->where("presupuesto_id", $presupuesto_id)
->delete();
}
public function insertLineasPresupuesto($presupuesto_id = -1, $datos=[])
public function insertLineasPresupuesto($presupuesto_id = -1, $datos = [])
{
$this->deleteLineasPresupuesto($presupuesto_id);
foreach($datos as $linea){
foreach ($datos as $linea) {
$this->db
->table($this->table . " t1")
->where("t1.presupuesto_id", $presupuesto_id)
->insert($linea);
}
}
public function getResourceByNForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.paginas AS paginas, t1.papel_impresion AS papel, t1.gramaje AS gramaje"
)
->where("t1.presupuesto_id", $presupuesto_id)
->whereIn('t1.tipo', ['lp_bn', 'lp_bnhq', 'lp_rot_bn']);
return $builder;
}
public function getResourceColorForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.paginas AS paginas, t1.papel_impresion AS papel, t1.gramaje AS gramaje"
)
->where("t1.presupuesto_id", $presupuesto_id)
->whereIn('t1.tipo', ['lp_color', 'lp_colorhq', 'lp_rot_color']);
return $builder;
}
}