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;
}
}

View File

@ -347,7 +347,7 @@ class PresupuestoModel extends \App\Models\GoBaseModel
/**
* Get resource data.
* Get resource data for creating PDFs.
*
* @param string $search
*
@ -364,20 +364,21 @@ class PresupuestoModel extends \App\Models\GoBaseModel
t1.retractilado AS retractilado, t1.guardas AS guardas, t1.marcapaginas AS marcapaginas,
t1.comentarios_pdf AS comentarios_pdf,
t1.total_presupuesto AS total_presupuesto, t1.total_precio_unidad AS total_precio_unidad,
t1.papel_formato_personalizado AS isPersonalizado,
CONCAT(t1.papel_formato_ancho, 'x', t1.papel_formato_alto) AS formatoPersonalizado,
t2.nombre AS cliente,
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t3.email AS email_comercial,
t6.estado AS estado"
CONCAT(t4.ancho, 'x', t4.alto) AS formato"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
$builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left");
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
$builder->join("lg_papel_formato t4", "t1.papel_formato_id = t4.id", "left");
$builder->where("t1.is_deleted", 0);
$builder->where("t1.id", $presupuesto_id);
return $builder;
}
}