diff --git a/ci4/app/Config/RBAC/permissionMatrix.php b/ci4/app/Config/RBAC/permissionMatrix.php index db81f0ce..e8a6010b 100644 --- a/ci4/app/Config/RBAC/permissionMatrix.php +++ b/ci4/app/Config/RBAC/permissionMatrix.php @@ -196,6 +196,8 @@ const SK_PERMISSION_MATRIX = [ "pedidos-cancelados.menu", "pedidos-todos.view", "pedidos-todos.menu", + "pedidos-gestion.toprod", + "pedidos-gestion.menu", "tarifa-preimpresion.create", "tarifa-preimpresion.edit", "tarifa-preimpresion.menu", diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index e53d3c53..e9590f5c 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -1001,7 +1001,10 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func $routes->group('planning', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { $routes->get('rotativa', 'Ordentrabajo::index_planning_rotativa'); $routes->get('papel/datatable', 'Ordentrabajo::papel_gramaje_datatable'); + $routes->get('papel/plana/datatable', 'Ordentrabajo::papel_pliego_datatable'); $routes->get('rotativa/datatable', 'Ordentrabajo::planning_rotativa_datatable'); + $routes->get('plana/datatable', 'Ordentrabajo::planning_plana_datatable'); + }); }); }); diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index bafb454b..44f5ebd9 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -193,8 +193,16 @@ class Ordentrabajo extends BaseController $q = $this->produccionService->papelGramajeDatatableQuery(); return DataTable::of($q) - ->edit("tiempoReal", fn($q) => float_seconds_to_hhmm_string($q->tiempoReal * 3600)) - ->add("metros", fn($q) => $q->papel_ancho*$q->totalTirada/1000) + ->edit("tiempoReal", fn($q) => $q->tiempoReal * 3600) + ->add("action", fn($q) => ["title" => lang('Produccion.datatable.filter_by_task'), 'data' => $q]) + ->toJson(true); + } + public function papel_pliego_datatable() + { + + $q = $this->produccionService->papelPliegoDatatableQuery(); + return DataTable::of($q) + ->edit("tiempoReal", fn($q) => $q->tiempoReal * 3600) ->add("action", fn($q) => ["title" => lang('Produccion.datatable.filter_by_task'), 'data' => $q]) ->toJson(true); } @@ -266,9 +274,17 @@ class Ordentrabajo extends BaseController ->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "") ->add("metros_check", fn($q) => $q->otId) ->add("corte", fn($q) => $q->otId) - ->add("metros", fn($q) => $q->papel_ancho*$q->ot_tirada/1000) ->add("action", fn($q) => $q) ->toJson(true); } + public function planning_plana_datatable() + { + $q = $this->produccionService->planningPlanaQueryDatatable(); + return DataTable::of($q) + ->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "") + ->add("pliegos_check", fn($q) => $q->otId) + ->add("action", fn($q) => $q) + ->toJson(true); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php index f0705d98..247a12ec 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -221,4 +221,8 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity return $nombre; } + public function isRotativa() : bool + { + return in_array($this->attributes['tipo'],['lp_rot_color','lp_rot_bn']); + } } diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 13ea3d6d..f2137fc9 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -792,6 +792,8 @@ return [ "menu_orden_trabajo_finalizados" => "OTs finalizados", "menu_orden_trabajo_pendientes" => "OTs pendientes", "menu_planning_rotativa" => "Planning rotativa", + "menu_planning" => "Plannings", + "menu_ordentrabajomaquetacion" => "Orden de trabajo maquetación", "menu_ordenmaquina" => "Orden máquina", diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index fdceace1..da69474a 100644 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -25,7 +25,9 @@ return [ "logo" => "Logo impresion", "filter_by_task" => "Filtrar por tarea", "metros" => "Metros", - "corte" => "Corte" + "corte" => "Corte", + "pliegos" => "Pliegos", + "pliegos_libro" => "Pliegos" ], @@ -71,7 +73,8 @@ return [ "preview_pdf" => "Previsualizar PDF", "imprimir_codigo_safekat" => "Imprimir código SAFEKAT", "imprimir_ferro" => "Imprimir ferro", - "planning_rotativa" => "Tareas rotativa", + "planning_rotativa" => "Planificación rotativa", + "planning_plana" => "Planificación plana", "solapa" => "Solapa", "papel_gramajes" => "Papel y gramajes" diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index e0f92923..d6a7d7c1 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -102,7 +102,7 @@ class OrdenTrabajoDate extends Model } return $data; } - protected function updateUserDateMap($data,$values){ + public function updateUserDateMap($orden_trabajo_id,$data){ $mapping = [ "fecha_encuadernado_at" => "encuadernacion_user_id", // "fecha_externo_at" => "null", @@ -121,10 +121,10 @@ class OrdenTrabajoDate extends Model ]; $otUser = model(OrdenTrabajoUser::class); $auth_user_id = auth()->user()->id; - foreach ($values as $key => $value) { + foreach ($data as $key => $value) { if(isset($mapping[$key])){ if($value){ - $otUser->where('orden_trabajo_id',$data['orden_trabajo_id']) + $otUser->where('orden_trabajo_id',$orden_trabajo_id) ->set([$mapping[$key] => $auth_user_id]) ->update(); } diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 70b5b11f..6f9ea0c6 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -13,10 +13,14 @@ use App\Models\OrdenTrabajo\OrdenTrabajoTarea; use App\Models\OrdenTrabajo\OrdenTrabajoUser; use App\Models\Usuarios\UserModel; use CodeIgniter\Config\BaseService; +use App\Entities\Configuracion\Maquina as MaquinaEntity; +use App\Entities\Produccion\OrdenTrabajoTareaEntity; +use App\Models\Configuracion\MaquinaModel; use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\BaseResult; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\I18n\Time; +use CodeIgniter\Model; use Dompdf\Dompdf; /** @@ -24,12 +28,19 @@ use Dompdf\Dompdf; */ class ProductionService extends BaseService { + public array $TIPOS_PLANA = ['lp_bn','lp_color','lp_colorhq']; + public array $TIPOS_ROTATIVA = ['lp_rot_bn','lp_rot_color']; + protected OrdenTrabajoModel $otModel; + protected OrdenTrabajoTarea $otTarea; protected OrdenTrabajoDate $otDate; protected OrdenTrabajoUser $otUser; protected OrdenTrabajoEntity $ot; protected UserModel $userModel; + protected string $defaultMaquinaCorteName = 'HT-1000'; + protected MaquinaEntity $defaultMaquinaCorte; + protected MaquinaModel $maquinaModel; protected array $MAPPING_DATE_USER = [ "fecha_encuadernado_at" => "encuadernacion_user_id", // "fecha_externo_at" => "null", @@ -70,10 +81,12 @@ class ProductionService extends BaseService } public function init(int $orden_trabajo_id): self { + $this->maquinaModel = model(MaquinaModel::class); $this->otModel = model(OrdenTrabajoModel::class); $this->ot = $this->otModel->find($orden_trabajo_id); $pedido = $this->ot->pedido(); $this->setPedido($pedido); + $this->defaultMaquinaCorte = $this->maquinaModel->where('nombre',$this->defaultMaquinaCorteName)->first(); return $this; } /** @@ -140,14 +153,17 @@ class ProductionService extends BaseService $fecha_encuadernado = Time::now()->addDays(2)->format("Y-m-d"); $fecha_entrega_real = Time::now()->addDays(5)->format("Y-m-d"); $fecha_embalaje_at = Time::now()->addDays(4)->format("Y-m-d"); - return $this->otDate->insert([ + $data = [ "orden_trabajo_id" => $this->ot->id, "fecha_encuadernado_at" => $fecha_encuadernado, "fecha_entrega_real_at" => $fecha_entrega_real, "fecha_impresion_at" => Time::now()->format("Y-m-d"), "embalaje_at" => $fecha_embalaje_at, "fecha_entrega_externo" => $this->pedido->fecha_entrega_externo, - ]); + ]; + $otDateId = $this->otDate->insert($data); + $this->otDate->updateUserDateMap($this->ot->id,$data); + return $otDateId; } protected function storeOrdenTrabajoUsers(): int|bool|string { @@ -171,7 +187,7 @@ class ProductionService extends BaseService return $r; } /** - * Inserta las tareas de la orden de trabajo. + * Inserta las tareas de la orden de trabajo.p * Acepta como argumento una entidad de la orden de trabajo OrdenTrabajoEntity * * @@ -196,9 +212,28 @@ class ProductionService extends BaseService $ot_tareas["tiempo_real"] = $p_linea->horas_maquina; //? Tiempo real se inserta manual? $insert_query_result = $this->otTarea->insert($ot_tareas); $ot_tareas = []; + $this->storeTareaCorte($p_linea); } return $insert_query_result; } + protected function storeTareaCorte(PresupuestoLineaEntity $pLinea): ?OrdenTrabajoTareaEntity + { + $otCorte = null; + if($pLinea->isRotativa()){ + $tareaId = $this->otTarea->insert([ + 'orden_trabajo_id' => $this->ot->id, + 'presupuesto_linea_id' => $pLinea->id, + 'nombre' => 'Corte', + 'maquina_id' => $this->defaultMaquinaCorte->id, + 'orden' => $this->defaultMaquinaCorte->orden_planning, + 'tiempo_estimado' => $pLinea->rotativa_tiempo_corte, + 'tiempo_real' => $pLinea->rotativa_tiempo_corte + ]); + $otCorte = $this->otTarea->find($tareaId); + } + return $otCorte; + } + protected function storeOrdenTrabajoAcabadoTareas(): bool { $p_lineas = $this->presupuesto_lineas_acabado(); @@ -404,6 +439,7 @@ class ProductionService extends BaseService "ordenes_trabajo.total_tirada as ot_tirada", "lg_papel_formato.ancho as papel_ancho", "lg_papel_formato.alto as papel_alto", + "presupuesto_linea.rotativa_metros_total as metros", // "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') as maquina_ancho", // "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') as maquina_alto", "lg_papel_impresion.nombre as papel_impresion", @@ -422,7 +458,49 @@ class ProductionService extends BaseService ->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left") ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") // ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) - ->whereIn("presupuesto_linea.tipo", ["lp_rot_bn", "lp_rot_color"]) + ->whereIn("presupuesto_linea.tipo", $this->TIPOS_ROTATIVA) + ->where('lg_maquinas.is_rotativa',true) + ->where("orden_trabajo_tareas.deleted_at", null) + ->orderBy("orden_trabajo_tareas.orden", "ASC"); + return $q; + } + /** + * Query para mostrar en datatable + * + * @return BaseBuilder + */ + public function planningPlanaQueryDatatable(): BaseBuilder + { + $q = $this->otModel->builder()->select([ + "ordenes_trabajo.id as otId", + "orden_trabajo_dates.fecha_entrega_real_at", + "presupuestos.titulo as presupuesto_titulo", + "orden_trabajo_tareas.maquina_id", + "lg_maquinas.nombre as maquina_planning_nombre", + "ordenes_trabajo.total_tirada as ot_tirada", + "lg_papel_formato.ancho as papel_ancho", + "lg_papel_formato.alto as papel_alto", + "presupuesto_linea.pliegos_pedido as pliegosPedido", + // "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') as maquina_ancho", + // "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') as maquina_alto", + "lg_papel_impresion.nombre as papel_impresion", + "presupuesto_linea.gramaje as papel_gramaje", + + + + ]) + ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("orden_trabajo_dates", "orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right") + ->join("lg_papel_formato", "lg_papel_formato.id = presupuestos.papel_formato_id", "left") + ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") + ->join("lg_papel_impresion", "lg_papel_impresion.id = presupuesto_linea.papel_impresion_id", "left") + ->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") + // ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) + ->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA) + ->where('lg_maquinas.is_rotativa',false) ->where("orden_trabajo_tareas.deleted_at", null) ->orderBy("orden_trabajo_tareas.orden", "ASC"); return $q; @@ -472,6 +550,7 @@ class ProductionService extends BaseService "lg_papel_formato.alto as papel_alto", // "CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') AS DOUBLE) as maquina_ancho", // "CAST(JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') AS DOUBLE) as maquina_alto", + "presupuesto_linea.rotativa_metros_total as metros", "SUM(ordenes_trabajo.total_tirada) as totalTirada", "SUM(orden_trabajo_tareas.tiempo_real) as tiempoReal" ]) @@ -482,6 +561,34 @@ class ProductionService extends BaseService ->join("lg_papel_formato", "lg_papel_formato.id = presupuestos.papel_formato_id", "left") ->where("orden_trabajo_tareas.deleted_at", null) ->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE) + ->whereIn("presupuesto_linea.tipo", $this->TIPOS_ROTATIVA) + ->groupBy('lg_papel_impresion.id'); + + + + return $q; + } + public function papelPliegoDatatableQuery(): BaseBuilder + { + $q = $this->otModel->builder()->select([ + "lg_papel_impresion.id as papelImpresionId", + "lg_papel_impresion.nombre as papelImpresionNombre", + "lg_papel_impresion.gramaje as papelImpresionGramaje", + "COUNT(orden_trabajo_tareas.id) as tareasCount", + "lg_papel_formato.ancho as papel_ancho", + "lg_papel_formato.alto as papel_alto", + "presupuesto_linea.pliegos_pedido as pliegosPedido", + "SUM(ordenes_trabajo.total_tirada) as totalTirada", + "SUM(orden_trabajo_tareas.tiempo_real) as tiempoReal" + ]) + ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right") + ->join("lg_papel_impresion", "presupuesto_linea.papel_impresion_id = lg_papel_impresion.id", "left") + ->join("lg_papel_formato", "lg_papel_formato.id = presupuestos.papel_formato_id", "left") + ->where("orden_trabajo_tareas.deleted_at", null) + ->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE) + ->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA) ->groupBy('lg_papel_impresion.id'); @@ -614,18 +721,23 @@ class ProductionService extends BaseService public function updateOrdenTrabajoDate($data) { - // // return $this->otDate->find($this->ot->id); + $result = []; $otDate = $this->otDate->where('orden_trabajo_id', $this->ot->id) ->set([$data['name'] => $data[$data['name']]]) ->update($data); + $this->otDate->updateUserDateMap($this->ot->id,$data); $ot_users = $this->ot->users(); - if($this->MAPPING_DATE_USER[$data["name"]]){ + if(isset($this->MAPPING_DATE_USER[$data["name"]])){ $user_id = $ot_users->{$this->MAPPING_DATE_USER[$data["name"]]}; $user = $this->userModel->find($user_id); - return ["user" => $user, "status" => $otDate]; + if($user_id){ + $result = ["user" => null, "status" => false]; + } + $result = ["user" => $user, "status" => $otDate]; }else{ - return ["user" => null, "status" => false]; + $result = ["user" => null, "status" => false]; } + return $result; } public function updateOrdenTrabajo($data): bool diff --git a/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php b/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php index cc71352d..e8427765 100644 --- a/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php @@ -19,7 +19,7 @@
| = lang('Produccion.datatable.papel') ?> | += lang('Produccion.datatable.gramaje') ?> (gr) | += lang('Produccion.datatable.tareas') ?> | += lang('Produccion.datatable.tirada') ?> | += lang('Produccion.datatable.pliegos_libro') ?> | += lang('Produccion.datatable.tiempo') ?>(HH:MM) | ++ + |
|---|---|---|---|---|---|---|
| Total: | ++ | + | + + | |||
| = lang('ID') ?> | += lang('Produccion.datatable.fecha_entrega_at') ?> | += lang('Produccion.datatable.titulo') ?> | += lang('Produccion.datatable.maquina') ?> | += lang('Produccion.datatable.tirada') ?> | += lang('Produccion.datatable.ancho') ?> | += lang('Produccion.datatable.alto') ?> | += lang('Produccion.datatable.papel') ?> | += lang('Produccion.datatable.gramaje') ?> | ++ | = lang('Produccion.datatable.pliegos') ?> | += lang('Basic.global.Action') ?> | +
|---|---|---|---|---|---|---|---|---|---|---|---|
| + | + | + | + | + | + | + | + | + |
+
+
+
+ |
+ + | + |