mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
festivo entity model
This commit is contained in:
14
ci4/app/Entities/Configuracion/FestivoEntity.php
Normal file
14
ci4/app/Entities/Configuracion/FestivoEntity.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entities\Configuracion;
|
||||||
|
|
||||||
|
use CodeIgniter\Entity\Entity;
|
||||||
|
|
||||||
|
class FestivoEntity extends Entity
|
||||||
|
{
|
||||||
|
protected $attributes = [
|
||||||
|
"id" => null,
|
||||||
|
"date" => null,
|
||||||
|
];
|
||||||
|
protected $casts = [];
|
||||||
|
}
|
||||||
132
ci4/app/Models/Configuracion/FestivoModel.php
Executable file
132
ci4/app/Models/Configuracion/FestivoModel.php
Executable file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Configuracion;
|
||||||
|
|
||||||
|
use App\Entities\Configuracion\FestivoEntity;
|
||||||
|
use App\Entities\Configuracion\Imposicion;
|
||||||
|
use App\Models\BaseModel;
|
||||||
|
|
||||||
|
class ImposicionModel extends BaseModel
|
||||||
|
{
|
||||||
|
protected $table = "festivos";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected $allowedFields = ["date"];
|
||||||
|
protected $returnType = FestivoEntity::class;
|
||||||
|
|
||||||
|
public static $labelField = "ancho";
|
||||||
|
|
||||||
|
protected $validationRules = [
|
||||||
|
|
||||||
|
"date" => [
|
||||||
|
"label" => "Festivos.fecha",
|
||||||
|
"rules" => "required|datetime",
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $validationMessages = [
|
||||||
|
"alto" => [
|
||||||
|
"integer" => "Imposiciones.validation.alto.integer",
|
||||||
|
"required" => "Imposiciones.validation.alto.required",
|
||||||
|
],
|
||||||
|
"ancho" => [
|
||||||
|
"integer" => "Imposiciones.validation.ancho.integer",
|
||||||
|
"required" => "Imposiciones.validation.ancho.required",
|
||||||
|
],
|
||||||
|
"etiqueta" => [
|
||||||
|
"max_length" => "Imposiciones.validation.etiqueta.max_length",
|
||||||
|
],
|
||||||
|
"maquina" => [
|
||||||
|
"max_length" => "Imposiciones.validation.maquina.max_length",
|
||||||
|
],
|
||||||
|
"orientacion" => [
|
||||||
|
"in_list" => "Imposiciones.validation.orientacion.in_list",
|
||||||
|
],
|
||||||
|
"unidades" => [
|
||||||
|
"integer" => "Imposiciones.validation.unidades.integer",
|
||||||
|
],
|
||||||
|
"imposicion_esquema_id" => [
|
||||||
|
"integer" => "Imposiciones.validation.unidades.integer",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get resource data.
|
||||||
|
*
|
||||||
|
* @param string $search
|
||||||
|
*
|
||||||
|
* @return \CodeIgniter\Database\BaseBuilder
|
||||||
|
*/
|
||||||
|
public function getResource(string $search = "")
|
||||||
|
{
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.id AS id, t1.ancho AS ancho, t1.alto AS alto, t1.unidades AS unidades, t1.orientacion AS orientacion, t1.maquina AS maquina, t1.etiqueta AS etiqueta"
|
||||||
|
);
|
||||||
|
|
||||||
|
return empty($search)
|
||||||
|
? $builder
|
||||||
|
: $builder
|
||||||
|
->groupStart()
|
||||||
|
->like("t1.id", $search)
|
||||||
|
->orlike("t1.ancho", $search)
|
||||||
|
->orLike("t1.alto", $search)
|
||||||
|
->orLike("t1.unidades", $search)
|
||||||
|
->orLike("t1.orientacion", $search)
|
||||||
|
->orLike("t1.maquina", $search)
|
||||||
|
->orLike("t1.etiqueta", $search)
|
||||||
|
->orlike("t1.id", $search)
|
||||||
|
->orLike("t1.ancho", $search)
|
||||||
|
->orLike("t1.alto", $search)
|
||||||
|
->orLike("t1.unidades", $search)
|
||||||
|
->orLike("t1.orientacion", $search)
|
||||||
|
->orLike("t1.maquina", $search)
|
||||||
|
->orLike("t1.etiqueta", $search)
|
||||||
|
->groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function querySelect(?string $q)
|
||||||
|
{
|
||||||
|
$query = $this->builder()->select([
|
||||||
|
"id",
|
||||||
|
"CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto,'_',COALESCE(lg_imposiciones.unidades,'NULL'),'_',COALESCE(lg_imposiciones.orientacion,'NULL')) as name",
|
||||||
|
"COALESCE(lg_imposiciones.etiqueta,'" . lang("Produccion.imposicion_no_label") . "') as description"
|
||||||
|
]);
|
||||||
|
if ($q) {
|
||||||
|
$query->orLike("CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto)", $q);
|
||||||
|
$query->orLike("lg_imposiciones.etiqueta", $q);
|
||||||
|
}
|
||||||
|
return $query
|
||||||
|
->orderBy('id', 'ASC')
|
||||||
|
->get()->getResultArray();
|
||||||
|
}
|
||||||
|
public function queryDatatable()
|
||||||
|
{
|
||||||
|
return $this->builder()
|
||||||
|
->select([
|
||||||
|
"lg_imposiciones.id",
|
||||||
|
"lg_imposiciones.ancho",
|
||||||
|
"lg_imposiciones.alto",
|
||||||
|
"lg_imposiciones.unidades",
|
||||||
|
"lg_imposiciones.maquina",
|
||||||
|
"lg_imposiciones.orientacion",
|
||||||
|
"lg_imposiciones.etiqueta",
|
||||||
|
"imposicion_esquemas.id as esquemaId",
|
||||||
|
"imposicion_esquemas.name as esquemaName"
|
||||||
|
])
|
||||||
|
->join("imposicion_esquemas","imposicion_esquemas.id = lg_imposiciones.imposicion_esquema_id","left")
|
||||||
|
->where('lg_imposiciones.deleted_at', null);
|
||||||
|
}
|
||||||
|
public static function datatable_buttons(int $id)
|
||||||
|
{
|
||||||
|
$btn = "";
|
||||||
|
if(auth()->user()->inGroup("admin")){
|
||||||
|
$btn.="<a type='button' href='/imposiciones/edit/{$id}' data-id='{$id}'><i class='ti ti-eye ti-sm'></i></a>";
|
||||||
|
$btn.="<a type='button'><i class='ti ti-trash ti-sm imposicion-delete' data-id='{$id}'></i></a>";
|
||||||
|
}
|
||||||
|
return $btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user