mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'mod/presupuesto_admin' of https://git.imnavajas.es/jjimenez/safekat into mod/presupuesto_admin
This commit is contained in:
@ -375,4 +375,24 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query for select2
|
||||
*
|
||||
* @param string|null $q Query param from select2 ajax request
|
||||
* @param string|null $type Tipo de maquina impresion,manipulado,acabado
|
||||
* @return 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);
|
||||
}
|
||||
if($type){
|
||||
$query->where("tipo",$type);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
}
|
||||
|
||||
68
ci4/app/Models/Configuracion/MaquinaTareaModel.php
Normal file
68
ci4/app/Models/Configuracion/MaquinaTareaModel.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\TareaMaquinaEntity;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class MaquinaTareaModel extends Model
|
||||
{
|
||||
protected $table = 'maquina_tareas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = TareaMaquinaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"name",
|
||||
"description",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query for select2
|
||||
*
|
||||
* @param string|null $q Query param from select2 ajax request
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function getSelectQuery(?string $q = null) : array
|
||||
{
|
||||
$query = $this->builder()->select(["id","name","description"])
|
||||
->where("deleted_at",null);
|
||||
if($q){
|
||||
$query->like("nombre",$q);
|
||||
}
|
||||
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
}
|
||||
143
ci4/app/Models/Configuracion/ServicioClienteModel.php
Normal file
143
ci4/app/Models/Configuracion/ServicioClienteModel.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use App\Entities\Configuracion\ServicioClienteEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ServicioClienteModel extends Model
|
||||
{
|
||||
|
||||
protected $table = 'servicios_cliente';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = ServicioClienteEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"code",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query para datatable
|
||||
*
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function getQueryDatatable(): BaseBuilder
|
||||
{
|
||||
$q = $this->builder()->select(["id", "nombre", "code", "created_at"])->where("deleted_at", null);
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
* Actualiza la tarifa de acabado `lg_tarifas_acabado` si ya existe una asociada o inserta si ya no existe.
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_acabado_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function upsertTarifaAcabado(int $servicio_cliente_id, int $tarifa_acabado_id): bool
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$q = $servicioClienteTareaModel
|
||||
->where("servicio_cliente_id", $servicio_cliente_id);
|
||||
if ($q->countAllResults() > 0) {
|
||||
$this->detachTarifas($servicio_cliente_id);
|
||||
}
|
||||
$r = $this->attachTarifaAcabado($servicio_cliente_id, $tarifa_acabado_id);
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Actualiza la tarifa de manipulado `lg_tarifas_manipulado` si ya existe una asociada o inserta si ya no existe.
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_manipulado_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function upsertTarifaManipulado(int $servicio_cliente_id, int $tarifa_manipulado_id): bool
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$q = $servicioClienteTareaModel
|
||||
->where("servicio_cliente_id", $servicio_cliente_id);
|
||||
if ($q->countAllResults() > 0) {
|
||||
$this->detachTarifas($servicio_cliente_id);
|
||||
}
|
||||
$r = $this->attachTarifaManipulado($servicio_cliente_id, $tarifa_manipulado_id);
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Asocia tarifa de acabado a servicio cliente
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_acabado_id
|
||||
* @return integer
|
||||
*/
|
||||
public function attachTarifaAcabado(int $servicio_cliente_id, int $tarifa_acabado_id): int
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$id = $servicioClienteTareaModel->insert([
|
||||
"servicio_cliente_id" => $servicio_cliente_id,
|
||||
"tarifa_acabado_id" => $tarifa_acabado_id
|
||||
]);
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* Asocia tarifa de manipulado a servicio cliente
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_manipulado_id
|
||||
* @return integer
|
||||
*/
|
||||
public function attachTarifaManipulado(int $servicio_cliente_id, int $tarifa_manipulado_id): int
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$id = $servicioClienteTareaModel->insert([
|
||||
"servicio_cliente_id" => $servicio_cliente_id,
|
||||
"tarifa_manipulado_id" => $tarifa_manipulado_id
|
||||
]);
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* Elimina todas las tarifas asociadas a un servicio cliente
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @return bool
|
||||
*/
|
||||
public function detachTarifas(int $servicio_cliente_id): bool
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$s = $servicioClienteTareaModel->where("servicio_cliente_id", $servicio_cliente_id)->delete();
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
53
ci4/app/Models/Configuracion/ServicioClienteTareaModel.php
Normal file
53
ci4/app/Models/Configuracion/ServicioClienteTareaModel.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ServicioClienteTareaModel extends Model
|
||||
{
|
||||
protected $table = 'servicio_cliente_tareas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"servicio_cliente_id",
|
||||
"tarifa_acabado_id",
|
||||
"tarifa_manipulado_id",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
|
||||
}
|
||||
132
ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php
Normal file
132
ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OrdenTrabajo;
|
||||
|
||||
use App\Entities\Produccion\OrdenTrabajoDateEntity;
|
||||
use CodeIgniter\Database\MySQLi\Builder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OrdenTrabajoDate extends Model
|
||||
{
|
||||
protected $table = 'orden_trabajo_dates';
|
||||
protected $primaryKey = 'orden_trabajo_id';
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = OrdenTrabajoDateEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"orden_trabajo_id",
|
||||
"fecha_entrada_at",
|
||||
"fecha_entrega_at",
|
||||
"fecha_entrega_real_at",
|
||||
"fecha_entrega_change_at",
|
||||
"fecha_impresion_at",
|
||||
"fecha_encuadernado_at",
|
||||
"fecha_externo_at",
|
||||
"pendiente_ferro_at",
|
||||
"ferro_en_cliente_at",
|
||||
"ferro_ok_at",
|
||||
"interior_bn_at",
|
||||
"interior_color_at",
|
||||
"preparacion_interiores_at",
|
||||
"cubierta_at",
|
||||
"plastificado_at",
|
||||
"encuadernacion_at",
|
||||
"corte_at",
|
||||
"embalaje_at",
|
||||
"envio_at",
|
||||
"entrada_manipulado_at"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [
|
||||
];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = ["updateOrdenTrabajoUser"];
|
||||
protected $beforeUpdate = ["updateOrdenTrabajoUser"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query datatable
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function getQueryDatatable(): Builder
|
||||
{
|
||||
$q = $this->builder()
|
||||
->select([
|
||||
"orden_trabajo_tareas.orden",
|
||||
"mp.nombre as maquina_presupuesto",
|
||||
"m.nombre as maquina_tarea",
|
||||
"orden_trabajo_tareas.tiempo_estimado",
|
||||
"orden_trabajo_tareas.tiempo_real"
|
||||
])
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->join("lg_maquinas m", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left")
|
||||
->join("lg_maquinas mp", "lg_maquinas.id = presupuesto_linea.maquina_id", "left")
|
||||
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left")
|
||||
->where("orden_trabajo_tareas.deleted_at", NULL);
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
protected function updateOrdenTrabajoUser(array $data) : array
|
||||
{
|
||||
if(!isset($data["data"])){
|
||||
return $data;
|
||||
}else{
|
||||
$this->updateUserDateMap($data["data"]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
protected function updateUserDateMap($data){
|
||||
$mapping = [
|
||||
"fecha_encuadernado_at" => "encuadernacion_user_id",
|
||||
// "fecha_externo_at" => "null",
|
||||
"fecha_impresion_at" => "null",
|
||||
"pendiente_ferro_at" => "pendiente_ferro_user_id",
|
||||
"ferro_en_cliente_at" => "ferro_en_cliente_user_id",
|
||||
"ferro_ok_at" => "ferro_ok_user_id",
|
||||
"interior_bn_at" => "interior_bn_user_id",
|
||||
"interior_color_at" => "interior_color_user_id",
|
||||
"preparacion_interiores_at" => "preparacion_interior_user_id",
|
||||
"cubierta_at" => "cubierta_user_id",
|
||||
"plastificado_at" => "plastificado_user_id",
|
||||
"corte_at" => "corte_user_id",
|
||||
"embalaje_at" => "embalaje_user_id",
|
||||
"entrada_manipulado_at" => "entrada_manipulado_user_id"
|
||||
];
|
||||
$otUser = model(OrdenTrabajoUser::class);
|
||||
$auth_user_id = auth()->user()->id;
|
||||
foreach ($data as $key => $value) {
|
||||
if(isset($mapping[$key])){
|
||||
if($value){
|
||||
$otUser->update($data["orden_trabajo_id"],[$mapping[$key] => $auth_user_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php
Normal file
120
ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OrdenTrabajo;
|
||||
|
||||
use App\Entities\Produccion\OrdenTrabajoEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
class OrdenTrabajoModel extends Model
|
||||
{
|
||||
protected $table = 'ordenes_trabajo';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = OrdenTrabajoEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"pedido_id",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"fecha_entrega_warning",
|
||||
"fecha_entrega_warning_revised",
|
||||
"total_tirada",
|
||||
"total_precio",
|
||||
"tipo_entrada",
|
||||
"progreso",
|
||||
"estado",
|
||||
"comentarios",
|
||||
"revisar_formato",
|
||||
"revisar_lomo",
|
||||
"revisar_solapa",
|
||||
"revisar_isbn",
|
||||
"revisar_codigo_barras",
|
||||
"realizar_imposicion",
|
||||
"enviar_impresion",
|
||||
"portada_path",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [
|
||||
"pedido_id" => "integer",
|
||||
"user_created_id" => "?integer",
|
||||
"user_updated_id" => "?integer",
|
||||
"fecha_entrega_warning" => "bool",
|
||||
"fecha_entrega_warning_revised" => "bool",
|
||||
"total_tirada" => "?integer",
|
||||
"total_precio" => "?integer",
|
||||
"tipo_entrada" => "?integer",
|
||||
"progreso" => "float",
|
||||
"revisar_formato" => "bool",
|
||||
"revisar_lomo" => "bool",
|
||||
"revisar_solapa" => "bool",
|
||||
"revisar_isbn" => "bool",
|
||||
"revisar_codigo_barras" => "bool",
|
||||
"realizar_imposicion" => "bool",
|
||||
"enviar_impresion" => "bool"
|
||||
];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function getDatatableQuery() : BaseBuilder
|
||||
{
|
||||
$q = $this->builder()
|
||||
->select([
|
||||
"ordenes_trabajo.id",
|
||||
"ordenes_trabajo.pedido_id",
|
||||
"orden_trabajo_dates.fecha_encuadernado_at",
|
||||
"clientes.nombre as cliente_nombre",
|
||||
"presupuestos.titulo as presupuesto_titulo",
|
||||
"ordenes_trabajo.estado",
|
||||
"ubicaciones.nombre as ubicacion_nombre",
|
||||
"pedidos.total_tirada",
|
||||
"tipos_presupuestos.codigo as tipo_presupuesto_impresion",
|
||||
"ordenes_trabajo.progreso",
|
||||
"presupuesto_linea.tipo as presupuesto_linea_tipo",
|
||||
"orden_trabajo_dates.ferro_ok_at"
|
||||
])
|
||||
->join("orden_trabajo_dates","orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id","left")
|
||||
->join("pedidos","pedidos.id = ordenes_trabajo.pedido_id","left")
|
||||
->join("pedidos_linea","pedidos.id = pedidos_linea.pedido_id","left")
|
||||
->join("presupuestos","presupuestos.id = pedidos_linea.presupuesto_id","left")
|
||||
->join("presupuesto_linea","presupuestos.id = presupuesto_linea.presupuesto_id","left")
|
||||
->join("clientes","clientes.id = presupuestos.cliente_id","left")
|
||||
->join("tipos_presupuestos","presupuestos.tipo_impresion_id = tipos_presupuestos.id","left")
|
||||
->join("ubicaciones","ubicaciones.id = pedidos_linea.ubicacion_id","left")
|
||||
->whereIn("presupuesto_linea.tipo",["lp_bn","lp_bnhq","lp_rot_bn","lp_color","lp_colorhq","lp_rot_color"])
|
||||
->where("ordenes_trabajo.deleted_at",null)
|
||||
->groupBy("ordenes_trabajo.id");
|
||||
return $q;
|
||||
}
|
||||
|
||||
public function updateMaquinas(OrdenTrabajoEntity $ot)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
90
ci4/app/Models/OrdenTrabajo/OrdenTrabajoTarea.php
Normal file
90
ci4/app/Models/OrdenTrabajo/OrdenTrabajoTarea.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OrdenTrabajo;
|
||||
|
||||
use App\Entities\Produccion\OrdenTrabajoTareaEntity;
|
||||
use CodeIgniter\Database\MySQLi\Builder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OrdenTrabajoTarea extends Model
|
||||
{
|
||||
protected $table = 'orden_trabajo_tareas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = OrdenTrabajoTareaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"orden_trabajo_id",
|
||||
"presupuesto_linea_id",
|
||||
"presupuesto_acabado_id",
|
||||
"presupuesto_preimpresion_id",
|
||||
"presupuesto_encuadernado_id",
|
||||
"presupuesto_extra_id",
|
||||
"presupuesto_manipulado_id",
|
||||
"nombre",
|
||||
"orden",
|
||||
"maquina_id",
|
||||
"imposicion_id",
|
||||
"tiempo_estimado",
|
||||
"tiempo_real",
|
||||
"comment"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query datatable
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function getQueryDatatable() : Builder
|
||||
{
|
||||
$q = $this->builder()
|
||||
->select([
|
||||
"orden_trabajo_tareas.orden",
|
||||
"mp.nombre as maquina_presupuesto",
|
||||
"m.nombre as maquina_tarea",
|
||||
"orden_trabajo_tareas.tiempo_estimado",
|
||||
"orden_trabajo_tareas.tiempo_real"
|
||||
])
|
||||
->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left")
|
||||
->join("lg_maquinas m","lg_maquinas.id = orden_trabajo_tareas.maquina_id","left")
|
||||
->join("lg_maquinas mp","lg_maquinas.id = presupuesto_linea.maquina_id","left")
|
||||
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id" , "left")
|
||||
->where("orden_trabajo_tareas.deleted_at" , NULL);
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
103
ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php
Normal file
103
ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OrdenTrabajo;
|
||||
|
||||
use App\Entities\Produccion\OrdenTrabajoUserEntity;
|
||||
use CodeIgniter\Database\MySQLi\Builder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OrdenTrabajoUser extends Model
|
||||
{
|
||||
protected $table = 'orden_trabajo_users';
|
||||
protected $primaryKey = 'orden_trabajo_id';
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = OrdenTrabajoUserEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"orden_trabajo_id",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
"inaplazable_revised_change_user_id",
|
||||
"ferro_disponible_hecho_user_id",
|
||||
"ferro_disponible_ok_user_id",
|
||||
"ferro_entregado_user_id",
|
||||
"pendiente_ferro_user_id",
|
||||
"ferro_en_cliente_user_id",
|
||||
"ferro_ok_user_id",
|
||||
"interior_bn_user_id",
|
||||
"interior_color_user_id",
|
||||
"preparacion_interior_user_id",
|
||||
"cubierta_user_id",
|
||||
"plastificado_user_id",
|
||||
"encuadernacion_user_id",
|
||||
"corte_user_id",
|
||||
"embalaje_user_id",
|
||||
"entrada_manipulado_user_id",
|
||||
"pre_formato_user_id",
|
||||
"pre_lomo_user_id",
|
||||
"pre_solapa_user_id",
|
||||
"pre_codbarras_user_id",
|
||||
"pre_imposicion_user_id",
|
||||
"pre_imprimir_user_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [
|
||||
"orden_trabajo_id" => "integer",
|
||||
"user_created_id" => "?integer",
|
||||
"user_update_id" => "?integer",
|
||||
"inaplazable_revised_change_user_id" => "?integer",
|
||||
"ferro_disponible_hecho_user_id" => "?integer",
|
||||
"ferro_disponible_ok_user_id" => "?integer",
|
||||
"ferro_entregado_user_id" => "?integer",
|
||||
"pendiente_ferro_user_id" => "?integer",
|
||||
"ferro_en_cliente_user_id" => "?integer",
|
||||
"ferro_ok_user_id" => "?integer",
|
||||
"interior_bn_user_id" => "?integer",
|
||||
"interior_color_user_id" => "?integer",
|
||||
"preparacion_interior_user_id" => "?integer",
|
||||
"cubierta_user_id" => "?integer",
|
||||
"plastificado_user_id" => "?integer",
|
||||
"encuadernacion_user_id" => "?integer",
|
||||
"corte_user_id" => "?integer",
|
||||
"embalaje_user_id" => "?integer",
|
||||
"entrada_manipulado_user_id" => "?integer",
|
||||
"pre_formato_user_id" => "?integer",
|
||||
"pre_lomo_user_id" => "?integer",
|
||||
"pre_solapa_user_id" => "?integer",
|
||||
"pre_codbarras_user_id" => "?integer",
|
||||
"pre_imposicion_user_id" => "?integer",
|
||||
"pre_imprimir_user_id" => "?integer"
|
||||
];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
use App\Entities\Presupuestos\OrdenTrabajoEntity;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
class PedidoModel extends \App\Models\BaseModel
|
||||
@ -90,7 +93,7 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
|
||||
return $lineasPresupuesto;
|
||||
}
|
||||
public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id) : array|object|null
|
||||
public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id): array|object|null
|
||||
{
|
||||
$q = $this->db->table($this->table)
|
||||
->select(
|
||||
@ -185,15 +188,51 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
public function getPedidoPresupuestoFicheros($pedido_id)
|
||||
{
|
||||
$query = $this->db->table($this->table)
|
||||
->select([
|
||||
'presupuesto_ficheros.nombre as fileName',
|
||||
'presupuesto_ficheros.file_path as filePath'
|
||||
])
|
||||
->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left')
|
||||
->where('pedidos.id', $pedido_id);
|
||||
$presupuesto_ficheros = $query->get()->getFirstRow();
|
||||
return $presupuesto_ficheros;
|
||||
->select([
|
||||
'presupuesto_ficheros.nombre as fileName',
|
||||
'presupuesto_ficheros.file_path as filePath'
|
||||
])
|
||||
->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left')
|
||||
->where('pedidos.id', $pedido_id);
|
||||
$presupuesto_ficheros = $query->get()->getFirstRow();
|
||||
return $presupuesto_ficheros;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea una orden de trabajo asociada al pedido
|
||||
*
|
||||
* @param integer $pedido_id
|
||||
* @return void
|
||||
*/
|
||||
public function createOrdenTrabajo(int $pedido_id)
|
||||
{
|
||||
$otModel = model(OrdenTrabajoModel::class);
|
||||
$ot = new OrdenTrabajoEntity(["pedido_id" => $pedido_id]);
|
||||
$existOt = $this->hasOrdenTrabajo($pedido_id);
|
||||
if ($existOt) {
|
||||
$ot = $otModel->find($pedido_id);
|
||||
return $ot;
|
||||
}
|
||||
$otModel->updateMaquinas($ot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si el pedido tiene ya una orden de trabajo asociada
|
||||
*
|
||||
* @param integer $pedido_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasOrdenTrabajo(int $pedido_id): bool
|
||||
{
|
||||
$hasOrdenTrabajo = false;
|
||||
$q = $this->builder()->select("orden_trabajo.pedido_id")
|
||||
->join("ordenes_trabajo", "ordenes_trabajo.pedido_id = pedidos.id", "left")
|
||||
->where("ordenes_trabajo.pedido_id", $pedido_id)->countAllResults();
|
||||
if ($q > 0) {
|
||||
$hasOrdenTrabajo = true;
|
||||
}
|
||||
return $hasOrdenTrabajo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas\Maquinas;
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\TarifaAcabadoMaquinaEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class TarifaAcabadoMaquinaModel extends Model
|
||||
{
|
||||
protected $table = 'tarifa_acabado_maquinas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = TarifaAcabadoMaquinaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"tarifa_acabado_id",
|
||||
"maquina_id",
|
||||
"maquina_tarea_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query for datatable
|
||||
*
|
||||
* @param integer|null $tarifa_acabado_id
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function queryDatatable(?int $tarifa_acabado_id = null) : BaseBuilder
|
||||
{
|
||||
$query = $this->builder()->select(
|
||||
[
|
||||
"tarifa_acabado_maquinas.id",
|
||||
"lg_maquinas.nombre as maquinaNombre",
|
||||
"maquina_tareas.name as tareaNombre"
|
||||
]
|
||||
)->join("lg_maquinas","lg_maquinas.id = tarifa_acabado_maquinas.maquina_id","left")
|
||||
->join("maquina_tareas","maquina_tareas.id = tarifa_acabado_maquinas.maquina_tarea_id","left")
|
||||
->where("tarifa_acabado_maquinas.deleted_at",null);
|
||||
if ($tarifa_acabado_id)
|
||||
$query->where("tarifa_acabado_maquinas.tarifa_acabado_id", $tarifa_acabado_id);
|
||||
return $query;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas\Maquinas;
|
||||
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\TarifaEncuadernacionMaquinaEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class TarifaEncuadernacionMaquinaModel extends Model
|
||||
{
|
||||
protected $table = 'tarifa_encuadernacion_maquinas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = TarifaEncuadernacionMaquinaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"tarifa_encuadernacion_id",
|
||||
"maquina_id",
|
||||
"maquina_tarea_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
/**
|
||||
* Query for datatable
|
||||
*
|
||||
* @param integer|null $tarifa_encuadernacion_id
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function queryDatatable(?int $tarifa_encuadernacion_id = null): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()->select(
|
||||
[
|
||||
"tarifa_encuadernacion_maquinas.id",
|
||||
"lg_maquinas.nombre as maquinaNombre",
|
||||
"maquina_tareas.name as tareaNombre"
|
||||
]
|
||||
)->join("lg_maquinas","lg_maquinas.id = tarifa_encuadernacion_maquinas.maquina_id","left")
|
||||
->join("maquina_tareas","maquina_tareas.id = tarifa_encuadernacion_maquinas.maquina_tarea_id","left")
|
||||
->where("tarifa_encuadernacion_maquinas.deleted_at",null);
|
||||
if ($tarifa_encuadernacion_id)
|
||||
$query->where("tarifa_encuadernacion_maquinas.tarifa_encuadernacion_id", $tarifa_encuadernacion_id);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
75
ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php
Normal file
75
ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas\Maquinas;
|
||||
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\TarifaExtraMaquinaEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class TarifaExtraMaquinaModel extends Model
|
||||
{
|
||||
protected $table = 'tarifa_acabado_maquinas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = TarifaExtraMaquinaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"tarifa_extra_id",
|
||||
"maquina_id",
|
||||
"maquina_tarea_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query for datatable
|
||||
*
|
||||
* @param integer|null $tarifa_extra_id
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function queryDatatable(?int $tarifa_extra_id = null): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()->select(
|
||||
[
|
||||
"tarifa_extra_maquinas.id",
|
||||
"lg_maquinas.nombre as maquinaNombre",
|
||||
"maquina_tareas.name as tareaNombre"
|
||||
]
|
||||
)->join("lg_maquinas", "lg_maquinas.id = tarifa_extra_maquinas.maquina_id", "left")
|
||||
->join("maquina_tareas", "maquina_tareas.id = tarifa_extra_maquinas.maquina_tarea_id", "left")
|
||||
->where("tarifa_extra_maquinas.deleted_at", null);
|
||||
if ($tarifa_extra_id)
|
||||
$query->where("tarifa_extra_maquinas.tarifa_extra_id", $tarifa_extra_id);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas\Maquinas;
|
||||
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\TarifaManipuladoMaquinaEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class TarifaManipuladoMaquinaModel extends Model
|
||||
{
|
||||
protected $table = 'tarifa_manipulado_maquinas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = TarifaManipuladoMaquinaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"tarifa_manipulado_id",
|
||||
"maquina_id",
|
||||
"maquina_tarea_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query for datatable
|
||||
*
|
||||
* @param integer|null $tarifa_manipulado_id
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function queryDatatable(?int $tarifa_manipulado_id = null): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()->select(
|
||||
[
|
||||
"tarifa_manipulado_maquinas.id",
|
||||
"lg_maquinas.nombre as maquinaNombre",
|
||||
"maquina_tareas.name as tareaNombre"
|
||||
]
|
||||
)->join("lg_maquinas", "lg_maquinas.id = tarifa_manipulado_maquinas.maquina_id", "left")
|
||||
->join("maquina_tareas", "maquina_tareas.id = tarifa_manipulado_maquinas.maquina_tarea_id", "left")
|
||||
->where("tarifa_manipulado_maquinas.deleted_at", null);
|
||||
if ($tarifa_manipulado_id)
|
||||
$query->where("tarifa_manipulado_maquinas.tarifa_manipulado_id", $tarifa_manipulado_id);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas\Maquinas;
|
||||
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\TarifaPreimpresionMaquinaEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class TarifaPreimpresionMaquinaModel extends Model
|
||||
{
|
||||
protected $table = 'tarifa_acabado_maquinas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = TarifaPreimpresionMaquinaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"tarifa_preimpresion_id",
|
||||
"maquina_id",
|
||||
"maquina_tarea_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query for datatable
|
||||
*
|
||||
* @param integer|null $tarifa_preimpresion_id
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function queryDatatable(?int $tarifa_preimpresion_id = null): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()->select(
|
||||
[
|
||||
"tarifa_preimpresion_maquinas.id",
|
||||
"lg_maquinas.nombre as maquinaNombre",
|
||||
"maquina_tareas.name as tareaNombre"
|
||||
]
|
||||
)->join("lg_maquinas", "lg_maquinas.id = tarifa_preimpresion_maquinas.maquina_id", "left")
|
||||
->join("maquina_tareas", "maquina_tareas.id = tarifa_preimpresion_maquinas.maquina_tarea_id", "left")
|
||||
->where("tarifa_preimpresion_maquinas.deleted_at", null);
|
||||
if ($tarifa_preimpresion_id)
|
||||
$query->where("tarifa_preimpresion_maquinas.tarifa_preimpresion_id", $tarifa_preimpresion_id);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@ -5,10 +5,13 @@ declare(strict_types=1);
|
||||
namespace App\Models;
|
||||
|
||||
use App\Entities\Usuarios\UsersEntity;
|
||||
use CodeIgniter\Shield\Authentication\Traits\HasAccessTokens;
|
||||
use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;
|
||||
|
||||
class UserModel extends ShieldUserModel
|
||||
{
|
||||
use HasAccessTokens;
|
||||
|
||||
protected function initialize(): void
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
Reference in New Issue
Block a user