mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add views
This commit is contained in:
@ -20,7 +20,8 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
3 => "t1.ancho_impresion",
|
||||
4 => "t1.alto_impresion",
|
||||
5 => "t1.min",
|
||||
6 => "t1.max", ];
|
||||
6 => "t1.max",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
@ -249,7 +250,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa , $inkjet)
|
||||
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa, $inkjet)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -262,7 +263,8 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getVelocidad($maquina_id){
|
||||
public function getVelocidad($maquina_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
@ -272,9 +274,9 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
|
||||
$resultObject = $builder->get()->getResultObject();
|
||||
|
||||
if(count($resultObject)>0)
|
||||
if (count($resultObject) > 0)
|
||||
return $resultObject[0]->velocidad;
|
||||
else{
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -318,7 +320,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaquinaImpresionForPresupuesto($is_rotativa, $tarifa_tipo, $uso_tarifa , $tirada, $papel_impresion_id = -1)
|
||||
public function getMaquinaImpresionForPresupuesto($is_rotativa, $tarifa_tipo, $uso_tarifa, $tirada, $papel_impresion_id = -1)
|
||||
{
|
||||
/*
|
||||
1.-> tarifa_Tipo impresion
|
||||
@ -338,10 +340,10 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
t1.forzar_num_formas_horizontales_cubierta AS forzar_num_formas_horizontales_cubierta,
|
||||
t1.forzar_num_formas_verticales_cubierta AS forzar_num_formas_verticales_cubierta"
|
||||
)
|
||||
->join("lg_maquinas_tarifas_impresion t2", "t1.id = t2.maquina_id", "left")
|
||||
->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)
|
||||
@ -351,28 +353,28 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
->where("t1.min <=", $tirada)
|
||||
->where("t1.max >=", $tirada);
|
||||
|
||||
if(is_array($tarifa_tipo)){
|
||||
foreach($tarifa_tipo as $tarifa){
|
||||
$builder->where("EXISTS (SELECT * FROM lg_maquinas_tarifas_impresion t2 WHERE t1.id=t2.maquina_id AND t2.tipo='{$tarifa}' AND t2.uso='{$uso_tarifa}' AND t2.is_deleted=0)");
|
||||
}
|
||||
}
|
||||
else{
|
||||
$builder->where("t2.tipo", $tarifa_tipo);
|
||||
$builder->where("t2.uso", $uso_tarifa);
|
||||
if (is_array($tarifa_tipo)) {
|
||||
foreach ($tarifa_tipo as $tarifa) {
|
||||
$builder->where("EXISTS (SELECT * FROM lg_maquinas_tarifas_impresion t2 WHERE t1.id=t2.maquina_id AND t2.tipo='{$tarifa}' AND t2.uso='{$uso_tarifa}' AND t2.is_deleted=0)");
|
||||
}
|
||||
} else {
|
||||
$builder->where("t2.tipo", $tarifa_tipo);
|
||||
$builder->where("t2.uso", $uso_tarifa);
|
||||
}
|
||||
|
||||
return $builder;
|
||||
|
||||
}
|
||||
|
||||
public function getNombre($id){
|
||||
public function getNombre($id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.nombre AS text");
|
||||
|
||||
"t1.nombre AS text"
|
||||
);
|
||||
|
||||
$builder->where("t1.id", $id);
|
||||
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
@ -383,16 +385,32 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
* @param string|null $type Tipo de maquina impresion,manipulado,acabado
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectQuery(?string $q = null, ?string $type = null) : array
|
||||
public function getSelectQuery(?string $q = null, ?string $type = null): array
|
||||
{
|
||||
$query = $this->builder()->select(["id","nombre","tipo as description"])
|
||||
->where("deleted_at",null);
|
||||
if($q){
|
||||
$query->like("nombre",$q);
|
||||
$query = $this->builder()->select(["id", "nombre", "tipo as description"])
|
||||
->where("deleted_at", null);
|
||||
if ($q) {
|
||||
$query->like("nombre", $q);
|
||||
}
|
||||
if($type){
|
||||
$query->where("tipo",$type);
|
||||
if ($type) {
|
||||
$query->where("tipo", $type);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function queryViewMaquinistaMaquinas($maquina_tipo = "impresion")
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select([
|
||||
'lg_maquinas.id as maquinaId',
|
||||
'lg_maquinas.nombre',
|
||||
'COUNT(orden_trabajo_tareas.id) as countTareas'
|
||||
])
|
||||
->join('orden_trabajo_tareas','orden_trabajo_tareas.maquina_id = lg_maquinas.id','left')
|
||||
->where('lg_maquinas.tipo', $maquina_tipo)
|
||||
->where('lg_maquinas.deleted_at',null)
|
||||
->groupBy('lg_maquinas.id');
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user