From 43f2daea5959f98cdc4351083b317f38c890f232 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Mon, 16 Dec 2024 09:19:08 +0100 Subject: [PATCH] ot --- ci4/app/Config/Routes.php | 3 +- .../Controllers/Produccion/Ordentrabajo.php | 21 ++- ...4-11-30-170001_OrdenTrabajoTareasTable.php | 41 +++++ .../Presupuestos/PresupuestoEntity.php | 31 ++++ .../Produccion/OrdenTrabajoEntity.php | 15 +- ci4/app/Language/es/Produccion.php | 28 +++- ci4/app/Services/ProductionService.php | 51 +++++- .../vuexy/form/produccion/ot/otDates.php | 22 +-- .../vuexy/form/produccion/ot/otDetails.php | 10 +- .../vuexy/form/produccion/ot/otProgress.php | 50 +++--- .../form/produccion/viewOrdenTrabajoEdit.php | 150 +++++++++++------- .../js/safekat/pages/produccion/edit.js | 7 + .../assets/js/safekat/pages/produccion/ot.js | 31 ++++ 13 files changed, 351 insertions(+), 109 deletions(-) create mode 100644 httpdocs/assets/js/safekat/pages/produccion/edit.js create mode 100644 httpdocs/assets/js/safekat/pages/produccion/ot.js diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 6de7cb2f..0ae3f7b5 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -853,7 +853,8 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { $routes->group('ordentrabajo', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { $routes->get('', 'Ordentrabajo::index', ['as' => 'viewOrdenTrabajoIndex']); - $routes->get('edit/$1', 'Ordentrabajo::edit/$1', ['as' => 'viewOrdenTrabajoEdit']); + $routes->get('edit/(:num)', 'Ordentrabajo::edit/$1', ['as' => 'viewOrdenTrabajoEdit']); + $routes->get('summary/(:num)', 'Ordentrabajo::get_orden_trabajo_summary/$1', ['as' => 'getOrdenTrabajoSumary']); $routes->get('datatable', 'Ordentrabajo::datatable', ['as' => 'datatableOrdenTrabajo']); diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index f9c6bb24..29b3f5cb 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -3,6 +3,7 @@ namespace App\Controllers\Produccion; use App\Controllers\BaseController; use App\Models\OrdenTrabajo\OrdenTrabajoModel; +use App\Services\ProductionService; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Hermawan\DataTables\DataTable; @@ -12,7 +13,7 @@ class Ordentrabajo extends BaseController { protected $format = 'json'; protected array $viewData = []; - + protected ProductionService $produccionService; protected OrdenTrabajoModel $otModel; protected static $viewPath = 'themes/vuexy/form/produccion/'; protected static $controllerSlug = "orden-trabajo"; @@ -22,6 +23,7 @@ class Ordentrabajo extends BaseController public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { $this->otModel = model(OrdenTrabajoModel::class); + $this->produccionService = new ProductionService(); parent::initController($request, $response, $logger); } @@ -29,8 +31,8 @@ class Ordentrabajo extends BaseController { // Breadcrumbs $this->viewData['breadcrumb'] = [ - ['title' => lang("App.orden_trabajo"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => "Table", 'route' => site_url('produccion/ordentrabajo'), 'active' => true] + ['title' => lang("Produccion.ot"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("Produccion.ots"), 'route' => site_url('produccion/ordentrabajo'), 'active' => true] ]; return view(static::$viewPath . $this->indexRoute, $this->viewData); } @@ -40,6 +42,10 @@ class Ordentrabajo extends BaseController } + public function get_orden_trabajo_summary($orden_trabajo_id){ + $summary = $this->produccionService->init($orden_trabajo_id)->getSummary(); + return $this->response->setJSON($summary); + } public function add() { @@ -49,9 +55,14 @@ class Ordentrabajo extends BaseController { // Breadcrumbs $this->viewData['breadcrumb'] = [ - ['title' => lang("App.orden_trabajo"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => "Table", 'route' => site_url('produccion/ordentrabajo'), 'active' => true] + ['title' => lang("Produccion.ot"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => $this->otModel->find($orden_trabajo_id)->pedido()->presupuesto()->titulo, 'route' => site_url('produccion/ordentrabajo/edit/'.$orden_trabajo_id), 'active' => true] ]; + $this->viewData["modelId"] = $orden_trabajo_id; + $this->produccionService->init($orden_trabajo_id); + $this->viewData["presupuesto"] = $this->produccionService->getPresupuesto(); + $this->viewData["cliente"] = $this->produccionService->getCliente(); + $this->viewData["ot"] = $this->produccionService->getOrdenTrabajo(); return view(static::$viewPath . $this->editRoute, $this->viewData); } diff --git a/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php b/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php index 8da1a89b..ab5fa878 100644 --- a/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php +++ b/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php @@ -27,6 +27,41 @@ class OrdenTrabajoTareasTable extends Migration "null" => true, "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", ], + "presupuesto_acabado_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_preimpresion_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_encuadernado_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_manipulado_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_extra_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], "nombre" => [ "type" => "VARCHAR", "constraint" => 255, @@ -89,6 +124,12 @@ class OrdenTrabajoTareasTable extends Migration $this->forge->addPrimaryKey("id"); $this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id","CASCADE","CASCADE"); $this->forge->addForeignKey("presupuesto_linea_id","presupuesto_linea","id"); + $this->forge->addForeignKey("presupuesto_acabado_id","presupuesto_acabados","id"); + $this->forge->addForeignKey("presupuesto_encuadernado_id","presupuesto_encuadernaciones","id"); + $this->forge->addForeignKey("presupuesto_manipulado_id","presupuesto_manipulados","id"); + $this->forge->addForeignKey("presupuesto_preimpresion_id","presupuesto_preimpresiones","id"); + $this->forge->addForeignKey("presupuesto_extra_id","presupuesto_serviciosExtra","id"); + $this->forge->addForeignKey("imposicion_id","lg_imposiciones","id"); $this->forge->addForeignKey("maquina_id","lg_maquinas","id"); $this->forge->createTable("orden_trabajo_tareas"); diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index b722c49a..df20aed4 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -2,8 +2,14 @@ namespace App\Entities\Presupuestos; +use App\Entities\Clientes\ClienteEntity; +use App\Models\Clientes\ClienteModel; +use App\Models\Presupuestos\PresupuestoAcabadosModel; +use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Presupuestos\PresupuestoLineaModel; +use App\Models\Presupuestos\PresupuestoManipuladosModel; use App\Models\Presupuestos\PresupuestoModel; +use App\Models\Presupuestos\PresupuestoPreimpresionesModel; use CodeIgniter\Entity; class PresupuestoEntity extends \CodeIgniter\Entity\Entity @@ -191,5 +197,30 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity return $q; } + public function cliente() : ClienteEntity + { + $m = model(ClienteModel::class); + return $m->find($this->attributes["cliente_id"]); + } + public function encuadernaciones(): array + { + $m = model(PresupuestoEncuadernacionesModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function acabados(): array + { + $m = model(PresupuestoAcabadosModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function preimpresiones(): array + { + $m = model(PresupuestoPreimpresionesModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function manipulados(): array + { + $m = model(PresupuestoManipuladosModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index cb388f7d..e1ffa4bb 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -2,8 +2,10 @@ namespace App\Entities\Produccion; +use App\Controllers\Produccion\Ordentrabajo; use App\Database\Migrations\OrdenTrabajoDatesTable; use App\Entities\Pedidos\PedidoEntity; +use App\Models\OrdenTrabajo\OrdenTrabajoDate; use App\Models\OrdenTrabajo\OrdenTrabajoTarea; use App\Models\Pedidos\PedidoModel; use CodeIgniter\Entity\Entity; @@ -50,12 +52,21 @@ class OrdenTrabajoEntity extends Entity * * @return PedidoEntity */ - public function pedido(): PedidoEntity + public function pedido(): ?PedidoEntity { $m = model(PedidoModel::class); return $m->find($this->attributes["pedido_id"]); } - + public function dates(): ?OrdenTrabajoDateEntity + { + $m = model(OrdenTrabajoDate::class); + return $m->find($this->attributes["id"]); + } + public function users(): ?OrdenTrabajoUserEntity + { + return null; + // return $m->find($this->attributes["id"]) + } /** * Almacena en la tabla `orden_trabajo_dates` las fechas correspondientes del pedido. * Se almacenan en una tabla externa porque puede haber modificaciones de estas fechas diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index cfeb2057..95c7d31d 100644 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -18,5 +18,31 @@ return [ "maquina_actual" => "Máquina actual", "tiempo_estimado" => "Tiempo estimado", "tiempo" => "Tiempo" - ] + ], + "ferro_ok" => "Ferro ok", + "envio" => "Envío", + "ot" => "Orden trabajo", + "ots" => "Órdenes trabajo", + "tiempo_procesamiento" => "Tiempo procesamiento", + "fecha_impresion" => "Fecha impresión", + "fecha_encuadernado" => "Fecha encuadernado", + "fecha_entrega_externo" => "Fecha entrega externo", + "fecha_entrega_real" => "Fecha entrega real", + "fecha_entrega_estimada" => "Fecha entrega estimada", + "formato" => "Formato", + "paginas" => "Páginas", + "tirada" => "Tirada", + "merma" => "Merma", + "pendiente_ferro" => "Pendiente ferro", + "ferro_cliente" => "Ferro cliente", + "impresion_color" => "Impresión color", + "portada" => "portada", + "plakene_traslucido" => "Plakene traslúcido", + "plastificado_mate" => "Plastificado mate", + "espiral" => "Espiral", + "embalaje" => "Embalaje", + "tiempo_consumido" => "Tiempo consumido", + "tiempo_estimado" => "Tiempo estimado", + "finalizar_orden" => "Finalizar orden" + ]; \ No newline at end of file diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 881204f8..320255bb 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Database\Migrations\OrdenTrabajoUsers; +use App\Entities\Clientes\ClienteEntity; use App\Entities\Configuracion\Maquina; use App\Entities\Pedidos\PedidoEntity; use App\Entities\Presupuestos\PresupuestoEntity; @@ -23,6 +24,7 @@ class ProductionService extends BaseService protected OrdenTrabajoModel $otModel; protected OrdenTrabajoTarea $otTarea; protected OrdenTrabajoDate $otDate; + protected OrdenTrabajoEntity $ot; /** * Pedido Entity @@ -37,6 +39,14 @@ class ProductionService extends BaseService */ protected PresupuestoEntity $presupuesto; + public function init(int $orden_trabajo_id): self + { + $this->otModel = model(OrdenTrabajoModel::class); + $this->ot = $this->otModel->find($orden_trabajo_id); + $pedido = $this->ot->pedido(); + $this->setPedido($pedido); + return $this; + } /** * Establece el pedido sobre el que se va a trabajar * @@ -66,6 +76,14 @@ class ProductionService extends BaseService { return $this->presupuesto; } + public function getCliente(): ClienteEntity + { + return $this->presupuesto->cliente(); + } + public function getOrdenTrabajo(): OrdenTrabajoEntity + { + return $this->ot; + } /** * Crea una instancia de la orden de trabajo * @@ -139,7 +157,7 @@ class ProductionService extends BaseService $ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina; $ot_tareas["tiempo_real"] = $p_linea->horas_maquina; //? Tiempo real se inserta manual? $insert_query_result = $this->otTarea->insert($ot_tareas); - $ot_tareas = []; + $ot_tareas = []; } return $insert_query_result; } @@ -199,4 +217,35 @@ class ProductionService extends BaseService ->orderBy("orden_trabajo_tareas.orden", "DESC"); return $q; } + + /** + * Get a summary from ot with the following structure + * + + * + * + * @return array + * ```php + * [ + * "ot" => OrdenTrabajoEntity + * "dates" => OrdenTrabajoDateEntity + * "tasks" => array + * ]; + * ``` + */ + public function getSummary(): array + { + + $summary = [ + "ot" => $this->ot, + "dates" => $this->ot->dates(), + "tasks" => $this->ot->tareas(), + "acabados" => $this->presupuesto->acabados(), + "preimpresiones" => $this->presupuesto->preimpresiones(), + "manipulados" => $this->presupuesto->manipulados(), + "encuadernaciones" => $this->presupuesto->encuadernaciones(), + + ]; + return $summary; + } } diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php index d913cfb7..10e80362 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php @@ -12,33 +12,33 @@
- - + +
- - + +
- - + +
- - + +
- - + +
- +
diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php index f26f8b6f..8536e9f8 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php @@ -12,27 +12,27 @@
- +
- +
- +
- +
- +
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 507d7740..3d362837 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php @@ -20,72 +20,72 @@
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
-

:

+

:

-

:

+

:

- +
diff --git a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php index 25d84649..b7d1f7d0 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php @@ -4,75 +4,109 @@ include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/vuexy/main/defaultlayout') ?> section('content'); ?> -
-
-