diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index 4f8be2d4..0e63dd5a 100755 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -12,14 +12,14 @@ class OrdenTrabajo extends BaseConfig "interior_bn_at" => "interior_bn_user_id", "interior_color_at" => "interior_color_user_id", "cubierta_at" => "cubierta_user_id", - "sobrecubierta_at" => "sobrecubierta_user_id", //TODO - "guarda_at" => "guarda_user_id", //TODO + "sobrecubierta_at" => "sobrecubierta_user_id", + "guarda_at" => "guarda_user_id", //ACABADO "plastificado_at" => "plastificado_user_id", - "plakene_at" => "plakene_user_id", //TODO + "plakene_at" => "plakene_user_id", "retractilado_at" => "retractilado_user_id", - "estampado_at" => "estampado_user_id", //TODO - "uvi_at" => "uvi_user_id", //TODO + "estampado_at" => "estampado_user_id", + "uvi_at" => "uvi_user_id", "encuadernacion_at" => "encuadernacion_user_id", "corte_at" => "corte_user_id", "preparacion_interiores_at" => "preparacion_interior_user_id", @@ -121,7 +121,14 @@ class OrdenTrabajo extends BaseConfig "default" => ["bg" => "white", "color" => "black"], ]; - + public array $OT_TAREA_STATUS_COLOR = [ + "P" => '#FFD63A', + "F" => '#67AE6E', + "S" => '#EB5B00', + "I" => '#3A59D1', + "E" => '#FF0B55', + "D" => '#FFA725', + ]; public function __construct() { diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 352a871e..fc2e1373 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -751,6 +751,10 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func $routes->get('datatable_pendientes', 'Ordentrabajo::datatable_pendientes'); $routes->get('datatable_ferro_pendiente', 'Ordentrabajo::datatable_ferro_pendiente'); $routes->get('datatable_ferro_ok', 'Ordentrabajo::datatable_ferro_ok'); + $routes->get('datatable_news', 'Ordentrabajo::datatable_news'); + $routes->get('datatable_prod', 'Ordentrabajo::datatable_prod'); + $routes->get('datatable_waiting', 'Ordentrabajo::datatable_waiting'); + $routes->get('datatable_revision_com', 'Ordentrabajo::datatable_revision_com'); $routes->get('tareas/datatable/(:num)', 'Ordentrabajo::tareas_datatable/$1', ['as' => 'datatableTareasOrdenTrabajo']); $routes->get("tarea/progress/(:num)", "Ordentrabajo::get_orden_trabajo_progress_date/$1"); $routes->get('tarea/(:num)', 'Ordentrabajo::find_tarea/$1'); diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 413bb991..9d244726 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -283,6 +283,62 @@ class Ordentrabajo extends BaseController ->add("action", fn($q) => $q->id) ->toJson(true); } + public function datatable_news() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery(); + 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( + "fecha_encuadernado_at", + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function datatable_prod() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, 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( + "fecha_encuadernado_at", + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function datatable_waiting() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.is_pedido_espera',1); + 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( + "fecha_encuadernado_at", + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function datatable_revision_com() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, 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( + "fecha_encuadernado_at", + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } public function papel_gramaje_datatable() { @@ -585,8 +641,15 @@ class Ordentrabajo extends BaseController $validated = $this->validation->run($bodyData, "orden_trabajo_tarea_progress_date"); // return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $this->validation->getValidated(),"errors" => $this->validation->getErrors()]); if ($validated) { - $r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($this->validation->getValidated()); - return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]); + $validatedData = $this->validation->getValidated(); + $r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($validatedData); + $otTareaEntity = $this->otTarea->find($validatedData['ot_tarea_id']); + $data = [ + "tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_trabajado()), + "tarea" => $otTareaEntity, + "estado" => $validatedData['estado'], + ]; + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $data]); } else { return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php index 1d32be82..3dcf518e 100755 --- a/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php @@ -178,6 +178,12 @@ class OrdenTrabajoTareaEntity extends Entity $m = model(OrdenTrabajoTareaProgressDate::class); return $m->where('ot_tarea_id', $this->attributes["id"])->findAll() ?? []; } + public function lastState() : ?OrdenTrabajoTareaProgressDateEntity + { + $m = model(OrdenTrabajoTareaProgressDate::class); + $progressDates = $m->where('ot_tarea_id', $this->attributes["id"])->orderBy('action_at', 'DESC')->first(); + return $progressDates; + } public function tiempo_trabajado() { $dates = $this->progress_dates(); diff --git a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php index 30d846b5..1af0fde3 100755 --- a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php +++ b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php @@ -24,11 +24,11 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity "deleted_at" => null, "created_at" => null, "updated_at" => null, - 'plastificado' => false, - 'plakene' => false, - 'rectractilado' => false, - 'estampado' => false, - 'uvi' => false, + 'plastificado' => null, + 'plakene' => null, + 'rectractilado' => null, + 'estampado' => null, + 'uvi' => null, 'plastificado_tipo' => null, 'plakene_tipo' => null, 'rectractilado_tipo' => null, diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index ee18d7b6..6d97b6fe 100755 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -1,15 +1,25 @@ [ + 'finalizadas' => 'Finalizadas', + 'pendientes' => 'Pendientes', + 'pendientes_ferro' => 'Ferro pendiente', + 'ferro_ok' => 'Ferro/Prototipo OK', + 'news' => 'Nuevas', + 'waiting' => 'En espera', + 'revision_com' => 'Revisión comercial', + 'prod' => 'Producción' + ], "datatable" => [ - "pedido_id"=> "Pedido ID", - "fecha_encuadernacion"=> "Fecha encuadernación", - "fecha_impresion"=> "Fecha impresión", - "cliente"=> "Cliente", - "titulo"=> "Título", - "ubicacion"=> "Ubicación", - "tirada"=> "Tirada", - "impresion"=> "Impresión", + "pedido_id" => "Pedido ID", + "fecha_encuadernacion" => "Fecha encuadernación", + "fecha_impresion" => "Fecha impresión", + "cliente" => "Cliente", + "titulo" => "Título", + "ubicacion" => "Ubicación", + "tirada" => "Tirada", + "impresion" => "Impresión", "fecha_entrega_at" => "Fecha entrega prevista", "maquina" => "Máquina", "ancho" => "Ancho", @@ -31,8 +41,6 @@ return [ "pliegos" => "Pliegos", "pliegos_libro" => "Pliegos", "fecha" => "fecha" - - ], "task" => [ "order" => "Orden", @@ -116,7 +124,7 @@ return [ "pre_solapa" => "Revisión solapa", "pre_codbarras" => "Revisión código barras", "pre_imposicion" => "Revisión imposición", - + "iniciada" => "Iniciada", "finalizada" => "Finalizada", "error" => "Error", @@ -128,7 +136,7 @@ return [ "attr_not_exist" => "El atributo {0,string} no pertenece al modelo Pedido" ], - + "progress_ferro" => "Ferro", "progress_preimpresion" => "Preimpresión", "progress_logistica" => "Logística", @@ -139,6 +147,7 @@ return [ "maquinas" => "Máquinas", "tareas_hoy" => "Tareas para HOY", "tareas_all" => "Todas", + "tareas_delay" => "Aplazadas", "play_tarea" => "Continuar", "play_pause" => "Pausar", "play_stop" => "Aplazar", @@ -146,6 +155,14 @@ return [ "cancel" => "Cancelar", ], + 'tarea_estados' => [ + 'P' => 'Pendiente', + 'I' => 'Iniciada', + 'F' => 'Finalizada', + 'S' => 'Pausada', + 'D' => 'Aplazada', + 'E' => 'Error' + ], 'duplicate_estado_tarea_progress' => "Último estado de la tarea repetido", 'task_already_finished' => "La tarea se ha marcado como finalizada.", 'print_label' => "Imprimir etiqueta", @@ -158,4 +175,4 @@ return [ "comentariosEncuadernacion" => "Comentarios encuadernación", "comentariosLogistica" => "Comentarios logística", "info_solapa_guillotina" => "Datos solapa y preparación guillotina", -]; \ No newline at end of file +]; diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index de5c7dfa..4add157d 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -110,6 +110,12 @@ class ProductionService extends BaseService * @var boolean */ public bool $isPlastificado = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene retractilado + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isRetractilado = false; //* CHECK DONE /** * Indica si la orden de trabajo contiene gofrado * Se usa para mostrar la fecha correspondiente en la vista @@ -273,6 +279,10 @@ class ProductionService extends BaseService $this->storeOrdenTrabajoUsers(); $this->storeOrdenTrabajoDates(); $this->storeAllTareas(); + try { + $this->updatePodDates(); + } catch (\Throwable $th) { + } $this->updatePedidoEspera(); return $this->ot; } @@ -844,6 +854,7 @@ class ProductionService extends BaseService "tareas_preimpresion" => $this->tareas_preimpresion(), "tareas_impresion" => $this->tareas_impresion(), "tiempo_procesamiento" => $this->getTiempoProcesamientoHHMM(), + "tiempo_total" => $this->getTiempoTotalTareas(), "statusColor" => $this->getOtColorStatus(), "tareaCosido" => $this->getTareaCosido(), ]; @@ -989,8 +1000,8 @@ class ProductionService extends BaseService throw new Exception(lang('Produccion.task_already_finished')); } } - if(isset($data['estado'])){ - if($data['estado'] == 'F'){ + if (isset($data['estado'])) { + if ($data['estado'] == 'F') { $tareaEntity = $this->otTarea->find($data['ot_tarea_id']); $this->init($tareaEntity->orden_trabajo_id); $dateName = $this->getOrdenTrabajoTareaDate($tareaEntity); @@ -1015,11 +1026,11 @@ class ProductionService extends BaseService $data["action_at"] = Time::now()->format('Y-m-d H:i:s'); $data["action_user_id"] = auth()->user()->id; $status = $this->otTareaProgressDate->where('ot_tarea_id', $orden_trabajo_tarea_id)->delete(); - if($status){ - $tareaEntity = $this->otTarea->find($orden_trabajo_tarea_id); - $this->init($tareaEntity->orden_trabajo_id); - $dateName = $this->getOrdenTrabajoTareaDate($tareaEntity); - $this->emptyOrdenTrabajoDate($this->ot->id,$dateName); + if ($status) { + $tareaEntity = $this->otTarea->find($orden_trabajo_tarea_id); + $this->init($tareaEntity->orden_trabajo_id); + $dateName = $this->getOrdenTrabajoTareaDate($tareaEntity); + $this->emptyOrdenTrabajoDate($this->ot->id, $dateName); } if ($status) { $response = $this->storeOrdenTrabajoTareaProgressDate($data); @@ -1409,14 +1420,33 @@ class ProductionService extends BaseService } public function getTiempoTareasImpresionHHMM(): string { - $tareas_impresion = $this->ot->tareas_impresion(); - $tiempo_seconds = 0; - foreach ($tareas_impresion as $key => $tarea) { - if ($tarea->is_corte == false) { - $tiempo_seconds += $tarea->tiempo_estimado; + try { + $tareas_impresion = $this->ot->tareas_impresion(); + $tiempo_seconds = 0; + foreach ($tareas_impresion as $key => $tarea) { + if ($tarea->is_corte == false) { + $tiempo_seconds += $tarea->tiempo_estimado; + } } + return float_seconds_to_hhmm_string($tiempo_seconds); + } catch (\Throwable $th) { + return '00:00'; + } + } + public function getTiempoTotalTareas(): string + { + try { + $tareas = $this->ot->tareas(); + $tiempo_seconds = 0; + foreach ($tareas as $key => $tarea) { + if ($tarea->tiempo_real) { + $tiempo_seconds += $tarea->tiempo_real; + } + } + return float_seconds_to_hhmm_string($tiempo_seconds); + } catch (\Throwable $th) { + return '00:00'; } - return float_seconds_to_hhmm_string($tiempo_seconds); } public function getUVI(): ?TarifaAcabadoEntity { @@ -1735,13 +1765,13 @@ class ProductionService extends BaseService $acabados = $this->presupuesto->acabados(); foreach ($acabados as $key => $acabado) { $tarifa_acabado = $acabado->tarifa(); - if ($tarifa_acabado->retractilado) { + if ($tarifa_acabado->rectractilado) { $flag = true; break; } } - $this->isPlakene = $flag; - return $this->isPlakene; + $this->isRetractilado = $flag; + return $this->isRetractilado; } public function plakene_tipo(): ?string { @@ -1891,7 +1921,7 @@ 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('orden_trabajo_tareas.maquina_id', $maquina_id) // ->where('pedidos.fecha_impresion IS NOT NULL', null, false) ->where("orden_trabajo_tareas.deleted_at", null) ->where("tarea_progress.estado", 'P') diff --git a/ci4/app/Views/themes/vuexy/form/produccion/maquinista/viewMaquinistaMaquinaTareas.php b/ci4/app/Views/themes/vuexy/form/produccion/maquinista/viewMaquinistaMaquinaTareas.php index 5645741a..6667d9da 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/maquinista/viewMaquinistaMaquinaTareas.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/maquinista/viewMaquinistaMaquinaTareas.php @@ -18,6 +18,8 @@ use CodeIgniter\I18n\Time;
= @lang("Produccion.tiempo_estimado") ?> : = $tiempo_estimado ?> (HH:MM)
+ = @lang("Produccion.tiempo_estimado") ?>(HH:MM) + = $tiempo_estimado ?>= @lang("Produccion.tiempo_consumido") ?> :
+ = @lang("Produccion.tiempo_consumido") ?>(HH:MM) +