diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index 8b029b02..4f8be2d4 100755 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -12,8 +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 //ACABADO "plastificado_at" => "plastificado_user_id", + "plakene_at" => "plakene_user_id", //TODO + "retractilado_at" => "retractilado_user_id", + "estampado_at" => "estampado_user_id", //TODO + "uvi_at" => "uvi_user_id", //TODO "encuadernacion_at" => "encuadernacion_user_id", "corte_at" => "corte_user_id", "preparacion_interiores_at" => "preparacion_interior_user_id", @@ -21,7 +27,6 @@ class OrdenTrabajo extends BaseConfig "cosido_at" => "cosido_user_id", "grapado_at" => "grapado_user_id", "solapa_at" => "solapa_user_id", - "retractilado_at" => "retractilado_user_id", "retractilado5_at" => "retractilado5_user_id", "prototipo_at" => "prototipo_user_id", "marcapaginas_at" => "marcapaginas_user_id", @@ -100,9 +105,9 @@ class OrdenTrabajo extends BaseConfig ]; public array $OT_PLASTIFICADO_COLOR = [ - "BRIL" => ["bg" => "#00B0F0", "color" => "white"], + "BRILLO" => ["bg" => "#00B0F0", "color" => "white"], "MATE" => ["bg" => "#FF0000", "color" => "white"], - "SOFT_TOUCH" => ["bg" => "#00B050", "color" => "white"], + "SOFT" => ["bg" => "#00B050", "color" => "white"], "SANDY" => ["bg" => "#782170", "color" => "white"], "ANTIRAYADO" => ["bg" => "#E97132", "color" => "white"], "GOFRADO" => ["bg" => "#FFFF00", "color" => "black"], diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 4ac5ac81..352a871e 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -754,6 +754,7 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func $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'); + $routes->get('tarea/dates/(:num)','Ordentrabajo::get_orden_trabajo_tareas_dates/$1'); /**====================== * UPDATES *========================**/ @@ -771,6 +772,7 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func $routes->get("color/(:num)", 'Ordentrabajo::get_orden_trabajo_color_status/$1'); $routes->post("update/tarea/progress", "Ordentrabajo::store_orden_trabajo_progress_date"); $routes->post("update/tarea/pliegos", "Ordentrabajo::update_orden_trabajo_pliegos"); + $routes->post("update/tarea/proveedor", "Ordentrabajo::update_presupuesto_tarea_proveedor"); $routes->delete("tarea/progress/(:num)", "Ordentrabajo::delete_orden_trabajo_progress_date/$1"); /**====================== @@ -783,6 +785,8 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func * PDF *========================**/ $routes->get('pdf/(:num)', 'Ordentrabajo::get_pdf/$1'); + $routes->get('pdf/ferro/(:num)', 'Ordentrabajo::get_ferro_pdf/$1'); + $routes->get('pdf/prototipo/(:num)', 'Ordentrabajo::get_prototipo_pdf/$1'); $routes->get('portada/(:num)', 'Ordentrabajo::get_portada_img/$1'); $routes->group('planning', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { $routes->get('select/maquina/rotativa', 'Ordentrabajo::select_maquina_planning_rot'); diff --git a/ci4/app/Config/Validation.php b/ci4/app/Config/Validation.php index 09717371..f8c5881c 100755 --- a/ci4/app/Config/Validation.php +++ b/ci4/app/Config/Validation.php @@ -184,4 +184,15 @@ class Validation extends BaseConfig "label" => "maquina", ], ]; + public array $proveedor_tarea = + [ + "proveedor_id" => [ + "rules" => "required|integer", + "label" => "Proveedor", + ], + "orden_trabajo_tarea_id" => [ + "rules" => "required|integer", + "label" => "Tarea", + ], + ]; } diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 61741e33..413bb991 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\Compras\ProveedorModel; use App\Models\Configuracion\MaquinaModel; use App\Models\OrdenTrabajo\OrdenTrabajoModel; use App\Models\OrdenTrabajo\OrdenTrabajoTarea; @@ -28,6 +29,7 @@ class Ordentrabajo extends BaseController protected OrdenTrabajoModel $otModel; protected OrdenTrabajoUser $otUserModel; protected OrdenTrabajoTarea $otTarea; + protected ProveedorModel $proveedorModel; protected MaquinaModel $maquinaModel; protected UserModel $userModel; protected Validation $validation; @@ -45,6 +47,7 @@ class Ordentrabajo extends BaseController $this->produccionService = new ProductionService(); $this->otTarea = model(OrdenTrabajoTarea::class); $this->maquinaModel = model(MaquinaModel::class); + $this->proveedorModel = model(ProveedorModel::class); $this->validation = service("validation"); helper("time"); parent::initController($request, $response, $logger); @@ -138,6 +141,18 @@ class Ordentrabajo extends BaseController return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); } } + public function update_presupuesto_tarea_proveedor(){ + $bodyData = $this->request->getPost(); + $validated = $this->validation->run($bodyData, "proveedor_tarea"); + if ($validated) { + $validatedData = $this->validation->getValidated(); + $r = $this->produccionService->updateProveedorLinea($validatedData['orden_trabajo_tarea_id'], $validatedData['proveedor_id']); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + + } public function reset_orden_trabajo_date() { $bodyData = $this->request->getPost(); @@ -305,6 +320,7 @@ class Ordentrabajo extends BaseController ->edit("orden", fn($q) => ["id" => $q->id, "orden" => $q->orden]) ->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmm_string($q->tiempo_estimado)) ->edit("tiempo_real", fn($q) => float_seconds_to_hhmm_string($q->tiempo_real)) + ->add("proveedor", fn($q) => $this->produccionService->getProveedorTarea($q->id)) ->edit("maquina_tarea", fn($q) => ["id" => $q->id, "maquina_id" => $q->maquina_tarea, "maquina_name" => $q->maquina_nombre]) ->add("imposicion", fn($q) => ["id" => $q->id, "imposicion_id" => $q->imposicion_id, "name" => $q->imposicion_name, "is_presupuesto_linea" => $q->presupuesto_linea_id ? true : false]) ->toJson(true); @@ -313,6 +329,14 @@ class Ordentrabajo extends BaseController { return $this->produccionService->init($orden_trabajo_id)->getPdf(); } + public function get_ferro_pdf($orden_trabajo_id) + { + return $this->produccionService->init($orden_trabajo_id)->getFerroPdf(); + } + public function get_prototipo_pdf($orden_trabajo_id) + { + return $this->produccionService->init($orden_trabajo_id)->getPrototipoPdf(); + } public function upload_orden_trabajo_portada() { try { @@ -572,7 +596,6 @@ class Ordentrabajo extends BaseController } public function delete_orden_trabajo_progress_date(int $orden_trabajo_tarea_id) { - $status = $this->produccionService->deleteOrdenTrabajoTareaProgressDates($orden_trabajo_tarea_id); return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]); } @@ -598,4 +621,9 @@ class Ordentrabajo extends BaseController } } + public function get_orden_trabajo_tareas_dates($orden_trabajo_id) + { + $data = $this->produccionService->init($orden_trabajo_id)->getOrdenTrabajoTareaDates(); + return $this->response->setJSON(["data" => $data ]); + } } diff --git a/ci4/app/Database/Migrations/2025-04-29_232200_AlterTarifasAcabadoAddBoleanColumns.php b/ci4/app/Database/Migrations/2025-04-29_232200_AlterTarifasAcabadoAddBoleanColumns.php new file mode 100755 index 00000000..fd9d45ea --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-29_232200_AlterTarifasAcabadoAddBoleanColumns.php @@ -0,0 +1,68 @@ + [ + 'type' => 'BOOLEAN', + 'default' => false, + ], + 'plakene' => [ + 'type' => 'BOOLEAN', + 'default' => false, + ], + 'rectractilado' => [ + 'type' => 'BOOLEAN', + 'default' => false, + ], + 'estampado' => [ + 'type' => 'BOOLEAN', + 'default' => false, + ], + 'uvi' => [ + 'type' => 'BOOLEAN', + 'default' => false, + ], + 'plastificado_tipo' => [ + 'type' => 'ENUM', + 'constraint' => ['BRILLO','MATE','SANDY','GOFRADO','SOFT','ANTIRAYADO'], + 'null' => true, + ], + 'plakene_tipo' => [ + 'type' => 'ENUM', + 'constraint' => ['TRASLUCIDO','MATE','NEGRO'], + 'null' => true, + ], + 'rectractilado_tipo' => [ + 'type' => 'ENUM', + 'constraint' => ['1','3','5'], + 'null' => true, + ], + 'estampado_tipo' => [ + 'type' => 'ENUM', + 'constraint' => ['ORO','PLATA','COBRE','BRONCE'], + 'null' => true, + ], + 'uvi_tipo' => [ + 'type' => 'ENUM', + 'constraint' => ['2D','3D','BRAILLE'], + 'null' => true, + ] + ]; + public function up() + { + + $this->forge->addColumn('lg_tarifa_acabado',$this->COLUMNS); + + } + + public function down() + { + $this->forge->dropColumn('lg_tarifa_acabado',array_keys($this->COLUMNS)); + + } +} diff --git a/ci4/app/Database/Migrations/2025-04-30_083700_AlterOrdenesTrabajoAddCommentColumns.php b/ci4/app/Database/Migrations/2025-04-30_083700_AlterOrdenesTrabajoAddCommentColumns.php new file mode 100755 index 00000000..3a991162 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-30_083700_AlterOrdenesTrabajoAddCommentColumns.php @@ -0,0 +1,43 @@ + [ + 'type' => 'LONGTEXT', + 'null' => true + ], + 'comment_cubierta' => [ + 'type' => 'LONGTEXT', + 'null' => true + ], + 'comment_encuadernacion' => [ + 'type' => 'LONGTEXT', + 'null' => true + ], + 'comment_logistica' => [ + 'type' => 'LONGTEXT', + 'null' => true + ], + "info_solapa_guillotina" => [ + 'type' => 'LONGTEXT', + 'null' => true + ] + ]; + public function up() + { + + $this->forge->addColumn('ordenes_trabajo',$this->COLUMNS); + + } + + public function down() + { + $this->forge->dropColumn('ordenes_trabajo',array_keys($this->COLUMNS)); + + } +} diff --git a/ci4/app/Database/Migrations/2025-05-01-044600_AddOrdenTrabajoDatesManipuladoImpresion.php b/ci4/app/Database/Migrations/2025-05-01-044600_AddOrdenTrabajoDatesManipuladoImpresion.php new file mode 100644 index 00000000..6f1cb065 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-05-01-044600_AddOrdenTrabajoDatesManipuladoImpresion.php @@ -0,0 +1,82 @@ + [ + "type" => "DATE", + "null" => true, + ], + "guarda_at" => [ + "type" => "DATE", + "null" => true, + ], + "plakene_at" => [ + "type" => "DATE", + "null" => true, + ], + "estampado_at" => [ + "type" => "DATE", + "null" => true, + ], + "uvi_at" => [ + "type" => "DATE", + "null" => true, + ], + + ]; + protected array $USERS = [ + "sobrecubierta_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "guarda_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "plakene_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "estampado_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "uvi_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/PresupuestoAcabadosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php index c0ab643e..c836a170 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php @@ -1,7 +1,9 @@ find($this->attributes["tarifa_acabado_id"]); } - + public function proveedor(): ?ProveedorEntity + { + $proveedor = null; + $m = model(ProveedorModel::class); + if ($this->attributes["proveedor_id"]) { + $proveedor = $m->find($this->attributes["proveedor_id"]); + } + return $proveedor; + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php index a586f2c1..7f067936 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php @@ -1,7 +1,10 @@ "float", "margen" => "float", ]; - public function maquinas() : array + public function maquinas(): array { $m = model(TarifaEncuadernacionMaquinaModel::class); - $tarifa_maquinas = $m->where("tarifa_encuadernacion_id",$this->attributes["tarifa_encuadernado_id"])->findAll(); + $tarifa_maquinas = $m->where("tarifa_encuadernacion_id", $this->attributes["tarifa_encuadernado_id"])->findAll(); $maquinaModel = model(MaquinaModel::class); $maquinas = []; foreach ($tarifa_maquinas as $key => $tarifa_maquina) { @@ -43,9 +46,18 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity } return $maquinas; } - public function tarifa() : TarifaEncuadernacionEntity + public function tarifa(): TarifaEncuadernacionEntity { $m = model(TarifaEncuadernacionModel::class); return $m->find($this->attributes["tarifa_encuadernado_id"]); } + public function proveedor(): ?ProveedorEntity + { + $proveedor = null; + $m = model(ProveedorModel::class); + if ($this->attributes["proveedor_id"]) { + $proveedor = $m->find($this->attributes["proveedor_id"]); + } + return $proveedor; + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index a013aab2..c7d0edc3 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -210,7 +210,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity $q = $model->where('presupuesto_id', $this->attributes["id"])->findAll(); - return $q; + return $q ?? []; } /** * Obtiene las lineas de presupuesto del actual presupuesto @@ -251,6 +251,14 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity return $q; } + public function presupuestoLineaGuarda(): ?PresupuestoLineaEntity + { + $model = model(PresupuestoLineaModel::class); + + $q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_guardas"])->first(); + + return $q; + } public function hasSobrecubierta(): bool { $hasSobrecubierta = false; diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php index 83ad9323..38744e7e 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -222,6 +222,7 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity return $nombre; } + public function isGuarda(): bool { return in_array($this->attributes["tipo"], ["lp_guardas"]); diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php index 19ad97ab..bd73e401 100755 --- a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -15,8 +15,15 @@ class OrdenTrabajoDateEntity extends Entity "interior_bn_at" => null, "interior_color_at" => null, "cubierta_at" => null, + "sobrecubierta_at" => null, //TODO + "guarda_at" => null, //TODO //ACABADO "plastificado_at" => null, + "plakene_at" => null, //TODO + "retractilado_at"=> null, + "estampado_at" => null, //TODO + "uvi_at" => null, //TODO + //MANIPULADO "encuadernacion_at" => null, "corte_at" => null, "preparacion_interiores_at" => null, @@ -24,9 +31,8 @@ class OrdenTrabajoDateEntity extends Entity "cosido_at" => null, "solapa_at" => null, "grapado_at" => null, - "retractilado_at"=> null, - "retractilado5_at"=> null, - "prototipo_at"=> null, + "retractilado5_at"=> null, // !DELETE + "prototipo_at"=> null, // !DELETE "marcapaginas_at"=> null, "espiral_at"=> null, //FERRO diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index b5d9216c..b80de21d 100755 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -30,6 +30,11 @@ class OrdenTrabajoEntity extends Entity "progreso" => 0.00, "estado" => "I", "comentarios" => null, + "comment_interior" => null, + "comment_cubierta" => null, + "comment_encuadernacion" => null, + "comment_logistica" => null, + "info_solapa_guillotina" => null, "revisar_formato" => null, "revisar_lomo" => null, "revisar_solapa" => null, @@ -52,7 +57,12 @@ class OrdenTrabajoEntity extends Entity "tipo_entrada" => "string", "progreso" => "float", "estado" => "string", - "comentarios" => "string", + "comentarios" => "?string", + "comment_interior" => "?string", + "comment_cubierta" => "?string", + "comment_encuadernacion" => "?string", + "comment_logistica" => "?string", + "info_solapa_guillotina" => "?string", "revisar_formato" => "bool", "revisar_lomo" => "bool", "revisar_solapa" => "bool", @@ -80,7 +90,22 @@ class OrdenTrabajoEntity extends Entity $m = model(OrdenTrabajoTarea::class); return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_linea_id IS NOT NULL", NULL, FALSE)->findAll() ?? []; } - /** + public function tareas_acabado(): array + { + $m = model(OrdenTrabajoTarea::class); + return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_acabado_id IS NOT NULL", NULL, FALSE)->findAll() ?? []; + } + public function tareas_encuadernado(): array + { + $m = model(OrdenTrabajoTarea::class); + return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_encuadernado_id IS NOT NULL", NULL, FALSE)->findAll() ?? []; + } + public function tareas_manipulado(): array + { + $m = model(OrdenTrabajoTarea::class); + return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_manipulado_id IS NOT NULL", NULL, FALSE)->findAll() ?? []; + } + /** * Devuelve el presupuesto de la orden de trabajo * * @return PresupuestoEntity @@ -183,4 +208,5 @@ class OrdenTrabajoEntity extends Entity ]; return $estados[$this->attributes["estado"]]; } + } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php index 6eb09ce3..1d32be82 100755 --- a/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php @@ -5,6 +5,7 @@ namespace App\Entities\Produccion; use App\Entities\Configuracion\Imposicion; use App\Entities\Configuracion\Maquina; use App\Entities\Presupuestos\PresupuestoAcabadosEntity; +use App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity; use App\Entities\Presupuestos\PresupuestoLineaEntity; use App\Entities\Presupuestos\PresupuestoManipuladosEntity; use App\Models\Configuracion\ImposicionModel; @@ -12,6 +13,7 @@ use App\Models\Configuracion\MaquinaModel; use App\Models\OrdenTrabajo\OrdenTrabajoModel; use App\Models\OrdenTrabajo\OrdenTrabajoTareaProgressDate; use App\Models\Presupuestos\PresupuestoAcabadosModel; +use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Presupuestos\PresupuestoLineaModel; use App\Models\Presupuestos\PresupuestoManipuladosModel; use CodeIgniter\Entity\Entity; @@ -23,6 +25,11 @@ class OrdenTrabajoTareaEntity extends Entity "id" => null, "orden_trabajo_id" => null, "presupuesto_linea_id" => null, + "presupuesto_acabado_id" => null, + "presupuesto_preimpresion_id" => null, + "presupuesto_encuadernado_id" => null, + "presupuesto_extra_id" => null, + "presupuesto_manipulado_id" => null, "nombre" => null, "orden" => null, "maquina_id" => null, @@ -96,10 +103,15 @@ class OrdenTrabajoTareaEntity extends Entity * * @return PresupuestoLineaEntity */ - public function presupuesto_linea(): PresupuestoLineaEntity + public function presupuesto_linea(): ?PresupuestoLineaEntity { + $presupuesto_linea = null; $m = model(PresupuestoLineaModel::class); - return $m->find($this->attributes["presupuesto_linea_id"]); + if ($this->attributes['presupuesto_linea_id']) { + + $presupuesto_linea = $m->find($this->attributes["presupuesto_linea_id"]); + } + return $presupuesto_linea; } /** * Devuelve la maquina original del presupuesto linea @@ -108,17 +120,35 @@ class OrdenTrabajoTareaEntity extends Entity */ public function maquina_presupuesto_linea(): Maquina { - return $this->presupuesto_linea()->maquina(); + return $this->presupuesto_linea()?->maquina(); } /** * Devuelve el presupuesto acabado origen de esta tarea * * @return PresupuestoAcabadosEntity */ - public function presupuesto_acabado(): PresupuestoAcabadosEntity + public function presupuesto_acabado(): ?PresupuestoAcabadosEntity { + $presupuesto_acabado = null; $m = model(PresupuestoAcabadosModel::class); - return $m->find($this->attributes["presupuesto_linea_id"]); + if ($this->attributes["presupuesto_acabado_id"]) { + $presupuesto_acabado = $m->find($this->attributes["presupuesto_acabado_id"]); + } + return $presupuesto_acabado; + } + /** + * Devuelve el presupuesto enducadernacion origen de esta tarea + * + * @return PresupuestoEncuadernacionesEntity + */ + public function presupuesto_encuadernacion(): ?PresupuestoEncuadernacionesEntity + { + $presupuesto_encuadernacion = null; + $m = model(PresupuestoEncuadernacionesModel::class); + if ($this->attributes["presupuesto_encuadernado_id"]) { + $presupuesto_encuadernacion = $m->find($this->attributes["presupuesto_encuadernado_id"]); + } + return $presupuesto_encuadernacion; } /** * Devuelve el presupuesto acabado origen de esta tarea @@ -152,8 +182,8 @@ class OrdenTrabajoTareaEntity extends Entity { $dates = $this->progress_dates(); $intervals = []; - $init = []; - $end = []; + $init = null; + $end = null; foreach ($dates as $key => $date) { if ($date->estado == "I") { if ($date->action_at) { @@ -161,7 +191,7 @@ class OrdenTrabajoTareaEntity extends Entity } } if ($date->estado == "S" || $date->estado == "F") { - if ($date->action_at) { + if ($date->action_at && $init) { $end = Time::createFromFormat('Y-m-d H:i:s', $date->action_at); $intervals[] = $init->difference($end)->getSeconds(); } @@ -182,4 +212,24 @@ class OrdenTrabajoTareaEntity extends Entity } return $isTareaCosido; } + public function isImpresion() : bool + { + return $this->attributes['presupuesto_linea_id'] != null; + } + public function isAcabado() : bool + { + return $this->attributes['presupuesto_acabado_id'] != null; + } + public function isManipulado() : bool + { + return $this->attributes['presupuesto_manipulado_id'] != null; + } + public function isEncuadernado() : bool + { + return $this->attributes['presupuesto_encuadernado_id'] != null; + } + public function isCorte() : bool + { + return $this->attributes['is_corte']; + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php index 0a95037a..076c6d16 100755 --- a/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php @@ -19,8 +19,13 @@ class OrdenTrabajoUserEntity extends Entity "interior_bn_user_id" => null, "interior_color_user_id" => null, "cubierta_user_id" => null, + "sobrecubierta_user_id" => null, + "guarda_user_id" => null, //ACABADO "plastificado_user_id" => null, + "plakene_user_id" => null, + "estampado_user_id" => null, + "uvi_user_id" => null, "encuadernacion_user_id" => null, "corte_user_id" => null, "preparacion_interior_user_id" => null, diff --git a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php index cb96db44..30d846b5 100755 --- a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php +++ b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php @@ -24,6 +24,16 @@ 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_tipo' => null, + 'plakene_tipo' => null, + 'rectractilado_tipo' => null, + 'estampado_tipo' => null, + 'uvi_tipo' => null, ]; protected $casts = [ "precio_min" => "float", @@ -33,6 +43,16 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", + 'plastificado' => 'boolean', + 'plakene' => 'boolean', + 'rectractilado' => 'boolean', + 'estampado' => 'boolean', + 'uvi' => 'boolean', + 'plastificado_tipo' => '?string', + 'plakene_tipo' => '?string', + 'rectractilado_tipo' => '?string', + 'estampado_tipo' => '?string', + 'uvi_tipo' => '?string', ]; /** * Devuelve las maquinas asociadas a esta tarifa de acabado @@ -48,6 +68,7 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity public function isUVI(): bool { - return in_array($this->attributes["code"],["R3D","R2D"]); + return $this->attributes['uvi']; } + } diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index a511f03e..ee18d7b6 100755 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -43,12 +43,13 @@ return [ "maquina_actual" => "Máquina actual", "tiempo_estimado" => "Tiempo estimado", "tiempo" => "Tiempo", + "proveedor" => "Proveedor", "imposicion" => "Imposición" ], "finalizadas" => "Finalizadas", "pendiente_ferro" => "Ferro pendiente", "pendientes" => "Pendientes", - "ferro_ok" => "Ferro ok", + "ferro_ok" => "Ferro/Prototipo ok", "envio" => "Envío", "ferro" => "Ferro", "ot" => "Orden trabajo", @@ -70,6 +71,7 @@ return [ "portada" => "portada", "plakene_traslucido" => "Plakene traslúcido", "plastificado_mate" => "Plastificado mate", + "plastificado" => "Plastificado", "espiral" => "Espiral", "embalaje" => "Embalaje", "tiempo_consumido" => "Tiempo consumido", @@ -80,6 +82,7 @@ return [ "preview_pdf" => "Previsualizar PDF", "imprimir_codigo_safekat" => "Imprimir código SAFEKAT", "imprimir_ferro" => "Imprimir ferro", + "imprimir_prototipo" => "Prototipo", "planning_rotativa" => "Planificación rotativa", "planning_plana" => "Planificación plana", "solapa" => "Solapa", @@ -97,12 +100,16 @@ return [ "grapado" => "Grapado", "solapa" => "Solapas", "retractilado" => "Retractilado", + "manipulado" => "Entrada manipulado", "retractilado5" => "Retractilado 5", "prototipo" => "Prototipo", "marcapaginas" => "Marcapáginas", //IMPRESION "impresion_bn" => "Impresión BN", "cubierta" => "Cubierta/Portada", + "guarda" => "Guarda", + "encuadernacion" => "Encuadernación", + //PREIMPRESION "pre_formato" => "Revisión formato", "pre_lomo" => "Revisión lomo", @@ -144,6 +151,11 @@ return [ 'print_label' => "Imprimir etiqueta", 'click_init' => "Clicks al inicio", 'click_end' => "Clicks al final", - - + "comentarios" => "Comentarios", + "comentariosOt" => "Comentarios orden", + "comentariosImpresionInterior" => "Comentarios interior", + "comentariosCubierta" => "Comentarios cubierta", + "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/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php index d48e8d8e..da0a6116 100755 --- a/ci4/app/Models/Compras/ProveedorModel.php +++ b/ci4/app/Models/Compras/ProveedorModel.php @@ -214,4 +214,12 @@ class ProveedorModel extends \App\Models\BaseModel return $builder->get()->getResultObject(); } + public function querySelect(?string $q) + { + $query = $this->builder()->select(['id','nombre as name']); + if($q){ + $query->like('nombre',$q); + } + return $query; + } } diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index ff8f3dcd..d462cc08 100755 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -427,6 +427,9 @@ class MaquinaModel extends \App\Models\BaseModel ->where('tarea_progress.deleted_at', null) ->groupBy('lg_maquinas.id') ->orderBy('countTareas','DESC'); + if($maquina_tipo == "impresion"){ + $query->where('orden_trabajo_tareas.is_corte',0); + } return $query; } diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index 51234724..d44055ab 100755 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -22,8 +22,14 @@ class OrdenTrabajoDate extends Model "interior_bn_at", "interior_color_at", "cubierta_at", + "sobrecubierta_at", //TODO + "guarda_at", //TODO //ACABADO "plastificado_at", + "plakene_at", //TODO + "retractilado_at", + "estampado_at", //TODO + "uvi_at", //TODO "encuadernacion_at", "corte_at", "preparacion_interiores_at", @@ -31,7 +37,6 @@ class OrdenTrabajoDate extends Model "cosido_at", "solapa_at", "grapado_at", - "retractilado_at", "retractilado5_at", "prototipo_at", "marcapaginas_at", diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php index d7a1f37a..3dc9a95f 100755 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php @@ -25,6 +25,11 @@ class OrdenTrabajoModel extends Model "progreso", "estado", "comentarios", + "comment_interior", + "comment_cubierta", + "comment_encuadernacion", + "comment_logistica", + "info_solapa_guillotina", "revisar_formato", "revisar_lomo", "revisar_solapa", diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php index 443bbcd0..60114c57 100755 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php @@ -23,11 +23,18 @@ class OrdenTrabajoUser extends Model "interior_bn_user_id", "interior_color_user_id", "cubierta_user_id", + "sobrecubierta_user_id", + "guarda_user_id", //ACABADO "plastificado_user_id", + "plakene_user_id", + "retractilado_user_id", + "estampado_user_id", + "uvi_user_id", + //ENCUADERNADO "encuadernacion_user_id", - "corte_user_id", "preparacion_interior_user_id", + "corte_user_id", "entrada_manipulado_user_id", "cosido_user_id", "solapa_user_id", diff --git a/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php b/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php index e345a774..384b06d5 100755 --- a/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php +++ b/ci4/app/Models/Tarifas/Acabados/TarifaAcabadoModel.php @@ -1,4 +1,5 @@ groupStart() - ->like("t1.nombre", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.nombre", $search) + ->groupEnd(); } public function getServiciosAcabadoSelector() diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index e4de8acd..de5c7dfa 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -23,6 +23,8 @@ use App\Models\Configuracion\MaquinaModel; use App\Models\OrdenTrabajo\OrdenTrabajoFileModel; use App\Models\OrdenTrabajo\OrdenTrabajoTareaProgressDate; use App\Models\Pedidos\PedidoModel; +use App\Models\Presupuestos\PresupuestoAcabadosModel; +use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Usuarios\UserModel; use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\BaseResult; @@ -65,6 +67,8 @@ class ProductionService extends BaseService protected MaquinaEntity $defaultMaquinaCorte; protected MaquinaModel $maquinaModel; protected OrdenTrabajo $ordenTrabajoConfig; + protected PresupuestoAcabadosModel $presupuestoAcabadoModel; + protected PresupuestoEncuadernacionesModel $presupuestoEncuadernacionModel; /** @@ -100,7 +104,24 @@ class ProductionService extends BaseService * @var boolean */ public bool $isGofrado = false; //* CHECK DONE - + /** + * Indica si la orden de trabajo contiene plastificado + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isPlastificado = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene gofrado + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isPlakene = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene gofrado + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isEstampado = false; //* CHECK DONE /** * Indica si la orden de trabajo contiene cosido * Se usa para mostrar la fecha correspondiente en la vista y pliegos @@ -110,10 +131,10 @@ class ProductionService extends BaseService /** * 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 + * TODO Hay que implementar un boolean en `lg_tarifa_manipulado` para identificar * @var boolean */ - public bool $isGrapado = true; //TODO + public bool $isGrapado = false; //TODO /** * Indica si la orden de trabajo contiene espiral * Se usa para mostrar la fecha correspondiente en la vista @@ -121,21 +142,14 @@ class ProductionService extends BaseService * DEFAULT true hasta implementacion * @var boolean */ - public bool $isEspiral = true; //TODO + public bool $isEspiral = false; //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 @@ -186,6 +200,8 @@ class ProductionService extends BaseService $this->otTareaProgressDate = model(OrdenTrabajoTareaProgressDate::class); $this->festivoModel = model(FestivoModel::class); $this->ordenTrabajoConfig = config('OrdenTrabajo'); + $this->presupuestoAcabadoModel = model(PresupuestoAcabadosModel::class); + $this->presupuestoEncuadernacionModel = model(PresupuestoEncuadernacionesModel::class); $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; $this->configVariableModel = model(ConfigVariableModel::class); $this->podValue = $this->configVariableModel->getVariable('POD')->value; @@ -365,7 +381,7 @@ class ProductionService extends BaseService $ot_tareas["maquina_id"] = $p_linea_maquina->id; $ot_tareas["imposicion_id"] = null; $ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina * 3600; - $ot_tareas["tiempo_real"] = 0; + $ot_tareas["tiempo_real"] = 0; $insert_query_result = $this->otTarea->insert($ot_tareas); $ot_tareas = []; $this->storeTareaCorte($p_linea); @@ -575,6 +591,14 @@ class ProductionService extends BaseService { return view("themes/vuexy/pdfs/orden_trabajo", $this->getDataPdf()); } + public function getFerroPdf() + { + return view("themes/vuexy/pdfs/ferro", $this->getDataPdf()); + } + public function getPrototipoPdf() + { + return view("themes/vuexy/pdfs/prototipo", $this->getDataPdf()); + } /** * Query para mostrar en datatable * @@ -595,6 +619,10 @@ class ProductionService extends BaseService "orden_trabajo_tareas.tiempo_real", "orden_trabajo_tareas.comment", "orden_trabajo_tareas.presupuesto_linea_id", + "orden_trabajo_tareas.presupuesto_acabado_id", + "orden_trabajo_tareas.presupuesto_manipulado_id", + "orden_trabajo_tareas.presupuesto_preimpresion_id", + "orden_trabajo_tareas.presupuesto_encuadernado_id", "presupuesto_linea.tipo", ]) @@ -837,6 +865,7 @@ class ProductionService extends BaseService "preimpresiones" => $this->presupuesto->preimpresiones(), "manipulados" => $this->presupuesto->manipulados(), "encuadernaciones" => $this->presupuesto->encuadernaciones(), + "encuadernacionCode" => $this->getEncuadernacionCode(), "linea_impresion" => $this->presupuesto->presupuestoLineaImpresion(), "linea_cubierta" => $this->presupuesto->presupuestoLineaCubierta(), "peso_unidad" => $logistica_data["peso_unidad"], @@ -847,7 +876,9 @@ class ProductionService extends BaseService "colors" => $this->getPdfColors(), "isPOD" => $this->isPOD, "uvi" => $this->getUVI(), + "flags" => $this->getFlags(), "tareaCosido" => $this->getTareaCosido(), + "plakene_tipo" => $this->plakene_tipo() ]; } public function getImposicionTareaImpresion(): ?Imposicion @@ -958,6 +989,18 @@ class ProductionService extends BaseService throw new Exception(lang('Produccion.task_already_finished')); } } + 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); + $dataDate = [ + 'name' => $dateName, + ]; + $dataDate[$dateName] = Time::now()->format('Y-m-d'); + $this->updateOrdenTrabajoDate($dataDate); + } + } return $this->otTareaProgressDate->insert($data); } public function getTareaLastState($tarea_id) @@ -972,6 +1015,12 @@ 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) { $response = $this->storeOrdenTrabajoTareaProgressDate($data); } @@ -1374,7 +1423,7 @@ class ProductionService extends BaseService $uvi = null; $acabados = $this->presupuesto->acabados(); foreach ($acabados as $key => $acabado) { - if ($acabado->tarifa()->isUVI()) { + if ($acabado->tarifa()->uvi) { $uvi = $acabado->tarifa(); } } @@ -1490,8 +1539,11 @@ class ProductionService extends BaseService { $code = ""; $encuadernaciones = $this->presupuesto->encuadernaciones(); - if (isset($encuadernaciones[0])) { - $code = $encuadernaciones[0]->tarifa()->code; + foreach ($encuadernaciones as $key => $value) { + $code = $value->tarifa()->code; + if ($code) { + break; + } } return $code; } @@ -1596,21 +1648,10 @@ class ProductionService extends BaseService foreach ($acabados as $key => $acabado) { $tarifa_acabado = $acabado->tarifa(); if ($tarifa_acabado->code) { - $plastificado_code = $tarifa_acabado->code; - if ($plastificado_code == "BRIL") { - $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['BRIL']; - } - if ($plastificado_code == "MATE") { - $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['MATE']; - } - if ($plastificado_code == "ANTI") { - $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['ANTIRAYADO']; - } - if ($plastificado_code == "SAND") { - $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['SANDY']; - } - if ($plastificado_code == "GOF") { - $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['GOFRADO']; + if ($tarifa_acabado->plastificado) { + if (isset($this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR[$tarifa_acabado->plastificado_tipo])) { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR[$tarifa_acabado->plastificado_tipo]; + } } } } @@ -1641,10 +1682,15 @@ class ProductionService extends BaseService $this->color(); return [ "isGofrado" => $this->gofrado(), - "isEspiral" => $this->isEspiral, + "isEspiral" => $this->isEspiral, //TODO + "isPlastificado" => $this->plastificado(), + "isPlakene" => $this->plakene(), + "isEstampado" => $this->estampado(), + "isRetractilado" => $this->retractilado(), "isUVI" => $this->uvi(), - "isPlastificado" => $this->isPlastificado, "isCubierta" => $this->cubierta(), + "isSobrecubierta" => $this->sobreCubierta(), + "isGuarda" => $this->guarda(), "isColor" => $this->isColor, "isBN" => $this->isBN, "isCorte" => $this->corte(), @@ -1669,6 +1715,75 @@ class ProductionService extends BaseService $this->isGofrado = $flag; return $this->isGofrado; } + public function plakene(): bool + { + $flag = false; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->plakene) { + $flag = true; + break; + } + } + $this->isPlakene = $flag; + return $this->isPlakene; + } + public function retractilado(): bool + { + $flag = false; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->retractilado) { + $flag = true; + break; + } + } + $this->isPlakene = $flag; + return $this->isPlakene; + } + public function plakene_tipo(): ?string + { + $tipo = ""; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->plakene) { + $tipo = $tarifa_acabado->plakene_tipo; + break; + } + } + return $tipo; + } + public function plastificado(): bool + { + $flag = false; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->plastificado) { + $flag = true; + break; + } + } + $this->isPlastificado = $flag; + return $this->isPlastificado; + } + public function estampado(): bool + { + $flag = false; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->estampado) { + $flag = true; + break; + } + } + $this->isEstampado = $flag; + return $this->isEstampado; + } public function cosido(): bool { $flag = false; @@ -1701,6 +1816,24 @@ class ProductionService extends BaseService } return $this->isCubierta; } + public function sobreCubierta(): bool + { + $flag = false; + $lineaCubierta = $this->presupuesto->presupuestoLineaSobreCubierta(); + if ($lineaCubierta) { + $flag = true; + } + return $flag; + } + public function guarda(): bool + { + $flag = false; + $lineaCubierta = $this->presupuesto->presupuestoLineaGuarda(); + if ($lineaCubierta) { + $flag = true; + } + return $flag; + } public function color(): bool { $linea_impresion = $this->presupuesto->presupuestoLineaImpresion(); @@ -1739,10 +1872,7 @@ class ProductionService extends BaseService "orden_trabajo_tareas.id as ot_tarea_id", "pedidos.fecha_impresion", "orden_trabajo_tareas.nombre as tareaName", - "presupuestos.titulo as presupuesto_titulo", "orden_trabajo_tareas.maquina_id", - "lg_papel_impresion.nombre as papel_impresion", - "presupuesto_linea.gramaje as papel_gramaje", "tarea_progress.estado as tareaEstado" ]) ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") @@ -1759,21 +1889,14 @@ class ProductionService extends BaseService 'tarea_progress.ot_tarea_id = orden_trabajo_tareas.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("pedidos", "pedidos.id = ordenes_trabajo.pedido_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") - ->groupStart() - ->orWhere('orden_trabajo_tareas.maquina_id', $maquina_id) //!TODO - ->orWhere('presupuesto_linea.maquina_id', $maquina_id) - ->groupEnd() + ->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') ->orderBy("pedidos.fecha_impresion", "ASC") - ->groupBy('orden_trabajo_tareas.nombre'); + ->groupBy('orden_trabajo_tareas.id'); return $q; } @@ -1860,4 +1983,176 @@ class ProductionService extends BaseService $dates = $this->createDatesForPOD(); return $this->pedidoModel->update($this->pedido->id, $dates); } + public function getProveedorTarea($tarea_id) + { + $proveedor = null; + $tareaEntity = $this->otTarea->find($tarea_id); + if ($tareaEntity) { + $proveedorEncuadernado = $tareaEntity->presupuesto_encuadernacion(); + $proveedorAcabado = $tareaEntity->presupuesto_acabado(); + if ($proveedorEncuadernado) { + $proveedor = $proveedorEncuadernado->proveedor(); + } elseif ($proveedorAcabado) { + $proveedor = $proveedorAcabado->proveedor(); + } else { + $proveedor = null; + } + } + return ["tarea" => $tareaEntity, "proveedor" => $proveedor]; + } + public function updateProveedorLinea($tarea_id, $proveedor_id) + { + $status = false; + $tareaEntity = $this->otTarea->find($tarea_id); + $presupuestoEncuadernado = $tareaEntity->presupuesto_encuadernacion(); + $presupuestoAcabado = $tareaEntity->presupuesto_acabado(); + if ($presupuestoEncuadernado) { + $status = $this->presupuestoEncuadernacionModel->update($presupuestoEncuadernado->id, ['proveedor_id' => $proveedor_id]); + } elseif ($presupuestoAcabado) { + $status = $this->presupuestoAcabadoModel->update($presupuestoAcabado->id, ['proveedor_id' => $proveedor_id]); + } else { + $status = null; + } + return $status; + } + public function otTareaImpresionWithDates() + { + $tareasImpresion = $this->ot->tareas_impresion(); + $data = []; + foreach ($tareasImpresion as $key => $tareaImpresion) { + if ($tareaImpresion->is_corte) { + $data[$tareaImpresion->id] = 'corte_at'; + continue; + } + $presupuestoLineaEntity = $tareaImpresion->presupuesto_linea(); + if ($presupuestoLineaEntity) { + if ($presupuestoLineaEntity->isGuarda()) { + $data[$tareaImpresion->id] = 'guarda_at'; + } elseif ($presupuestoLineaEntity->isCubierta()) { + $data[$tareaImpresion->id] = 'cubierta_at'; + } elseif ($presupuestoLineaEntity->isColor()) { + $data[$tareaImpresion->id] = 'interior_color_at'; + } elseif ($presupuestoLineaEntity->isBN()) { + $data[$tareaImpresion->id] = 'interior_bn_at'; + } elseif ($presupuestoLineaEntity->isSobreCubierta()) { + $data[$tareaImpresion->id] = 'sobrecubierta_at'; + } + } + } + return $data; + } + public function tareaImpresionDate($tarea): string + { + + $dateName = ""; + $presupuestoLineaEntity = $tarea->presupuesto_linea(); + if ($presupuestoLineaEntity) { + if ($presupuestoLineaEntity->isGuarda()) { + $dateName = 'guarda_at'; + } elseif ($presupuestoLineaEntity->isCubierta()) { + $dateName = 'cubierta_at'; + } elseif ($presupuestoLineaEntity->isColor()) { + $dateName = 'interior_color_at'; + } elseif ($presupuestoLineaEntity->isBN()) { + $dateName = 'interior_bn_at'; + } elseif ($presupuestoLineaEntity->isSobreCubierta()) { + $dateName = 'sobrecubierta_at'; + } + if ($tarea->is_corte) { + $dateName = 'corte_at'; + } + } + return $dateName; + } + public function otTareaAcabadoWithDates() + { + $tareasAcabado = $this->ot->tareas_acabado(); + $data = []; + foreach ($tareasAcabado as $key => $tareasAcabado) { + $tarifaAcabado = $tareasAcabado->presupuesto_acabado()?->tarifa(); + if ($tarifaAcabado) { + if ($tarifaAcabado->plastificado) { + $data[$tareasAcabado->id] = 'plastificado_at'; + } + if ($tarifaAcabado->rectractilado) { + $data[$tareasAcabado->id] = 'rectractilado_at'; + } + if ($tarifaAcabado->estampado) { + $data[$tareasAcabado->id] = 'estampado_at'; + } + if ($tarifaAcabado->uvi) { + $data[$tareasAcabado->id] = 'uvi_at'; + } + } + } + return $data; + } + public function tareaAcabadoDate($tarea): string + { + + $dateName = ""; + $tarifaAcabado = $tarea->presupuesto_acabado()?->tarifa();; + if ($tarifaAcabado) { + if ($tarifaAcabado->plastificado) { + $dateName = 'plastificado_at'; + } + if ($tarifaAcabado->rectractilado) { + $dateName = 'rectractilado_at'; + } + if ($tarifaAcabado->plakene) { + $dateName = 'plakene_at'; + } + if ($tarifaAcabado->estampado) { + $dateName = 'estampado_at'; + } + if ($tarifaAcabado->uvi) { + $dateName = 'uvi_at'; + } + } + return $dateName; + } + public function otTareaEncuadernadoWithDates() + { + $tareas = $this->ot->tareas_encuadernado(); + $data = []; + foreach ($tareas as $key => $tarea) { + $data[$tarea->id] = "encuadernacion_at"; + } + return $data; + } + + public function otTareaManipuladooWithDates() + { + $tareas = $this->ot->tareas_manipulado(); + $data = []; + foreach ($tareas as $key => $tarea) { + $data[$tarea->id] = "entrada_manipulado_at"; + } + return $data; + } + public function getOrdenTrabajoTareaDates(): array + { + $dates = []; + foreach ($this->ot->tareas() as $key => $tarea) { + $dates[] = $this->getOrdenTrabajoTareaDate($tarea); + } + return array_unique($dates); + } + public function getOrdenTrabajoTareaDate(OrdenTrabajoTareaEntity $tarea): ?string + { + $dateName = null; + if ($tarea->isImpresion()) { + $dateName = $this->tareaImpresionDate($tarea); + } + if ($tarea->isAcabado()) { + $dateName = $this->tareaAcabadoDate($tarea); + } + if ($tarea->isManipulado()) { + $dateName = "entrada_manipulado_at"; + } + if ($tarea->isEncuadernado()) { + $dateName = "encuadernacion_at"; + } + return $dateName; + } } diff --git a/ci4/app/Views/themes/vuexy/components/tables/maquinista_tarea_table.php b/ci4/app/Views/themes/vuexy/components/tables/maquinista_tarea_table.php index cbf06dde..2ff699af 100755 --- a/ci4/app/Views/themes/vuexy/components/tables/maquinista_tarea_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/maquinista_tarea_table.php @@ -6,9 +6,6 @@
+ = $ot->comment_interior ?> +
+