diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index dcedbdc3..35f58438 100644 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -25,6 +25,7 @@ class OrdenTrabajo extends BaseConfig "retractilado5_at" => "retractilado5_user_id", "prototipo_at" => "prototipo_user_id", "marcapaginas_at" => "marcapaginas_user_id", + "espiral_at" => "espiral_user_id", //FERRO "pendiente_ferro_at" => "pendiente_ferro_user_id", "ferro_en_cliente_at" => "ferro_en_cliente_user_id", diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 6ffd2d9d..d483680a 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -152,8 +152,13 @@ class Ordentrabajo extends BaseController $this->viewData["presupuesto"] = $this->produccionService->getPresupuesto(); $this->viewData["cliente"] = $this->produccionService->getCliente(); $this->viewData["ot"] = $this->produccionService->getOrdenTrabajo(); + $this->viewData["is_finalizada"] = $this->produccionService->getOrdenTrabajo()->estado == "F"; $this->viewData["user_dates"] = $this->produccionService->userDates(); $this->viewData["pedido_user_dates"] = $this->produccionService->pedidoUserDates(); + $this->viewData["colors"] = $this->produccionService->getPdfColors(); + $this->viewData["tiempo_estimado"] = $this->produccionService->getTiempoProcesamientoHHMM(); + $this->viewData["flags"] = $this->produccionService->getFlags(); + return view(static::$viewPath . $this->editRoute, $this->viewData); } diff --git a/ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php b/ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php new file mode 100644 index 00000000..bdf79a02 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php @@ -0,0 +1,41 @@ + [ + "type" => "DATE", + "null" => true, + ], + ]; + protected array $USERS = [ + "espiral_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + ]; + + public function up() + { + $this->forge->addColumn("orden_trabajo_dates", $this->DATES); + $this->forge->addColumn("orden_trabajo_users", $this->USERS); + foreach ($this->USERS as $key => $value) { + $this->forge->addForeignKey([$key],"users",["id"]); + } + } + + public function down() + { + $this->forge->dropColumn("orden_trabajo_dates", array_keys($this->DATES)); + $this->forge->dropColumn("orden_trabajo_users", array_keys($this->USERS)); + + + } +} diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index c9c71790..8d776bc7 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -4,8 +4,10 @@ namespace App\Entities\Presupuestos; use App\Entities\Clientes\ClienteEntity; use App\Entities\Configuracion\PapelFormatoEntity; +use App\Entities\Configuracion\TipoPresupuestoEntity; use App\Models\Clientes\ClienteModel; use App\Models\Configuracion\PapelFormatoModel; +use App\Models\Configuracion\TipoPresupuestoModel; use App\Models\Presupuestos\PresupuestoAcabadosModel; use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Presupuestos\PresupuestoFicheroModel; @@ -300,5 +302,15 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity $files = $m->where('presupuesto_id',$this->attributes['id'])->findAll(); return $files ?? []; } + public function tipo_presupuesto() : ?TipoPresupuestoEntity + { + $tipo_presupuesto = null; + $m = model(TipoPresupuestoModel::class); + if($this->attributes["tipo_impresion_id"]){ + $tipo_presupuesto = $m->find($this->attributes['tipo_impresion_id']); + } + return $tipo_presupuesto; + + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php index e106c57c..19ad97ab 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -28,6 +28,7 @@ class OrdenTrabajoDateEntity extends Entity "retractilado5_at"=> null, "prototipo_at"=> null, "marcapaginas_at"=> null, + "espiral_at"=> null, //FERRO "pendiente_ferro_at" => null, "ferro_en_cliente_at" => null, diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index 8bc67adc..9df7e7ce 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -153,4 +153,14 @@ class OrdenTrabajoEntity extends Entity } return $portada_path; } + public function getEstadoText(): string + { + $estados = [ + "E" => lang('Produccion.error'), + "I" => lang('Produccion.iniciada'), + "F" => lang('Produccion.finalizada'), + "PM" => lang("Produccion.pendiente_material") + ]; + return $estados[$this->attributes["estado"]]; + } } diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index e5b622b0..cd8b95d3 100644 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -71,6 +71,7 @@ return [ "tiempo_consumido" => "Tiempo consumido", "tiempo_estimado" => "Tiempo estimado", "finalizar_orden" => "Finalizar orden", + "reactivar_orden" => "Reactivar", "comments" => "Comentarios orden trabajo", "preview_pdf" => "Previsualizar PDF", "imprimir_codigo_safekat" => "Imprimir código SAFEKAT", @@ -105,13 +106,22 @@ return [ "pre_codbarras" => "Revisión código barras", "pre_imposicion" => "Revisión imposición", - + "iniciada" => "Iniciada", + "finalizada" => "Finalizada", + "error" => "Error", + "pendiente_material" => "Pendiente material", + "empty" => "Vacio", "errors" => [ "date_not_exist" => "Esta fecha no existe en el modelo", "attr_not_exist" => "El atributo {0,string} no pertenece al modelo Pedido" - ] + ], + + "progress_preimpresion" => "Preimpresión", + "progress_logistica" => "Ferro/Logística", + "progress_impresion" => "Impresión", + "progress_manipulado" => "Manipulado/Acabado" diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index 555f6415..51234724 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -35,6 +35,7 @@ class OrdenTrabajoDate extends Model "retractilado5_at", "prototipo_at", "marcapaginas_at", + "espiral_at", //FERRO "pendiente_ferro_at", "ferro_en_cliente_at", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 72411210..784365a7 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -35,7 +35,17 @@ use Exception; */ class ProductionService extends BaseService { + /** + * Tipos de impresion para identificar linea de impresion plana/general + * + * @var array + */ public array $TIPOS_PLANA = ['lp_bn', 'lp_color', 'lp_colorhq']; + /** + * Tipos de impresion para idenficiar si es rotativa + * + * @var array + */ public array $TIPOS_ROTATIVA = ['lp_rot_bn', 'lp_rot_color']; protected OrdenTrabajoModel $otModel; @@ -48,14 +58,98 @@ class ProductionService extends BaseService protected PedidoModel $pedidoModel; protected UserModel $userModel; protected ConfigVariableModel $configVariableModel; - protected string $defaultMaquinaCorteName = 'HT-1000'; - protected int $podValue = 0; - protected bool $isPOD = false; protected MaquinaEntity $defaultMaquinaCorte; protected MaquinaModel $maquinaModel; protected OrdenTrabajo $ordenTrabajoConfig; - public string $statusColor; + + /** + * Nombre de la maquina por defecto para realizar la tarea de corte. + * + * @var string 'HT-1000' + */ + protected string $defaultMaquinaCorteName = 'HT-1000'; + /** + * Color del header en el formulario de orden de trabajo + * + * @var string + */ + public string $statusColor; + /** + * Valor límite del POD + * + * `$this->configVariableModel->getVariable('POD')->value;` + * @var integer + */ + protected int $podValue = 0; + /** + * Indica si es POD + * + * `tirada <= podValue` + * @var boolean + */ + protected bool $isPOD = false; + + /** + * Indica si la orden de trabajo contiene gofrado + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isGofrado = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene gofrado + * Se usa para mostrar la fecha correspondiente en la vista + * TODO Hay que implementar un boolean en `lg_tarifa_acabado` para identificar + * @var boolean + */ + public bool $isGrapado = true; //TODO + /** + * Indica si la orden de trabajo contiene espiral + * Se usa para mostrar la fecha correspondiente en la vista + * TODO Hay que implementar un boolean en `lg_tarifa_manipulado` para identificar + * DEFAULT true hasta implementacion + * @var boolean + */ + public bool $isEspiral = true; //TODO + /** + * Indica si la orden de trabajo contiene UVI + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isUVI = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene plastificado + * Se usa para mostrar la fecha correspondiente en la vista + * TODO Hay que implementar un boolean en `lg_tarifa_acabado` para identificar + * DEFAULT true hasta implementacion + * @var boolean + */ + public bool $isPlastificado = true; //TODO + /** + * Indica si la orden de trabajo contiene cubierta + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isCubierta = false; //* CHECK DONE + /** + * Indica si la impresion es en color + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isColor = false; //* CHECK DONE + /** + * Indica si la impresion es en bn + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isBN = false; //* CHECK DONE + /** + * Indica si hay una tarea de corte + * Se usa para mostrar la fecha correspondiente en la vista + * ! Se añade por defecto siempre en una rotativa una tarea de corte + * @var boolean + */ + public bool $isCorte = false; //* CHECK DONE /** * Pedido Entity * @@ -83,10 +177,10 @@ class ProductionService extends BaseService $this->configVariableModel = model(ConfigVariableModel::class); $this->podValue = $this->configVariableModel->getVariable('POD')->value; } + public function init(int $orden_trabajo_id): self { try { - //code... $this->maquinaModel = model(MaquinaModel::class); $this->otModel = model(OrdenTrabajoModel::class); $this->ot = $this->otModel->find($orden_trabajo_id); @@ -177,12 +271,22 @@ class ProductionService extends BaseService $this->otDate->updateUserDateMap($this->ot->id, $data); return $otDateId; } + /** + * Crea un registro en `orden_trabajo_users` + * + * @return integer|boolean|string + */ protected function storeOrdenTrabajoUsers(): int|bool|string { return $this->otUser->insert([ "orden_trabajo_id" => $this->ot->id, ]); } + /** + * Crea un registro en `orden_trabajo_users` si no ha sido creado previamente + * + * @return integer|boolean|string + */ public function reInsertOrdenTrabajoUsers(): int|bool|string { $status = false; @@ -191,6 +295,11 @@ class ProductionService extends BaseService } return $status; } + /** + * Crea un registro en `orden_trabajo_dates` si no ha sido creado previamente + * + * @return integer|boolean|string + */ public function reInsertOrdenTrabajoDates(): int|bool|string { $status = false; @@ -199,6 +308,11 @@ class ProductionService extends BaseService } return $status; } + /** + * General las correspondientes tareas de la orden de trabajo en la table `orden_trabajo_tareas` + * + * @return integer|boolean|string + */ protected function storeAllTareas() { $this->storeOrdenTrabajoTareas(); @@ -208,6 +322,12 @@ class ProductionService extends BaseService $this->storeOrdenTrabajoEncuadernacionTareas(); // $this->storeOrdenTrabajoExtraTareas(); } + /** + * Regenera las tareas. + * !! Se eliminan las que hay previamente sin `softDelete` + * + * @return integer|boolean|string + */ public function resetAllTareas(): BaseResult|bool { $r = $this->otTarea->where("orden_trabajo_id", $this->ot->id)->delete(purge: true); @@ -244,6 +364,12 @@ class ProductionService extends BaseService } return $insert_query_result; } + /** + * Inserta una tarea de corte si la impresion es en `rotativa` + * + * @param PresupuestoLineaEntity $pLinea + * @return OrdenTrabajoTareaEntity|null + */ protected function storeTareaCorte(PresupuestoLineaEntity $pLinea): ?OrdenTrabajoTareaEntity { $otCorte = null; @@ -264,6 +390,11 @@ class ProductionService extends BaseService return $otCorte; } + /** + * General las tareas de acabado segun las líneas de presupuesto_acabados + * + * @return boolean + */ protected function storeOrdenTrabajoAcabadoTareas(): bool { $p_lineas = $this->presupuesto_lineas_acabado(); @@ -290,6 +421,11 @@ class ProductionService extends BaseService } return true; } + /** + * General las tareas de acabado segun las líneas de presupuesto_manipulados + * + * @return boolean + */ protected function storeOrdenTrabajoManipuladoTareas(): bool { $p_lineas = $this->presupuesto_lineas_manipulado(); @@ -316,6 +452,11 @@ class ProductionService extends BaseService } return true; } + /** + * General las tareas de acabado segun las líneas de presupuesto_preimpresion + * + * @return boolean + */ protected function storeOrdenTrabajoPreimpresionTareas(): bool { $p_lineas = $this->presupuesto_lineas_preimpresion(); @@ -342,6 +483,11 @@ class ProductionService extends BaseService } return true; } + /** + * General las tareas de acabado segun las líneas de presupuesto_encuadernaciones + * + * @return boolean + */ protected function storeOrdenTrabajoEncuadernacionTareas(): bool { $p_lineas = $this->presupuesto_lineas_encuadernaciones(); @@ -1126,19 +1272,23 @@ class ProductionService extends BaseService $seconds = array_sum($time_tareas_seconds); return float_seconds_to_hhmm_string($seconds); } - public function getTiempoTareasImpresionHHMM():string { + public function getTiempoTareasImpresionHHMM(): string + { $tareas_impresion = $this->ot->tareas_impresion(); - $time_tareas_seconds = array_map(fn($q) => $q->tiempo_estimado ?? 0, $tareas_impresion); - $seconds = array_sum($time_tareas_seconds); - return float_seconds_to_hhmm_string($seconds); - + $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); } - public function getUVI() : ?TarifaAcabadoEntity + public function getUVI(): ?TarifaAcabadoEntity { $uvi = null; $acabados = $this->presupuesto->acabados(); foreach ($acabados as $key => $acabado) { - if($acabado->tarifa()->isUVI()){ + if ($acabado->tarifa()->isUVI()) { $uvi = $acabado->tarifa(); } } @@ -1360,6 +1510,9 @@ class ProductionService extends BaseService if ($plastificado_code == "SAND") { $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['SANDY']; } + if ($plastificado_code == "GOF") { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['GOFRADO']; + } } } return $color; @@ -1367,10 +1520,9 @@ class ProductionService extends BaseService public function getImpresionInteriorPPALColor() { $isRotativa = $this->presupuesto->presupuestoLineaImpresion()->isRotativa(); - $color = $isRotativa ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['ROTATIVA'] : $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['GENERAL'] ; + $color = $isRotativa ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['ROTATIVA'] : $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['GENERAL']; $color = $this->isPOD ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['POD'] : $color; return $color; - } public function getPdfColors(): array { @@ -1384,4 +1536,80 @@ class ProductionService extends BaseService "impresion_interior_ppal" => $this->getImpresionInteriorPPALColor() ]; } + + public function getFlags() + { + $this->color(); + return [ + "isGofrado" => $this->gofrado(), + "isEspiral" => $this->isEspiral, + "isUVI" => $this->uvi(), + "isPlastificado" => $this->isPlastificado, + "isCubierta" => $this->cubierta(), + "isColor" => $this->isColor, + "isBN" => $this->isBN, + "isCorte" => $this->corte(), + "isGrapado" => $this->isGrapado + ]; + } + public function gofrado(): bool + { + $flag = false; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->code) { + $plastificado_code = $tarifa_acabado->code; + if ($plastificado_code == "GOF") { + $flag = true; + break; + } + } + } + $this->isGofrado = $flag; + return $this->isGofrado; + } + public function uvi(): bool + { + $flag = false; + $tarifa_acabado_uvi = $this->getUVI(); + if ($tarifa_acabado_uvi) { + $flag = true; + } + $this->isUVI = $flag; + return $this->isUVI; + } + public function cubierta(): bool + { + $lineaCubierta = $this->presupuesto->presupuestoLineaCubierta(); + if ($lineaCubierta) { + $this->isCubierta = true; + } + return $this->isCubierta; + } + public function color(): bool + { + $linea_impresion = $this->presupuesto->presupuestoLineaImpresion(); + if ($linea_impresion) { + if ($linea_impresion->isColor()) { + $this->isColor = true; + $this->isBN = false; + } else { + $this->isColor = false; + $this->isBN = true; + } + } + return $this->isColor; + } + public function corte(): bool + { + $ot_tareas = $this->ot->tareas(); + foreach ($ot_tareas as $key => $tarea) { + if ($tarea->is_corte) { + $this->isCorte = true; + break; + } + } + return $this->isCorte; + } } 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 c45bb0c8..532f6237 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php @@ -22,7 +22,7 @@