From 30c5b06d3d818b414f2ba4a4d278cf9e18b0ee35 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Tue, 6 May 2025 08:30:01 +0200 Subject: [PATCH 1/7] update progress based on task time and task date --- ci4/app/Services/ProductionService.php | 65 ++++++++++++++++---------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 25679b40..db2463b8 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -228,8 +228,8 @@ class ProductionService extends BaseService $this->maquinaModel = model(MaquinaModel::class); $this->otModel = model(OrdenTrabajoModel::class); $ot = $this->otModel->find($orden_trabajo_id); - if($ot == null){ - throw new Exception(lang('Produccion.errors.ot_not_found',['ot_id' => $orden_trabajo_id])); + if ($ot == null) { + throw new Exception(lang('Produccion.errors.ot_not_found', ['ot_id' => $orden_trabajo_id])); } $this->ot = $ot; $pedido = $this->ot->pedido(); @@ -610,11 +610,11 @@ class ProductionService extends BaseService } return ["tareas" => $tareas]; } - public function getTareasWithMaquina(int $maquina_id,?array $tareaEstados = null) : ?array + public function getTareasWithMaquina(int $maquina_id, ?array $tareaEstados = null): ?array { return $this->otModel->queryMaquinaTareas($maquina_id, $tareaEstados) - ->where('ordenes_trabajo.id', $this->ot->id) - ->get()->getResult(OrdenTrabajoTareaEntity::class); + ->where('ordenes_trabajo.id', $this->ot->id) + ->get()->getResult(OrdenTrabajoTareaEntity::class); } public function getPdf() @@ -1439,6 +1439,16 @@ class ProductionService extends BaseService } return $pedidoUserDates; } + public function getTiempoEstimadoTotalTareasSeconds(): int + { + try { + $time_tareas_seconds = array_map(fn($q) => $q->tiempo_estimado ?? 0, $this->ot->tareas()); + $seconds = array_sum($time_tareas_seconds); + return $seconds; + } catch (\Throwable $th) { + return 0; + } + } public function getTiempoProcesamientoHHMMSS(): ?string { try { @@ -1490,33 +1500,31 @@ class ProductionService extends BaseService } return $uvi; } - //TODO ACTUALIZAR + public function updateProgress(): bool { - $userDates = $this->ordenTrabajoConfig->DATE_USER_MAPPING; - $pedidoUserDates = $this->ordenTrabajoConfig->DATE_USER_MAPPING_PEDIDO; - - $fill_dates = 0; - $status = false; - $total = count($userDates) + count($pedidoUserDates); + $progress = $this->getOtProgress(); if ($this->ot->estado != "F") { - if ($this->ot->dates()) { - - foreach ($userDates as $key => $value) { - if ($this->ot->dates()->{$key} != null) $fill_dates++; - } - foreach ($pedidoUserDates as $key => $value) { - if ($this->pedido->{$key} != null) $fill_dates++; - } - - $progreso = (float) $fill_dates / $total * 100; - $status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso, 2)]); - } + $status = $this->otModel->update($this->ot->id, ["progreso" => round($progress, 2)]); } else { $status = $this->otModel->update($this->ot->id, ["progreso" => 100]); } return $status; } + public function getOtProgress() + { + $datesWithTime = $this->getOrdenTrabajoTareaDatesWithTiempoEstimado(); + $tiempo_estimado_total = $this->getTiempoEstimadoTotalTareasSeconds(); + $progress = 0; + $otDates = $this->ot->dates(); + foreach ($datesWithTime as $key => $dateWithTime) { + ["date" => $date, "tiempo_estimado" => $tiempo_estimado] = $dateWithTime; + if ($otDates->{$date}) { + $progress += $tiempo_estimado / $tiempo_estimado_total * 100; + } + } + return $progress; + } public function getOtColorStatus(): string { if ($this->ot->dates()) { @@ -2194,6 +2202,15 @@ class ProductionService extends BaseService } return $data; } + public function getOrdenTrabajoTareaDatesWithTiempoEstimado(): array + { + $dates = []; + foreach ($this->ot->tareas() as $key => $tarea) { + $dates[$tarea->id]["date"] = $this->getOrdenTrabajoTareaDate($tarea); + $dates[$tarea->id]["tiempo_estimado"] = $tarea->tiempo_estimado; + } + return $dates; + } public function getOrdenTrabajoTareaDates(): array { $dates = []; From ddd7c471a1b09cf205199a4c0f48aff5440a76cd Mon Sep 17 00:00:00 2001 From: amazuecos Date: Tue, 6 May 2025 08:40:07 +0200 Subject: [PATCH 2/7] progress ot --- ci4/app/Language/es/Produccion.php | 1 + ci4/app/Services/ProductionService.php | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index 90aeda9d..728920c0 100755 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -119,6 +119,7 @@ return [ //IMPRESION "impresion_bn" => "Impresión BN", "cubierta" => "Cubierta/Portada", + "sobrecubierta" => "Sobrecubierta", "guarda" => "Guarda", "encuadernacion" => "Encuadernación", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index db2463b8..0105df94 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -1519,8 +1519,13 @@ class ProductionService extends BaseService $otDates = $this->ot->dates(); foreach ($datesWithTime as $key => $dateWithTime) { ["date" => $date, "tiempo_estimado" => $tiempo_estimado] = $dateWithTime; - if ($otDates->{$date}) { - $progress += $tiempo_estimado / $tiempo_estimado_total * 100; + try { + if ($otDates->{$date}) { + $progress += $tiempo_estimado / $tiempo_estimado_total * 100; + } + } catch (\Throwable $th) { + //throw $th; + $progress += 0; } } return $progress; From f6b8d2ba85509a61f25052473da92a4ebb95d431 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Tue, 6 May 2025 10:06:33 +0200 Subject: [PATCH 3/7] columns searching and ordering ots --- .../components/datatables/otDatatable.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/httpdocs/assets/js/safekat/components/datatables/otDatatable.js b/httpdocs/assets/js/safekat/components/datatables/otDatatable.js index d1e1f0b8..527f15f1 100644 --- a/httpdocs/assets/js/safekat/components/datatables/otDatatable.js +++ b/httpdocs/assets/js/safekat/components/datatables/otDatatable.js @@ -16,14 +16,14 @@ class OrdenTrabajoDatatable { this.datatableColumns = [ { data: 'pdf_check', searchable: false, sortable: false, render: d => `` }, - { data: 'id', searchable: false, sortable: true }, - { data: 'pedido_id', searchable: false, sortable: false }, - { data: 'fecha_encuadernado_at', searchable: false, sortable: false }, - { data: 'cliente_nombre', searchable: false, sortable: false }, - { data: 'presupuesto_titulo', searchable: false, sortable: false }, - { data: 'ubicacion_nombre', searchable: false, sortable: false }, - { data: 'total_tirada', searchable: false, sortable: false, render: (d) => `${d}` }, - { data: 'tipo_presupuesto_impresion', searchable: false, sortable: false }, + { data: 'id', searchable: true, sortable: true }, + { data: 'pedido_id', searchable: true, sortable: true }, + { data: 'fecha_encuadernado_at',name:"pedidos.fecha_encuadernado", searchable: true, sortable: true }, + { data: 'cliente_nombre', name:"clientes.nombre", searchable: true, sortable: false }, + { data: 'presupuesto_titulo', name:"presupuestos.titulo", searchable: true, sortable: true }, + { data: 'ubicacion_nombre', name:"ubicaciones.nombre", searchable: true, sortable: true }, + { data: 'total_tirada', name:"pedidos.total_tirada",searchable: true, sortable: true, render: (d) => `${d}` }, + { data: 'tipo_presupuesto_impresion', name:"tipos_presupuestos.codigo", searchable: true, sortable: true }, { data: 'logo', searchable: false, sortable: false, render: (d, t) => { return `
@@ -33,7 +33,7 @@ class OrdenTrabajoDatatable { } }, { - data: 'progreso', searchable: false, sortable: false, render: (d, t) => { + data: 'progreso',name:"ordenes_trabajo.progreso", searchable: false, sortable: true, render: (d, t) => { return `
${d}%
From 8b340b76d3b99914c07c987af4748bf8ff1c4b82 Mon Sep 17 00:00:00 2001 From: Ignacio Martinez Navajas Date: Tue, 6 May 2025 10:17:33 +0200 Subject: [PATCH 4/7] =?UTF-8?q?A=C3=B1adidos=20IDs=20de=20los=20usuarios?= =?UTF-8?q?=20creador=20y=20actualizador=20al=20guardar=20desde=20presupue?= =?UTF-8?q?sto=20cliente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Models/Presupuestos/PresupuestoModel.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index c57aa1c0..04699831 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -508,15 +508,17 @@ class PresupuestoModel extends \App\Models\BaseModel 'excluir_rotativa' => $excluir_rotativa, ]; + /* Actualizacion */ if ($id != 0) { $fields['id'] = $id; $fields['updated_at'] = date('Y-m-d H:i:s', now()); - } - - if ($id != 0) { + $fields['user_update_id'] = auth()->id(); $this->db->table($this->table)->where('id', $id)->update($fields); return $id; - } else { + } + /* Inserccion */ + else { + $fields['user_created_id'] = auth()->id(); $this->db->table($this->table)->insert($fields); return $this->db->insertID(); } From 20594bd44c0ee555e971697e26afd06184aca26e Mon Sep 17 00:00:00 2001 From: Ignacio Martinez Navajas Date: Tue, 6 May 2025 10:55:21 +0200 Subject: [PATCH 5/7] Al crear un presupuesto hay que fijar el user_update_id. FIXED --- ci4/app/Models/Presupuestos/PresupuestoModel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 04699831..9b6a137f 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -519,6 +519,7 @@ class PresupuestoModel extends \App\Models\BaseModel /* Inserccion */ else { $fields['user_created_id'] = auth()->id(); + $fields['user_update_id'] = auth()->id(); $this->db->table($this->table)->insert($fields); return $this->db->insertID(); } From cab7bc3daf555feba535b6784c7d3dad1dd9f585 Mon Sep 17 00:00:00 2001 From: Ignacio Martinez Navajas Date: Tue, 6 May 2025 12:09:54 +0200 Subject: [PATCH 6/7] Arreglado bug en listado de comerciales en vista diferente al buscador de presupuestos --- ci4/app/Models/Presupuestos/PresupuestoModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 9b6a137f..d2cf953d 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -271,7 +271,7 @@ class PresupuestoModel extends \App\Models\BaseModel t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado" ); $builder->join("clientes t2", "t1.cliente_id = t2.id", "left"); - $builder->join("users t3", "t1.user_update_id = t3.id", "left"); + $builder->join("users t3", "t2.comercial_id = t3.id", "left"); $builder->join("lg_paises t5", "t1.pais_id = t5.id", "left"); $builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left"); From d3dd18a156d3140b4840e9498545a57ab85f6e88 Mon Sep 17 00:00:00 2001 From: Ignacio Martinez Navajas Date: Tue, 6 May 2025 12:23:00 +0200 Subject: [PATCH 7/7] Expuestos campos ID y PrecioTonelada en visualizacion de papeles de impresion --- .../Configuracion/PapelImpresionModel.php | 32 ++++++++++--------- .../papel/viewPapelImpresionList.php | 8 +++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index fc03ccae..d816b9c6 100755 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -13,20 +13,22 @@ class PapelImpresionModel extends \App\Models\BaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.nombre", - 1 => "t2.nombre", - 2 => "t1.gramaje", - 3 => "t1.interior", - 4 => "t1.bn", - 5 => "t1.color", - 6 => "t1.cubierta", - 7 => "t1.use_for_tapa_dura", - 8 => "t1.sobrecubierta", - 9 => "t1.guardas", - 10 => "t1.inkjet", - 11 => "t1.rotativa", - 12 => "t1.isActivo", - 13 => "t1.use_in_client", + 0 => "t1.id", + 1 => "t1.nombre", + 2 => "t2.nombre", + 3 => "t1.gramaje", + 4 => "t1.interior", + 5 => "t1.bn", + 6 => "t1.color", + 7 => "t1.cubierta", + 8 => "t1.use_for_tapa_dura", + 9 => "t1.sobrecubierta", + 10 => "t1.guardas", + 11 => "t1.inkjet", + 12 => "t1.rotativa", + 13 => "t1.isActivo", + 14 => "t1.use_in_client", + 15 => "t1.precio_tonelada", ]; @@ -173,7 +175,7 @@ class PapelImpresionModel extends \App\Models\BaseModel ->groupStart() ->like("t1.nombre", $search) ->orLike("t1.gramaje", $search) - ->orLike("t1.nombre", $search) + ->orLike("t1.precio_tonelada", $search) ->orLike("t1.gramaje", $search) ->orLike("t2.nombre", $search) ->groupEnd(); diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php index 3702621a..f3f41f75 100755 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php @@ -18,6 +18,7 @@ + @@ -32,6 +33,7 @@ + @@ -80,7 +82,7 @@ } ], stateSave: true, - order: [[1, 'asc']], + order: [[2, 'asc']], language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, @@ -98,6 +100,7 @@ } ], columns : [ + { 'data': 'id' }, { 'data': 'nombre' }, { 'data': 'papel_generico_id' }, { 'data': 'gramaje', render : (d) => `${d}`}, @@ -112,13 +115,14 @@ { 'data': 'rotativa' }, { 'data': 'isActivo' }, { 'data': 'use_in_client' }, + { 'data': 'precio_tonelada' }, { 'data': actionBtns } ] }); theTable.on( 'draw.dt', function () { - const boolCols = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; + const boolCols = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : '';