mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat : mensajes internos module
This commit is contained in:
@ -761,6 +761,18 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route
|
||||
$routes->get('contacts/(:num)', 'ChatController::get_chat_internal_contact/$1', ['as' => 'getChatInternalContact']);
|
||||
$routes->get('contact/(:num)/messages', 'ChatController::get_chat_internal_messages/$1', ['as' => 'getChatInternalMessages']);
|
||||
$routes->get('notifications', 'ChatController::get_chat_cliente/$1', ['as' => 'getChatCliente']);
|
||||
$routes->get('users/internal', 'ChatController::get_chat_users_internal', ['as' => 'getChatUsersInternal']);
|
||||
$routes->post('hebra/presupuesto', 'ChatController::store_hebra_presupuesto', ['as' => 'storeHebraPresupuesto']);
|
||||
$routes->post('hebra/pedido', 'ChatController::store_hebra_pedido', ['as' => 'storeHebraPedido']);
|
||||
$routes->post('hebra/factura', 'ChatController::store_hebra_factura', ['as' => 'storeHebraFactura']);
|
||||
$routes->post('hebra/(:num)', 'ChatController::update_hebra/$1', ['as' => 'updateHebra']);
|
||||
$routes->get('hebra/presupuesto/(:num)',"ChatController::get_hebra_presupuesto/$1",["as" => "getHebraPresupuesto"]);
|
||||
$routes->get('hebra/pedido/(:num)',"ChatController::get_hebra_pedido/$1",["as" => "getHebraPedido"]);
|
||||
$routes->get('hebra/factura/(:num)',"ChatController::get_hebra_factura/$1",["as" => "getHebraFactura"]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -7,6 +7,8 @@ use App\Models\Chat\ChatDeparmentModel;
|
||||
use App\Models\Chat\ChatDeparmentUserModel;
|
||||
use App\Models\Chat\ChatMessageModel;
|
||||
use App\Models\Chat\ChatModel;
|
||||
use App\Models\ChatNotification;
|
||||
use App\Models\ChatUser;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -22,6 +24,8 @@ class ChatController extends BaseController
|
||||
protected ChatMessageModel $chatMessageModel;
|
||||
protected UserModel $userModel;
|
||||
protected ClienteModel $clienteModel;
|
||||
protected ChatUser $chatUserModel;
|
||||
protected ChatNotification $chatNotificationModel;
|
||||
|
||||
|
||||
|
||||
@ -40,6 +44,9 @@ class ChatController extends BaseController
|
||||
$this->chatMessageModel = model(ChatMessageModel::class);
|
||||
$this->userModel = model(UserModel::class);
|
||||
$this->clienteModel = model(ClienteModel::class);
|
||||
$this->chatUserModel = model(ChatUser::class);
|
||||
$this->chatNotificationModel = model(ChatNotification::class);
|
||||
|
||||
|
||||
}
|
||||
public function index() {}
|
||||
@ -55,11 +62,13 @@ class ChatController extends BaseController
|
||||
$data = [
|
||||
"chat" => null,
|
||||
"messages" => null,
|
||||
"count" => 0,
|
||||
];
|
||||
$chat = $this->chatModel->getChatPresupuesto($chat_department_id, $presupuesto_id);
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
return $this->response->setJSON($data);
|
||||
@ -70,11 +79,13 @@ class ChatController extends BaseController
|
||||
$data = [
|
||||
"chat" => null,
|
||||
"messages" => null,
|
||||
"count" => 0,
|
||||
];
|
||||
$chat = $this->chatModel->getChatPedido($chat_department_id, $pedido_id);
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
@ -86,12 +97,13 @@ class ChatController extends BaseController
|
||||
$data = [
|
||||
"chat" => null,
|
||||
"messages" => null,
|
||||
"count" => 0,
|
||||
];
|
||||
$chat = $this->chatModel->getChatFactura($chat_department_id, $factura_id);
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
return $this->response->setJSON($data);
|
||||
@ -151,7 +163,7 @@ class ChatController extends BaseController
|
||||
public function store_chat_message_single()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
|
||||
$existChat = $this->chatMessageModel->get_chat_contact_messages($data["receiver_id"]);
|
||||
if (count($existChat) > 0) {
|
||||
$chatId = $existChat[0]->chat_id;
|
||||
@ -171,7 +183,7 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function get_chat_internal_contacts()
|
||||
{
|
||||
if(auth()->user()->cliente_id){
|
||||
if (auth()->user()->cliente_id) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
@ -187,7 +199,7 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function get_chat_internal_contact(int $user_id)
|
||||
{
|
||||
if(auth()->user()->cliente_id){
|
||||
if (auth()->user()->cliente_id) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
@ -207,7 +219,7 @@ class ChatController extends BaseController
|
||||
{
|
||||
$cliente_id = auth()->user()->cliente_id;
|
||||
$response = [];
|
||||
if($cliente_id){
|
||||
if ($cliente_id) {
|
||||
$data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id);
|
||||
$response["totalMessages"] = 0;
|
||||
$response["chatFacturas"] = $this->chatModel->getClienteChatFacturas($data["facturas"]);
|
||||
@ -223,8 +235,7 @@ class ChatController extends BaseController
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
$response["data"] = $data;
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$response["internals"] = $this->chatModel->getChatDepartmentNotifications();
|
||||
$internal_notifications = $this->chatModel->getChatInternalNotifications();
|
||||
foreach ($internal_notifications as $value) {
|
||||
@ -243,4 +254,167 @@ class ChatController extends BaseController
|
||||
$data = $this->chatDeparmentModel->getChatDepartmentUsers($chat_department_id);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_users_internal()
|
||||
{
|
||||
$query = $this->userModel->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"CONCAT(first_name,' ',last_name,'(',username,')') as name"
|
||||
]
|
||||
)->where("cliente_id", null)
|
||||
->where("deleted_at", null)
|
||||
->whereNotIn("id",[auth()->user()->id]);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("users.username", $this->request->getGet("q"))
|
||||
->orLike("CONCAT(first_name,' ',last_name)", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
public function store_hebra_presupuesto()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"presupuesto_id" => $bodyData["modelId"],
|
||||
"title" => $bodyData["title"]
|
||||
]);
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
$this->chatUserModel->insertBatch($chatUserData);
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
}
|
||||
|
||||
public function store_hebra_pedido()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"pedido_id" => $bodyData["modelId"],
|
||||
"title" => $bodyData["title"]
|
||||
|
||||
]);
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
$this->chatUserModel->insertBatch($chatUserData);
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
}
|
||||
|
||||
public function store_hebra_factura()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"factura_id" => $bodyData["modelId"],
|
||||
"title" => $bodyData["title"]
|
||||
]);
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
$this->chatUserModel->insertBatch($chatUserData);
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
|
||||
}
|
||||
public function update_hebra($chat_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
]);
|
||||
$actualUsers = $this->chatUserModel->builder()->select("user_id")->where("chat_id",$chat_id)->get()->getResultArray();
|
||||
$actualUsersArray = array_map(fn($x) => $x["user_id"],$actualUsers);
|
||||
foreach ($actualUsersArray as $key => $user_id) {
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $user_id]);
|
||||
}
|
||||
if(isset($bodyData["users"])){
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
if(in_array($userId,$actualUsersArray) == false){
|
||||
$chatUserData = ["user_id" => $userId,"chat_id" => $chat_id];
|
||||
$this->chatUserModel->insert($chatUserData);
|
||||
|
||||
}
|
||||
$this->chatNotificationModel->insert(
|
||||
["chat_message_id" => $chatMessageId,"user_id" => $userId]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra actualizada correctamente","status" => true]);
|
||||
}
|
||||
public function get_hebra_presupuesto($presupuesto_id){
|
||||
$data = $this->chatModel->getPresupuestoHebras($presupuesto_id);
|
||||
$notifications = $this->chatModel->builder()->select([
|
||||
"chat_notifications.id"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.presupuesto_id",$presupuesto_id)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->get()->getResultArray();
|
||||
foreach ($notifications as $notification) {
|
||||
$this->chatNotificationModel->update($notification["id"],["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_hebra_pedido($pedido_id){
|
||||
$data = $this->chatModel->getPedidoHebras($pedido_id);
|
||||
$notifications = $this->chatModel->builder()->select([
|
||||
"chat_notifications.id"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.pedido_id",$pedido_id)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->get()->getResultArray();
|
||||
foreach ($notifications as $notification) {
|
||||
$this->chatNotificationModel->update($notification["id"],["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_hebra_factura($factura_id){
|
||||
$data = $this->chatModel->getFacturaHebras($factura_id);
|
||||
$notifications = $this->chatModel->builder()->select([
|
||||
"chat_notifications.id"
|
||||
])
|
||||
->join("chat_messages","chat_messages.chat_id = chats.id","left")
|
||||
->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left")
|
||||
->where("chats.factura_id",$factura_id)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->get()->getResultArray();
|
||||
foreach ($notifications as $notification) {
|
||||
$this->chatNotificationModel->update($notification["id"],["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
55
ci4/app/Database/Migrations/2024-10-12-151500_ChatUsers.php
Normal file
55
ci4/app/Database/Migrations/2024-10-12-151500_ChatUsers.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatUsers extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"chat_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey(["user_id"], "users", ["id"]);
|
||||
$this->forge->addForeignKey(["chat_id"], "chats", ["id"]);
|
||||
$this->forge->createTable("chat_users", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_users");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterChatTableAddTitleColumn extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
|
||||
"title" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => 255,
|
||||
"null" => true
|
||||
],
|
||||
|
||||
|
||||
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
|
||||
$this->forge->addColumn("chats",$this->COLUMNS);
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropColumn("chats","title");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class ChatNotifications extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"chat_message_id" => [
|
||||
"type" => "INT",
|
||||
],
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"viewed" => [
|
||||
"type" => "BOOLEAN",
|
||||
"default" => false
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey(["chat_message_id"], "chat_messages", ["id"]);
|
||||
$this->forge->addForeignKey(["user_id"], "users", ["id"]);
|
||||
$this->forge->createTable("chat_notifications", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_notifications");
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
"chat" => "Chat"
|
||||
"chat" => "Mensajería",
|
||||
"modal" => [
|
||||
"new_hebra" => "Nueva hebra",
|
||||
"title" => "Título",
|
||||
"new_message" => "Nuevo mensaje",
|
||||
"new_receivers" => "Nuevos participantes",
|
||||
"btn_send" => "Enviar",
|
||||
"btn_send_update" => "Enviar"
|
||||
]
|
||||
];
|
||||
@ -53,13 +53,17 @@ class ChatDeparmentModel extends Model
|
||||
public function getChatDepartments(string $type = "general"): array
|
||||
{
|
||||
$userModel = model(UserModel::class);
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
|
||||
$query = $this->db->table('chat_departments')
|
||||
->select(
|
||||
[
|
||||
|
||||
'chat_departments.id',
|
||||
'chat_departments.name',
|
||||
'chat_departments.display',
|
||||
'chat_department_users.user_id',
|
||||
'chats.id as chatId',
|
||||
]
|
||||
)
|
||||
->join(
|
||||
@ -67,22 +71,28 @@ class ChatDeparmentModel extends Model
|
||||
"chat_department_users.chat_department_id = chat_departments.id",
|
||||
'left'
|
||||
)
|
||||
->join("chats", "chats.chat_department_id = chat_departments.id", "left")
|
||||
->join(
|
||||
"users",
|
||||
"chat_department_users.user_id = users.id",
|
||||
'left'
|
||||
)->where("chat_departments.type",$type);
|
||||
if(auth()->user()->cliente_id == null){
|
||||
$query->where("chat_department_users.user_id",auth()->user()->id);
|
||||
}
|
||||
|
||||
)->join(
|
||||
"chat_messages",
|
||||
"chat_messages.chat_id = chats.id",
|
||||
"left"
|
||||
)
|
||||
->where("chat_departments.type", $type);
|
||||
if (auth()->user()->cliente_id == null) {
|
||||
$query->where("chat_department_users.user_id", auth()->user()->id);
|
||||
}
|
||||
|
||||
$results = $query->get()->getResultArray();
|
||||
// Create the desired structure
|
||||
$departments = [];
|
||||
|
||||
foreach ($results as $row) {
|
||||
$departmentName = $row['name'];
|
||||
|
||||
|
||||
// If the department is not yet added to the array, initialize it
|
||||
if (!isset($departments[$departmentName])) {
|
||||
$departments[$departmentName] = [
|
||||
@ -117,9 +127,8 @@ class ChatDeparmentModel extends Model
|
||||
"users",
|
||||
"chat_department_users.user_id = users.id",
|
||||
'left'
|
||||
)->where("chat_departments.id",$chat_deparment_id)
|
||||
)->where("chat_departments.id", $chat_deparment_id)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
use App\Models\ChatNotification;
|
||||
use App\Models\Facturas\FacturaModel;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
@ -22,6 +23,7 @@ class ChatModel extends Model
|
||||
"chat_department_id",
|
||||
"presupuesto_id",
|
||||
"factura_id",
|
||||
"title"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
@ -279,6 +281,7 @@ class ChatModel extends Model
|
||||
}
|
||||
public function getChatDepartmentNotifications()
|
||||
{
|
||||
$chatDeparmentModel = model(ChatDeparmentModel::class);
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$presupuestoModel = model(PresupuestoModel::class);
|
||||
$facturaModel = model(FacturaModel::class);
|
||||
@ -299,11 +302,14 @@ class ChatModel extends Model
|
||||
->where("chat_department_users.user_id",auth()->user()->id);
|
||||
$rows = $q->get()->getResultObject();
|
||||
|
||||
|
||||
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)
|
||||
if($m->viewed == false && $m->sender_id != auth()->user()->id && in_array($m->sender_id,$chatDeparmentUsersId) == false)
|
||||
$count++;
|
||||
}
|
||||
if($row->presupuestoId){
|
||||
@ -335,25 +341,184 @@ class ChatModel extends Model
|
||||
public function getChatInternalNotifications()
|
||||
{
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$userModel = model(UserModel::class);
|
||||
$internalMessages = $chatMessageModel->builder()
|
||||
$presupuestoModel = model(PresupuestoModel::class);
|
||||
$facturaModel = model(FacturaModel::class);
|
||||
$pedidoModel = model(PedidoModel::class);
|
||||
$chatNotificationModel = model(ChatNotification::class);
|
||||
|
||||
$q = $this->db->table("chats")
|
||||
->select([
|
||||
"chat_id as chatId",
|
||||
"sender_id",
|
||||
"COUNT(viewed) as unreadMessages",
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.factura_id as facturaId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.title as chatDisplay"
|
||||
])
|
||||
->where("receiver_id",auth()->user()->id)
|
||||
->where("viewed",false)->get()->getResultObject();
|
||||
foreach ($internalMessages as $m) {
|
||||
if($m->sender_id){
|
||||
$sender = $userModel->find($m->sender_id);
|
||||
$m->model = $sender;
|
||||
$m->title = $sender->username;
|
||||
$m->chatDisplay = ($sender->first_name ?? "")." ".($sender->last_name ?? "");
|
||||
$m->avatar = strtoupper(mb_substr($sender->first_name, 0, 1).mb_substr($sender->last_name, 0, 1));
|
||||
$m->uri = "#";
|
||||
->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);
|
||||
$rows = $q->get()->getResultObject();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if($row->presupuestoId){
|
||||
$row->model = $presupuestoModel->find($row->presupuestoId);
|
||||
$row->uri = "/presupuestos/cosidotapablanda/edit/".$row->presupuestoId;
|
||||
$row->title = $row->presupuestoId;
|
||||
$row->avatar = "PRE";
|
||||
$row->unreadMessages = $this->countUnreadMessagePresupuesto($row->presupuestoId);
|
||||
}
|
||||
elseif($row->pedidoId){
|
||||
$row->model = $pedidoModel->find($row->pedidoId);
|
||||
$row->uri = "/pedidos/edit/".$row->pedidoId;
|
||||
$row->title = $row->pedidoId;
|
||||
$row->avatar = "P";
|
||||
$row->unreadMessages = $this->countUnreadMessagePedido($row->pedidoId);
|
||||
|
||||
|
||||
}
|
||||
elseif($row->facturaId){
|
||||
$row->model = $facturaModel->find($row->facturaId);
|
||||
$row->uri = "/facturas/edit/".$row->facturaId;
|
||||
$row->avatar = "F";
|
||||
$row->title = $row->facturaId;
|
||||
$row->unreadMessages = $this->countUnreadMessageFactura($row->facturaId);
|
||||
|
||||
}
|
||||
}
|
||||
return $internalMessages;
|
||||
return $rows;
|
||||
}
|
||||
public function getChatInternalHebraPresupuesto(int $chat_id,int $presupuesto_id) : array
|
||||
{
|
||||
|
||||
$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.presupuesto_id",$presupuesto_id);
|
||||
$data["chatId"] = $chat_id;
|
||||
$data["messages"] = $query->get()->getResultObject();
|
||||
$data["chatTitle"] = $this->find($chat_id)->title;
|
||||
$data["users"] = $this->getChatUsers($chat_id);
|
||||
return $data;
|
||||
}
|
||||
public function getChatInternalHebraPedido($chat_id,$pedido_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.pedido_id",$pedido_id);
|
||||
$data["chatId"] = $chat_id;
|
||||
$data["messages"] = $query->get()->getResultObject();
|
||||
$data["chatTitle"] = $this->find($chat_id)->title;
|
||||
$data["users"] = $this->getChatUsers($chat_id);
|
||||
return $data;
|
||||
}
|
||||
public function getChatInternalHebraFactura($chat_id,$factura_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.factura_id",$factura_id);
|
||||
$data["chatId"] = $chat_id;
|
||||
$data["messages"] = $query->get()->getResultObject();
|
||||
$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([
|
||||
"users.username",
|
||||
"CONCAT(users.first_name,' ',users.last_name) as userFullName",
|
||||
])
|
||||
->join("chat_users","chat_users.chat_id = chats.id")
|
||||
->join("users","users.id = chat_users.user_id","left")
|
||||
->where("chats.id",$chat_id);
|
||||
return $query->get()->getResultObject();
|
||||
}
|
||||
public function getPresupuestoHebras($presupuesto_id) : array
|
||||
{
|
||||
$data = [];
|
||||
$chats = $this->builder()->select("chats.id as chatId")
|
||||
->where("chats.chat_department_id",null)
|
||||
->where("chats.presupuesto_id",$presupuesto_id)->get()->getResultObject();
|
||||
foreach ($chats as $chat) {
|
||||
$data[$chat->chatId] = $this->getChatInternalHebraPresupuesto($chat->chatId,$presupuesto_id);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function getPedidoHebras($pedido_id) : array
|
||||
{
|
||||
$data = [];
|
||||
$chats = $this->builder()->select("chats.id as chatId")
|
||||
->where("chats.chat_department_id",null)
|
||||
->where("chats.pedido_id",$pedido_id)->get()->getResultObject();
|
||||
foreach ($chats as $chat) {
|
||||
$data[$chat->chatId] = $this->getChatInternalHebraPedido($chat->chatId,$pedido_id);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function getFacturaHebras($factura_id) : array
|
||||
{
|
||||
$data = [];
|
||||
$chats = $this->builder()->select("chats.id as chatId")
|
||||
->where("chats.chat_department_id",null)
|
||||
->where("chats.factura_id",$factura_id)->get()->getResultObject();
|
||||
foreach ($chats as $chat) {
|
||||
$data[$chat->chatId] = $this->getChatInternalHebraFactura($chat->chatId,$factura_id);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function countUnreadMessagePresupuesto($presupuesto_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.presupuesto_id",$presupuesto_id)
|
||||
->where("chat_notifications.viewed",false)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->countAllResults();
|
||||
}
|
||||
public function countUnreadMessagePedido($pedido_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.pedido_id",$pedido_id)
|
||||
->where("chat_notifications.viewed",false)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)
|
||||
->countAllResults();
|
||||
}
|
||||
public function countUnreadMessageFactura($factura_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.factura_id",$factura_id)
|
||||
->where("chat_notifications.viewed",false)
|
||||
->where("chat_notifications.user_id",auth()->user()->id)->countAllResults();
|
||||
}
|
||||
}
|
||||
|
||||
50
ci4/app/Models/ChatNotification.php
Normal file
50
ci4/app/Models/ChatNotification.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatNotification extends Model
|
||||
{
|
||||
protected $table = 'chat_notifications';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"chat_message_id",
|
||||
"user_id",
|
||||
"viewed"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
49
ci4/app/Models/ChatUser.php
Normal file
49
ci4/app/Models/ChatUser.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatUser extends Model
|
||||
{
|
||||
protected $table = 'chat_users';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"user_id",
|
||||
"chat_id"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
@ -1,140 +1,116 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionChatFactura">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingChatFactura">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatFacturaTip" aria-expanded="false" aria-controls="accordionChatFacturaTip">
|
||||
<h3><?= lang("Chat.chat") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatFacturaTip" class="accordion-collapse collapse"
|
||||
data-bs-parent="#accordionChatFactura">
|
||||
<div class="accordion-body">
|
||||
<div class="container-xxl flex-grow-1 container-p-y" id="chat-factura" data-id="<?= $modelId ?>">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
<div class="container-xxl flex-grow-1 container-p-y" id="chat-factura" data-id="<?= $modelId ?>">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
|
||||
<!-- Chat & Contacts -->
|
||||
<div class="col app-chat-contacts app-sidebar flex-grow-0 overflow-hidden border-end"
|
||||
id="app-chat-contacts">
|
||||
<div class="sidebar-header">
|
||||
<div class="d-flex align-items-center me-3 me-lg-0">
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<span class="avatar-initial rounded-circle bg-label-success">U</span>
|
||||
</div>
|
||||
<!-- Chat & Contacts -->
|
||||
<div class="col app-chat-contacts app-sidebar flex-grow-0 overflow-hidden border-end"
|
||||
id="app-chat-contacts">
|
||||
<div class="sidebar-header">
|
||||
<div class="d-flex align-items-center me-3 me-lg-0">
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<span class="avatar-initial rounded-circle bg-label-success">U</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-grow-1 input-group input-group-merge rounded-pill">
|
||||
<span class="input-group-text" id="basic-addon-search31">
|
||||
<i class="ti ti-search"></i>
|
||||
</span>
|
||||
<input type="text" class="form-control chat-search-input"
|
||||
placeholder="Buscar..." aria-label="Buscar..."
|
||||
aria-describedby="basic-addon-search31" />
|
||||
</div>
|
||||
</div>
|
||||
<i class="ti ti-x cursor-pointer d-lg-none d-block position-absolute mt-2 me-1 top-0 end-0"
|
||||
data-overlay data-bs-toggle="sidebar" data-target="#app-chat-contacts"></i>
|
||||
<div class="flex-grow-1 input-group input-group-merge rounded-pill">
|
||||
<span class="input-group-text" id="basic-addon-search31">
|
||||
<i class="ti ti-search"></i>
|
||||
</span>
|
||||
<input type="text" class="form-control chat-search-input"
|
||||
placeholder="Buscar..." aria-label="Buscar..."
|
||||
aria-describedby="basic-addon-search31" />
|
||||
</div>
|
||||
</div>
|
||||
<i class="ti ti-x cursor-pointer d-lg-none d-block position-absolute mt-2 me-1 top-0 end-0"
|
||||
data-overlay data-bs-toggle="sidebar" data-target="#app-chat-contacts"></i>
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
<!-- Chats -->
|
||||
<ul class="list-unstyled chat-contact-list" id="chat-list">
|
||||
<li class="chat-contact-list-item chat-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Chats Found</h6>
|
||||
</li>
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat contacts -->
|
||||
|
||||
<!-- Chat History -->
|
||||
<div class="col app-chat-history bg-body">
|
||||
<div class="chat-history-wrapper ">
|
||||
<div class="chat-history-header border-bottom">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex overflow-hidden align-items-center">
|
||||
<i class="ti ti-menu-2 ti-sm cursor-pointer d-lg-none d-block me-2"
|
||||
data-bs-toggle="sidebar" data-overlay
|
||||
data-target="#app-chat-contacts"></i>
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span
|
||||
class="avatar-initial rounded-circle bg-label-primary">P</span>
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
<!-- Chats -->
|
||||
<ul class="list-unstyled chat-contact-list" id="chat-list">
|
||||
<li class="chat-contact-list-item chat-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Chats Found</h6>
|
||||
</li>
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
<!-- Contacts -->
|
||||
<ul class="list-unstyled chat-contact-list mb-0" id="contact-list">
|
||||
<li class="chat-contact-list-item chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0">Contacts</h5>
|
||||
</li>
|
||||
<li class="chat-contact-list-item contact-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Contacts Found</h6>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="m-0"></h6>
|
||||
<small class="user-status text-muted"></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /Chat contacts -->
|
||||
|
||||
<!-- Chat History -->
|
||||
<div class="col app-chat-history bg-body">
|
||||
<div class="chat-history-wrapper ">
|
||||
<div class="chat-history-header border-bottom">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex overflow-hidden align-items-center">
|
||||
<i class="ti ti-menu-2 ti-sm cursor-pointer d-lg-none d-block me-2"
|
||||
data-bs-toggle="sidebar" data-overlay
|
||||
data-target="#app-chat-contacts"></i>
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span
|
||||
class="avatar-initial rounded-circle bg-label-primary">P</span>
|
||||
</div>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="m-0"></h6>
|
||||
<small class="user-status text-muted"></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" id="chat-header-users"
|
||||
aria-labelledby="chat-header-users">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" id="chat-header-users"
|
||||
aria-labelledby="chat-header-users">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
<div class="chat-history-footer shadow-sm">
|
||||
<div
|
||||
class="form-send-message d-flex justify-content-between align-items-center">
|
||||
<input class="form-control message-input border-0 me-3 shadow-none"
|
||||
placeholder="Type your message here" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<a class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</a>
|
||||
<a class="btn btn-primary d-flex send-msg-btn"
|
||||
id="send-msg-btn-internal">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block ">Enviar</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
<div class="chat-history-footer shadow-sm">
|
||||
<div
|
||||
class="form-send-message d-flex justify-content-between align-items-center">
|
||||
<input class="form-control message-input border-0 me-3 shadow-none"
|
||||
placeholder="Type your message here" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<a class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</a>
|
||||
<a class="btn btn-primary d-flex send-msg-btn"
|
||||
id="send-msg-btn-internal">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block ">Enviar</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionChatFactura">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingChatFactura">
|
||||
<button type="button" class="accordion-button collapsed" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatFacturaTip" aria-expanded="false"
|
||||
aria-controls="accordionChatFacturaTip">
|
||||
<h3><?= lang("Chat.chat") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatFacturaTip" class="accordion-collapse collapse"
|
||||
data-bs-parent="#accordionChatFactura">
|
||||
<div class="accordion-body">
|
||||
<div class="nav-align-top">
|
||||
<ul class="nav nav-pills mb-4" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false">Chat</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false">Mensajes internos</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="navs-pills-top-chat" role="tabpanel">
|
||||
<?= view("themes/vuexy/components/chat_factura", data: ["modelId" => $modelId,"type" => "factura"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="navs-pills-top-internal-messages" role="tabpanel">
|
||||
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId,"type" => "factura"]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,34 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionChatPedido">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingChatPedido">
|
||||
<button type="button" class="accordion-button collapsed" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatPedidoTip" aria-expanded="false"
|
||||
aria-controls="accordionChatPedidoTip">
|
||||
<h3><?= lang("Chat.chat") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatPedidoTip" class="accordion-collapse collapse"
|
||||
data-bs-parent="#accordionChatPedido">
|
||||
<div class="accordion-body">
|
||||
<div class="nav-align-top">
|
||||
<ul class="nav nav-pills mb-4" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false">Chat</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false">Mensajes internos</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="navs-pills-top-chat" role="tabpanel">
|
||||
<?= view("themes/vuexy/components/chat_pedido", data: ["modelId" => $modelId, "type" => "pedido"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="navs-pills-top-internal-messages" role="tabpanel">
|
||||
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId, "type" => "pedido"]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,34 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionChatPresupuesto">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingChatPresupuesto">
|
||||
<button type="button" class="accordion-button collapsed" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatPresupuestoTip" aria-expanded="false"
|
||||
aria-controls="accordionChatPresupuestoTip">
|
||||
<h3><?= lang("Chat.chat") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatPresupuestoTip" class="accordion-collapse collapse"
|
||||
data-bs-parent="#accordionChatPresupuesto">
|
||||
<div class="accordion-body">
|
||||
<div class="nav-align-top">
|
||||
<ul class="nav nav-pills mb-4" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false">Chat</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false">Mensajes internos</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="navs-pills-top-chat" role="tabpanel">
|
||||
<?= view("themes/vuexy/components/chat_presupuesto", data: ["modelId" => $modelId, "type" => "presupuesto"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="navs-pills-top-internal-messages" role="tabpanel">
|
||||
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId, "type" => "presupuesto"]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1,140 +1,125 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionChatPedido">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingChatPedido">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatPedidoTip" aria-expanded="false" aria-controls="accordionChatPedidoTip">
|
||||
<h3><?= lang("Chat.chat") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatPedidoTip" class="accordion-collapse collapse" data-bs-parent="#accordionChatPedido">
|
||||
<div class="accordion-body">
|
||||
<div class="container-xxl flex-grow-1 container-p-y" id="chat-pedido" data-id="<?= $modelId ?>">
|
||||
<div class="container-xxl flex-grow-1 container-p-y" id="chat-pedido" data-id="<?= $modelId ?>">
|
||||
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
|
||||
<!-- Chat & Contacts -->
|
||||
<div class="col app-chat-contacts app-sidebar flex-grow-0 overflow-hidden border-end"
|
||||
id="app-chat-contacts">
|
||||
<div class="sidebar-header">
|
||||
<div class="d-flex align-items-center me-3 me-lg-0">
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<span class="avatar-initial rounded-circle bg-label-success">U</span>
|
||||
</div>
|
||||
<!-- Chat & Contacts -->
|
||||
<div class="col app-chat-contacts app-sidebar flex-grow-0 overflow-hidden border-end"
|
||||
id="app-chat-contacts">
|
||||
<div class="sidebar-header">
|
||||
<div class="d-flex align-items-center me-3 me-lg-0">
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<span class="avatar-initial rounded-circle bg-label-success">U</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-grow-1 input-group input-group-merge rounded-pill">
|
||||
<span class="input-group-text" id="basic-addon-search31">
|
||||
<i class="ti ti-search"></i>
|
||||
</span>
|
||||
<input type="text" class="form-control chat-search-input"
|
||||
placeholder="Buscar..." aria-label="Buscar..."
|
||||
aria-describedby="basic-addon-search31" />
|
||||
</div>
|
||||
</div>
|
||||
<i class="ti ti-x cursor-pointer d-lg-none d-block position-absolute mt-2 me-1 top-0 end-0"
|
||||
data-overlay data-bs-toggle="sidebar" data-target="#app-chat-contacts"></i>
|
||||
<div class="flex-grow-1 input-group input-group-merge rounded-pill">
|
||||
<span class="input-group-text" id="basic-addon-search31">
|
||||
<i class="ti ti-search"></i>
|
||||
</span>
|
||||
<input type="text" class="form-control chat-search-input"
|
||||
placeholder="Buscar..." aria-label="Buscar..."
|
||||
aria-describedby="basic-addon-search31" />
|
||||
</div>
|
||||
</div>
|
||||
<i class="ti ti-x cursor-pointer d-lg-none d-block position-absolute mt-2 me-1 top-0 end-0"
|
||||
data-overlay data-bs-toggle="sidebar" data-target="#app-chat-contacts"></i>
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
<!-- Chats -->
|
||||
<ul class="list-unstyled chat-contact-list" id="chat-list">
|
||||
<li class="chat-contact-list-item chat-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Chats Found</h6>
|
||||
</li>
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
<!-- Contacts -->
|
||||
<ul class="list-unstyled chat-contact-list mb-0" id="contact-list">
|
||||
<li class="chat-contact-list-item chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0">Contactos</h5>
|
||||
</li>
|
||||
<li class="chat-contact-list-item contact-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Contacts Found</h6>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat contacts -->
|
||||
|
||||
<!-- Chat History -->
|
||||
<div class="col app-chat-history bg-body">
|
||||
<div class="chat-history-wrapper ">
|
||||
<div class="chat-history-header border-bottom">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex overflow-hidden align-items-center">
|
||||
<i class="ti ti-menu-2 ti-sm cursor-pointer d-lg-none d-block me-2"
|
||||
data-bs-toggle="sidebar" data-overlay
|
||||
data-target="#app-chat-contacts"></i>
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span
|
||||
class="avatar-initial rounded-circle bg-label-primary">P</span>
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
<!-- Chats -->
|
||||
<ul class="list-unstyled chat-contact-list" id="chat-list">
|
||||
<li class="chat-contact-list-item chat-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Chats Found</h6>
|
||||
</li>
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
<!-- Contacts -->
|
||||
<ul class="list-unstyled chat-contact-list mb-0" id="contact-list">
|
||||
<li class="chat-contact-list-item chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0">Contactos</h5>
|
||||
</li>
|
||||
<li class="chat-contact-list-item contact-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Contacts Found</h6>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="m-0"></h6>
|
||||
<small class="user-status text-muted"></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /Chat contacts -->
|
||||
|
||||
<!-- Chat History -->
|
||||
<div class="col app-chat-history bg-body">
|
||||
<div class="chat-history-wrapper ">
|
||||
<div class="chat-history-header border-bottom">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex overflow-hidden align-items-center">
|
||||
<i class="ti ti-menu-2 ti-sm cursor-pointer d-lg-none d-block me-2"
|
||||
data-bs-toggle="sidebar" data-overlay
|
||||
data-target="#app-chat-contacts"></i>
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span
|
||||
class="avatar-initial rounded-circle bg-label-primary">P</span>
|
||||
</div>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="m-0"></h6>
|
||||
<small class="user-status text-muted"></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" id="chat-header-users"
|
||||
aria-labelledby="chat-header-users">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" id="chat-header-users"
|
||||
aria-labelledby="chat-header-users">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
<div class="chat-history-footer shadow-sm">
|
||||
<div
|
||||
class="form-send-message d-flex justify-content-between align-items-center">
|
||||
<input class="form-control message-input border-0 me-3 shadow-none"
|
||||
placeholder="Type your message here" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<a class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</a>
|
||||
<a class="btn btn-primary d-flex send-msg-btn"
|
||||
id="send-msg-btn-internal">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block ">Enviar</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
<div class="chat-history-footer shadow-sm">
|
||||
<div
|
||||
class="form-send-message d-flex justify-content-between align-items-center">
|
||||
<input class="form-control message-input border-0 me-3 shadow-none"
|
||||
placeholder="Type your message here" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<a class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</a>
|
||||
<a class="btn btn-primary d-flex send-msg-btn"
|
||||
id="send-msg-btn-internal">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block ">Enviar</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
|
||||
@ -1,138 +1,112 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionChatPresupuesto">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingChatPresupuesto">
|
||||
<button type="button" class="accordion-button collapsed" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatPresupuestoTip" aria-expanded="false"
|
||||
aria-controls="accordionChatPresupuestoTip">
|
||||
<h3><?= lang("Chat.chat") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatPresupuestoTip" class="accordion-collapse collapse"
|
||||
data-bs-parent="#accordionChatPresupuesto">
|
||||
<div class="accordion-body">
|
||||
<div class="container-xxl flex-grow-1" id="chat-presupuesto" data-id="<?= $modelId ?>">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
<div class="container-xl flex-grow-1 container-p-y" id="chat-presupuesto" data-id="<?= $modelId ?>">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
|
||||
<!-- Chat & Contacts -->
|
||||
<div class="col app-chat-contacts app-sidebar flex-grow-0 overflow-hidden border-end"
|
||||
id="app-chat-contacts">
|
||||
<div class="sidebar-header">
|
||||
<div class="d-flex align-items-center me-3 me-lg-0">
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<span class="avatar-initial rounded-circle bg-label-success">U</span>
|
||||
</div>
|
||||
<!-- Chat & Contacts -->
|
||||
<div class="col app-chat-contacts app-sidebar flex-grow-0 overflow-hidden border-end"
|
||||
id="app-chat-contacts">
|
||||
<div class="sidebar-header">
|
||||
<div class="d-flex align-items-center me-3 me-lg-0">
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<span class="avatar-initial rounded-circle bg-label-success">U</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-grow-1 input-group input-group-merge rounded-pill">
|
||||
<span class="input-group-text" id="basic-addon-search31">
|
||||
<i class="ti ti-search"></i>
|
||||
</span>
|
||||
<input type="text" class="form-control chat-search-input"
|
||||
placeholder="Buscar..." aria-label="Buscar..."
|
||||
aria-describedby="basic-addon-search31" />
|
||||
</div>
|
||||
</div>
|
||||
<i class="ti ti-x cursor-pointer d-lg-none d-block position-absolute mt-2 me-1 top-0 end-0"
|
||||
data-overlay data-bs-toggle="sidebar" data-target="#app-chat-contacts"></i>
|
||||
<div class="flex-grow-1 input-group input-group-merge rounded-pill">
|
||||
<span class="input-group-text" id="basic-addon-search31">
|
||||
<i class="ti ti-search"></i>
|
||||
</span>
|
||||
<input type="text" class="form-control chat-search-input"
|
||||
placeholder="Buscar..." aria-label="Buscar..."
|
||||
aria-describedby="basic-addon-search31" />
|
||||
</div>
|
||||
</div>
|
||||
<i class="ti ti-x cursor-pointer d-lg-none d-block position-absolute mt-2 me-1 top-0 end-0"
|
||||
data-overlay data-bs-toggle="sidebar" data-target="#app-chat-contacts"></i>
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
<!-- Chats -->
|
||||
<ul class="list-unstyled chat-contact-list" id="chat-list">
|
||||
<li class="chat-contact-list-item chat-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Chats Found</h6>
|
||||
</li>
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat contacts -->
|
||||
|
||||
<!-- Chat History -->
|
||||
<div class="col app-chat-history bg-body">
|
||||
<div class="chat-history-wrapper ">
|
||||
<div class="chat-history-header border-bottom">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex overflow-hidden align-items-center">
|
||||
<i class="ti ti-menu-2 ti-sm cursor-pointer d-lg-none d-block me-2"
|
||||
data-bs-toggle="sidebar" data-overlay
|
||||
data-target="#app-chat-contacts"></i>
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span
|
||||
class="avatar-initial rounded-circle bg-label-primary">P</span>
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
<!-- Chats -->
|
||||
<ul class="list-unstyled chat-contact-list" id="chat-list">
|
||||
<li class="chat-contact-list-item chat-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Chats Found</h6>
|
||||
</li>
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
<!-- Contacts -->
|
||||
<ul class="list-unstyled chat-contact-list mb-0 d-none" id="contact-list">
|
||||
<li class="chat-contact-list-item chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0">Contacts</h5>
|
||||
</li>
|
||||
<li class="chat-contact-list-item contact-list-item-0 d-none">
|
||||
<h6 class="text-muted mb-0">No Contacts Found</h6>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="m-0"></h6>
|
||||
<small class="user-status text-muted"></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /Chat contacts -->
|
||||
|
||||
<!-- Chat History -->
|
||||
<div class="col app-chat-history bg-body">
|
||||
<div class="chat-history-wrapper ">
|
||||
<div class="chat-history-header border-bottom">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex overflow-hidden align-items-center">
|
||||
<i class="ti ti-menu-2 ti-sm cursor-pointer d-lg-none d-block me-2"
|
||||
data-bs-toggle="sidebar" data-overlay
|
||||
data-target="#app-chat-contacts"></i>
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span
|
||||
class="avatar-initial rounded-circle bg-label-primary">P</span>
|
||||
</div>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="m-0"></h6>
|
||||
<small class="user-status text-muted"></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" id="chat-header-users"
|
||||
aria-labelledby="chat-header-users">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" id="chat-header-users"
|
||||
aria-labelledby="chat-header-users">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
<div class="chat-history-footer shadow-sm">
|
||||
<div
|
||||
class="form-send-message d-flex justify-content-between align-items-center">
|
||||
<input class="form-control message-input border-0 me-3 shadow-none"
|
||||
placeholder="Type your message here" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<a class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</a>
|
||||
<a class="btn btn-primary d-flex send-msg-btn"
|
||||
id="send-msg-btn-internal">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block ">Enviar</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
<div class="chat-history-footer shadow-sm">
|
||||
<div
|
||||
class="form-send-message d-flex justify-content-between align-items-center">
|
||||
<input class="form-control message-input border-0 me-3 shadow-none"
|
||||
placeholder="Type your message here" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<a class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</a>
|
||||
<a class="btn btn-primary d-flex send-msg-btn"
|
||||
id="send-msg-btn-internal">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block ">Enviar</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
19
ci4/app/Views/themes/vuexy/components/internal_messages.php
Normal file
19
ci4/app/Views/themes/vuexy/components/internal_messages.php
Normal file
@ -0,0 +1,19 @@
|
||||
<div id="internal_messages_chat" data-id="<?= $modelId ?>" data-type="<?= $type ?>">
|
||||
<div class="d-flex flex-column bd-highlight mb-3">
|
||||
<div class="row p-1">
|
||||
<div class="col">
|
||||
<div class="d-flex justify-content-start">
|
||||
<button type="button" class="btn btn-warning btn-md waves-effect waves-light btn-new-hebra">
|
||||
<span class="ti-xs ti ti-mail me-1"></span>
|
||||
Nuevo mensaje interno
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row p-1">
|
||||
<div id="container-internal-messages" class="col">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= view("themes/vuexy/components/modals/modalNewInternalMessage") ?>
|
||||
</div>
|
||||
@ -0,0 +1,40 @@
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="modalNewInternalMessage" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel1"><?= lang('Chat.modal.new_hebra') ?></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="formEditConfigVariable">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-0">
|
||||
<label for="description" class="form-label"><?= lang('Chat.modal.title') ?></label>
|
||||
<input type="input" rows="4" cols="10" id="new-internal-message-title" placeholder="Escriba un título" name="title" class="form-control" />
|
||||
</div>
|
||||
<div class="col-12 mb-0">
|
||||
<label for="description" class="form-label"><?= lang('Chat.modal.new_message') ?></label>
|
||||
<textarea type="input" rows="4" cols="10" id="new-internal-message-text" placeholder="Escribe el mensaje ..." name="message" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-0">
|
||||
<label for="selectUsersHebra" class="form-label"><?= lang('Chat.modal.new_receivers') ?></label>
|
||||
<select id="selectUsersHebra" class="select2 form-select" multiple>
|
||||
<option value="0" class="" disabled>Seleccione a los participantes</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-label-secondary" data-bs-dismiss="modal"><?= lang('App.come_back') ?></button>
|
||||
<button type="button" id="submit_new_hebra" class="btn btn-primary d-none"><?= lang('Chat.modal.btn_send') ?></button>
|
||||
<button type="button" id="submit_update_hebra" class="btn btn-primary d-none"><?= lang('Chat.modal.btn_send_update') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -28,7 +28,7 @@
|
||||
<?php if($facturaEntity->estado !='borrador' && (strpos($facturaEntity->numero, "REC ") === 0) ) : ?>
|
||||
<?= view("themes/vuexy/form/facturas/_rectificadaFacturasItems") ?>
|
||||
<?php endif; ?>
|
||||
<?= view("themes/vuexy/components/chat_factura",data:["modelId" => $facturaEntity->id]) ?>
|
||||
<?= view("themes/vuexy/components/chat_internal_factura",data:["modelId" =>$facturaEntity->id,"type" => "factura"]) ?>
|
||||
|
||||
<div class="pt-4">
|
||||
<?php if($facturaEntity->estado =='borrador') : ?>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<?= view("themes/vuexy/form/pedidos/_albaranesItems") ?>
|
||||
<?php endif; ?>
|
||||
<?= view("themes/vuexy/form/pedidos/_facturasItems") ?>
|
||||
<?= view("themes/vuexy/components/chat_pedido", data: ["modelId" => $pedidoEntity->id]) ?>
|
||||
<?= view("themes/vuexy/components/chat_internal_pedido", data: ["modelId" => $pedidoEntity->id,"type" => "pedido"]) ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="pt-4">
|
||||
<?= anchor(route_to("listaPresupuestos"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
<?= view("themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems") ?>
|
||||
<?= view("themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios") ?>
|
||||
<?= view("themes/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems") ?>
|
||||
<?= view("themes/vuexy/components/chat_presupuesto",data:["modelId" => $presupuestoId]) ?>
|
||||
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?>
|
||||
<?= view("themes/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems") ?>
|
||||
<?= view("themes/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems") ?>
|
||||
<?php else: ?>
|
||||
|
||||
@ -116,7 +116,7 @@ $picture = "/assets/img/default-user.png";
|
||||
id="message-notification-dropdown"
|
||||
aria-expanded="false">
|
||||
<span class="tf-icons ti-md ti ti-message-circle"></span>
|
||||
<span id="chat-notification-number" class="badge bg-danger text-white badge-notifications"></span>
|
||||
<span id="chat-notification-number" class="badge bg-danger text-white badge-notifications d-none"></span>
|
||||
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-end py-0">
|
||||
|
||||
@ -149,6 +149,7 @@ class Chat {
|
||||
this.domItem.find(".chat-history-header div.chat-contact-info h6").text(row.display)
|
||||
this.domItem.find(".chat-history-header div.chat-contact-info small.user-status").text(row.display)
|
||||
this._getChatMessage()
|
||||
this._getChatTotalMessages(row.name)
|
||||
this._getChatDeparmentUsers()
|
||||
})
|
||||
|
||||
@ -213,13 +214,26 @@ class Chat {
|
||||
${row.display}
|
||||
</p>
|
||||
</div>
|
||||
${row.unreadMessages ? `<span
|
||||
class="badge badge-center rounded-pill bg-primary messages-unread-contact">${row.unreadMessages}</span>` : ""}
|
||||
<span class="badge badge-center rounded-pill bg-danger messages-unread-contact">0</span>
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
return chat
|
||||
}
|
||||
_getChatTotalMessages(row_name) {
|
||||
let ajax = new Ajax(
|
||||
`/chat/department/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`,
|
||||
null,
|
||||
null,
|
||||
(data)=> {
|
||||
this.chatList.find(`#chat_${row_name} .messages-unread-contact`).text(data.count)
|
||||
},
|
||||
null
|
||||
|
||||
|
||||
);
|
||||
ajax.get();
|
||||
}
|
||||
_getChatMessage() {
|
||||
let ajax = new Ajax(
|
||||
`/chat/department/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`,
|
||||
@ -463,7 +477,11 @@ export const showNotificationMessages = (dom) => {
|
||||
null,
|
||||
(data) => {
|
||||
dom.empty()
|
||||
$("#chat-notification-number").text(data.totalMessages ?? 0)
|
||||
$("#chat-notification-number")
|
||||
if(data.totalMessages > 0){
|
||||
$("#chat-notification-number").removeClass("d-none")
|
||||
$("#chat-notification-number").text(data.totalMessages ?? 0)
|
||||
}
|
||||
data?.internals?.map((e) => {
|
||||
let numberOfMessages = e.unreadMessages
|
||||
if(numberOfMessages > 0){
|
||||
|
||||
199
httpdocs/assets/js/safekat/components/internalMessagesSection.js
Normal file
199
httpdocs/assets/js/safekat/components/internalMessagesSection.js
Normal file
@ -0,0 +1,199 @@
|
||||
import Ajax from "./ajax.js"
|
||||
import Modal from "./modal.js"
|
||||
import ClassSelect from "./select2.js"
|
||||
|
||||
const getInitials = (name) => name.split(" ").map(e => e.charAt(0)).join("")
|
||||
const hebraList = (message) => `
|
||||
<div class="list-group-item list-group-item-action d-flex align-items-center cursor-pointer">
|
||||
<div class="avatar avatar-sm me-2">
|
||||
<span class="avatar-initial rounded-circle bg-primary" title="${message.senderFullName}">${getInitials(message.senderFullName)}</span>
|
||||
</div>
|
||||
<div class="w-100 px-4">
|
||||
<div class="d-flex flex-column">
|
||||
<div class="d-flex align-items-center">
|
||||
<p class="px-1">
|
||||
<span class="ti ti-xs ti-clock"></span>
|
||||
</p>
|
||||
<p class="px-1">
|
||||
${message.created_at}
|
||||
</p>
|
||||
<h6>
|
||||
${message.senderFullName} (${message.senderUserName})
|
||||
</h6>
|
||||
</div>
|
||||
<p class="text-start">${message.message}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
const hebraUsersList = (user) => `
|
||||
|
||||
<div class="avatar avatar-sm me-2">
|
||||
<span class="avatar-initial rounded-circle bg-secondary" title="${user.userFullName}">${getInitials(user.userFullName)}</span>
|
||||
</div>
|
||||
|
||||
`
|
||||
class InternalMessages {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.containerMessages = this.item.find("#container-internal-messages")
|
||||
this.btnNewHebra = this.item.find(".btn-new-hebra")
|
||||
this.btnNewHebraMessage = this.item.find(".btn-new-hebra-message")
|
||||
this.modalNewMessage = new Modal($("#modalNewInternalMessage"))
|
||||
this.selectUsers = this.item.find("#selectUsersHebra")
|
||||
this.btnNewHebraSubmit = this.item.find("#submit_new_hebra")
|
||||
this.textAreaMessage = this.item.find("#new-internal-message-text")
|
||||
this.hebraTitle = this.item.find("#new-internal-message-title")
|
||||
this.btnUpdateHebraSubmit = this.item.find("#submit_update_hebra")
|
||||
this.message = ""
|
||||
this.formNewValues = ""
|
||||
this.formUpdateValues = ""
|
||||
this.subjectHebra = ""
|
||||
this.modelId = this.item.data("id")
|
||||
this.type = this.item.data("type")
|
||||
this.chatId = null
|
||||
|
||||
this.selectMessageUsers = new ClassSelect(this.selectUsers, '/chat/users/internal', "Seleccione un usuario",true)
|
||||
}
|
||||
init() {
|
||||
this.selectMessageUsers.init()
|
||||
this.item.on("click", ".btn-new-hebra", this.handleBtnNewHebra.bind(this))
|
||||
this.item.on("click", ".btn-new-hebra-message", this.handleBtnUpdateHebra.bind(this))
|
||||
this.modalNewMessage.item.on("click","#submit_new_hebra",this.handlePostNewHebra.bind(this))
|
||||
this.modalNewMessage.item.on("click","#submit_update_hebra",this.handleUpdateHebra.bind(this))
|
||||
this.handleGetInternalMessages()
|
||||
|
||||
}
|
||||
handleGetInternalMessages() {
|
||||
this.containerMessages.empty()
|
||||
let ajax = new Ajax(
|
||||
`/chat/hebra/${this.type}/${this.modelId}`,
|
||||
null,
|
||||
null,
|
||||
this._handleGetInternalMessagesSuccess.bind(this),
|
||||
this._handleGetInternalMessagesError.bind(this)
|
||||
)
|
||||
ajax.get()
|
||||
}
|
||||
handlePostNewHebra(){
|
||||
this._handleUpdateFormNewHebraValues()
|
||||
let ajax = new Ajax(
|
||||
`/chat/hebra/${this.type}`,
|
||||
this.formNewValues,
|
||||
null,
|
||||
this.handlePostNewHebraSuccess.bind(this),
|
||||
this.handlePostNewHebraError.bind(this),
|
||||
)
|
||||
ajax.post()
|
||||
|
||||
}
|
||||
handlePostNewHebraSuccess(data){
|
||||
this.modalNewMessage.toggle()
|
||||
this.handleGetInternalMessages()
|
||||
}
|
||||
handlePostNewHebraError(err){}
|
||||
handleUpdateHebra(){
|
||||
this._handleUpdateFormUpdateHebraValues()
|
||||
let ajax = new Ajax(
|
||||
`/chat/hebra/${this.chatId}`,
|
||||
this.formUpdateValues,
|
||||
null,
|
||||
this.handleUpdateNewHebraSuccess.bind(this),
|
||||
this.handleUpdateNewHebraError.bind(this),
|
||||
)
|
||||
ajax.post()
|
||||
}
|
||||
handleUpdateNewHebraSuccess(data){
|
||||
this.modalNewMessage.toggle()
|
||||
this.handleGetInternalMessages()
|
||||
}
|
||||
handleUpdateNewHebraError(err){}
|
||||
handleBtnNewHebra(e) {
|
||||
e.preventDefault()
|
||||
this.chatId = null
|
||||
this.modalNewMessage.item.find(".modal-title").text("Nueva hebra")
|
||||
this.selectMessageUsers.reset()
|
||||
this.textAreaMessage.val("")
|
||||
this.hebraTitle.val("")
|
||||
this.hebraTitle.parent().removeClass("d-none")
|
||||
this.btnNewHebraSubmit.removeClass("d-none")
|
||||
this.btnUpdateHebraSubmit.addClass("d-none")
|
||||
this.modalNewMessage.show()
|
||||
this._handleUpdateFormNewHebraValues()
|
||||
}
|
||||
handleBtnUpdateHebra(e) {
|
||||
e.preventDefault()
|
||||
this.chatId = $(e.currentTarget).data("id")
|
||||
this.selectMessageUsers.reset()
|
||||
this.textAreaMessage.val("")
|
||||
this.hebraTitle.val("")
|
||||
this.hebraTitle.parent().addClass("d-none")
|
||||
this.modalNewMessage.item.find(".modal-title").text("Nuevo mensaje")
|
||||
this.btnUpdateHebraSubmit.removeClass("d-none")
|
||||
this.btnNewHebraSubmit.addClass("d-none")
|
||||
this.modalNewMessage.show()
|
||||
this._handleUpdateFormUpdateHebraValues()
|
||||
|
||||
}
|
||||
_handleUpdateFormNewHebraValues() {
|
||||
this.formNewValues = {
|
||||
title : this.hebraTitle.val(),
|
||||
users: this.selectMessageUsers.getVal(),
|
||||
message: this.textAreaMessage.val(),
|
||||
modelId : this.modelId
|
||||
}
|
||||
}
|
||||
_handleUpdateFormUpdateHebraValues() {
|
||||
this.formUpdateValues = {
|
||||
users: this.selectMessageUsers.getVal(),
|
||||
message: this.textAreaMessage.val(),
|
||||
modelId : this.modelId
|
||||
}
|
||||
}
|
||||
_handleGetInternalMessagesSuccess(data){
|
||||
Object.values(data).map((k) => {
|
||||
this._addHebraDOM(k.chatId,k.chatTitle,k.messages,k.users)
|
||||
})
|
||||
}
|
||||
_handleGetInternalMessagesError(err){}
|
||||
|
||||
_addHebraDOM(key,chatTitle,messages,users) {
|
||||
const itemHebra = $(`<div id="hebra-item-${key}"></div>`).addClass("border border-container flex-grow-0 container-p-y mt-4 p-5")
|
||||
const headerHebra = $("<div></div>").addClass("d-flex justify-content-between align-items-center")
|
||||
const contentHeaderHebra = $("<h4></h4>").text(`${chatTitle}`)
|
||||
const btnNewHebra = $("<button></button>").attr("type", "button").addClass("btn btn-danger btn-sm btn-new-hebra")
|
||||
btnNewHebra.append('<span class="ti-xs ti ti-git-branch"></span>')
|
||||
btnNewHebra.append("Nueva hebra")
|
||||
headerHebra.append(contentHeaderHebra,btnNewHebra)
|
||||
itemHebra.append(headerHebra)
|
||||
let itemMessagesHebraRow = $("<div></div>").addClass("row")
|
||||
let itemMessagesHebraCol = $("<div></div>").addClass("col")
|
||||
let itemMessagesListGroup = $("<div></div>").addClass("list-group")
|
||||
itemMessagesHebraRow.append(itemMessagesHebraCol)
|
||||
itemMessagesHebraCol.append(itemMessagesListGroup)
|
||||
let itemFooterHebra = $("<div></div>").addClass("d-flex justify-content-between align-items-center")
|
||||
let itemFooterUserFlex = $("<div></div>").addClass("d-flex justify-content-start ")
|
||||
let itemFooterHebraUserFlexChildren = $("<div></div>").addClass("d-flex align-items-center avatar-group mb-4 mt-4")
|
||||
itemFooterUserFlex.append(itemFooterHebraUserFlexChildren)
|
||||
itemFooterHebra.append(itemFooterUserFlex)
|
||||
users.map((user) => {
|
||||
let avatarUsers = hebraUsersList(user)
|
||||
itemFooterHebraUserFlexChildren.append(avatarUsers)
|
||||
})
|
||||
itemFooterHebra.append(`
|
||||
<button class="btn btn-primary btn-md waves-effect waves-light btn-new-hebra-message" data-id="${key}">
|
||||
<span class="ti-xs ti ti-message-2 me-1"></span>
|
||||
Nuevo mensaje
|
||||
</button>
|
||||
`)
|
||||
messages.map((message) => {
|
||||
let messageContent = hebraList(message)
|
||||
itemMessagesListGroup.append(messageContent)
|
||||
})
|
||||
itemHebra.append(itemMessagesListGroup)
|
||||
itemHebra.append(itemFooterHebra)
|
||||
this.containerMessages.append(itemHebra)
|
||||
}
|
||||
}
|
||||
|
||||
export default InternalMessages;
|
||||
73
httpdocs/assets/js/safekat/components/select2.js
Normal file
73
httpdocs/assets/js/safekat/components/select2.js
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
*
|
||||
* @param {DOM} domItem
|
||||
* @param {String} url
|
||||
* @param {String} placeholder
|
||||
*/
|
||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false) {
|
||||
this.url = url;
|
||||
this.item = domItem;
|
||||
this.config = {
|
||||
placeholder: placeholder,
|
||||
allowClear: allowClear,
|
||||
dropdownParent: domItem.parent(),
|
||||
ajax: {
|
||||
url: () => {
|
||||
return this.url;
|
||||
},
|
||||
data: function (params) {
|
||||
return {
|
||||
q: $.trim(params.term),
|
||||
};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: $.map(data, function (obj) {
|
||||
return {
|
||||
id: obj.id,
|
||||
text: obj.nombre ?? obj.name,
|
||||
desc: obj.description,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
};
|
||||
this.init = function () {
|
||||
if (this.item.length) {
|
||||
this.item = this.item.select2(this.config);
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function () {};
|
||||
}
|
||||
};
|
||||
this.setOption = function (id, nombre) {
|
||||
var newOption = new Option(nombre , id, false, false);
|
||||
this.item.append(newOption);
|
||||
this.item.val(id).trigger("change");
|
||||
};
|
||||
this.reset = function () {
|
||||
this.item.val(null).trigger("change");
|
||||
};
|
||||
this.getVal = function () {
|
||||
return this.item.val();
|
||||
};
|
||||
this.setVal = function (val) {
|
||||
return this.item.val(val).trigger("change");
|
||||
};
|
||||
this.empty = function () {
|
||||
return this.item.empty().trigger("change");
|
||||
};
|
||||
this.readOnly = function () {
|
||||
this.item.enable(false);
|
||||
};
|
||||
this.enable = () => {
|
||||
this.item.enable(true);
|
||||
};
|
||||
this.fixWithScroll = function () {};
|
||||
this.getText = () => {
|
||||
return this.item.find(":selected").text();
|
||||
};
|
||||
};
|
||||
|
||||
export default ClassSelect;
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
import Chat from '../components/chat.js'
|
||||
import InternalMessages from "../components/internalMessagesSection.js"
|
||||
|
||||
let chat = new Chat($("#chat-factura"))
|
||||
chat.init()
|
||||
chat.initFactura()
|
||||
chat._handleListContacts()
|
||||
$(document).ready(() => {
|
||||
let chat = new Chat($("#chat-factura"))
|
||||
chat.init()
|
||||
chat.initFactura()
|
||||
let internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
|
||||
})
|
||||
@ -1,6 +1,11 @@
|
||||
import Chat from '../components/chat.js'
|
||||
import InternalMessages from "../components/internalMessagesSection.js"
|
||||
|
||||
let chat = new Chat($("#chat-pedido"))
|
||||
chat.init()
|
||||
chat.initPedido()
|
||||
chat._handleListContacts()
|
||||
$(document).ready(() => {
|
||||
let chat = new Chat($("#chat-pedido"))
|
||||
chat.init()
|
||||
chat.initPedido()
|
||||
let internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
|
||||
})
|
||||
@ -1,6 +1,11 @@
|
||||
import Chat from '../components/chat.js'
|
||||
import InternalMessages from "../components/internalMessagesSection.js"
|
||||
|
||||
let chat = new Chat($("#chat-presupuesto"))
|
||||
chat.init()
|
||||
chat.initPresupuesto()
|
||||
chat._handleListContacts()
|
||||
$(document).ready(() => {
|
||||
let chat = new Chat($("#chat-presupuesto"))
|
||||
chat.init()
|
||||
chat.initPresupuesto()
|
||||
let internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user