terminando la consulta get resource del modelo maquinaspapelimpresion

This commit is contained in:
Jaime Jimenez
2023-06-30 11:34:30 +02:00
parent 38dd7cdadf
commit d356974178
11 changed files with 269 additions and 110 deletions

View File

@ -1,7 +1,7 @@
<?php
namespace App\Models\Configuracion;
class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
{
protected $table = "lg_maquina_papel_impresion";
@ -13,9 +13,15 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
protected $useAutoIncrement = true;
const SORTABLE = [
1 => "t1.maquina_id",
2 => "t1.papel_impresion_id",
3 => "t1.active",
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"];
@ -29,20 +35,34 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource(string $search = "", $tarifas = null, $isRotativa = false)
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"
"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", "t3.papel_impresion_id = t3.id", "left");
$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 = "";
if (!is_null($tarifas)){
// Si hay tarifas...
/*if (!empty($tarifas)){
foreach ($tarifas as $tarifa){
if (!$isFirst)
$where_str += ' OR ';
@ -55,17 +75,13 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
}
$builder->where($where_str);
}
if($isRotativa){
$builder->where("t3.rotativa", 1);
}
else{
$builder->where("t3.rotativa", 0);
}
}*/
// si no hay tarifas no hay que devolver nada
/*else{
return "";
}*/
$builder->where("t2.is_deleted", 0);
$builder->where("t3.is_deleted", 0);
return empty($search)
? $builder

View File

@ -18,11 +18,10 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
3 => "t1.tipo",
4 => "t1.precio",
5 => "t1.uso",
6 => "t1.predeterminado",
7 => "t2.nombre",
6 => "t2.nombre",
];
protected $allowedFields = ["maquina_id", "tipo", "precio", "uso", "predeterminado"];
protected $allowedFields = ["maquina_id", "tipo", "precio", "uso"];
protected $returnType = "App\Entities\Configuracion\MaquinasTarifasImpresionEntity";
protected $useTimestamps = true;
@ -96,7 +95,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tipo AS tipo, t1.precio AS precio, t1.uso AS uso, t1.predeterminado AS predeterminado, t2.nombre AS maquina"
"t1.id AS id, t1.tipo AS tipo, t1.precio AS precio, t1.uso AS uso, t2.nombre AS maquina"
);
//JJO