mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
ya funcionando la consulta de papel_impresion/maquinas
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class MaquinaModel extends \App\Models\GoBaseModel
|
||||
@ -26,8 +27,8 @@ class MaquinaModel extends \App\Models\GoBaseModel
|
||||
9 => "t1.orden_planning",
|
||||
10 => "t1.min",
|
||||
11 => "t1.max",
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
@ -252,14 +253,15 @@ class MaquinaModel extends \App\Models\GoBaseModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa){
|
||||
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"'".$papel_impresion_id."'". " as papel_impresion_id, t1.id AS maquina_id, '0' as active"
|
||||
);
|
||||
"'" . $papel_impresion_id . "'" . " as papel_impresion_id, t1.id AS maquina_id, '0' as active"
|
||||
);
|
||||
$builder->where("t1.is_rotativa", $rotativa);
|
||||
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
@ -280,57 +282,87 @@ class MaquinaModel extends \App\Models\GoBaseModel
|
||||
$builder->join("lg_maquinas t2", "t1.padre_id = t2.id", "left");
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.velocidad", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.ancho_impresion", $search)
|
||||
->orLike("t1.alto_impresion", $search)
|
||||
->orLike("t1.alto_click", $search)
|
||||
->orLike("t1.min", $search)
|
||||
->orLike("t1.max", $search)
|
||||
->orLike("t1.duracion_jornada", $search)
|
||||
->orLike("t1.orden_planning", $search)
|
||||
->orLike("t1.precio_tinta_negro", $search)
|
||||
->orLike("t1.precio_tinta_color", $search)
|
||||
->orLike("t1.velocidad_corte", $search)
|
||||
->orLike("t1.precio_hora_corte", $search)
|
||||
->orLike("t1.metrosxminuto", $search)
|
||||
->orLike("t1.forzar_num_formas_horizontales_portada", $search)
|
||||
->orLike("t1.forzar_num_formas_verticales_portada", $search)
|
||||
->orLike("t1.observaciones", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.velocidad", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.ancho_impresion", $search)
|
||||
->orLike("t1.alto_impresion", $search)
|
||||
->orLike("t1.alto_click", $search)
|
||||
->orLike("t1.padre_id", $search)
|
||||
->orLike("t1.min", $search)
|
||||
->orLike("t1.max", $search)
|
||||
->orLike("t1.duracion_jornada", $search)
|
||||
->orLike("t1.orden_planning", $search)
|
||||
->orLike("t1.precio_tinta_negro", $search)
|
||||
->orLike("t1.precio_tinta_color", $search)
|
||||
->orLike("t1.velocidad_corte", $search)
|
||||
->orLike("t1.precio_hora_corte", $search)
|
||||
->orLike("t1.metrosxminuto", $search)
|
||||
->orLike("t1.forzar_num_formas_horizontales_portada", $search)
|
||||
->orLike("t1.forzar_num_formas_verticales_portada", $search)
|
||||
->orLike("t1.observaciones", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.velocidad", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.ancho_impresion", $search)
|
||||
->orLike("t1.alto_impresion", $search)
|
||||
->orLike("t1.alto_click", $search)
|
||||
->orLike("t1.min", $search)
|
||||
->orLike("t1.max", $search)
|
||||
->orLike("t1.duracion_jornada", $search)
|
||||
->orLike("t1.orden_planning", $search)
|
||||
->orLike("t1.precio_tinta_negro", $search)
|
||||
->orLike("t1.precio_tinta_color", $search)
|
||||
->orLike("t1.velocidad_corte", $search)
|
||||
->orLike("t1.precio_hora_corte", $search)
|
||||
->orLike("t1.metrosxminuto", $search)
|
||||
->orLike("t1.forzar_num_formas_horizontales_portada", $search)
|
||||
->orLike("t1.forzar_num_formas_verticales_portada", $search)
|
||||
->orLike("t1.observaciones", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.velocidad", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.ancho_impresion", $search)
|
||||
->orLike("t1.alto_impresion", $search)
|
||||
->orLike("t1.alto_click", $search)
|
||||
->orLike("t1.padre_id", $search)
|
||||
->orLike("t1.min", $search)
|
||||
->orLike("t1.max", $search)
|
||||
->orLike("t1.duracion_jornada", $search)
|
||||
->orLike("t1.orden_planning", $search)
|
||||
->orLike("t1.precio_tinta_negro", $search)
|
||||
->orLike("t1.precio_tinta_color", $search)
|
||||
->orLike("t1.velocidad_corte", $search)
|
||||
->orLike("t1.precio_hora_corte", $search)
|
||||
->orLike("t1.metrosxminuto", $search)
|
||||
->orLike("t1.forzar_num_formas_horizontales_portada", $search)
|
||||
->orLike("t1.forzar_num_formas_verticales_portada", $search)
|
||||
->orLike("t1.observaciones", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getMaquinaImpresionForPresupuesto($is_rotativa, $tarifa_tipo, $papel_impresion_id = -1)
|
||||
{
|
||||
/*
|
||||
1.-> tarifa_Tipo impresion
|
||||
2.-> Maquina
|
||||
3.-> Papeles impresion asociados a esa maquina
|
||||
4.-> papeles genericos que aparecen en esos papeles impresion
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->distinct('t1.id')
|
||||
->select(
|
||||
"t1.id AS maquina_id, t1.nombre AS maquina, t1.ancho_impresion AS ancho_impresion,
|
||||
t1.alto_impresion AS alto_impresion, t1.is_rotativa AS is rotativa"
|
||||
)
|
||||
->join("lg_maquinas_tarifas_impresion t2", "t1.id = t2.maquina_id", "left")
|
||||
->join("lg_maquina_papel_impresion t3", "t1.id = t3.maquina_id", "left")
|
||||
|
||||
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.tipo", "impresion")
|
||||
->where("t1.is_rotativa", $is_rotativa)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.tipo", $tarifa_tipo)
|
||||
->where("t3.papel_impresion_id", $papel_impresion_id)
|
||||
->where("t3.active", 1);
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,16 +13,14 @@ class MaquinasCallesModel extends \App\Models\GoBaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.formas_min",
|
||||
1 => "t1.formas_max",
|
||||
2 => "t1.internas",
|
||||
3 => "t1.externas",
|
||||
0 => "t1.formas",
|
||||
1 => "t1.internas",
|
||||
2 => "t1.externas",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"maquina_id",
|
||||
"formas_min",
|
||||
"formas_max",
|
||||
"formas",
|
||||
"internas",
|
||||
"externas",
|
||||
"user_created_id",
|
||||
@ -43,10 +41,7 @@ class MaquinasCallesModel extends \App\Models\GoBaseModel
|
||||
public static $labelField = "maquina_id";
|
||||
|
||||
protected $validationRules = [
|
||||
"formas_min" => [
|
||||
"rules" => "required|int",
|
||||
],
|
||||
"formas_max" => [
|
||||
"formas" => [
|
||||
"rules" => "required|int",
|
||||
],
|
||||
"internas" => [
|
||||
@ -70,8 +65,8 @@ class MaquinasCallesModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.maquina_id as maquina, t1.formas_min AS formas_min,
|
||||
t1.formas_max AS formas_max, t1.internas AS internas, t1.externas AS externas,"
|
||||
"t1.id AS id, t1.maquina_id as maquina, t1.formas AS formas,
|
||||
t1.internas AS internas, t1.externas AS externas,"
|
||||
);
|
||||
|
||||
//JJO
|
||||
@ -82,29 +77,22 @@ class MaquinasCallesModel extends \App\Models\GoBaseModel
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.formas_min", $search)
|
||||
->orLike("t1.formas_max", $search)
|
||||
->like("t1.formas", $search)
|
||||
->orLike("t1.internas", $search)
|
||||
->orLike("t1.externas", $search)
|
||||
->orLike("t1.formas_min", $search)
|
||||
->orLike("t1.formas_max", $search)
|
||||
->orLike("t1.formas", $search)
|
||||
->orLike("t1.internas", $search)
|
||||
->orLike("t1.externas", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function checkIntervals($data = [], $id = null){
|
||||
public function checkDuplicatedFormas($data = [], $id = null){
|
||||
|
||||
helper('general');
|
||||
|
||||
if(floatval($data["formas_min"])>= floatval($data["formas_max"])){
|
||||
return lang('MaquinasCalles.validation.error_calle_range');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$rows = $this->db
|
||||
->table($this->table)
|
||||
->select("id, formas_min, formas_max")
|
||||
->select("id, formas")
|
||||
->where("is_deleted", 0)
|
||||
->where("maquina_id", $data['maquina_id'])
|
||||
->get()->getResultObject();
|
||||
@ -116,9 +104,8 @@ class MaquinasCallesModel extends \App\Models\GoBaseModel
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(check_overlap(floatval($data["formas_min"]), floatval($data["formas_max"]),
|
||||
$row->formas_min, $row->formas_max)){
|
||||
return lang('MaquinasCalles.validation.error_calle_overlap');
|
||||
if(intval($data["formas"]) == $row->formas){
|
||||
return lang('MaquinasCalles.validation.error_formas_exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,4 +209,52 @@ class PapelImpresionModel extends \App\Models\GoBaseModel
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $papel_generico_id
|
||||
* @param null $gramaje
|
||||
* @param mixed $options
|
||||
* array con las opciones para bn,color,cubierta,sobrecubierta,rotativa
|
||||
* @param mixed $is_activo=true
|
||||
*
|
||||
* @return [type]
|
||||
*/
|
||||
public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options=[]){
|
||||
$bn = array_key_exists('bn', $options) ? $options['bn'] : null;
|
||||
$color = array_key_exists('color', $options)? $options['color'] : null;
|
||||
$cubierta = array_key_exists('cubierta', $options)? $options['cubierta'] : null;
|
||||
$sobrecubierta = array_key_exists('sobrecubierta', $options)? $options['sobrecubierta'] : null;
|
||||
$rotativa = array_key_exists('rotativa', $options)? $options['rotativa'] : null;
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->distinct("t1.id")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.papel_generico_id AS papel_generico_id,
|
||||
t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa");
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.isActivo", 1);
|
||||
|
||||
$builder->where("t1.papel_generico_id", $papel_generico_id);
|
||||
$builder->where("t1.gramaje", $gramaje);
|
||||
|
||||
if(!is_null($bn)){
|
||||
$builder->where("t1.bn", $bn);
|
||||
}
|
||||
if(!is_null($color)){
|
||||
$builder->where("t1.color", $color);
|
||||
}
|
||||
if(!is_null($cubierta)){
|
||||
$builder->where("t1.cubierta", $cubierta);
|
||||
}
|
||||
if(!is_null($sobrecubierta)){
|
||||
$builder->where("t1.sobrecubierta", $sobrecubierta);
|
||||
}
|
||||
if(!is_null($rotativa)){
|
||||
$builder->where("t1.rotativa", $rotativa);
|
||||
}
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user