diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index 1d91e1d2..2c9a9474 100644 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -18,6 +18,13 @@ class OrdenTrabajo extends BaseConfig "corte_at" => "corte_user_id", "preparacion_interiores_at" => "preparacion_interior_user_id", "entrada_manipulado_at" => "entrada_manipulado_user_id", + "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", //FERRO "pendiente_ferro_at" => "pendiente_ferro_user_id", "ferro_en_cliente_at" => "ferro_en_cliente_user_id", @@ -40,6 +47,18 @@ class OrdenTrabajo extends BaseConfig "fecha_encuadernado" => "fecha_encuadernado_change_user_id", "fecha_entrega_externo" => "fecha_entrega_externo_change_user_id", ]; + public array $OT_COLORS = [ + "sin_imprimir" => "#FF6363", + "impreso_int" => "#AFDDFF", + "impreso_cub" => "#3A59D1", + "plastificado" => "#FFD63A", + "preparado" => "#FF0B55", + "solapa" => "#4F1C51", + "cosido" => "#FF0B55", + "grapado" => "#FEBA17", + "encuadernado" => "#FEBA17", + "corte" => "#67AE6E" + ]; public function __construct() { diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 3f308c76..718e504b 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -647,6 +647,8 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route $routes->get('direct/client/users/select/presupuesto/(:num)', 'ChatController::get_presupuesto_client_users/$1/$2', ['as' => 'getPresupuestoClientUsers']); $routes->get('direct/client/users/select/pedido/(:num)', 'ChatController::get_pedido_client_users/$1/$2', ['as' => 'getPedidoClientUsers']); $routes->get('direct/client/users/select/factura/(:num)', 'ChatController::get_factura_client_users/$1/$2', ['as' => 'getFacturaClientUsers']); + $routes->get('direct/client/users/select/ot/(:num)', 'ChatController::get_orden_trabajo_client_users/$1/$2', ['as' => 'getOrdenTrabajoClientUsers']); + $routes->get('direct/users/(:num)', 'ChatController::get_chat_direct_users', ['as' => 'getChatDirectUsers']); $routes->post('direct/users/(:num)', 'ChatController::store_chat_direct_users/$1', ['as' => 'storeChatDirectUsers']); @@ -663,7 +665,10 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route $routes->get('department/presupuesto/(:num)/(:num)', 'ChatController::get_chat_presupuesto/$1/$2', ['as' => 'getChatPresupuesto']); $routes->get('department/pedido/(:num)/(:num)', 'ChatController::get_chat_pedido/$1/$2', ['as' => 'getChatPedido']); $routes->get('department/factura/(:num)/(:num)', 'ChatController::get_chat_factura/$1/$2', ['as' => 'getChatFactura']); + $routes->get('department/ot/(:num)/(:num)', 'ChatController::get_chat_orden_trabajo/$1/$2', ['as' => 'getChatOrdenTrabajo']); $routes->get('department/users/presupuesto/(:num)/(:num)', 'ChatController::get_chat_department_presupuesto_users/$1/$2', ['as' => 'getPresupuestoChatDepartmentUsers']); + $routes->get('department/users/ot/(:num)/(:num)', 'ChatController::get_chat_department_orden_trabajo_users/$1/$2', ['as' => 'getOrdenTrabajoChatDepartmentUsers']); + $routes->get('department/datatable', 'ChatController::chat_department_datatable', ['as' => 'chatDepartmentDatatable']); $routes->get('department/edit/(:num)', 'ChatController::chat_department_edit/$1', ['as' => 'chatDepartmentEditView']); $routes->get('department/users/datatable/(:num)', 'ChatController::chat_department_user_datatable/$1', ['as' => 'chatDepartmentUsersDatatable']); diff --git a/ci4/app/Controllers/Chat/ChatController.php b/ci4/app/Controllers/Chat/ChatController.php index ba44d28e..71ee0d2d 100644 --- a/ci4/app/Controllers/Chat/ChatController.php +++ b/ci4/app/Controllers/Chat/ChatController.php @@ -11,6 +11,7 @@ use App\Models\ChatNotification; use App\Models\ChatUser; use App\Models\Clientes\ClienteModel; use App\Models\Facturas\FacturaModel; +use App\Models\OrdenTrabajo\OrdenTrabajoModel; use App\Models\Pedidos\PedidoModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Usuarios\UserModel; @@ -132,6 +133,25 @@ class ChatController extends BaseController $data["chat"] = $chat; return $this->response->setJSON($data); } + public function get_chat_orden_trabajo(int $chat_department_id, int $orden_trabajo_id) + { + + $data = [ + "department" => $this->chatDeparmentModel->find($chat_department_id), + "chat" => null, + "messages" => null, + "count" => 0, + ]; + $chat = $this->chatModel->getChatOrdenTrabajo($chat_department_id, $orden_trabajo_id); + if ($chat) { + $data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id); + $this->chatMessageModel->set_chat_department_messages_as_read($chat->id); + $this->chatModel->setAsViewedChatUserNotifications($chat->id, auth()->user()->id); + $data["count"] = count($data["messages"]); + } + $data["chat"] = $chat; + return $this->response->setJSON($data); + } public function get_chat_direct_view($chat_id) { $chat = $this->chatModel->find($chat_id); @@ -295,6 +315,11 @@ class ChatController extends BaseController $data = $this->chatDeparmentModel->find($chat_department_id)->withUsers($factura_id, 'factura'); return $this->response->setJSON($data); } + public function get_chat_department_orden_trabajo_users(int $chat_department_id, $orden_trabajo_id) + { + $data = $this->chatDeparmentModel->find($chat_department_id)->withUsers($orden_trabajo_id, 'ot'); + return $this->response->setJSON($data); + } public function get_chat_users_internal() { $query = $this->userModel->builder()->select( @@ -357,6 +382,15 @@ class ChatController extends BaseController $clienteContactos = $cm->querySelectClienteContacto($f->cliente_id,$this->request->getGet('q')); return $this->response->setJSON($clienteContactos); } + public function get_orden_trabajo_client_users(int $orden_trabajo_id) + { + $otm = model(OrdenTrabajoModel::class); + $ot = $otm->find($orden_trabajo_id); + $cm = model(ClienteModel::class); + $cliente = $ot->pedido()->cliente(); + $clienteContactos = $cm->querySelectClienteContacto($cliente->id,$this->request->getGet('q')); + return $this->response->setJSON($clienteContactos); + } public function store_hebra(string $model) { $auth_user = auth()->user(); diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 5bbff500..a7a59257 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -133,7 +133,7 @@ class Ordentrabajo extends BaseController try { $bodyData = $this->request->getPost(); $r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoPedido($bodyData); - return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]); } catch (\Throwable $th) { return $this->response->setJSON(["errors" => $th->getMessage(), "status" => false])->setStatusCode(500); } @@ -163,7 +163,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado", "F"); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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", $q->fecha_encuadernado_at)->format("d/m/Y") : "" @@ -178,7 +178,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"]); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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", $q->fecha_encuadernado_at)->format("d/m/Y") : "" @@ -193,7 +193,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->where("ferro_ok_at", null); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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", $q->fecha_encuadernado_at)->format("d/m/Y") : "" @@ -208,7 +208,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL", NULL, FALSE); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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", $q->fecha_encuadernado_at)->format("d/m/Y") : "" diff --git a/ci4/app/Database/Migrations/2025-04-11-180001_AddUserIdFechaEntregaPedido copy.php b/ci4/app/Database/Migrations/2025-04-11-180001_AddUserIdFechaEntregaPedido.php similarity index 100% rename from ci4/app/Database/Migrations/2025-04-11-180001_AddUserIdFechaEntregaPedido copy.php rename to ci4/app/Database/Migrations/2025-04-11-180001_AddUserIdFechaEntregaPedido.php diff --git a/ci4/app/Database/Migrations/2025-04-14-204500_UpdateDateFieldsOrdenTrabajoDates.php b/ci4/app/Database/Migrations/2025-04-14-204500_UpdateDateFieldsOrdenTrabajoDates.php new file mode 100644 index 00000000..b6d5e06f --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-14-204500_UpdateDateFieldsOrdenTrabajoDates.php @@ -0,0 +1,101 @@ + [ + "type" => "DATE", + "null" => true, + ], + "solapa_at" => [ + "type" => "DATE", + "null" => true, + ], + "grapado_at" => [ + "type" => "DATE", + "null" => true, + ], + "retractilado_at" => [ + "type" => "DATE", + "null" => true, + ], + "retractilado5_at" => [ + "type" => "DATE", + "null" => true, + ], + "prototipo_at" => [ + "type" => "DATE", + "null" => true, + ], + "marcapaginas_at" => [ + "type" => "DATE", + "null" => true, + ], + ]; + protected array $USERS = [ + "cosido_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "solapa_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "grapado_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "retractilado_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "retractilado5_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "prototipo_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "marcapaginas_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/Database/Migrations/2025-04-14-235200_AddFkOrdenTrabajoChatDepartment.php b/ci4/app/Database/Migrations/2025-04-14-235200_AddFkOrdenTrabajoChatDepartment.php new file mode 100644 index 00000000..3c86d242 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-14-235200_AddFkOrdenTrabajoChatDepartment.php @@ -0,0 +1,40 @@ + [ + "type" => "INT", + "constraint" => 10, + "unsigned" => true, + "null" => true + ], + ]; + + + public function up() + { + $this->forge->addColumn("chats", $this->COLUMNS); + $this->forge->addColumn("chat_department_users", $this->COLUMNS); + $this->forge->addForeignKey('orden_trabajo_id', 'ordenes_trabajo', 'id'); + $this->forge->processIndexes('chats'); + $this->forge->addForeignKey('orden_trabajo_id', 'ordenes_trabajo', 'id'); + $this->forge->processIndexes('chat_department_users'); + + + + + } + + public function down() + { + $this->forge->dropColumn("chats", ["orden_trabajo_id"]); + $this->forge->dropColumn("chat_department_users", ["orden_trabajo_id"]); + + } +} diff --git a/ci4/app/Entities/Chat/ChatDepartmentEntity.php b/ci4/app/Entities/Chat/ChatDepartmentEntity.php index 5017c310..ba3a1049 100644 --- a/ci4/app/Entities/Chat/ChatDepartmentEntity.php +++ b/ci4/app/Entities/Chat/ChatDepartmentEntity.php @@ -36,7 +36,9 @@ class ChatDepartmentEntity extends Entity $chatDepartmentUsers = $m->where('chat_department_id',$this->attributes['id']) ->where('pedido_id',null) ->where('factura_id',null) - ->where('presupuesto_id',null)->findAll(); + ->where('presupuesto_id',null) + ->where('orden_trabajo_id',null) + ->findAll(); return $chatDepartmentUsers; } /** @@ -62,6 +64,9 @@ class ChatDepartmentEntity extends Entity case 'factura': $m->where('pedido_id',$modelFkId); break; + case 'ot': + $m->where('orden_trabajo_id',$modelFkId); + break; default: break; } diff --git a/ci4/app/Entities/Chat/ChatDepartmentUserEntity.php b/ci4/app/Entities/Chat/ChatDepartmentUserEntity.php index c261f568..047070f4 100644 --- a/ci4/app/Entities/Chat/ChatDepartmentUserEntity.php +++ b/ci4/app/Entities/Chat/ChatDepartmentUserEntity.php @@ -20,6 +20,7 @@ class ChatDepartmentUserEntity extends Entity "pedido_id" => null, "factura_id" => null, "presupuesto_id" => null, + "orden_trabajo_id" => null, ]; @@ -29,6 +30,7 @@ class ChatDepartmentUserEntity extends Entity "pedido_id" => "?integer", "factura_id" => "?integer", "presupuesto_id" => "?integer", + "orden_trabajo_id" => "?integer", ]; public function user() : ?UserEntity diff --git a/ci4/app/Entities/Chat/ChatEntity.php b/ci4/app/Entities/Chat/ChatEntity.php index 1669f3cd..2bae32de 100644 --- a/ci4/app/Entities/Chat/ChatEntity.php +++ b/ci4/app/Entities/Chat/ChatEntity.php @@ -5,11 +5,13 @@ namespace App\Entities\Chat; use App\Entities\Facturas\FacturaEntity; use App\Entities\Pedidos\PedidoEntity; use App\Entities\Presupuestos\PresupuestoEntity; +use App\Entities\Produccion\OrdenTrabajoEntity; use App\Entities\Usuarios\UserEntity; use App\Models\Chat\ChatDeparmentModel; use App\Models\Chat\ChatMessageModel; use App\Models\ChatUser; use App\Models\Facturas\FacturaModel; +use App\Models\OrdenTrabajo\OrdenTrabajoModel; use App\Models\Pedidos\PedidoModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Usuarios\UserModel; @@ -25,6 +27,7 @@ class ChatEntity extends Entity "pedido_id" => null, "presupuesto_id" => null, "factura_id" => null, + "orden_trabajo_id" => null, "title" => null ]; @@ -34,6 +37,7 @@ class ChatEntity extends Entity "pedido_id" => "?integer", "presupuesto_id" => "?integer", "factura_id" => "?integer", + "orden_trabajo_id" => "?integer", "title" => "string" ]; @@ -71,6 +75,11 @@ class ChatEntity extends Entity $m = model(FacturaEntity::class); return $m->find($this->attributes['factura_id']); } + public function orden_trabajo(): ?OrdenTrabajoEntity + { + $m = model(OrdenTrabajoModel::class); + return $m->find($this->attributes['orden_trabajo_id']); + } public function messages(): ?array { $m = model(ChatMessageModel::class); @@ -100,12 +109,14 @@ class ChatEntity extends Entity $models = [ "presupuesto_id" => model(PresupuestoModel::class), "pedido_id" => model(PedidoModel::class), - "factura_id" => model(FacturaModel::class) + "factura_id" => model(FacturaModel::class), + "orden_trabajo_id" => model(OrdenTrabajoModel::class), ]; $fks = [ "presupuesto_id" => $this->attributes["presupuesto_id"], "pedido_id" => $this->attributes["pedido_id"], "factura_id" => $this->attributes["factura_id"], + "orden_trabajo_id" => $this->attributes["orden_trabajo"], ]; foreach ($fks as $key => $fk) { if ($fk) { @@ -123,6 +134,7 @@ class ChatEntity extends Entity "presupuesto" => $this->attributes["presupuesto_id"], "pedido" => $this->attributes["pedido_id"], "factura" => $this->attributes["factura_id"], + "ot" => $this->attributes["orden_trabajo_id"], ]; foreach ($fks as $key => $fk) { if ($fk) { diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php index 352e3ac8..b796e380 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -21,6 +21,13 @@ class OrdenTrabajoDateEntity extends Entity "corte_at" => null, "preparacion_interiores_at" => null, "entrada_manipulado_at" => null, + "cosido_at" => null, + "solapa_at" => null, + "cosido_at" => null, + "retractilado_at"=> null, + "retractilado5_at"=> null, + "prototipo_at"=> null, + "marcapaginas_at"=> null, //FERRO "pendiente_ferro_at" => null, "ferro_en_cliente_at" => null, @@ -43,9 +50,50 @@ class OrdenTrabajoDateEntity extends Entity 'deleted_at', ]; - protected $casts = [ - ]; - - + protected $casts = []; + public function sinImprimirStatus(): bool + { + return !( + $this->attributes['interior_bn_at'] == null + && $this->attributes['interior_color_at'] == null + && $this->attributes['cubierta_at'] == null + ); + } + public function impresionInteriorStatus():bool + { + return $this->attributes['interior_bn_at']|| $this->attributes['interior_color_at']; + } + public function impresionCubiertaStatus():bool + { + return $this->attributes['cubierta_at'] != null; + } + public function plastificadoStatus():bool + { + return $this->attributes['plastificado_at'] != null; + } + public function encuadernadoStatus():bool + { + return $this->attributes['encuadernacion_at'] != null; + } + public function preparacionInterioresStatus():bool + { + return $this->attributes['preparacion_interiores_at'] != null; + } + public function corteStatus():bool + { + return $this->attributes['corte_at'] != null; + } + public function cosidoStatus():bool + { + return $this->attributes['cosido_at'] != null; + } + public function grapadoStatus():bool + { + return $this->attributes['grapado_at'] != null; + } + public function solapaStatus():bool + { + return $this->attributes['solapa_at'] != null; + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index 0728d4b9..c14bfa37 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -21,21 +21,21 @@ class OrdenTrabajoEntity extends Entity "pedido_id" => null, "user_created_id" => null, "user_updated_id" => null, - "fecha_entrega_warning" => false, - "fecha_entrega_warning_revised" => false, + "fecha_entrega_warning" => null, + "fecha_entrega_warning_revised" => null, "total_tirada" => null, "total_precio" => null, "tipo_entrada" => "out", "progreso" => 0.00, "estado" => "I", "comentarios" => null, - "revisar_formato" => false, - "revisar_lomo" => false, - "revisar_solapa" => false, - "revisar_isbn" => false, - "revisar_codigo_barras" => false, - "realizar_imposicion" => false, - "enviar_impresion" => false, + "revisar_formato" => null, + "revisar_lomo" => null, + "revisar_solapa" => null, + "revisar_isbn" => null, + "revisar_codigo_barras" => null, + "realizar_imposicion" => null, + "enviar_impresion" => null, "portada_path" => null, "is_pedido_espera" => null, "pedido_espera_by" => null, diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php index 4f516ecd..57356b8b 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php @@ -25,6 +25,13 @@ class OrdenTrabajoUserEntity extends Entity "corte_user_id" => null, "preparacion_interior_user_id" => null, "entrada_manipulado_user_id" => null, + "cosido_user_id" => null, + "solapa_user_id" => null, + "grapado_user_id" => null, + "retractilado_user_id" => null, + "retractilado5_user_id" => null, + "prototipo_user_id" => null, + "marcapaginas_user_id" => null, //FERRO "pendiente_ferro_user_id" => null, "ferro_en_cliente_user_id" => null, @@ -39,9 +46,9 @@ class OrdenTrabajoUserEntity extends Entity "pre_codbarras_user_id" => null, "pre_imposicion_user_id" => null, //UNUSED - "inaplazable_revised_change_user_id" => null,//!DELETE - "ferro_disponible_hecho_user_id" => null,//!DELETE - "ferro_entregado_user_id" => null,//!DELETE + "inaplazable_revised_change_user_id" => null, //!DELETE + "ferro_disponible_hecho_user_id" => null, //!DELETE + "ferro_entregado_user_id" => null, //!DELETE "pre_imprimir_user_id" => null, //!DELETE "ferro_disponible_ok_user_id" => null, //!DELETE ]; @@ -85,7 +92,7 @@ class OrdenTrabajoUserEntity extends Entity } return $user; } - public function getPlastificadoBy() : ?UserEntity + public function getPlastificadoBy(): ?UserEntity { return $this->userBy('plastificado_user_id'); } diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index c8cb238b..e5b622b0 100644 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -87,6 +87,14 @@ return [ "ejemplares" => "Ejemplares", "tipo" => "Tipo", "lomo" => "Lomo", + + "cosido" => "Cosido", + "grapado" => "Grapado", + "solapa" => "Solapas", + "retractilado" => "Retractilado", + "retractilado5" => "Retractilado 5", + "prototipo" => "Prototipo", + "marcapaginas" => "Marcapáginas", //IMPRESION "impresion_bn" => "Impresión BN", "cubierta" => "Cubierta/Portada", @@ -96,6 +104,7 @@ return [ "pre_solapa" => "Revisión solapa", "pre_codbarras" => "Revisión código barras", "pre_imposicion" => "Revisión imposición", + "errors" => [ diff --git a/ci4/app/Models/Chat/ChatDeparmentModel.php b/ci4/app/Models/Chat/ChatDeparmentModel.php index c5d81c87..efe215b8 100644 --- a/ci4/app/Models/Chat/ChatDeparmentModel.php +++ b/ci4/app/Models/Chat/ChatDeparmentModel.php @@ -136,6 +136,7 @@ class ChatDeparmentModel extends Model ->where('chat_department_users.presupuesto_id',null) ->where('chat_department_users.pedido_id',null) ->where('chat_department_users.factura_id',null) + ->where('chat_department_users.orden_trabajo_id',null) ->get(); return $result->getResultObject() ?: []; @@ -161,6 +162,13 @@ class ChatDeparmentModel extends Model ->get()->getResultObject(); return $result; } + public function getChatDeparmentOrdenTrabajoUsers(int $chat_deparment_id, int $orden_trabajo_id) + { + $result = $this->getChatDeparmentUserQuery($chat_deparment_id) + ->where('chat_department_users.orden_trabajo_id', $orden_trabajo_id) + ->get()->getResultObject(); + return $result; + } public function getDisplay(int $chat_deparment_id): string { return $this->find($chat_deparment_id)->display; diff --git a/ci4/app/Models/Chat/ChatDeparmentUserModel.php b/ci4/app/Models/Chat/ChatDeparmentUserModel.php index 1afdca85..b311e11e 100644 --- a/ci4/app/Models/Chat/ChatDeparmentUserModel.php +++ b/ci4/app/Models/Chat/ChatDeparmentUserModel.php @@ -19,7 +19,9 @@ class ChatDeparmentUserModel extends Model "user_id", "pedido_id", "factura_id", - "presupuesto_id" + "presupuesto_id", + "orden_trabajo_id", + ]; protected bool $allowEmptyInserts = false; diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index 88bbad19..5ac10631 100644 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -6,11 +6,13 @@ use App\Entities\Chat\ChatEntity; use App\Models\ChatNotification; use App\Models\ChatUser; use App\Models\Facturas\FacturaModel; +use App\Models\OrdenTrabajo\OrdenTrabajoModel; use App\Models\Pedidos\PedidoModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Usuarios\UserModel; use CodeIgniter\Model; use CodeIgniter\Database\BaseBuilder; +use Config\OrdenTrabajo; class ChatModel extends Model { @@ -25,6 +27,7 @@ class ChatModel extends Model "chat_department_id", "presupuesto_id", "factura_id", + "orden_trabajo_id", "title" ]; @@ -86,6 +89,10 @@ class ChatModel extends Model { return $this->builder()->where("factura_id", $factura_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow(); } + public function getChatOrdenTrabajo(int $chat_department_id, int $orden_trabajo_id) + { + return $this->builder()->where("orden_trabajo_id", $orden_trabajo_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow(); + } public function createChatPresupuesto(int $chat_department_id, int $presupuesto_id): int { @@ -123,6 +130,17 @@ class ChatModel extends Model "chat_department_id" => $chat_department_id ]); } + public function createChatOrdenTrabajo(int $chat_department_id, int $orden_trabajo_id): int + { + $model = model(OrdenTrabajoModel::class); + $chatDeparmentModel = model(ChatDeparmentModel::class); + $ot = $model->find($orden_trabajo_id); + return $this->insert([ + "title" => "[OT]".$ot->id . "[" . $chatDeparmentModel->getDisplay($chat_department_id) . "]", + "orden_trabajo_id" => $orden_trabajo_id, + "chat_department_id" => $chat_department_id + ]); + } public function createChatSingle(): int { return $this->insert(["chat_department_id" => null]); @@ -323,6 +341,7 @@ class ChatModel extends Model "chats.pedido_id as pedidoId", "chats.presupuesto_id as presupuestoId", "chats.factura_id as facturaId", + "chats.orden_trabajo_id as ordenTrabajoId", "chats.title as chatDisplay", "COUNT(chat_notifications.id) as unreadMessages" ]) @@ -363,6 +382,13 @@ class ChatModel extends Model $row->title = $row->facturaId; $rows_new[] = $row; } + elseif ($row->ordenTrabajoId) { + // $row->model = $facturaModel->find($row->facturaId); + $row->uri = "/chat/ot/" . $row->ordenTrabajoId . "#accordionChatOrdenTrabajo"; + $row->avatar = "OT"; + $row->title = $row->ordenTrabajoId; + $rows_new[] = $row; + } } return $rows_new; } @@ -374,6 +400,7 @@ class ChatModel extends Model "chats.chat_department_id as chatDepartmentId", "chats.pedido_id as pedidoId", "chats.presupuesto_id as presupuestoId", + "chats.orden_trabajo_id as ordenTrabajoId", "chats.factura_id as facturaId", "chats.title as chatDisplay", "COUNT(chat_messages.id) as unreadMessages" @@ -413,6 +440,13 @@ class ChatModel extends Model $row->title = $row->facturaId; $rows_new[] = $row; } + elseif ($row->ordenTrabajoId) { + $row->uri = "/produccion/ordentrabajo/edit/" . $row->ordenTrabajoId . "#accordionChatOrdenTrabajo"; + $row->avatar = "OT"; + $row->chatDisplay .= "[INTERNAL]"; + $row->title = $row->ordenTrabajoId; + $rows_new[] = $row; + } } return $rows_new; } @@ -433,6 +467,7 @@ class ChatModel extends Model ->where("chats.chat_department_id", null) ->where("chats.pedido_id", null) ->where("chats.factura_id", null) + ->where("chats.orden_trabajo_id", null) ->where("chat_notifications.viewed", false) ->where("chat_notifications.user_id", auth()->user()->id); $rows = $q->get()->getResultObject(); @@ -513,6 +548,27 @@ class ChatModel extends Model $data["users"] = $this->getChatUsers($chat_id); return $data; } + public function getChatInternalHebraOrdenTrabajo($chat_id, $orden_trabajo_id) + { + $data = []; + $query = $this->builder()->select([ + "chats.id as chatId", + "chat_messages.message", + "users.username as senderUserName", + "chat_messages.created_at", + "CONCAT(users.first_name,' ',users.last_name) as senderFullName", + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("users", "users.id = chat_messages.sender_id", "left") + ->where("chats.id", $chat_id) + ->where("chats.orden_trabajo_id", $orden_trabajo_id); + $data["chatId"] = $chat_id; + $data["messages"] = $query->get()->getResultObject(); + $data["chatTitle"] = "OT" . "[" . $orden_trabajo_id . "] - "; + $data["chatTitle"] .= $this->find($chat_id)->title; + $data["users"] = $this->getChatUsers($chat_id); + return $data; + } public function getChatUsers(int $chat_id) { $query = $this->builder()->select([ @@ -557,6 +613,17 @@ class ChatModel extends Model } return $data; } + public function getOrdenTrabajoHebras($orden_trabajo_id): array + { + $data = []; + $chats = $this->builder()->select("chats.id as chatId") + ->where("chats.chat_department_id", null) + ->where("chats.orden_trabajo_id", $orden_trabajo_id)->get()->getResultObject(); + foreach ($chats as $chat) { + $data[$chat->chatId] = $this->getChatInternalHebraOrdenTrabajo($chat->chatId, $orden_trabajo_id); + } + return $data; + } public function countUnreadMessagePresupuesto(int $presupuesto_id): int|string { return $this->builder()->select() @@ -586,6 +653,15 @@ class ChatModel extends Model ->where("chat_notifications.viewed", false) ->where("chat_notifications.user_id", auth()->user()->id)->countAllResults(); } + public function countUnreadMessageOrdenTrabajo($orden_trabajo_id): int|string + { + return $this->builder()->select() + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.orden_trabajo_id", $orden_trabajo_id) + ->where("chat_notifications.viewed", false) + ->where("chat_notifications.user_id", auth()->user()->id)->countAllResults(); + } public function countUnreadMessageDirectos(int $chat_id): int|string { return $this->builder()->select() @@ -606,6 +682,7 @@ class ChatModel extends Model ->where("chats.presupuesto_id", null) ->where("chats.pedido_id", null) ->where("chats.factura_id", null) + ->where("chats.orden_trabajo_id", null) ->where("chats.id", $chat_id) ->where("chat_messages.receiver_id", auth()->user()->id)->get()->getFirstRow(); $userModel = model(UserModel::class); @@ -837,6 +914,36 @@ class ChatModel extends Model } return $query->groupBy('chatMessageId'); } + public function getQueryDatatableMessageOrdenTrabajo(int $user_id): BaseBuilder + { + $query = $this->builder() + ->select([ + "chats.id", + "cm.id as chatMessageId", + "u.id as userId", + "cm.message", + "chats.created_at", + " + ( + SELECT cm2.updated_at + FROM chat_messages cm2 + WHERE cm2.chat_id = chats.id + ORDER BY cm2.updated_at DESC LIMIT 1 + ) as updated_at", + "CONCAT(u.first_name,' ',u.last_name) as creator", + "chats.title", + ]) + ->join("chat_messages cm", "chats.id = cm.chat_id", "left") + ->join("users u", "u.id = cm.sender_id", 'left') + ->join("ordenes_trabajo", "ordenes_trabajo.id = chats.orden_trabajo_id", "left") + ->where("chats.orden_trabajo_id is NOT NULL", NULL, FALSE); + + if (auth()->user()->inGroup("cliente-administrador","cliente")) { + $query->where('facturas.cliente_id', auth()->user()->cliente_id) + ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); + } + return $query->groupBy('chatMessageId'); + } public function createNewDirectChat(string $title, string $message, array $users) { $chatMessageModel = model(ChatMessageModel::class); diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index 83f62c54..1d82ec12 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -28,6 +28,13 @@ class OrdenTrabajoDate extends Model "corte_at", "preparacion_interiores_at", "entrada_manipulado_at", + "cosido_at", + "solapa_at", + "cosido_at", + "retractilado_at", + "retractilado5_at", + "prototipo_at", + "marcapaginas_at", //FERRO "pendiente_ferro_at", "ferro_en_cliente_at", diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php index 3bc18711..df4d0541 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php @@ -29,6 +29,13 @@ class OrdenTrabajoUser extends Model "corte_user_id", "preparacion_interior_user_id", "entrada_manipulado_user_id", + "cosido_user_id", + "solapa_user_id", + "grapado_user_id", + "retractilado_user_id", + "retractilado5_user_id", + "prototipo_user_id", + "marcapaginas_user_id", //FERRO "pendiente_ferro_user_id", "ferro_en_cliente_user_id", diff --git a/ci4/app/Services/ChatService.php b/ci4/app/Services/ChatService.php index 9b0a002d..cf651ef6 100644 --- a/ci4/app/Services/ChatService.php +++ b/ci4/app/Services/ChatService.php @@ -40,6 +40,7 @@ class ChatService extends BaseService "presupuesto" => "presupuesto_id", "pedido" => "pedido_id", "factura" => "factura_id", + "ot" => "orden_trabajo_id" ]; protected array $modelClassMap; public function __construct() @@ -122,6 +123,9 @@ class ChatService extends BaseService case 'factura': $r = $this->chatModel->createChatFactura($chatDepartmentId, $modelId); break; + case 'ot': + $r = $this->chatModel->createChatOrdenTrabajo($chatDepartmentId, $modelId); + break; default: break; } diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index ade89a42..c073dc38 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -50,6 +50,7 @@ class ProductionService extends BaseService protected MaquinaEntity $defaultMaquinaCorte; protected MaquinaModel $maquinaModel; protected OrdenTrabajo $ordenTrabajoConfig; + public string $statusColor; /** * Pedido Entity @@ -74,6 +75,7 @@ class ProductionService extends BaseService $this->otFileModel = model(OrdenTrabajoFileModel::class); $this->pedidoModel = model(PedidoModel::class); $this->ordenTrabajoConfig = config('OrdenTrabajo'); + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; } public function init(int $orden_trabajo_id): self { @@ -83,6 +85,7 @@ class ProductionService extends BaseService $pedido = $this->ot->pedido(); $this->setPedido($pedido); $this->defaultMaquinaCorte = $this->maquinaModel->where('nombre', $this->defaultMaquinaCorteName)->first(); + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; return $this; } /** @@ -631,6 +634,7 @@ class ProductionService extends BaseService "tareas_preimpresion" => $this->tareas_preimpresion(), "tareas_impresion" => $this->tareas_impresion(), "tiempo_procesamiento" => $this->getTiempoProcesamientoHHMM(), + "statusColor" => $this->getOtColorStatus(), ]; return $summary; } @@ -1107,10 +1111,89 @@ class ProductionService extends BaseService } $progreso = (float) $fill_dates / $total * 100; - $status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso,2)]); - }else{ + $status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso, 2)]); + } else { $status = $this->otModel->update($this->ot->id, ["progreso" => 100]); } return $status; } + public function getOtColorStatus(): string + { + if($this->ot->dates()){ + $this->updateColor(); + } + return $this->statusColor; + } + protected function otSinImprimirColor() + { + if ($this->ot->dates()->sinImprimirStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; + }; + } + protected function otImpresionIntColor() + { + if ($this->ot->dates()->impresionInteriorStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["impreso_int"]; + }; + } + protected function otImpresionCubiertaColor() + { + if ($this->ot->dates()->impresionCubiertaStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["impreso_cub"]; + }; + } + protected function otPlastificadoColor() + { + if ($this->ot->dates()->plastificadoStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["plastificado"]; + }; + } + protected function otSolapaColor() + { + if ($this->ot->dates()->solapaStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["solapa"]; + }; + } + protected function otEncuadernadoColor() + { + if ($this->ot->dates()->encuadernadoStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["encuadernado"]; + }; + } + protected function otPreparadoColor() + { + if ($this->ot->dates()->preparacionInterioresStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["preparado"]; + }; + } + protected function otCorteColor() + { + if ($this->ot->dates()->corteStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["corte"]; + }; + } + protected function otCosidoColor() + { + if ($this->ot->dates()->cosidoStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["cosido"]; + }; + } + protected function otGrapadoColor() + { + if ($this->ot->dates()->grapadoStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["grapado"]; + }; + } + protected function updateColor(){ + $this->otSinImprimirColor(); + $this->otImpresionIntColor(); + $this->otCosidoColor(); + $this->otImpresionCubiertaColor(); + $this->otPlastificadoColor(); + $this->otSolapaColor(); + $this->otPreparadoColor(); + $this->otGrapadoColor(); + $this->otEncuadernadoColor(); + $this->otCorteColor(); + } } diff --git a/ci4/app/Views/themes/vuexy/components/chat_internal_orden_trabajo.php b/ci4/app/Views/themes/vuexy/components/chat_internal_orden_trabajo.php new file mode 100644 index 00000000..5fd73e23 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/chat_internal_orden_trabajo.php @@ -0,0 +1,41 @@ +
+
+

+ +

+
+
+ +
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/chat_orden_trabajo.php b/ci4/app/Views/themes/vuexy/components/chat_orden_trabajo.php new file mode 100644 index 00000000..546e488c --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/chat_orden_trabajo.php @@ -0,0 +1,156 @@ +
+ +
+
+ +
+ +
+ +
+ + + +
+
+
+
+
+ +
+ P +
+
+
+ +
+ +
+ +
+ user()->inGroup('cliente-administrador','cliente')): ?> + +
+ +
+
+ +
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
    + +
+
+ + +
+
+ + +
+
+
+
+ +section('css') ?> + + +endSection() ?> + + + +section("additionalExternalJs") ?> + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/tables/ot_table.php b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php index a611a1c4..21388a84 100644 --- a/ci4/app/Views/themes/vuexy/components/tables/ot_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php @@ -1,6 +1,6 @@
- +
diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php index bc0093b6..01d0782b 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php @@ -2,7 +2,7 @@
Revisión
-
- - -
- - -
-
- -
- - -
-
- -
- - -
- -
- -
- - -
- -
- -
- - -
- -
-
-
+
-
+
-
+
- -
- - -
-
-
+
+ +
"> + + +
+
+ +
+ + +
+
+ +
"> + + +
+
+ +
"> + + +
+
+ +
"> + + +
+
+ +
"> + + +
+
+ + +
"> + + +
+
-
+
@@ -115,43 +116,78 @@
-
+
"> -
+
-
+
"> -
- +
-
+
"> -
+
-
+
-
+
+
+ + +
"> + + +
+
+ +
"> + + +
+
+ +
"> + + +
+ +
+ +
"> + + +
+ +
+ +
"> + + +
+ +
+
diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php index 40eb9437..94dbbd9f 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php @@ -3,7 +3,7 @@

-

@@ -62,10 +59,6 @@
- -
diff --git a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php index 9a262c65..c44f29dc 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php @@ -9,7 +9,7 @@
- +
@@ -26,6 +26,10 @@
+
+ $modelId, "type" => "orden_trabajo"]) ?> +
+
@@ -35,19 +39,19 @@
-
-
-
- "> - - - - +
+
+
+ "> + + + + +
-