mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
leyendo lp y pasandolas a las tablas
This commit is contained in:
332
ci4/app/Models/Presupuestos/PresupuestoLineaModel.php
Normal file
332
ci4/app/Models/Presupuestos/PresupuestoLineaModel.php
Normal file
@ -0,0 +1,332 @@
|
||||
<?php
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoLineaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "presupuesto_linea";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $allowedFields = [
|
||||
"presupuesto_id",
|
||||
"tipo",
|
||||
"paginas",
|
||||
"paginas_color_posicion",
|
||||
"solapas_ancho",
|
||||
"papel_id",
|
||||
"papel_impresion_id",
|
||||
"formas",
|
||||
"gramaje",
|
||||
"pliegos_libro",
|
||||
"pliegos_pedido",
|
||||
"pliegos_precio",
|
||||
"libro",
|
||||
"pedido",
|
||||
"mano",
|
||||
"peso",
|
||||
"maquina_id",
|
||||
"tarifa_impresion_id",
|
||||
"click",
|
||||
"precio",
|
||||
"rotativa_impresion",
|
||||
"rotativa_pag_color",
|
||||
"rotativa_set_values",
|
||||
"rotativa_negro",
|
||||
"rotativa_cyan",
|
||||
"rotativa_magenta",
|
||||
"rotativa_amarillo",
|
||||
"rotativa_gota_negro",
|
||||
"rotativa_gota_color",
|
||||
"rotativa_saturacion",
|
||||
"rotativa_a_favor_fibra",
|
||||
"rotativa_mxm",
|
||||
"rotativa_area_paginas",
|
||||
"rotativa_num_gotas_negro",
|
||||
"rotativa_num_gotas_cyan",
|
||||
"rotativa_num_gotas_magenta",
|
||||
"rotativa_num_gotas_amarillo",
|
||||
"rotativa_peso_gotas_negro",
|
||||
"rotativa_peso_gotas_cyan",
|
||||
"rotativa_peso_gotas_magenta",
|
||||
"rotativa_peso_gotas_amarillo",
|
||||
"rotativa_precio_pag_negro",
|
||||
"rotativa_precio_pag_color",
|
||||
"rotativa_factor_altura",
|
||||
"rotativa_factor_anchura",
|
||||
"rotativa_pag_por_pliego",
|
||||
"rotativa_metros_libro",
|
||||
"rotativa_metros_total",
|
||||
"rotativa_clicks_libro",
|
||||
"rotativa_clicks_total",
|
||||
"rotativa_precio_tinta",
|
||||
"rotativa_total_impresion",
|
||||
"rotativa_velocidad_corte",
|
||||
"rotativa_tiempo_corte",
|
||||
"rotativa_precio_hora_corte",
|
||||
"rotativa_total_corte",
|
||||
"isActiva",
|
||||
];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoLineaEntity";
|
||||
|
||||
public static $labelField = "presupuesto_id";
|
||||
|
||||
protected $validationRules = [
|
||||
"click" => [
|
||||
"label" => "PresupuestoLineas.click",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"formas" => [
|
||||
"label" => "PresupuestoLineas.formas",
|
||||
"rules" => "trim|max_length[16313]",
|
||||
],
|
||||
"gramaje" => [
|
||||
"label" => "PresupuestoLineas.gramaje",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"libro" => [
|
||||
"label" => "PresupuestoLineas.libro",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"mano" => [
|
||||
"label" => "PresupuestoLineas.mano",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"paginas" => [
|
||||
"label" => "PresupuestoLineas.paginas",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"paginas_color_posicion" => [
|
||||
"label" => "PresupuestoLineas.paginasColorPosicion",
|
||||
"rules" => "trim|max_length[16313]",
|
||||
],
|
||||
"pedido" => [
|
||||
"label" => "PresupuestoLineas.pedido",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"peso" => [
|
||||
"label" => "PresupuestoLineas.peso",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"pliegos_libro" => [
|
||||
"label" => "PresupuestoLineas.pliegosLibro",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"pliegos_pedido" => [
|
||||
"label" => "PresupuestoLineas.pliegosPedido",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"pliegos_precio" => [
|
||||
"label" => "PresupuestoLineas.pliegosPrecio",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"precio" => [
|
||||
"label" => "PresupuestoLineas.precio",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"rotativa_amarillo" => [
|
||||
"label" => "PresupuestoLineas.rotativaAmarillo",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_area_paginas" => [
|
||||
"label" => "PresupuestoLineas.rotativaAreaPaginas",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_clicks_libro" => [
|
||||
"label" => "PresupuestoLineas.rotativaClicksLibro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_clicks_total" => [
|
||||
"label" => "PresupuestoLineas.rotativaClicksTotal",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_cyan" => [
|
||||
"label" => "PresupuestoLineas.rotativaCyan",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_factor_altura" => [
|
||||
"label" => "PresupuestoLineas.rotativaFactorAltura",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_factor_anchura" => [
|
||||
"label" => "PresupuestoLineas.rotativaFactorAnchura",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_gota_color" => [
|
||||
"label" => "PresupuestoLineas.rotativaGotaColor",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_gota_negro" => [
|
||||
"label" => "PresupuestoLineas.rotativaGotaNegro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_impresion" => [
|
||||
"label" => "PresupuestoLineas.rotativaImpresion",
|
||||
"rules" => "required|in_list[negro,color]",
|
||||
],
|
||||
"rotativa_magenta" => [
|
||||
"label" => "PresupuestoLineas.rotativaMagenta",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_metros_libro" => [
|
||||
"label" => "PresupuestoLineas.rotativaMetrosLibro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_metros_total" => [
|
||||
"label" => "PresupuestoLineas.rotativaMetrosTotal",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_mxm" => [
|
||||
"label" => "PresupuestoLineas.rotativaMxm",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"rotativa_negro" => [
|
||||
"label" => "PresupuestoLineas.rotativaNegro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_num_gotas_amarillo" => [
|
||||
"label" => "PresupuestoLineas.rotativaNumGotasAmarillo",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_num_gotas_cyan" => [
|
||||
"label" => "PresupuestoLineas.rotativaNumGotasCyan",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_num_gotas_magenta" => [
|
||||
"label" => "PresupuestoLineas.rotativaNumGotasMagenta",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_num_gotas_negro" => [
|
||||
"label" => "PresupuestoLineas.rotativaNumGotasNegro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_pag_color" => [
|
||||
"label" => "PresupuestoLineas.rotativaPagColor",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"rotativa_pag_por_pliego" => [
|
||||
"label" => "PresupuestoLineas.rotativaPagPorPliego",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_peso_gotas_amarillo" => [
|
||||
"label" => "PresupuestoLineas.rotativaPesoGotasAmarillo",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_peso_gotas_cyan" => [
|
||||
"label" => "PresupuestoLineas.rotativaPesoGotasCyan",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_peso_gotas_magenta" => [
|
||||
"label" => "PresupuestoLineas.rotativaPesoGotasMagenta",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_peso_gotas_negro" => [
|
||||
"label" => "PresupuestoLineas.rotativaPesoGotasNegro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_precio_hora_corte" => [
|
||||
"label" => "PresupuestoLineas.rotativaPrecioHoraCorte",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_precio_pag_color" => [
|
||||
"label" => "PresupuestoLineas.rotativaPrecioPagColor",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_precio_pag_negro" => [
|
||||
"label" => "PresupuestoLineas.rotativaPrecioPagNegro",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_precio_tinta" => [
|
||||
"label" => "PresupuestoLineas.rotativaPrecioTinta",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_saturacion" => [
|
||||
"label" => "PresupuestoLineas.rotativaSaturacion",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_tiempo_corte" => [
|
||||
"label" => "PresupuestoLineas.rotativaTiempoCorte",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_total_corte" => [
|
||||
"label" => "PresupuestoLineas.rotativaTotalCorte",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_total_impresion" => [
|
||||
"label" => "PresupuestoLineas.rotativaTotalImpresion",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"rotativa_velocidad_corte" => [
|
||||
"label" => "PresupuestoLineas.rotativaVelocidadCorte",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"solapas_ancho" => [
|
||||
"label" => "PresupuestoLineas.solapasAncho",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tipo" => [
|
||||
"label" => "PresupuestoLineas.tipo",
|
||||
"rules" => "required|in_list[bn,bnhq,color,colorhq,cubierta,sobrecubierta,rot_bn,rot_color]",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.id AS presupuesto, t3.nombre AS papel, t4.nombre AS papel_impresion, t5.nombre AS maquina, t6.tipo AS tarifa_impresion FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN presupuestos t2 ON t1.presupuesto_id = t2.id LEFT JOIN lg_papel_generico t3 ON t1.papel_id = t3.id LEFT JOIN lg_papel_impresion t4 ON t1.papel_impresion_id = t4.id LEFT JOIN lg_maquinas t5 ON t1.maquina_id = t5.id LEFT JOIN lg_maquinas_tarifas_impresion t6 ON t1.tarifa_impresion_id = t6.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . intval($limit);
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . intval($offset);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function createForPresupuesto($presupuesto_id){
|
||||
|
||||
$tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color'];
|
||||
foreach($tipos as $tipo){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuesto_id,
|
||||
'tipo' => $tipo,
|
||||
];
|
||||
|
||||
$builder->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function getLineasPresupuesto($presupuesto_id = -1)
|
||||
{
|
||||
/*
|
||||
Todos los servicios de manipulado activas que se pueden usar en presupuestos
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"*"
|
||||
)
|
||||
->where("t1.presupuesto_id", $presupuesto_id)
|
||||
->where("t1.isActiva", 1);
|
||||
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -313,13 +313,15 @@ class PresupuestoModel extends \App\Models\GoBaseModel
|
||||
"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_pedido AS total_pedido, t6.estado AS estado"
|
||||
t1.total_pedido AS total_pedido, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado"
|
||||
);
|
||||
$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("lg_paises t5", "t1.pais_id = t5.id", "left");
|
||||
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
|
||||
Reference in New Issue
Block a user