From 6433faec023924933a0dbd84a2784fdd0f8dfd4c Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sat, 4 Jan 2025 12:52:26 +0100 Subject: [PATCH 1/5] fix select tarifa maquina encuadernado --- ci4/app/Config/Routes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 6ee2a32e..908e1388 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -55,10 +55,12 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ( $routes->get('acabado/select', 'TarifaMaquinas::get_select_maquina_acabado'); $routes->get('manipulado/select', 'TarifaMaquinas::get_select_maquina_manipulado'); $routes->get('impresion/select', 'TarifaMaquinas::get_select_maquina_impresion'); + $routes->get('encuadernacion/select', 'TarifaMaquinas::get_select_maquina_manipulado'); $routes->get('tareas/select', 'TarifaMaquinas::get_select_maquina_tareas'); + $routes->get('acabado/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_acabado_maquina/$1'); $routes->get('manipulado/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_manipulado_maquina/$1'); $routes->get('preimpresion/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_preimpresion_maquina/$1'); From dac82253a27c1085f7ac47f2d06f54469c17d27f Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sat, 4 Jan 2025 17:36:58 +0100 Subject: [PATCH 2/5] fix uri messages --- ci4/app/Models/Chat/ChatModel.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index 78628011..caa560ee 100644 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -239,7 +239,7 @@ class ChatModel extends Model $count++; } } - $row->uri = "/pedidos/edit/" . $row->pedidoId; + $row->uri = "/chat/pedido/" . $row->chatId; $row->unreadMessages = $count; } return $results; @@ -273,7 +273,7 @@ class ChatModel extends Model $count++; } } - $row->uri = "/facturas/edit/" . $row->facturaId; + $row->uri = "/chat/factura/" . $row->chatId; $row->unreadMessages = $count; } return $results; @@ -307,7 +307,7 @@ class ChatModel extends Model $count++; } } - $row->uri = "/presupuestos/presupuestocliente/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; $row->unreadMessages = $count; } @@ -334,7 +334,6 @@ class ChatModel extends Model ->join("chat_department_users", "chat_department_users.chat_department_id = chats.chat_department_id", "left") ->where("chat_department_users.user_id", auth()->user()->id); $rows = $q->get()->getResultObject(); - $auth_user = auth()->user(); foreach ($rows as $row) { $messages = $chatMessageModel->get_chat_messages($row->chatId); @@ -348,9 +347,9 @@ class ChatModel extends Model if ($row->presupuestoId) { $row->model = $presupuestoModel->find($row->presupuestoId); if($auth_user->cliente_id){ - $row->uri = "/presupuestocliente/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; }else{ - $row->uri = "/presupuestoadmin/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; } $row->title = $row->presupuestoId; @@ -358,13 +357,13 @@ class ChatModel extends Model $row->unreadMessages = $count; } elseif ($row->pedidoId) { $row->model = $pedidoModel->find($row->pedidoId); - $row->uri = "/pedidos/edit/" . $row->pedidoId; + $row->uri = "/chat/pedido/" . $row->chatId; $row->title = $row->pedidoId; $row->avatar = "P"; $row->unreadMessages = $count; } elseif ($row->facturaId) { $row->model = $facturaModel->find($row->facturaId); - $row->uri = "/facturas/edit/" . $row->facturaId; + $row->uri = "/chat/factura/" . $row->chatId; $row->avatar = "F"; $row->title = $row->facturaId; $row->unreadMessages = $count; @@ -392,7 +391,8 @@ class ChatModel extends Model ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") ->where("chat_notifications.user_id", auth()->user()->id) - ->where("chat_notifications.viewed", false); + ->where("chat_notifications.viewed", false) + ->where("chats.chat_department_id",null); $auth_user = auth()->user(); $rows = $q->get()->getResultObject(); $rows_new = []; From b076db3a7c4c5cca256505028784ea4aff71ba70 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sun, 5 Jan 2025 10:29:07 +0100 Subject: [PATCH 3/5] fix uri chat notifications --- ci4/app/Models/Chat/ChatModel.php | 60 +++++++++++-------- httpdocs/assets/js/safekat/components/chat.js | 12 +++- .../assets/js/safekat/pages/chatFactura.js | 15 +++-- .../assets/js/safekat/pages/chatPedido.js | 15 +++-- .../js/safekat/pages/chatPresupuesto.js | 13 ++-- 5 files changed, 72 insertions(+), 43 deletions(-) diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index caa560ee..0b14e266 100644 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -321,65 +321,73 @@ class ChatModel extends Model $facturaModel = model(FacturaModel::class); $pedidoModel = model(PedidoModel::class); - $q = $this->db->table("chats") + $q = $this->builder() ->select([ "chats.id as chatId", + "chats.chat_department_id as chatDepartmentId", "chats.pedido_id as pedidoId", "chats.presupuesto_id as presupuestoId", "chats.factura_id as facturaId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", + "chats.title as chatDisplay", ]) - ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") - ->join("chat_department_users", "chat_department_users.chat_department_id = chats.chat_department_id", "left") - ->where("chat_department_users.user_id", auth()->user()->id); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chat_notifications.user_id", auth()->user()->id) + ->where("chat_notifications.viewed", false) + ->where("chats.chat_department_id is NOT NULL",NULL,FALSE); + $rows = $q->get()->getResultObject(); $auth_user = auth()->user(); + $rows_new = []; foreach ($rows as $row) { - $messages = $chatMessageModel->get_chat_messages($row->chatId); - $count = 0; - $chatDeparmentUsers = $chatDeparmentModel->getChatDepartmentUsers($row->chatDepartmentId); - $chatDeparmentUsersId = array_map(fn($x) => $x->id, $chatDeparmentUsers); - foreach ($messages as $m) { - if ($m->viewed == false && $m->sender_id != auth()->user()->id && in_array($m->sender_id, $chatDeparmentUsersId) == false) - $count++; - } + $row->unreadMessages = 0; if ($row->presupuestoId) { $row->model = $presupuestoModel->find($row->presupuestoId); if($auth_user->cliente_id){ $row->uri = "/chat/presupuesto/" . $row->chatId; }else{ $row->uri = "/chat/presupuesto/" . $row->chatId; - } $row->title = $row->presupuestoId; + if($row->chatDepartmentId){ + $row->chatDisplay = $row->model->titulo; + }else{ + $row->chatDisplay .="[INTERNAL]"; + } $row->avatar = "PRE"; - $row->unreadMessages = $count; + $row->unreadMessages = $this->countUnreadMessagePresupuesto($row->presupuestoId); + $rows_new[] = $row; } elseif ($row->pedidoId) { $row->model = $pedidoModel->find($row->pedidoId); $row->uri = "/chat/pedido/" . $row->chatId; $row->title = $row->pedidoId; + if($row->chatDepartmentId){ + $row->chatDisplay .= "[INTERNAL]"; + } $row->avatar = "P"; - $row->unreadMessages = $count; + $row->unreadMessages = $this->countUnreadMessagePedido($row->pedidoId); + $rows_new[] = $row; } elseif ($row->facturaId) { $row->model = $facturaModel->find($row->facturaId); $row->uri = "/chat/factura/" . $row->chatId; $row->avatar = "F"; + if($row->chatDepartmentId){ + $row->chatDisplay .= "[INTERNAL]"; + } $row->title = $row->facturaId; - $row->unreadMessages = $count; + $row->unreadMessages = $this->countUnreadMessageFactura($row->facturaId); + $rows_new[] = $row; } } - return $rows; + return $rows_new; } public function getChatInternalNotifications() { - $chatMessageModel = model(ChatMessageModel::class); $presupuestoModel = model(PresupuestoModel::class); $facturaModel = model(FacturaModel::class); $pedidoModel = model(PedidoModel::class); - $chatNotificationModel = model(ChatNotification::class); - $q = $this->db->table("chats") + $q = $this->builder() ->select([ "chats.id as chatId", "chats.chat_department_id as chatDepartmentId", @@ -401,9 +409,9 @@ class ChatModel extends Model if ($row->presupuestoId) { $row->model = $presupuestoModel->find($row->presupuestoId); if($auth_user->cliente_id){ - $row->uri = "/presupuestocliente/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; }else{ - $row->uri = "/presupuestoadmin/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; } $row->title = $row->presupuestoId; if($row->chatDepartmentId){ @@ -416,7 +424,7 @@ class ChatModel extends Model $rows_new[] = $row; } elseif ($row->pedidoId) { $row->model = $pedidoModel->find($row->pedidoId); - $row->uri = "/pedidos/edit/" . $row->pedidoId; + $row->uri = "/chat/pedido/" . $row->chatId; $row->title = $row->pedidoId; if($row->chatDepartmentId){ $row->chatDisplay .= "[INTERNAL]"; @@ -426,7 +434,7 @@ class ChatModel extends Model $rows_new[] = $row; } elseif ($row->facturaId) { $row->model = $facturaModel->find($row->facturaId); - $row->uri = "/facturas/edit/" . $row->facturaId; + $row->uri = "/chat/factura/" . $row->chatId; $row->avatar = "F"; if($row->chatDepartmentId){ $row->chatDisplay .= "[INTERNAL]"; diff --git a/httpdocs/assets/js/safekat/components/chat.js b/httpdocs/assets/js/safekat/components/chat.js index 8d0e7f06..e572b1fc 100644 --- a/httpdocs/assets/js/safekat/components/chat.js +++ b/httpdocs/assets/js/safekat/components/chat.js @@ -14,7 +14,7 @@ class Chat { this.sendBtnMessageDepartment = this.domItem.find("#send-msg-btn-deparment") this.sendBtnMessageInternal = this.domItem.find("#send-msg-btn-internal") this.chatSidebarLeftUserAbout = this.domItem.find('.chat-sidebar-left-user-about'), - this.messageInput = this.domItem.find(".message-input") + this.messageInput = this.domItem.find(".message-input") this.sideBar = this.domItem.find(".sidebar-body") this.chatDeparmentId = undefined this.searchInput = this.domItem.find(".chat-search-input") @@ -78,6 +78,8 @@ class Chat { this.btnUpdateMessagesUnviewed = this.domItem.find("#update-message-unviewed") this.btnDirectMessageSubmit = this.domItem.find("#send-msg-btn-direct") this.btnDirectMessageSubmit.on("click", this._handleStoreChatDirectMessage.bind(this)) + this.messageInput.on("keypress", this._sendDirectMessagePressKey.bind(this)) + this.selectParticipants = new ClassSelect(this.modalNewParticipant.item.find("#select-users"), `/chat/direct/users/select/${this.modelId}`, this.selectPlaceholder, true) this.authUserId = this.domItem.data("user-id") this.checkboxNotificationMessage = this.modalNewParticipant.item.find("#checkbox-notification-chat") @@ -157,6 +159,7 @@ class Chat { this.sendBtnMessageDepartment.removeClass("d-none") this.sendBtnMessageInternal.addClass("d-none") } + /**============================================ * PRESUPUESTOS *=============================================**/ @@ -380,6 +383,13 @@ class Chat { this._sendMessage() } + } + _sendDirectMessagePressKey(e) { + if (e.which == 13) { + e.preventDefault(); + this._handleStoreChatDirectMessage() + } + } _sendMessage() { diff --git a/httpdocs/assets/js/safekat/pages/chatFactura.js b/httpdocs/assets/js/safekat/pages/chatFactura.js index f05ead5a..8465e69b 100644 --- a/httpdocs/assets/js/safekat/pages/chatFactura.js +++ b/httpdocs/assets/js/safekat/pages/chatFactura.js @@ -2,7 +2,7 @@ import Chat from '../components/chat.js' import InternalMessages from "../components/internalMessagesSection.js" import ModalDirectMessageClient from '../components/modals/modalDirectMessageClient.js' -$(document).ready(() => { +$(() => { let chat = new Chat($("#chat-factura")) chat.init() chat.initFactura() @@ -10,9 +10,12 @@ $(document).ready(() => { let internalMessages = new InternalMessages($("#internal_messages_chat")) internalMessages.init() } - let modalDirectMessageClient = new ModalDirectMessageClient("factura", $("#modalNewDirectMessageClient")) - modalDirectMessageClient.init() - $("#direct-message-cliente").on("click",() => { - modalDirectMessageClient.modal.show() - }) + if ($("#modalNewDirectMessageClient").length > 0) { + + let modalDirectMessageClient = new ModalDirectMessageClient("presupuesto", $("#modalNewDirectMessageClient")) + modalDirectMessageClient.init() + $("#direct-message-cliente").on("click", () => { + modalDirectMessageClient.modal.show() + }) + } }) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/chatPedido.js b/httpdocs/assets/js/safekat/pages/chatPedido.js index 2115a246..f6592a32 100644 --- a/httpdocs/assets/js/safekat/pages/chatPedido.js +++ b/httpdocs/assets/js/safekat/pages/chatPedido.js @@ -2,7 +2,7 @@ import Chat from '../components/chat.js' import InternalMessages from "../components/internalMessagesSection.js" import ModalDirectMessageClient from '../components/modals/modalDirectMessageClient.js' -$(document).ready(() => { +$(() => { let chat = new Chat($("#chat-pedido")) chat.init() chat.initPedido() @@ -10,10 +10,13 @@ $(document).ready(() => { let internalMessages = new InternalMessages($("#internal_messages_chat")) internalMessages.init() } - let modalDirectMessageClient = new ModalDirectMessageClient("pedido", $("#modalNewDirectMessageClient")) - modalDirectMessageClient.init() - $("#direct-message-cliente").on("click",() => { - modalDirectMessageClient.modal.show() - }) + if ($("#modalNewDirectMessageClient").length > 0) { + + let modalDirectMessageClient = new ModalDirectMessageClient("presupuesto", $("#modalNewDirectMessageClient")) + modalDirectMessageClient.init() + $("#direct-message-cliente").on("click", () => { + modalDirectMessageClient.modal.show() + }) + } }) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/chatPresupuesto.js b/httpdocs/assets/js/safekat/pages/chatPresupuesto.js index 1f306f0c..ef2090df 100644 --- a/httpdocs/assets/js/safekat/pages/chatPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/chatPresupuesto.js @@ -5,14 +5,19 @@ $(function () { let chat = new Chat($("#chat-presupuesto")) chat.init() chat.initPresupuesto() - if ($("#internal_messages_chat").length > 0) { - let internalMessages = new InternalMessages($("#internal_messages_chat")) - internalMessages.init() + if ($("#modalNewDirectMessageClient").length > 0) { + let modalDirectMessageClient = new ModalDirectMessageClient("presupuesto", $("#modalNewDirectMessageClient")) modalDirectMessageClient.init() - $("#direct-message-cliente").on("click",() => { + $("#direct-message-cliente").on("click", () => { modalDirectMessageClient.modal.show() }) } + if ($("#internal_messages_chat").length > 0) { + let internalMessages = new InternalMessages($("#internal_messages_chat")) + internalMessages.init() + + + } }) \ No newline at end of file From 50b057d4e525150b78c4b6db3a7b4ab695bf712a Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sun, 5 Jan 2025 10:37:37 +0100 Subject: [PATCH 4/5] fix/nav-link-message-accordion --- .../themes/vuexy/components/chat_internal_presupuesto.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php b/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php index d8509da1..8e399ead 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php +++ b/ci4/app/Views/themes/vuexy/components/chat_internal_presupuesto.php @@ -13,20 +13,20 @@