This commit is contained in:
amazuecos
2024-12-15 16:07:54 +01:00
parent 71157bfda5
commit d5719b70a1
31 changed files with 970 additions and 502 deletions

View File

@ -0,0 +1,97 @@
<?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 = true;
protected $returnType = OrdenTrabajoDateEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
protected $allowedFields = [
"orden_trabajo_id",
"fecha_entrada_at",
"fecha_entrega_at",
"fecha_entrega_change_at",
"fecha_entrega_real_at",
"fecha_entrega_real_warning",
"fecha_impresion_at",
"fecha_encuadernado_at",
"fecha_externo_at",
"fecha_entrega_warning" ,
"fecha_entrega_warning_revised",
"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 = [];
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;
}
}

View File

@ -15,54 +15,14 @@ class OrdenTrabajoModel extends Model
protected $protectFields = true;
protected $allowedFields = [
"pedido_id",
"maquina_orden_negro_id",
"maquina_orden_color_id",
"maquina_orden_portada_id",
"maquina_orden_cubierta_id",
"negro_forma_id",
"color_forma_id",
"portada_forma_id",
"cubierta_forma_id",
"tirada",
"negro_pliegos_pedido",
"color_pliegos_pedido",
"portada_pliegos_pedido",
"cubierta_pliegos_pedido",
"negro_clicks_pedido",
"color_clicks_pedido",
"portada_clicks_pedido",
"cubierta_clicks_pedido",
"pliegos1",
"paginas1",
"pliegos2",
"paginas2",
"negro_proveedor_nombre",
"color_proveedor_nombre",
"portada_proveedor_nombre",
"corte_pie",
"lomo",
"user_created_id",
"user_updated_id",
"total_tirada",
"total_precio",
"tipo_entrada",
"fecha_entrega_real_warning",
"fecha_entrega_warning",
"fecha_entrega_warning_revised",
"ferro_disponible",
"ferro_disponible_thread_id",
"ferro_cp",
"ferro_proveedor",
"ferro_tracking",
"pre_formato",
"pre_lomo",
"pre_solapa",
"pre_isbn",
"pre_codbarras",
"pre_imposicion",
"pre_imprimir",
"pre_faltan_materiales",
"pre_faltan_materiales_note",
"progreso",
"message_production_send",
"finalizado",
"comentarios"
"estado",
"comentarios",
];
protected bool $allowEmptyInserts = false;
@ -97,23 +57,26 @@ class OrdenTrabajoModel extends Model
public function getDatatableQuery() : BaseBuilder
{
$q = $this->builder("ordenes_trabajo ot")
$q = $this->builder()
->select([
"pedidos.id",
"ordenes_trabajo.id",
"ordenes_trabajo.pedido_id",
"orden_trabajo_dates.fecha_encuadernado_at",
"clientes.nombre as client_name",
"presupuestos.titulo as presupuesto_title",
"tp.codigo as tipo_presupuesto_impresion",
"ubicaciones.nombre as ubicacion_name",
"clientes.nombre as cliente_nombre",
"presupuestos.titulo as presupuesto_titulo",
"ubicaciones.nombre as ubicacion_nombre",
"pedidos.total_tirada",
"tipos_presupuestos.codigo as tipo_presupuesto_impresion",
])
->join("orden_trabajo_dates otdates","otdates.orden_trabajo_id = ot.id","left")
->join("pedidos","pedidos.id = ot.pedido_id","left")
->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("clientes","clientes.id = presupuestos.cliente_id","left")
->join("tipos_presupuestos tp","presupuestos.tipo_impresion_id = tp.id","left")
->join("tipos_presupuestos","presupuestos.tipo_impresion_id = tipos_presupuestos.id","left")
->join("ubicaciones","ubicaciones.id = pedidos_linea.ubicacion_id","left")
->groupBy("ot.id");
->where("ordenes_trabajo.deleted_at",null)
->groupBy("ordenes_trabajo.id");
return $q;
}

View File

@ -0,0 +1,81 @@
<?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",
"nombre",
"orden",
"maquina_id",
"imposicion_id",
"tiempo_estimado",
"tiempo_real"
];
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;
}
}

View File

@ -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();