mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el formulario maquinas
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_maquina_papel_impresion";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.maquina_id",
|
||||
2 => "t1.papel_impresion_id",
|
||||
3 => "t1.active",
|
||||
];
|
||||
|
||||
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 = "", $tarifas = null, $isRotativa = false)
|
||||
{
|
||||
$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"
|
||||
);
|
||||
|
||||
$builder->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left");
|
||||
$builder->join("lg_papel_impresion t3", "t3.papel_impresion_id = t3.id", "left");
|
||||
|
||||
$isFirst = false;
|
||||
$where_str = "";
|
||||
if (!is_null($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);
|
||||
}
|
||||
if($isRotativa){
|
||||
$builder->where("t3.rotativa", 1);
|
||||
}
|
||||
else{
|
||||
$builder->where("t3.rotativa", 0);
|
||||
}
|
||||
|
||||
$builder->where("t2.is_deleted", 0);
|
||||
$builder->where("t3.is_deleted", 0);
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t2.nombre", $search)
|
||||
->orLike("t3.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user