ordenes trabajo

This commit is contained in:
amazuecos
2025-01-02 10:50:56 +01:00
parent 340ab4ec5f
commit b50ba4f2a3
57 changed files with 3005 additions and 417 deletions

View File

@ -10,7 +10,7 @@ class OrdenTrabajoDate extends Model
{
protected $table = 'orden_trabajo_dates';
protected $primaryKey = 'orden_trabajo_id';
protected $useAutoIncrement = true;
protected $useAutoIncrement = false;
protected $returnType = OrdenTrabajoDateEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
@ -18,14 +18,11 @@ class OrdenTrabajoDate extends Model
"orden_trabajo_id",
"fecha_entrada_at",
"fecha_entrega_at",
"fecha_entrega_change_at",
"fecha_entrega_real_at",
"fecha_entrega_real_warning",
"fecha_entrega_change_at",
"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",
@ -38,13 +35,14 @@ class OrdenTrabajoDate extends Model
"corte_at",
"embalaje_at",
"envio_at",
"entrada_manipulado_at"
"entrada_manipulado_at"
];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $casts = [
];
protected array $castHandlers = [];
// Dates
@ -63,8 +61,8 @@ class OrdenTrabajoDate extends Model
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterInsert = ["updateOrdenTrabajoUser"];
protected $beforeUpdate = ["updateOrdenTrabajoUser"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
@ -76,22 +74,59 @@ class OrdenTrabajoDate extends Model
*
* @return Builder
*/
protected function getQueryDatatable() : 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);
->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]);
}
}
}
}
}

View File

@ -17,18 +17,45 @@ class OrdenTrabajoModel extends Model
"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 = [];
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
@ -64,17 +91,23 @@ class OrdenTrabajoModel extends Model
"orden_trabajo_dates.fecha_encuadernado_at",
"clientes.nombre as cliente_nombre",
"presupuestos.titulo as presupuesto_titulo",
"ubicaciones.nombre as ubicacion_nombre",
"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;

View File

@ -27,7 +27,8 @@ class OrdenTrabajoTarea extends Model
"maquina_id",
"imposicion_id",
"tiempo_estimado",
"tiempo_real"
"tiempo_real",
"comment"
];
protected bool $allowEmptyInserts = false;
@ -83,4 +84,7 @@ class OrdenTrabajoTarea extends Model
return $q;
}
}

View 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 = [];
}