From a88ffda50df60eac365ee2fdfe47b825755400b9 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Fri, 2 May 2025 21:02:53 +0200 Subject: [PATCH] add revision preimpresion ot --- .../Controllers/Produccion/Ordentrabajo.php | 2 +- ...rdenesTrabajoRevisionPreimpresionCheck.php | 33 ++++++++++ .../Produccion/OrdenTrabajoEntity.php | 17 ++++++ ci4/app/Language/es/Produccion.php | 1 + .../Models/OrdenTrabajo/OrdenTrabajoModel.php | 5 +- ci4/app/Services/ProductionService.php | 13 ++-- .../vuexy/form/produccion/ot/otProgress.php | 60 ++++++++++++++----- .../assets/js/safekat/pages/produccion/ot.js | 8 +++ 8 files changed, 119 insertions(+), 20 deletions(-) create mode 100755 ci4/app/Database/Migrations/2025-05-02_202300_AlterOrdenesTrabajoRevisionPreimpresionCheck.php diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 9d244726..32a1a647 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -287,7 +287,7 @@ class Ordentrabajo extends BaseController { $logo = config(LogoImpresion::class); - $q = $this->otModel->getDatatableQuery(); + $q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada',false); return DataTable::of($q) ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()]) ->edit( diff --git a/ci4/app/Database/Migrations/2025-05-02_202300_AlterOrdenesTrabajoRevisionPreimpresionCheck.php b/ci4/app/Database/Migrations/2025-05-02_202300_AlterOrdenesTrabajoRevisionPreimpresionCheck.php new file mode 100755 index 00000000..a7078c6f --- /dev/null +++ b/ci4/app/Database/Migrations/2025-05-02_202300_AlterOrdenesTrabajoRevisionPreimpresionCheck.php @@ -0,0 +1,33 @@ + [ + 'type' => 'BOOL', + 'default' => false + ], + 'preimpresion_revisada_by' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 11, + ], + ]; + public function up() + { + + $this->forge->addColumn('ordenes_trabajo',$this->COLUMNS); + $this->forge->addForeignKey('preimpresion_revisada_by','users','id','NULL','NULL'); + $this->forge->processIndexes('ordenes_trabajo'); + } + + public function down() + { + $this->forge->dropForeignKey('ordenes_trabajo','ordenes_trabajo_preimpresion_revisada_by_foreign'); + $this->forge->dropColumn('ordenes_trabajo',array_keys($this->COLUMNS)); + } +} diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index b80de21d..5a1af2e0 100755 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -45,6 +45,9 @@ class OrdenTrabajoEntity extends Entity "portada_path" => null, "is_pedido_espera" => null, "pedido_espera_by" => null, + "preimpresion_revisada" => false, + "preimpresion_revisada_by" => null, + ]; protected $casts = [ "pedido_id" => "integer", @@ -72,6 +75,7 @@ class OrdenTrabajoEntity extends Entity "enviar_impresion" => "bool", "portada_path" => "string", "is_pedido_espera" => "bool", + "preimpresion_revisada" => "bool", ]; @@ -178,10 +182,23 @@ class OrdenTrabajoEntity extends Entity return null; } } + public function preimpresionRevisadaUser(): ?UserEntity + { + $m = model(UserModel::class); + if ($this->attributes['preimpresion_revisada_by']) { + return $m->findById($this->attributes['preimpresion_revisada_by']); + } else { + return null; + } + } public function getPedidoEsperaBy(): ?UserEntity { return $this->pedidoEsperaBy(); } + public function getPreimpresionRevisadaBy(): ?UserEntity + { + return $this->preimpresionRevisadaUser(); + } public function getFullPath(): ?string { helper('filesystem'); diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index 6d97b6fe..6a1e4d10 100755 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -97,6 +97,7 @@ return [ "papel_gramajes" => "Papel y gramajes", "estado" => "Estado", "pedido_espera" => "Pedido en espera", + "preimpresion_revisada" => "Preimpresión revisada", "imposicion_no_label" => "Sin etiqueta", "pliegos_de" => "pliegos de", "size" => "Tamaño", diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php index 3dc9a95f..96652556 100755 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php @@ -39,7 +39,10 @@ class OrdenTrabajoModel extends Model "enviar_impresion", "portada_path", "is_pedido_espera", - "pedido_espera_by" + "pedido_espera_by", + "preimpresion_revisada", + "preimpresion_revisada_by", + ]; protected bool $allowEmptyInserts = false; diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 4add157d..14742531 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -259,7 +259,7 @@ class ProductionService extends BaseService * * @return self */ - public function createOrdenTrabajo(): OrdenTrabajoEntity|DatabaseException + public function createOrdenTrabajo(bool $imported = false): OrdenTrabajoEntity|DatabaseException { $auth_user = auth()->user(); @@ -272,7 +272,8 @@ class ProductionService extends BaseService "user_created_id" => $auth_user->id, "user_updated_id" => $auth_user->id, "total_tirada" => $this->pedido->total_tirada, - "total_precio" => $this->pedido->total_precio + "total_precio" => $this->pedido->total_precio, + "preimpresion_revisada" => $imported ]; $id = $this->otModel->insert($data); $this->init($id); @@ -1116,6 +1117,9 @@ class ProductionService extends BaseService if (isset($data["is_pedido_espera"])) { $data["pedido_espera_by"] = auth()->user()->id; } + if (isset($data["preimpresion_revisada"])) { + $data["preimpresion_revisada_by"] = auth()->user()->id; + } return $this->otModel->update($this->ot->id, $data); } public function updateOrdenTrabajoPedido($data) @@ -1906,7 +1910,7 @@ class ProductionService extends BaseService "tarea_progress.estado as tareaEstado" ]) ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") - // Obtener el ultimo estado de la tarea + //* Obtener el ultimo estado de la tarea ->join( '(SELECT ot_tarea_id, estado FROM orden_trabajo_tarea_progress_dates @@ -1922,7 +1926,8 @@ class ProductionService extends BaseService ->join("pedidos", "pedidos.id = ordenes_trabajo.pedido_id", "right") ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") ->where('orden_trabajo_tareas.maquina_id', $maquina_id) - // ->where('pedidos.fecha_impresion IS NOT NULL', null, false) + // ->where('pedidos.fecha_impresion IS NOT NULL', null, false) //! Dejar comentado por ahora + ->where('ordenes_trabajo.preimpresion_revisada', true) ->where("orden_trabajo_tareas.deleted_at", null) ->where("tarea_progress.estado", 'P') ->orderBy("pedidos.fecha_impresion", "ASC") diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php index 2045ebdc..e9457217 100755 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php @@ -12,15 +12,37 @@
-
-
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
-
+
"> @@ -318,16 +340,7 @@
-
-
- (HH:MM) - -
-
- (HH:MM) - -
-
+
@@ -344,12 +357,31 @@ + + +
+
+
+
+ + -
diff --git a/httpdocs/assets/js/safekat/pages/produccion/ot.js b/httpdocs/assets/js/safekat/pages/produccion/ot.js index 4d9062f2..75fa3b81 100644 --- a/httpdocs/assets/js/safekat/pages/produccion/ot.js +++ b/httpdocs/assets/js/safekat/pages/produccion/ot.js @@ -25,7 +25,9 @@ class OrdenTrabajo { this.tiempoEstimado = this.item.find('#tiempo-estimado') this.btnResetTareas = this.item.find("#btn-reset-tareas") this.pedidoEnEsperaCheck = this.item.find("#ot-pedido-espera"); + this.otPreimpresionRevisadaCheck = this.item.find("#ot-preimpresion-revisada"); this.pedidoEnEsperaBy = this.item.find("#pedido_espera_by"); + this.otPreimpresionRevisadaUser = this.item.find("#preimpresion_revisada_by"); this.otEstado = this.item.find("#ot-estado"); this.datatableColumns = [ @@ -516,12 +518,18 @@ class OrdenTrabajo { this.embalaje.setDate(this.summaryData.dates.embalaje_at) this.envio.setDate(this.summaryData.dates.envio_at) this.pedidoEnEsperaCheck.prop("checked", this.summaryData.ot.is_pedido_espera); + this.otPreimpresionRevisadaCheck.prop("checked", this.summaryData.ot.preimpresion_revisada); this.tiempoProcesamiento.val(this.summaryData.tiempo_procesamiento); if (this.summaryData.ot.pedido_espera_by) { this.pedidoEnEsperaBy.text([this.summaryData.ot.pedido_espera_by.first_name, this.summaryData.ot.pedido_espera_by.last_name].join(" ")) } else { this.pedidoEnEsperaBy.text(""); } + if (this.summaryData.ot.preimpresion_revisada_by) { + this.otPreimpresionRevisadaUser.text([this.summaryData.ot.preimpresion_revisada_by.first_name, this.summaryData.ot.preimpresion_revisada_by.last_name].join(" ")) + } else { + this.otPreimpresionRevisadaUser.text("") + } this.otEstado.val(this.summaryData.ot.estado) this.preFormatoAt.setDate(this.summaryData.dates.pre_formato_at) this.preLomoAt.setDate(this.summaryData.dates.pre_lomo_at)