Merge branch 'feat/presupuestos_pdf' into 'main'

Revisada la generacion de presupuestos en PDf

See merge request jjimenez/safekat!567
This commit is contained in:
Ignacio Martinez Navajas
2025-02-22 22:26:47 +00:00
6 changed files with 397 additions and 329 deletions

View File

@ -21,6 +21,8 @@ class PrintPresupuestos extends BaseController
$data['lp_Color'] = $lineasPresupuestoModel->getResourceColorForPdf($id_presupuesto)->get()->getRow();
$data['lp_Cubierta'] = $lineasPresupuestoModel->getResourceCubiertaForPdf($id_presupuesto)->get()->getRow();
$data['lp_Sobrecubierta'] = $lineasPresupuestoModel->getResourceSobrecubiertaForPdf($id_presupuesto)->get()->getRow();
$data['lp_Guardas'] = $lineasPresupuestoModel->getResourceGuardasForPdf($id_presupuesto)->get()->getRow();
$data['lp_Faja'] = $lineasPresupuestoModel->getResourceFajaForPdf($id_presupuesto)->get()->getRow();
$data['acabado_cubierta'] = $presupuestoAcabadosModel->getAcabadoCubiertaForPdf($id_presupuesto)->get()->getRow();
$data['acabado_sobrecubierta'] = $presupuestoAcabadosModel->getAcabadoSobrecubiertaForPdf($id_presupuesto)->get()->getRow();
$data['acabado_reserva_uvi'] = $presupuestoAcabadosModel->getAcabadoReservaUviForPdf($id_presupuesto)->get()->getRow();
@ -44,6 +46,8 @@ class PrintPresupuestos extends BaseController
$data['lp_Color'] = $lineasPresupuestoModel->getResourceColorForPdf($presupuesto_id)->get()->getRow();
$data['lp_Cubierta'] = $lineasPresupuestoModel->getResourceCubiertaForPdf($presupuesto_id)->get()->getRow();
$data['lp_Sobrecubierta'] = $lineasPresupuestoModel->getResourceSobrecubiertaForPdf($presupuesto_id)->get()->getRow();
$data['lp_Guardas'] = $lineasPresupuestoModel->getResourceGuardasForPdf($presupuesto_id)->get()->getRow();
$data['lp_Faja'] = $lineasPresupuestoModel->getResourceFajaForPdf($presupuesto_id)->get()->getRow();
$data['acabado_cubierta'] = $presupuestoAcabadosModel->getAcabadoCubiertaForPdf($presupuesto_id)->get()->getRow();
$data['acabado_sobrecubierta'] = $presupuestoAcabadosModel->getAcabadoSobrecubiertaForPdf($presupuesto_id)->get()->getRow();
$data['acabado_reserva_uvi'] = $presupuestoAcabadosModel->getAcabadoReservaUviForPdf($presupuesto_id)->get()->getRow();
@ -59,7 +63,7 @@ class PrintPresupuestos extends BaseController
// Metodo que funciona en el docker
$css = file_get_contents(getenv('theme.path'). 'css/pdf.presupuesto.css');
$html = view(getenv('theme.path') . 'pdfs/presupuesto', $data);
$html = "<style>$css</style>" . $html;
$html = "<style>$css</style>" . $html;
$dompdf->loadHtml($html);
//$dompdf->loadHtml(view(getenv('theme.path') . 'pdfs/presupuesto', $data));

View File

@ -12,12 +12,12 @@ class TipoPresupuestoModel extends \App\Models\BaseModel
*/
protected $useAutoIncrement = true;
protected $allowedFields = ["codigo", "is_cosido", "is_deleted", 'deleted_at', 'updated_at', 'created_at'];
protected $allowedFields = ["codigo", "encuadernado", "is_cosido", "is_deleted", 'deleted_at', 'updated_at', 'created_at'];
protected $returnType = "App\Entities\Configuracion\TipoPresupuestoEntity";
public static $labelField = "codigo";
public function get_isCosido(int $id){
$builder = $this->db
@ -50,5 +50,5 @@ class TipoPresupuestoModel extends \App\Models\BaseModel
}

View File

@ -217,7 +217,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.tarifa_acabado_id AS tarifa_id, t1.precio_unidad AS precio_unidad,
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.tarifa_acabado_id AS tarifa_id, t1.precio_unidad AS precio_unidad,
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta,
t1.faja AS faja,
t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,"
@ -291,8 +291,8 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
);
$builder->join("lg_tarifa_acabado t2", "t1.tarifa_acabado_id = t2.id", "left");
$builder->where("t1.tarifa_acabado_id", self::TARIFA_RESERVA_UVI_ID);
$builder->where("t1.presupuesto_id", $presupuesto_id);
$builder->like("t2.nombre", "reserva uvi", "both");
return $builder;
}

View File

@ -468,7 +468,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
if($new_linea['tipo_maquina'] =='inkjet'){
$data += [
'rotativa_total_impresion' => $rot_total_impresion,
'rotativa_negro' => $new_linea['datosTipologias']->negro ?? 0,
'rotativa_cyan' => $new_linea['datosTipologias']->cyan ?? 0,
'rotativa_magenta' => $new_linea['datosTipologias']->magenta ?? 0,
@ -492,7 +492,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
'rotativa_peso_gotas_magenta_pedido' => $new_linea['peso_gotas_magenta_pedido'] ?? 0,
'rotativa_peso_gotas_amarillo_pedido' => $new_linea['peso_gotas_amarillo_pedido'] ?? 0,
'rotativa_peso_gotas_cg_pedido' => $new_linea['peso_gotas_cg_pedido'] ?? 0,
'rotativa_pag_color' => $new_linea['paginas_color'],
'rotativa_resolucion' => $new_linea['resolucion'],
'rotativa_area_paginas' => $new_linea['superficie'],
@ -507,7 +507,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
'rotativa_mxm' => $new_linea['maquina_velocidad'],
];
}
if (strpos($new_linea['tipo_linea'], 'rot') !== false) {
$data += [
'rotativa_metros_libro' => $new_linea['metros_papel_libro'],
@ -516,12 +516,12 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
'rotativa_precio_hora_corte' => $new_linea['precio_hora_corte'],
'rotativa_tiempo_corte' => $new_linea['tiempo_corte'],
'rotativa_total_corte' => $new_linea['total_corte'],
'rotativa_a_favor_fibra' => $new_linea['a_favor_fibra']
'rotativa_a_favor_fibra' => $new_linea['a_favor_fibra']
];
}
if($new_linea['tipo_linea'] =='lp_guardas')
$data = array_merge($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
$data = array_merge($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
return $this->db
->table($this->table . " t1")
@ -603,6 +603,32 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
return $builder;
}
public function getResourceGuardasForPdf($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_guardas']);
return $builder;
}
public function getResourceFajaForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.papel_impresion AS papel, t1.gramaje AS gramaje"
)
->where("t1.presupuesto_id", $presupuesto_id)
->whereIn('t1.tipo', ['lp_faja']);
return $builder;
}
public function duplicateLineasPresupuesto($presupuesto_id, $new_presupuesto_id)
{
$lineas = $this->getLineasPresupuesto($presupuesto_id);

View File

@ -228,15 +228,15 @@ class PresupuestoModel extends \App\Models\BaseModel
$selcols .
", t2.nombre AS cliente, t3.nombre AS forma_pago, t4.nombre AS tipo_impresion, t5.nombre AS tipologia, t6.nombre AS pais, t7.estado AS estado, t8.id AS papel_formato, t9.first_name AS total_confirmado_user, t10.first_name AS aprobado_user FROM " .
$this->table .
" t1 LEFT JOIN clientes
t2 ON t1.cliente_id = t2.id LEFT JOIN formas_pago
t3 ON t1.forma_pago_id = t3.id LEFT JOIN lg_tipos_impresion
t4 ON t1.tipo_impresion_id = t4.id LEFT JOIN lg_tipologias_libros
t5 ON t1.tipologia_id = t5.id LEFT JOIN lg_paises
t6 ON t1.pais_id = t6.id = t7.id LEFT JOIN presupuesto_estados
t7 ON t1.estado_id = t8.id LEFT JOIN lg_papel_formato
t8 ON t1.papel_formato_id = t9.id LEFT JOIN lg_papel_generico
t9 ON t1.total_confirmado_user_id = t26.id LEFT JOIN users
" t1 LEFT JOIN clientes
t2 ON t1.cliente_id = t2.id LEFT JOIN formas_pago
t3 ON t1.forma_pago_id = t3.id LEFT JOIN lg_tipos_impresion
t4 ON t1.tipo_impresion_id = t4.id LEFT JOIN lg_tipologias_libros
t5 ON t1.tipologia_id = t5.id LEFT JOIN lg_paises
t6 ON t1.pais_id = t6.id = t7.id LEFT JOIN presupuesto_estados
t7 ON t1.estado_id = t8.id LEFT JOIN lg_papel_formato
t8 ON t1.papel_formato_id = t9.id LEFT JOIN lg_papel_generico
t9 ON t1.total_confirmado_user_id = t26.id LEFT JOIN users
t10 ON t1.aprobado_user_id = t27.id LEFT JOIN users";
if (!is_null($limit) && intval($limit) > 0) {
@ -264,7 +264,7 @@ class PresupuestoModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.created_at AS fecha, t2.nombre AS cliente,
"t1.id AS id, t1.created_at AS fecha, t2.nombre AS cliente,
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo,
t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada,
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado"
@ -316,23 +316,25 @@ class PresupuestoModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.created_at AS fecha, t1.titulo AS titulo, t1.autor AS autor, t1.ferro AS ferro,
t1.ferro_digital AS ferro_digital, t1.prototipo AS prototipo, t1.solapas AS solapas, t1.solapas_sobrecubierta AS solapas_sobrecubierta,
"t1.id AS id, t1.created_at AS fecha, t1.titulo AS titulo, t1.autor AS autor, t1.ferro AS ferro,
t1.ferro_digital AS ferro_digital, t1.prototipo AS prototipo, t1.solapas AS solapas, t1.solapas_sobrecubierta AS solapas_sobrecubierta,
t1.lomo_cubierta AS lomo_cubierta, t1.lomo_sobrecubierta AS lomo_sobrecubierta,
t1.solapas_ancho AS solapas_ancho, t1.solapas_ancho_sobrecubierta AS solapas_sobrecubierta_ancho, t1.paginas AS paginas, t1.tirada AS tirada, t1.coleccion AS coleccion,
t1.retractilado AS retractilado, t1.guardas AS guardas, t1.marcapaginas AS marcapaginas,
t1.comentarios_pdf AS comentarios_pdf, t1.tirada_alternativa_json_data AS tiradas_alternativas,
t1.total_presupuesto AS total_presupuesto, t1.total_precio_unidad AS total_precio_unidad,
t1.total_presupuesto AS total_presupuesto, t1.total_precio_unidad AS total_precio_unidad,
t1.papel_formato_personalizado AS isPersonalizado, t1.envios_recoge_cliente AS recoge_cliente,
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, t5.secret AS email_comercial,
CONCAT(t4.ancho, 'x', t4.alto) AS formato"
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t5.secret AS email_comercial,
CONCAT(t4.ancho, 'x', t4.alto) AS formato, t6.encuadernacion AS tipo_encuadernado,
t1.comp_tipo_impresion AS tipo_impresion"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
$builder->join("users t3", "t1.user_update_id = t3.id", "left");
$builder->join("lg_papel_formato t4", "t1.papel_formato_id = t4.id", "left");
$builder->join("auth_identities t5", "t1.user_update_id = t5.id", "left");
$builder->join("tipos_presupuestos t6", "t1.tipo_impresion_id = t6.id", "left");
$builder->where("t1.is_deleted", 0);
$builder->where("t1.id", $presupuesto_id);
@ -346,10 +348,10 @@ class PresupuestoModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.created_at AS fecha, t7.codigo as codigo, t2.nombre AS cliente,
"t1.id AS id, t1.created_at AS fecha, t7.codigo as codigo, t2.nombre AS cliente,
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo,
t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada,
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto,
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto,
t6.estado AS estado"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
@ -600,7 +602,7 @@ class PresupuestoModel extends \App\Models\BaseModel
->table($this->table . " t1")
->select(
"t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas,
t1.titulo AS titulo, t1.autor AS autor, t1.isbn AS isbn,
t1.titulo AS titulo, t1.autor AS autor, t1.isbn AS isbn,
t1.papel_formato_id AS papel_formato_id, t1.papel_formato_personalizado AS papel_formato_personalizado,
t1.papel_formato_ancho AS papel_formato_ancho, t1.papel_formato_alto AS papel_formato_alto,
CONCAT(CAST(t2.ancho AS INT), 'x', CAST(t2.alto AS INT)) AS tamanio,

File diff suppressed because one or more lines are too long