mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
95 lines
2.8 KiB
PHP
95 lines
2.8 KiB
PHP
<?php
|
|
namespace App\Models\Configuracion;
|
|
|
|
class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|
{
|
|
protected $table = "lg_maquina_papel_impresion";
|
|
|
|
/**
|
|
* Whether primary key uses auto increment.
|
|
*
|
|
* @var bool
|
|
*/
|
|
protected $useAutoIncrement = true;
|
|
|
|
const SORTABLE = [
|
|
0 => "t1.active",
|
|
1 => "t4.nombre",
|
|
2 => "t3.nombre",
|
|
3 => "t3.gramaje",
|
|
4 => "t3.bn",
|
|
5 => "t3.color",
|
|
6 => "t3.cubierta",
|
|
7 => "t3.sobrecubierta",
|
|
8 => "t3.rotativa",
|
|
];
|
|
|
|
protected $allowedFields = ["maquina_id", "papel_impresion_id", "active"];
|
|
protected $returnType = "App\Entities\Configuracion\MaquinasPapelesImpresionEntity";
|
|
|
|
|
|
/**
|
|
* Get resource data.
|
|
*
|
|
* @param string $search
|
|
*
|
|
* @return \CodeIgniter\Database\BaseBuilder
|
|
*/
|
|
public function getResource(string $search = "", $isRotativa = 0)
|
|
{
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.maquina_id AS maquina_id, t1.papel_impresion_id AS papel_impresion_id, t1.active AS active, t2.nombre AS maquina,
|
|
t3.nombre AS papel_impresion, t3.gramaje AS gramaje, , t3.bn AS bn, t3.color AS color, t3.cubierta AS cubierta, , t3.sobrecubierta AS sobrecubierta,
|
|
t3.rotativa AS rotativa, t4.nombre as papel_generico"
|
|
);
|
|
|
|
|
|
$builder->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left");
|
|
$builder->join("lg_papel_impresion t3", "t1.papel_impresion_id = t3.id", "left");
|
|
$builder->join("lg_papel_generico t4", "t3.papel_generico_id = t4.id", "left");
|
|
|
|
$builder->where("t2.is_deleted", 0);
|
|
$builder->where("t3.is_deleted", 0);
|
|
$builder->where("t4.is_deleted", 0);
|
|
$builder->where("t3.isActivo", 1);
|
|
|
|
$builder->where("t3.rotativa", $isRotativa);
|
|
|
|
|
|
|
|
$isFirst = false;
|
|
$where_str = "";
|
|
// Si hay tarifas...
|
|
/*if (!empty($tarifas)){
|
|
foreach ($tarifas as $tarifa){
|
|
if (!$isFirst)
|
|
$where_str += ' OR ';
|
|
if ($tarifa->uso == 'portada')
|
|
$where_str += "t3.portada=1 AND ";
|
|
if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq')
|
|
$where_str += "t3.bn=1";
|
|
else
|
|
$where_str += "t3.bn=1";
|
|
}
|
|
|
|
$builder->where($where_str);
|
|
}*/
|
|
// si no hay tarifas no hay que devolver nada
|
|
/*else{
|
|
return "";
|
|
}*/
|
|
|
|
|
|
|
|
return empty($search)
|
|
? $builder
|
|
: $builder
|
|
->groupStart()
|
|
->like("t2.nombre", $search)
|
|
->orLike("t3.nombre", $search)
|
|
->groupEnd();
|
|
}
|
|
}
|