mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'refactor/messages-view' into 'main'
Refactor/messages view See merge request jjimenez/safekat!414
This commit is contained in:
@ -761,9 +761,36 @@ $routes->group('mensajes', ['namespace' => 'App\Controllers\Mensajeria'], functi
|
||||
$routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
|
||||
$routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);*/
|
||||
});
|
||||
});
|
||||
$routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($routes) {
|
||||
$routes->get('datatable', 'ChatController::datatable_messages', ['as' => 'getDatatableMessages']);
|
||||
$routes->get('datatable/presupuesto', 'ChatController::datatable_presupuesto_messages', ['as' => 'getDatatablePresupuestoMessages']);
|
||||
$routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']);
|
||||
$routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']);
|
||||
|
||||
$routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']);
|
||||
$routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']);
|
||||
|
||||
|
||||
});
|
||||
$routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($routes) {
|
||||
|
||||
$routes->get('direct/(:num)', 'ChatController::get_chat_direct_view/$1', ['as' => 'getChatDirectView']);
|
||||
$routes->get('presupuesto/(:num)', 'ChatController::get_chat_presupuesto_view/$1', ['as' => 'getChatPresupuestoView']);
|
||||
$routes->get('pedido/(:num)', 'ChatController::get_chat_pedido_view/$1', ['as' => 'getChatPedidoView']);
|
||||
$routes->get('factura/(:num)', 'ChatController::get_chat_factura_view/$1', ['as' => 'getChatFacturaView']);
|
||||
|
||||
$routes->get('direct/conversation/(:num)', 'ChatController::get_chat_direct/$1', ['as' => 'getChatDirect']);
|
||||
$routes->get('direct/users/select/(:num)', 'ChatController::get_chat_direct_select_users/$1', ['as' => 'getChatDirectSelectUsers']);
|
||||
$routes->get('direct/users/(:num)', 'ChatController::get_chat_direct_users', ['as' => 'getChatDirectUsers']);
|
||||
$routes->post('direct/users/(:num)', 'ChatController::store_chat_direct_users/$1', ['as' => 'storeChatDirectUsers']);
|
||||
$routes->get('direct/messages/(:num)', 'ChatController::get_chat_direct_messages/$1', ['as' => 'getChatDirectMessages']);
|
||||
$routes->post('direct/messages/(:num)', 'ChatController::store_chat_direct_message/$1', ['as' => 'storeChatDirectMessages']);
|
||||
$routes->post('direct/messages/unread/(:num)', 'ChatController::update_chat_direct_message_unread/$1', ['as' => 'updateChatDirectMessageUnread']);
|
||||
|
||||
|
||||
$routes->get('departments', 'ChatController::get_chat_departments', ['as' => 'getChatDepartments']);
|
||||
$routes->get('departments/select', 'ChatController::get_chat_department_select', ['as' => 'getChatDepartmentSelect']);
|
||||
$routes->get('department/presupuesto/(:num)/(:num)', 'ChatController::get_chat_presupuesto/$1/$2', ['as' => 'getChatPresupuesto']);
|
||||
$routes->get('department/pedido/(:num)/(:num)', 'ChatController::get_chat_pedido/$1/$2', ['as' => 'getChatPedido']);
|
||||
$routes->get('department/factura/(:num)/(:num)', 'ChatController::get_chat_factura/$1/$2', ['as' => 'getChatFactura']);
|
||||
@ -780,6 +807,8 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route
|
||||
$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->get('users/all', 'ChatController::get_chat_users_all', ['as' => 'getChatUsersAll']);
|
||||
|
||||
$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']);
|
||||
|
||||
@ -11,10 +11,13 @@ use App\Models\ChatNotification;
|
||||
use App\Models\ChatUser;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Services\MessageService;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\Log\Logger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class ChatController extends BaseController
|
||||
{
|
||||
@ -26,8 +29,8 @@ class ChatController extends BaseController
|
||||
protected ClienteModel $clienteModel;
|
||||
protected ChatUser $chatUserModel;
|
||||
protected ChatNotification $chatNotificationModel;
|
||||
|
||||
|
||||
protected array $viewData;
|
||||
protected static $viewPath = 'themes/vuexy/form/mensajes/';
|
||||
|
||||
|
||||
public function initController(
|
||||
@ -46,8 +49,6 @@ class ChatController extends BaseController
|
||||
$this->clienteModel = model(ClienteModel::class);
|
||||
$this->chatUserModel = model(ChatUser::class);
|
||||
$this->chatNotificationModel = model(ChatNotification::class);
|
||||
|
||||
|
||||
}
|
||||
public function index() {}
|
||||
public function get_chat_departments()
|
||||
@ -56,6 +57,10 @@ class ChatController extends BaseController
|
||||
$data = $this->chatDeparmentModel->getChatDepartments();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_department_select(){
|
||||
$query = $this->chatDeparmentModel->getChatDepartmentSelect($this->request->getGet("q"));
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
public function get_chat_presupuesto(int $chat_department_id, int $presupuesto_id)
|
||||
{
|
||||
|
||||
@ -86,7 +91,6 @@ class ChatController extends BaseController
|
||||
$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);
|
||||
@ -108,6 +112,76 @@ class ChatController extends BaseController
|
||||
$data["chat"] = $chat;
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_chat_direct_view($chat_id)
|
||||
{
|
||||
$chat = $this->chatModel->find($chat_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false],
|
||||
['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true]
|
||||
];
|
||||
$this->viewData["chatId"] = $chat_id;
|
||||
$auth_user = auth()->user();
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id);
|
||||
$this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id);
|
||||
|
||||
return view(static::$viewPath . 'messageChat', $this->viewData);
|
||||
}
|
||||
public function get_chat_presupuesto_view($chat_id)
|
||||
{
|
||||
$chat = $this->chatModel->find($chat_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false],
|
||||
['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true]
|
||||
];
|
||||
$this->viewData["modelId"] = $chat->presupuesto_id;
|
||||
$this->viewData["type"] = "presupuesto";
|
||||
$auth_user = auth()->user();
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id);
|
||||
$this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id);
|
||||
|
||||
if($chat->chat_department_id){
|
||||
return view(static::$viewPath . 'messageChatPresupuesto', $this->viewData);
|
||||
}else{
|
||||
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
|
||||
}
|
||||
}
|
||||
public function get_chat_pedido_view($chat_id)
|
||||
{
|
||||
$chat = $this->chatModel->find($chat_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false],
|
||||
['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true]
|
||||
];
|
||||
$this->viewData["modelId"] = $chat->pedido_id;
|
||||
$this->viewData["type"] = "pedido";
|
||||
$auth_user = auth()->user();
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id);
|
||||
$this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id);
|
||||
if($chat->chat_department_id ){
|
||||
return view(static::$viewPath . 'messageChatPedido', $this->viewData);
|
||||
}else{
|
||||
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
|
||||
}
|
||||
}
|
||||
public function get_chat_factura_view($chat_id)
|
||||
{
|
||||
$chat = $this->chatModel->find($chat_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false],
|
||||
['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true]
|
||||
];
|
||||
$this->viewData["modelId"] = $chat->factura_id;
|
||||
$this->viewData["type"] = "factura";
|
||||
$auth_user = auth()->user();
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id);
|
||||
$this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id);
|
||||
|
||||
if($chat->chat_department_id){
|
||||
return view(static::$viewPath . 'messageChatFactura', $this->viewData);
|
||||
}else{
|
||||
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
|
||||
}
|
||||
}
|
||||
public function get_chat(int $chat_id)
|
||||
{
|
||||
|
||||
@ -128,6 +202,12 @@ class ChatController extends BaseController
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
$chatDepartmentUsers = $this->chatDeparmentModel->getChatDepartmentUsers($data["chat_department_id"]);
|
||||
foreach ($chatDepartmentUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function store_chat_message_pedido()
|
||||
@ -143,6 +223,12 @@ class ChatController extends BaseController
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
$chatDepartmentUsers = $this->chatDeparmentModel->getChatDepartmentUsers($data["chat_department_id"]);
|
||||
foreach ($chatDepartmentUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function store_chat_message_factura()
|
||||
@ -158,6 +244,12 @@ class ChatController extends BaseController
|
||||
}
|
||||
$chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
$chatDepartmentUsers = $this->chatDeparmentModel->getChatDepartmentUsers($data["chat_department_id"]);
|
||||
foreach ($chatDepartmentUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function store_chat_message_single()
|
||||
@ -178,7 +270,7 @@ class ChatController extends BaseController
|
||||
"receiver_id" => $data["receiver_id"],
|
||||
]
|
||||
);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id,"user_id" =>$data["receiver_id"]]);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $data["receiver_id"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
@ -187,11 +279,11 @@ class ChatController extends BaseController
|
||||
$auth_user = auth()->user();
|
||||
if ($auth_user->cliente_id) {
|
||||
$users = $this->chatModel->getOpenChatCliente($auth_user->id);
|
||||
}else{
|
||||
} else {
|
||||
$users = $this->userModel->builder()
|
||||
->whereNotIn("id", [$auth_user->id])
|
||||
->where("deleted_at", null)
|
||||
->get()->getResultObject();
|
||||
->whereNotIn("id", [$auth_user->id])
|
||||
->where("deleted_at", null)
|
||||
->get()->getResultObject();
|
||||
}
|
||||
foreach ($users as $user) {
|
||||
$user->unreadMessages = $this->chatMessageModel->get_chat_messages_count($user->id);
|
||||
@ -275,7 +367,26 @@ class ChatController extends BaseController
|
||||
]
|
||||
)->where("cliente_id", null)
|
||||
->where("deleted_at", null)
|
||||
->whereNotIn("id",[auth()->user()->id]);
|
||||
->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 get_chat_users_all()
|
||||
{
|
||||
$query = $this->userModel->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"CONCAT(first_name,' ',last_name,'(',username,')') as name"
|
||||
]
|
||||
)
|
||||
->where("deleted_at", null)
|
||||
->whereNotIn("id", [auth()->user()->id]);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("users.username", $this->request->getGet("q"))
|
||||
@ -287,6 +398,7 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function store_hebra_presupuesto()
|
||||
{
|
||||
$auth_user = auth()->user();
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_id = $this->chatModel->insert([
|
||||
"presupuesto_id" => $bodyData["modelId"],
|
||||
@ -295,17 +407,19 @@ class ChatController extends BaseController
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"message" => $bodyData["message"],
|
||||
"sender_id" => auth()->user()->id
|
||||
"sender_id" => $auth_user->id
|
||||
]);
|
||||
if(isset($bodyData["users"])){
|
||||
$chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]);
|
||||
if (isset($bodyData["users"])) {
|
||||
$bodyData["users"][] = $auth_user->id;
|
||||
$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]);
|
||||
["chat_message_id" => $chatMessageId, "user_id" => $userId]
|
||||
);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente", "status" => true]);
|
||||
}
|
||||
|
||||
public function store_hebra_pedido()
|
||||
@ -321,15 +435,16 @@ class ChatController extends BaseController
|
||||
"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"]);
|
||||
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]);
|
||||
["chat_message_id" => $chatMessageId, "user_id" => $userId]
|
||||
);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente", "status" => true]);
|
||||
}
|
||||
|
||||
public function store_hebra_factura()
|
||||
@ -344,89 +459,242 @@ class ChatController extends BaseController
|
||||
"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"]);
|
||||
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]);
|
||||
["chat_message_id" => $chatMessageId, "user_id" => $userId]
|
||||
);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]);
|
||||
|
||||
return $this->response->setJSON(["message" => "Hebra creada correctamente", "status" => true]);
|
||||
}
|
||||
public function update_hebra($chat_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chatMessageId = $this->chatMessageModel->insert([
|
||||
$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);
|
||||
$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]);
|
||||
["chat_message_id" => $chatMessageId, "user_id" => $user_id]
|
||||
);
|
||||
}
|
||||
if(isset($bodyData["users"])){
|
||||
if (isset($bodyData["users"])) {
|
||||
foreach ($bodyData["users"] as $userId) {
|
||||
if(in_array($userId,$actualUsersArray) == false){
|
||||
$chatUserData = ["user_id" => $userId,"chat_id" => $chat_id];
|
||||
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]);
|
||||
["chat_message_id" => $chatMessageId, "user_id" => $userId]
|
||||
);
|
||||
}
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Hebra actualizada correctamente","status" => true]);
|
||||
return $this->response->setJSON(["message" => "Hebra actualizada correctamente", "status" => true]);
|
||||
}
|
||||
public function get_hebra_presupuesto($presupuesto_id){
|
||||
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();
|
||||
->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]);
|
||||
$this->chatNotificationModel->update($notification["id"], ["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_hebra_pedido($pedido_id){
|
||||
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();
|
||||
->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]);
|
||||
$this->chatNotificationModel->update($notification["id"], ["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function get_hebra_factura($factura_id){
|
||||
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();
|
||||
->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]);
|
||||
$this->chatNotificationModel->update($notification["id"], ["viewed" => true]);
|
||||
}
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
public function datatable_messages()
|
||||
{
|
||||
$auth_user_id = auth()->user()->id;
|
||||
$query = $this->chatModel->getQueryDatatable($auth_user_id);
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i"))
|
||||
->edit('updated_at', fn($q) => Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i"))
|
||||
->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName)
|
||||
->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id))
|
||||
->add("action", fn($q) => ["type" => "direct","modelId" => $q->id])
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_presupuesto_messages()
|
||||
{
|
||||
$auth_user_id = auth()->user()->id;
|
||||
$query = $this->chatModel->getQueryDatatableMessagePresupuesto($auth_user_id);
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "")
|
||||
->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName)
|
||||
->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id))
|
||||
->add("action", fn($q) => ["type" => "presupuesto","modelId" => $q->id])
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_pedido_messages()
|
||||
{
|
||||
$auth_user_id = auth()->user()->id;
|
||||
$query = $this->chatModel->getQueryDatatableMessagePedido($auth_user_id);
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "")
|
||||
->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName)
|
||||
->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id))
|
||||
->add("action", fn($q) => ["type" => "pedido","modelId" => $q->id])
|
||||
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_factura_messages()
|
||||
{
|
||||
$auth_user_id = auth()->user()->id;
|
||||
$query = $this->chatModel->getQueryDatatableMessageFactura($auth_user_id);
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "")
|
||||
->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName)
|
||||
->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id))
|
||||
->add("action", fn($q) => ["type" => "factura","modelId" => $q->id])
|
||||
|
||||
->toJson(true);
|
||||
}
|
||||
public function store_new_direct_message()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$rules = [
|
||||
"title" => "required|string",
|
||||
"message" => "required|string",
|
||||
"users" => "required",
|
||||
|
||||
];
|
||||
if (!$this->validate($rules)) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'message' => lang('App.global_alert_save_error'),
|
||||
'status' => 'error',
|
||||
'errors' => $this->validator->getErrors(),
|
||||
]);
|
||||
}
|
||||
$this->chatModel->createNewDirectChat(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("Chat.new_message_ok"), "status" => true]);
|
||||
}
|
||||
public function store_new_direct_message_client()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$rules = [
|
||||
"title" => "required|string",
|
||||
"message" => "required|string",
|
||||
"chat_department_id" => "required",
|
||||
|
||||
];
|
||||
if (!$this->validate($rules)) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'message' => lang('App.global_alert_save_error'),
|
||||
'status' => 'error',
|
||||
'errors' => $this->validator->getErrors(),
|
||||
]);
|
||||
}
|
||||
$users = $this->chatDeparmentModel->getChatDepartmentUsers($bodyData["chat_department_id"]);
|
||||
$bodyData["users"] = array_map(fn($q) => $q->id,$users);
|
||||
dd(1);
|
||||
$this->chatModel->createNewDirectChat(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("Chat.new_message_ok"), "status" => true]);
|
||||
}
|
||||
public function get_chat_direct($chat_id)
|
||||
{
|
||||
$chatData = $this->chatModel->getChatDirect($chat_id);
|
||||
return $this->response->setJSON($chatData);
|
||||
}
|
||||
public function get_chat_direct_select_users($chat_id)
|
||||
{
|
||||
$chat_users_id = $this->chatUserModel->getChatUserArrayId($chat_id);
|
||||
|
||||
$query = $this->userModel->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"CONCAT(first_name,' ',last_name,'(',username,')') as name"
|
||||
]
|
||||
)
|
||||
->where("deleted_at", null)
|
||||
->whereNotIn("id", $chat_users_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_chat_direct_users($chat_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$chat_users = [];
|
||||
foreach ($bodyData["users"] as $user_id) {
|
||||
$chat_users[] = ["chat_id" => $chat_id, "user_id" => $user_id];
|
||||
if ($bodyData["notification"]) {
|
||||
$this->chatModel->createNotificationsToNewChatUser($chat_id, $user_id);
|
||||
}
|
||||
}
|
||||
$this->chatUserModel->insertBatch($chat_users);
|
||||
return $this->response->setJSON(["message" => "ok", "status" => true]);
|
||||
}
|
||||
public function store_chat_direct_message(int $chat_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$auth_user = auth()->user();
|
||||
$bodyData["sender_id"] = $auth_user->id;
|
||||
$chat_message_id = $this->chatMessageModel->insert($bodyData);
|
||||
$users_id = $this->chatUserModel->getChatUserArrayId($chat_id);
|
||||
foreach ($users_id as $user_id) {
|
||||
if ($user_id != $auth_user->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user_id]);
|
||||
}
|
||||
};
|
||||
$message = $this->chatMessageModel->get_chat_message($chat_message_id);
|
||||
return $this->response->setJSON($message);
|
||||
}
|
||||
public function update_chat_direct_message_unread($chat_id)
|
||||
{
|
||||
$this->chatModel->setAsUnviewedChatUserNotifications($chat_id, auth()->user()->id);
|
||||
return $this->response->setJSON(["message" => "ok", "status" => true]);
|
||||
}
|
||||
}
|
||||
|
||||
52
ci4/app/Database/Seeds/MessageSeeder.php
Normal file
52
ci4/app/Database/Seeds/MessageSeeder.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
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 CodeIgniter\Database\Seeder;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
class MessageSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
|
||||
$data = [
|
||||
"title" => "Message Test",
|
||||
"messages" => [
|
||||
[
|
||||
"sender_id" => 1,
|
||||
"receiver_id" => 127,
|
||||
],
|
||||
[
|
||||
"sender_id" => 127,
|
||||
"receiver_id" => 1,
|
||||
]
|
||||
]
|
||||
];
|
||||
$chatModel = model(ChatModel::class);
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
$chatNotificationModel = model(ChatNotification::class);
|
||||
$userModel = model(UserModel::class);
|
||||
foreach (range(1,100) as $key => $value) {
|
||||
$chat_id = $chatModel->insert(["title" => $data["title"]." ".$value]);
|
||||
foreach ($data["messages"] as $key => $value) {
|
||||
$first_name = $userModel->find($value["receiver_id"])?->first_name;
|
||||
$chat_message_id = $chatMessageModel->insert([
|
||||
"chat_id" => $chat_id,
|
||||
"sender_id" => $value["sender_id"],
|
||||
"receiver_id" => $value["receiver_id"],
|
||||
"message" => "Hola"." ".$first_name
|
||||
]);
|
||||
$chatNotificationModel->insert([
|
||||
"chat_message_id" => $chat_message_id,
|
||||
"user_id" => $value["receiver_id"]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
return [
|
||||
"chat" => "Mensajería",
|
||||
"messages" => "Mensajes",
|
||||
"message" => "Mensaje",
|
||||
"modal" => [
|
||||
"new_hebra" => "Nuevo hilo",
|
||||
"title" => "Título",
|
||||
@ -10,5 +11,22 @@ return [
|
||||
"new_receivers" => "Nuevos participantes",
|
||||
"btn_send" => "Enviar",
|
||||
"btn_send_update" => "Enviar"
|
||||
]
|
||||
],
|
||||
"datatable_messages" => [
|
||||
"created_at" => "Fecha creación",
|
||||
"updated_at" => "Fecha actualización",
|
||||
"title" => "Título",
|
||||
"creator" => "Creador",
|
||||
"viewed" => "Leído",
|
||||
|
||||
],
|
||||
"new_message_ok" => "Mensaje enviado correctamente",
|
||||
"participants" => "Participantes",
|
||||
"choose_department" => "Elige un departamento",
|
||||
"new_participant" => "Añadir nuevos participantes",
|
||||
"write_message_placeholder" => "Escriba aquí su mensaje...",
|
||||
"add_notification" => "Notificación",
|
||||
"check_as_unviewed" => "Marcar como no leídos",
|
||||
"add_notification_message" => "Envía a los usuarios añadidos una notificación con los mensajes presentes en el chat.",
|
||||
"chat_title_presupuesto" => 'Presupuesto[{title,string,0}][{id}]'
|
||||
];
|
||||
@ -10,7 +10,7 @@ class ChatDeparmentModel extends Model
|
||||
protected $table = 'chat_departments';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
@ -126,4 +126,21 @@ class ChatDeparmentModel extends Model
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
public function getDisplay(int $chat_deparment_id) : string
|
||||
{
|
||||
return $this->find($chat_deparment_id)->display;
|
||||
}
|
||||
public function getChatDepartmentSelect(string $query = null)
|
||||
{
|
||||
$q = $this->builder()->select([
|
||||
"id",
|
||||
"display as name",
|
||||
"description"
|
||||
]);
|
||||
if($query){
|
||||
$q->orLike("display",$query)
|
||||
->orLike("name",$query);
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,14 +5,15 @@ namespace App\Models\Chat;
|
||||
use App\Models\ChatNotification;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
|
||||
class ChatMessageModel extends Model
|
||||
{
|
||||
protected $table = 'chat_messages';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"message",
|
||||
@ -29,7 +30,7 @@ class ChatMessageModel extends Model
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
@ -72,6 +73,23 @@ class ChatMessageModel extends Model
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
public function get_chat_message(int $chat_message_id): object
|
||||
{
|
||||
$user = model(UserModel::class);
|
||||
$auth_user = auth()->user();
|
||||
$message = $this->find($chat_message_id);
|
||||
$message->pos = $auth_user->id == $message->sender_id ? "right" : "left";
|
||||
if ($auth_user->id == $message->sender_id) {
|
||||
$message->sender_first_name = $auth_user->first_name;
|
||||
$message->sender_last_name = $auth_user->last_name;
|
||||
|
||||
} else {
|
||||
$sender_user = $user->find($message->sender_id);
|
||||
$message->sender_first_name = $sender_user->first_name;
|
||||
$message->sender_last_name = $sender_user->last_name;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
public function get_chat_contact_messages(int $receiver_id): array
|
||||
{
|
||||
$conversationArray = [];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -47,4 +47,16 @@ class ChatNotification extends Model
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function isChatMessageViewed(int $chat_message_id) : bool
|
||||
{
|
||||
$status = false;
|
||||
$count = $this->where("chat_message_id",$chat_message_id)->where("viewed",false)->countAllResults();
|
||||
if($count>0){
|
||||
$status = false;
|
||||
}else{
|
||||
$status = true;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ class ChatUser extends Model
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"user_id",
|
||||
@ -24,7 +24,7 @@ class ChatUser extends Model
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
@ -46,4 +46,12 @@ class ChatUser extends Model
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
public function getChatUserArrayId(int $chat_id) : array
|
||||
{
|
||||
$queryResult = $this->builder()
|
||||
->select(['chat_users.user_id'])
|
||||
->where("chat_users.chat_id",$chat_id)
|
||||
->get()->getResultObject();
|
||||
return array_map(fn($q) => $q->user_id,$queryResult);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,5 +91,4 @@ class UserModel extends ShieldUserModel
|
||||
return $result === null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
14
ci4/app/Services/MessageService.php
Normal file
14
ci4/app/Services/MessageService.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
class MessageService extends BaseService
|
||||
{
|
||||
public static function get_chat_title_from_presupuesto(int $presuesto_id,?string $department_name = null) : string
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
ci4/app/Views/themes/vuexy/components/alerts/alert.php
Normal file
11
ci4/app/Views/themes/vuexy/components/alerts/alert.php
Normal file
@ -0,0 +1,11 @@
|
||||
<div class="alert alert-success d-flex align-items-baseline d-none" role="alert" id="<?= $id ?>">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-sm icon-alert"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"></h5>
|
||||
<div class="alert-body">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
153
ci4/app/Views/themes/vuexy/components/chat_direct.php
Normal file
153
ci4/app/Views/themes/vuexy/components/chat_direct.php
Normal file
@ -0,0 +1,153 @@
|
||||
<div class="col-md-12" id="chat-direct-message" data-id="<?= $modelId ?>" data-user-id="<?= $userId ?>">
|
||||
<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">
|
||||
<?php if (auth()->user()->inGroup('admin')) { ?>
|
||||
<div class="flex-shrink-0 avatar me-3">
|
||||
<button title="<?= lang("Chat.new_participant") ?>" class="btn btn-primary btn-icon me-2 rounded-circle" id="btn-chat-add-participant"><span class="ti ti-sm ti-user-plus"></span></button>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<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>
|
||||
<div class="sidebar-body">
|
||||
|
||||
<!-- CLIENTES -->
|
||||
<ul class="list-unstyled chat-contact-list mb-0">
|
||||
|
||||
<li class="chat-contact-list-item chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0"><?= lang("Chat.participants") ?></h5>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="list-unstyled chat-contact-list mb-0" id="contact-list">
|
||||
|
||||
<div class="d-flex justify-content-center chat-loader">
|
||||
<div class="sk-wave sk-primary ">
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <li class="chat-contact-list-item">
|
||||
<a class="d-flex align-items-center">
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span class="avatar-initial rounded-circle bg-label-primary">JJ</span>
|
||||
</div>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="chat-contact-name text-truncate m-0">Jaime Jimenez</h6>
|
||||
</div>
|
||||
</a>
|
||||
</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>
|
||||
<h5 class="text-primary mb-0" id="chat-direct-title"><br></h5>
|
||||
<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">
|
||||
<button class="btn p-0" type="button" id="chat-header-actions"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
<i class="ti ti-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end"
|
||||
aria-labelledby="chat-header-actions">
|
||||
<a class="dropdown-item" id="update-message-unviewed" href="javascript:void(0);"><?= lang("Chat.check_as_unviewed") ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<div class="d-flex justify-content-center chat-loader">
|
||||
<div class="sk-wave sk-primary ">
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
</div>
|
||||
</div>
|
||||
<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="<?= lang("Chat.write_message_placeholder") ?>" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<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-direct">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block"><?= lang("Chat.modal.btn_send") ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Chat History -->
|
||||
|
||||
<div class="app-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= view("themes/vuexy/components/modals/modalAddNewChatParticipant") ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
<!------------------------------------------------------->
|
||||
<!-- Código JS logica -->
|
||||
<!------------------------------------------------------->
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script type="module" src="<?= site_url('assets/js/safekat/pages/messages/directMessagePage.js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,4 +1,4 @@
|
||||
<div class="container-xxl flex-grow-1 container-p-y" id="chat-factura" data-id="<?= $modelId ?>">
|
||||
<div class="col-md-12" id="chat-factura" data-id="<?= $modelId ?>">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
|
||||
@ -30,9 +30,10 @@
|
||||
</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>
|
||||
<div class="d-flex justify-content-center chat-loader">
|
||||
|
||||
</div>
|
||||
|
||||
<!-- CHAT LIST -->
|
||||
|
||||
</ul>
|
||||
@ -76,6 +77,15 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<div class="d-flex justify-content-center chat-loader">
|
||||
<div class="sk-wave sk-primary ">
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
@ -112,6 +122,7 @@
|
||||
</div>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
<!------------------------------------------------------->
|
||||
|
||||
@ -137,6 +137,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
<!------------------------------------------------------->
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<div class="container-xxl flex-grow-1 container-p-y" id="chat-pedido" data-id="<?= $modelId ?>">
|
||||
<div class="col-md-12" id="chat-pedido" data-id="<?= $modelId ?>">
|
||||
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
@ -31,9 +31,8 @@
|
||||
</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>
|
||||
@ -76,6 +75,15 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<div class="d-flex justify-content-center chat-loader">
|
||||
<div class="sk-wave sk-primary ">
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
@ -113,6 +121,7 @@
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
<!------------------------------------------------------->
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<div id="chat-presupuesto" data-id="<?= $modelId ?>">
|
||||
<div class="col-md-12" id="chat-presupuesto" data-id="<?= $modelId ?>">
|
||||
<div class="app-chat card overflow-hidden">
|
||||
<div class="row g-0">
|
||||
|
||||
@ -30,9 +30,8 @@
|
||||
</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>
|
||||
@ -76,9 +75,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-history-body bg-body ">
|
||||
<div class="d-flex justify-content-center chat-loader">
|
||||
<div class="sk-wave sk-primary ">
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
<div class="sk-wave-rect"></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-unstyled chat-history" id="chat-conversation">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Chat message form -->
|
||||
@ -112,6 +119,7 @@
|
||||
</div>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
<!------------------------------------------------------->
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="modalAddNewChatParticipant" 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_receivers') ?></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="col-12 mb-0">
|
||||
<?= view("themes/vuexy/components/alerts/alert", ["id" => "alertNewParticipant"]) ?>
|
||||
</div>
|
||||
<form id="formNewParticipant">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-2">
|
||||
<label for="select-users" class="required form-label"><?= lang('Chat.modal.new_receivers') ?></label>
|
||||
<select id="select-users" name="users" class="select2 form-control" multiple required>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 mb-2">
|
||||
<div class="text-light small fw-medium mb-2"><?= lang("Chat.add_notification") ?></div>
|
||||
<label class="switch">
|
||||
<input type="checkbox" class="switch-input" name="notification" id="checkbox-notification-chat" checked />
|
||||
<span class="switch-toggle-slider">
|
||||
<span class="switch-on"></span>
|
||||
<span class="switch-off"></span>
|
||||
</span>
|
||||
<span class="switch-label"><?= lang("Chat.add_notification_message") ?></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-label-secondary" data-bs-dismiss="modal"><?= lang('App.global_come_back') ?></button>
|
||||
<button type="button" id="btn-chat-add-participant-submit" class="btn btn-primary d-none"><?= lang('App.global_save') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,47 @@
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="modalNewDirectMessage" 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_message') ?></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="col-12 mb-0">
|
||||
<?= view("themes/vuexy/components/alerts/alert", ["id" => "alertDirectMessage"]) ?>
|
||||
</div>
|
||||
<form id="formNewDirectMessage">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12 mb-0">
|
||||
<label for="new-direct-message-title" class="form-label"><?= lang('Chat.modal.title') ?></label>
|
||||
<input type="input" rows="4" cols="10" id="new-direct-message-title" name="title" placeholder="Escriba un título" name="title" class="form-control" required />
|
||||
</div>
|
||||
<div class="col-12 mb-0">
|
||||
<label for="description" class="required form-label"><?= lang('Chat.modal.new_message') ?></label>
|
||||
<textarea type="input" rows="4" cols="10" id="new-direct-message-text" name="message" placeholder="Escribe el mensaje ..." name="message" class="form-control" required></textarea>
|
||||
</div>
|
||||
<div class="col-12 mb-0">
|
||||
<label for="select-users" class="required form-label"><?= lang('Chat.modal.new_receivers') ?></label>
|
||||
<select id="select-users" name="users" class="form-control" multiple required>
|
||||
<option value="0"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-label-secondary" data-bs-dismiss="modal"><?= lang('App.global_come_back') ?></button>
|
||||
<?php if (auth()->user()->inGroup('admin')) { ?>
|
||||
<button type="button" id="submit-new-direct-message" class="btn btn-primary"><?= lang('Chat.modal.btn_send') ?></button>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,15 @@
|
||||
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Chat.datatable_messages.created_at') ?></th>
|
||||
<th><?= lang('Chat.datatable_messages.updated_at') ?></th>
|
||||
<th><?= lang('Chat.datatable_messages.title') ?></th>
|
||||
<th><?= lang('Chat.datatable_messages.creator') ?></th>
|
||||
<th><?= lang('Chat.datatable_messages.viewed') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@ -1,10 +1,73 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<!--Content Body-->
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<?= view("themes/vuexy/components/chat_general", data: ["modelId" => null]) ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="nav-tabs-shadow nav-align-top">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" id="navs-top-align-directos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-directos">Directos</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-presupuestos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-presupuestos">Presupuestos</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-pedidos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-pedidos">Pedidos</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-facturas-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-facturas">Facturas</button>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="tab-content" id="message-datatables-container">
|
||||
<div class="tab-pane fade show active" id="navs-top-align-directos">
|
||||
<?php if (auth()->user()->inGroup('admin')) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12 d-flex justify-content-start">
|
||||
<button class="btn btn-primary" id="btn-new-message"><span class="ti ti-md ti-plus"></span>Nuevo mensaje</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tableMessages"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-presupuestos">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tablePresupuestoMessages"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-pedidos">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tablePedidoMessages"]) ?>
|
||||
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-facturas">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tableFacturaMessages"]) ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!--//.card -->
|
||||
</div>
|
||||
</div>
|
||||
<!--//.col -->
|
||||
</div>
|
||||
|
||||
<?= view("themes/vuexy/components/modals/modalNewDirectMessage") ?>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/messages/index.js') ?>">
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
27
ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php
Normal file
27
ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<!--Content Body-->
|
||||
<div class="row">
|
||||
<?= view("themes/vuexy/components/chat_direct",["modelId" => $chatId,"userId" => auth()->user()->id]) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,30 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<!--Content Body-->
|
||||
<div class="row">
|
||||
|
||||
|
||||
<?= view("themes/vuexy/components/chat_factura",["modelId" => $modelId]) ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,28 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<!--Content Body-->
|
||||
<div class="row">
|
||||
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId, "type" => $type]) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/messages/internalMessagePage.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,27 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<!--Content Body-->
|
||||
<div class="row">
|
||||
<?= view("themes/vuexy/components/chat_pedido",["modelId" => $modelId]) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,27 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<!--Content Body-->
|
||||
<div class="row">
|
||||
<?= view("themes/vuexy/components/chat_presupuesto", ["modelId" => $modelId]) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/pages/app-chat.css') ?>">
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -147,18 +147,6 @@ $picture = "/assets/img/default-user.png";
|
||||
</div>
|
||||
</li>
|
||||
<!-- Notification -->
|
||||
<li class="nav-item dropdown-notifications navbar-dropdown dropdown me-3 me-xl-1">
|
||||
<a
|
||||
class="nav-link dropdown-toggle hide-arrow"
|
||||
href="javascript:void(0);"
|
||||
data-bs-toggle="dropdown"
|
||||
data-bs-auto-close="outside"
|
||||
aria-expanded="false">
|
||||
<i class="ti ti-bell ti-md"></i>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<!--/ Notification -->
|
||||
|
||||
<!-- Search Budgets -->
|
||||
<li class="nav-item navbar-dropdown dropdown me-3 me-xl-1">
|
||||
|
||||
53
httpdocs/assets/js/safekat/components/alerts/alert.js
Normal file
53
httpdocs/assets/js/safekat/components/alerts/alert.js
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
class Alert {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.headingTitle = this.item.find(".alert-heading")
|
||||
this.body = this.item.find(".alert-body")
|
||||
this.icon = this.item.find(".icon-alert")
|
||||
this.iconSuccess = "ti-circle-check"
|
||||
this.iconError = "ti-exclamation-mark"
|
||||
|
||||
|
||||
|
||||
}
|
||||
setIcon(iconClass){
|
||||
this.icon.removeClass(this.iconSuccess)
|
||||
this.icon.removeClass(this.iconError)
|
||||
this.icon.addClass(iconClass)
|
||||
}
|
||||
setAsError() {
|
||||
this.item.removeClass("alert-success")
|
||||
this.item.addClass("alert-danger")
|
||||
this.setIcon(this.iconError)
|
||||
|
||||
}
|
||||
setAsSuccess() {
|
||||
this.item.removeClass("alert-danger")
|
||||
this.item.addClass("alert-success")
|
||||
this.setIcon(this.iconSuccess)
|
||||
}
|
||||
setAsWarning() {
|
||||
this.item.removeClass("alert-success")
|
||||
this.item.addClass("alert-warning")
|
||||
}
|
||||
setAsInfo() {
|
||||
this.item.removeClass("alert-*")
|
||||
this.item.addClass("alert-info")
|
||||
}
|
||||
show() {
|
||||
this.item.removeClass("d-none")
|
||||
}
|
||||
hide() {
|
||||
this.item.addClass("d-none")
|
||||
}
|
||||
setHeadingTitle(title) {
|
||||
this.headingTitle.text(title)
|
||||
}
|
||||
setContent(content) {
|
||||
this.body.append(content)
|
||||
}
|
||||
setErrors() { }
|
||||
}
|
||||
|
||||
export default Alert;
|
||||
@ -1,4 +1,6 @@
|
||||
import Ajax from '../components/ajax.js'
|
||||
import Modal from './modal.js'
|
||||
import ClassSelect from './select2.js'
|
||||
|
||||
|
||||
|
||||
@ -66,12 +68,43 @@ class Chat {
|
||||
});
|
||||
}
|
||||
}
|
||||
initDirectMessage() {
|
||||
this.chatType = "direct"
|
||||
this.modalNewParticipant = new Modal(this.domItem.find("#modalAddNewChatParticipant"))
|
||||
this.selectPlaceholder = {
|
||||
id: '0',
|
||||
text: "Seleccione un usuario"
|
||||
}
|
||||
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.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")
|
||||
|
||||
this.btnAddParticipant = this.domItem.find("#btn-chat-add-participant")
|
||||
this.btnAddParticipantSubmit = this.domItem.find("#btn-chat-add-participant-submit")
|
||||
this.btnAddParticipantSubmit.on("click", this._handleStoreChatDirectUsers.bind(this))
|
||||
this.btnAddParticipant.on("click", () => {
|
||||
this.selectParticipants.init()
|
||||
this.modalNewParticipant.toggle()
|
||||
})
|
||||
|
||||
this.selectParticipants.item.on("change", () => {
|
||||
if (this.selectParticipants.getVal().length > 0) {
|
||||
this.btnAddParticipantSubmit.removeClass("d-none")
|
||||
} else {
|
||||
this.btnAddParticipantSubmit.addClass("d-none")
|
||||
}
|
||||
})
|
||||
this.btnUpdateMessagesUnviewed.on("click",this._handleUpdateChatMessagesUnread.bind(this))
|
||||
this._handleGetChatDirect()
|
||||
setInterval(this._handleReloadChatDirectMessages.bind(this),10000)
|
||||
}
|
||||
initGeneral() {
|
||||
this.chatType = "general"
|
||||
this._handleGetChatList()
|
||||
this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this))
|
||||
|
||||
|
||||
}
|
||||
initPresupuesto() {
|
||||
this.chatType = "presupuesto"
|
||||
@ -128,18 +161,18 @@ class Chat {
|
||||
* PRESUPUESTOS
|
||||
*=============================================**/
|
||||
_handleGetChatList(event) {
|
||||
this.domItem.find(".chat-loader").removeClass("d-none")
|
||||
let ajax = new Ajax(
|
||||
"/chat/departments",
|
||||
null,
|
||||
null,
|
||||
this._handleGetChatListSuccess.bind(this),
|
||||
this._handleGetChatListError.bind(this),
|
||||
|
||||
|
||||
);
|
||||
ajax.get();
|
||||
}
|
||||
_handleGetChatListSuccess(data) {
|
||||
this.domItem.find(".chat-loader").addClass("d-none")
|
||||
Object.values(data).map(row => {
|
||||
this.chatList.append(this._getContact(row))
|
||||
this.chatDeparmentId = row.id
|
||||
@ -147,6 +180,7 @@ class Chat {
|
||||
this.chatList.find(`#chat_${row.name}`).on("click", (event) => {
|
||||
$(".chat-contact-list-item").removeClass("active")
|
||||
$(event.currentTarget).parent().addClass("active")
|
||||
this.chatHistory.empty()
|
||||
this.chatDeparmentId = this.chatList.find(`#chat_${row.name}`).data("id")
|
||||
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)
|
||||
@ -216,7 +250,7 @@ class Chat {
|
||||
${row.display}
|
||||
</p>
|
||||
</div>
|
||||
<span class="badge badge-center rounded-pill bg-danger messages-unread-contact">${row.totalMessages ?? 0}</span>
|
||||
<span class="badge badge-center rounded-pill bg-secondary messages-unread-contact">${row.totalMessages ?? 0}</span>
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
@ -236,8 +270,7 @@ class Chat {
|
||||
);
|
||||
ajax.get();
|
||||
}
|
||||
_getChatDepartmentMessageCount()
|
||||
{
|
||||
_getChatDepartmentMessageCount() {
|
||||
let ajax = new Ajax(
|
||||
`/chat/department/count/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`,
|
||||
null,
|
||||
@ -249,12 +282,14 @@ class Chat {
|
||||
);
|
||||
ajax.get();
|
||||
}
|
||||
_getChatDepartmentMessageCountSuccess(data){
|
||||
_getChatDepartmentMessageCountSuccess(data) {
|
||||
this.domItem.find(`chat_${data.name}`).find(".messages-unread-contact").text(data.count)
|
||||
}
|
||||
_getChatDepartmentMessageCountError(){}
|
||||
_getChatDepartmentMessageCountError() { }
|
||||
|
||||
_getChatMessage() {
|
||||
this.chatHistory.empty()
|
||||
this.domItem.find(".chat-loader").removeClass("d-none")
|
||||
let ajax = new Ajax(
|
||||
`/chat/department/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`,
|
||||
null,
|
||||
@ -267,7 +302,7 @@ class Chat {
|
||||
ajax.get();
|
||||
}
|
||||
_getChatMessageSuccess(data) {
|
||||
this.chatHistory.empty()
|
||||
this.domItem.find(".chat-loader").addClass("d-none")
|
||||
this._setBtnDeparment()
|
||||
if (data.messages) {
|
||||
data.messages.map((m) => {
|
||||
@ -288,12 +323,12 @@ class Chat {
|
||||
<div class="chat-message-text">
|
||||
<p class="mb-0">${chatMessage?.message}</p>
|
||||
</div>
|
||||
<div class="text-end text-muted mt-1">
|
||||
<div class="text-start text-muted mt-1">
|
||||
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
|
||||
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
|
||||
<i class="ti me-1"></i>
|
||||
<small>${chatMessage?.user?.first_name + " " + chatMessage?.user?.last_name}</small>
|
||||
</div>
|
||||
<i class="ti ti-checks ti-xs me-1 text-success"></i>
|
||||
<i class="ti ${chatMessage?.viewed ? "ti-checks" : "ti-check"} ti-xs me-1 text-success"></i>
|
||||
<small>${chatMessage.created_at}</small>
|
||||
</div>
|
||||
|
||||
@ -309,6 +344,36 @@ class Chat {
|
||||
this.chatHistory.append(chatItem)
|
||||
return chatItem
|
||||
}
|
||||
_addChatDirectMessages(chatMessage) {
|
||||
let chatItem = `
|
||||
<li class="chat-message chat-message-${chatMessage.pos}">
|
||||
<div class="d-flex overflow-hidden">
|
||||
<div class="chat-message-wrapper flex-grow-1">
|
||||
|
||||
<div class="chat-message-text">
|
||||
<p class="mb-0">${chatMessage?.message}</p>
|
||||
</div>
|
||||
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
|
||||
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
|
||||
<i class="ti me-1"></i>
|
||||
<small>${chatMessage?.sender_first_name + " " + chatMessage?.sender_last_name}</small>
|
||||
</div>
|
||||
<i class="ti ${chatMessage?.viewed == "1" ? "ti-checks" : "ti-check"} ti-xs me-1 text-success"></i>
|
||||
<small>${chatMessage.created_at}</small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="user-avatar flex-shrink-0 ms-3">
|
||||
<div class="avatar avatar-sm">
|
||||
<span class="avatar-initial rounded-circle bg-label-primary">${chatMessage?.sender_first_name.charAt(0) + chatMessage?.sender_last_name.charAt(0)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
`
|
||||
this.chatHistory.append(chatItem)
|
||||
return chatItem
|
||||
}
|
||||
_sendMessagePressKey(e) {
|
||||
if (e.which == 13) {
|
||||
e.preventDefault();
|
||||
@ -491,7 +556,7 @@ class Chat {
|
||||
</p>
|
||||
</div>
|
||||
${contact.unreadMessages ? `<span
|
||||
class="badge badge-center rounded-pill bg-danger messages-unread-contact">${contact.unreadMessages}</span>` : ""}
|
||||
class="badge badge-center rounded-pill bg-secondary messages-unread-contact">${contact.unreadMessages}</span>` : ""}
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
@ -500,6 +565,145 @@ class Chat {
|
||||
this.sideBar.find("#contact-list").append(contactItem)
|
||||
}
|
||||
}
|
||||
_addParticipantToList(contact) {
|
||||
let contactItem =
|
||||
`
|
||||
<li class="chat-contact-list-item ${this.authUserId == contact.id ? "active" : ""}">
|
||||
<div class="d-flex align-items-center contact-chat" data-id="${contact.id}"
|
||||
id="chat-contact-list-item-${contact.id}">
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
<span class="avatar-initial rounded-circle bg-label-primary">
|
||||
${contact?.first_name?.charAt(0) ?? "?"
|
||||
+ contact?.last_name?.charAt(0) ?? "?"}</span>
|
||||
|
||||
</div>
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="chat-contact-name text-truncate m-0">${contact?.first_name ?? "" + " " +
|
||||
contact?.last_name ?? ""}</h6>
|
||||
<p class="chat-contact-status text-muted text-truncate mb-0">
|
||||
${contact?.cliente_id ? "[CLIENTE]" : ""}${contact.username}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
`
|
||||
|
||||
if (contact.first_name || contact.last_name) {
|
||||
this.sideBar.find("#contact-list").append(contactItem)
|
||||
}
|
||||
}
|
||||
_handleGetChatDirect() {
|
||||
const ajax = new Ajax(
|
||||
`/chat/${this.chatType}/conversation/${this.modelId}`,
|
||||
null,
|
||||
null,
|
||||
this._handleGetChatDirectSuccess.bind(this),
|
||||
this._handleGetChatDirectError.bind(this)
|
||||
)
|
||||
ajax.get()
|
||||
}
|
||||
|
||||
_handleGetChatDirectSuccess(response) {
|
||||
const { chat, users, messages } = response
|
||||
if (users.length > 0) {
|
||||
users.map(c => this._addParticipantToList(c))
|
||||
}
|
||||
if (messages.length > 0) {
|
||||
messages.map(m => this._addChatDirectMessages(m))
|
||||
}
|
||||
this.domItem.find("#chat-direct-title").text(chat.title)
|
||||
this.domItem.find(".chat-loader").addClass("d-none")
|
||||
}
|
||||
_handleGetChatDirectError(error) { }
|
||||
_handleReloadChatDirectMessages() {
|
||||
const ajax = new Ajax(
|
||||
`/chat/${this.chatType}/conversation/${this.modelId}`,
|
||||
null,
|
||||
null,
|
||||
this._handleReloadChatDirectMessagesSuccess.bind(this),
|
||||
this._handleReloadChatDirectMessagesError.bind(this)
|
||||
)
|
||||
ajax.get()
|
||||
}
|
||||
_handleReloadChatDirectMessagesSuccess(response) {
|
||||
const { chat, users, messages } = response
|
||||
this.chatHistory.empty()
|
||||
|
||||
if (messages.length > 0) {
|
||||
messages.map(m => this._addChatDirectMessages(m))
|
||||
}
|
||||
this.domItem.find("#chat-direct-title").text(chat.title)
|
||||
this.domItem.find(".chat-loader").addClass("d-none")
|
||||
}
|
||||
_handleReloadChatDirectMessagesError(error) { }
|
||||
_handleStoreChatDirectUsers() {
|
||||
const data = { "users": this.selectParticipants.getVal() ,"notification" : this.checkboxNotificationMessage.prop("checked")}
|
||||
this.domItem.find(".chat-loader").removeClass("d-none")
|
||||
|
||||
const ajax = new Ajax(
|
||||
`/chat/${this.chatType}/users/${this.modelId}`,
|
||||
data,
|
||||
null,
|
||||
this._handleStoreChatDirectUsersSuccess.bind(this),
|
||||
this._handleStoreChatDirectUsersError.bind(this)
|
||||
)
|
||||
ajax.post()
|
||||
}
|
||||
_handleStoreChatDirectUsersSuccess(response) {
|
||||
this.domItem.find(".chat-loader").removeClass("d-none")
|
||||
this.chatHistory.empty()
|
||||
this.sideBar.find("#contact-list").empty()
|
||||
this.modalNewParticipant.toggle()
|
||||
this._handleGetChatDirect()
|
||||
this.selectParticipants.reset()
|
||||
}
|
||||
_handleStoreChatDirectUsersError() {
|
||||
this.domItem.find(".chat-loader").removeClass("d-none")
|
||||
}
|
||||
_handleStoreChatDirectMessage() {
|
||||
const data = { "message": this.messageInput.val(), "chat_id": this.modelId }
|
||||
if (data.message) {
|
||||
const ajax = new Ajax(
|
||||
`/chat/${this.chatType}/messages/${this.modelId}`,
|
||||
data,
|
||||
null,
|
||||
this._handleStoreChatDirectMessageSuccess.bind(this),
|
||||
this._handleStoreChatDirectMessageError.bind(this)
|
||||
)
|
||||
ajax.post()
|
||||
}
|
||||
}
|
||||
_handleStoreChatDirectMessageSuccess(response) {
|
||||
try {
|
||||
let message = response
|
||||
this._addChatDirectMessages(message)
|
||||
this.messageInput.val("")
|
||||
} catch (error) {
|
||||
|
||||
} finally {
|
||||
this.scrollbarChatHistory.update()
|
||||
this.chatHistoryBody[0].scrollTop = this.scrollbarChatHistory.containerHeight
|
||||
}
|
||||
|
||||
}
|
||||
_handleStoreChatDirectMessageError(error) { }
|
||||
|
||||
_handleUpdateChatMessagesUnread() {
|
||||
const ajax = new Ajax(
|
||||
`/chat/${this.chatType}/messages/unread/${this.modelId}`,
|
||||
null,
|
||||
null,
|
||||
this._handleUpdateChatMessagesUnreadSuccess.bind(this),
|
||||
this._handleUpdateChatMessagesUnreadError.bind(this)
|
||||
)
|
||||
ajax.post()
|
||||
}
|
||||
_handleUpdateChatMessagesUnreadSuccess(){
|
||||
this._handleReloadChatDirectMessages();
|
||||
}
|
||||
_handleUpdateChatMessagesUnreadError(){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -537,7 +741,7 @@ export const showNotificationMessages = (dom) => {
|
||||
<div class="chat-contact-info flex-grow-1 ms-2">
|
||||
<h6 class="chat-contact-name text-truncate m-0">[${e.title}] ${e.chatDisplay}</h6>
|
||||
</div>
|
||||
<span class="badge badge-center rounded-pill bg-primary p-1">${numberOfMessages}</span>
|
||||
<span class="badge badge-center rounded-pill bg-primary p-1 m-2">${numberOfMessages}</span>
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
|
||||
@ -0,0 +1,107 @@
|
||||
import Ajax from "../ajax.js";
|
||||
|
||||
class MessagesDatatable {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.datatableItem = this.item.find("#tableMessages")
|
||||
this.datatablePresupuestoMessageItem = this.item.find("#tablePresupuestoMessages")
|
||||
this.datatablePedidoMessageItem = this.item.find("#tablePedidoMessages")
|
||||
this.datatableFacturaMessageItem = this.item.find("#tableFacturaMessages")
|
||||
|
||||
this.datatableColumns = [
|
||||
{ data: 'created_at', searchable: true, sortable: true },
|
||||
{ data: 'updated_at', searchable: true, sortable: true },
|
||||
{ data: 'title', searchable: true, sortable: true },
|
||||
{ data: 'creator', searchable: false, sortable: false },
|
||||
{
|
||||
data: 'viewed', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
const iconClass = d == true ? "ti ti-sm ti-check" : "ti ti-sm ti-x"
|
||||
return `<span class="${iconClass}"</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'action', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
return `<div class="btn-group btn-group-sm">
|
||||
<a href="/chat/${d.type}/${d.modelId}" class="message-edit"><i class="ti ti-eye ti-sm mx-2"></i></a>
|
||||
</div>`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
}
|
||||
init() {
|
||||
this.datatable = this.datatableItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
serverSide: true,
|
||||
pageLength: 10,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/messages/datatable'
|
||||
});
|
||||
|
||||
this.datatablePresupuestoMessage = this.datatablePresupuestoMessageItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
serverSide: true,
|
||||
pageLength: 10,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/messages/datatable/presupuesto'
|
||||
});
|
||||
this.datatablePedidoMessage = this.datatablePedidoMessageItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
serverSide: true,
|
||||
pageLength: 10,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/messages/datatable/pedido'
|
||||
});
|
||||
this.datatableFacturaMessage = this.datatableFacturaMessageItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
serverSide: true,
|
||||
pageLength: 10,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/messages/datatable/factura'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default MessagesDatatable;
|
||||
@ -13,6 +13,7 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param
|
||||
placeholder: placeholder,
|
||||
allowClear: allowClear,
|
||||
dropdownParent: domItem.parent(),
|
||||
language: "es",
|
||||
ajax: {
|
||||
url: () => {
|
||||
return this.url;
|
||||
@ -47,7 +48,7 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param
|
||||
this.init = function () {
|
||||
if (this.item.length) {
|
||||
this.item = this.item.select2(this.config);
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function () {};
|
||||
// $.fn.modal.Constructor.prototype.enforceFocus = function () {};
|
||||
}
|
||||
};
|
||||
this.setOption = function (id, nombre) {
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import {showNotificationMessages} from "../components/chat.js";
|
||||
|
||||
showNotificationMessages($("#chat-notification-list"))
|
||||
|
||||
setInterval(() => {
|
||||
showNotificationMessages($("#chat-notification-list"))
|
||||
},10000)
|
||||
$("#message-notification-dropdown").on("click",(e) => {
|
||||
showNotificationMessages($("#chat-notification-list"))
|
||||
})
|
||||
@ -0,0 +1,5 @@
|
||||
import MessagePage from "./messagePage.js";
|
||||
|
||||
const messagePage = new MessagePage()
|
||||
|
||||
messagePage.init()
|
||||
@ -0,0 +1,132 @@
|
||||
import MessagesDatatable from "../../../components/datatables/MessagesDatatable.js";
|
||||
import Modal from "../../../components/modal.js";
|
||||
import Ajax from "../../../components/ajax.js";
|
||||
import ClassSelect from "../../../components/select2.js";
|
||||
import Alert from "../../../components/alerts/alert.js";
|
||||
class MessagePage {
|
||||
constructor() {
|
||||
this.messageDatatable = new MessagesDatatable($("#message-datatables-container")) // mensajesView.php
|
||||
this.modalNewMessage = new Modal($("#modalNewDirectMessage"))
|
||||
this.btnNewMessage = $("#btn-new-message")
|
||||
this.btnSubmitNewDirectMessage = this.modalNewMessage.item.find("#submit-new-direct-message")
|
||||
this.btnSubmitNewDirectMessageCliente = this.modalNewMessage.item.find("#submit-new-direct-message-client")
|
||||
|
||||
this.formNewDirectMessage = this.modalNewMessage.item.find("#formNewDirectMessage")
|
||||
this.alert = new Alert($("#alertDirectMessage"))
|
||||
this.selectUsers = $("#select-users")
|
||||
this.selectUsers = $("#select-departments")
|
||||
|
||||
this.selectPlaceholder = {
|
||||
id: '0',
|
||||
text: "Seleccione un usuario"
|
||||
}
|
||||
this.selectDepartmentPlaceholder = {
|
||||
id: '0',
|
||||
text: "Seleccione un departamento"
|
||||
}
|
||||
this.selectMessageUsers = new ClassSelect(this.selectUsers, '/chat/users/all', this.selectPlaceholder, true)
|
||||
this.selectChatDepartment = new ClassSelect(this.selectUsers, '/chat/department/select', this.selectDepartmentPlaceholder, true)
|
||||
|
||||
}
|
||||
init() {
|
||||
this.events()
|
||||
this.messageDatatable.init()
|
||||
}
|
||||
events() {
|
||||
// Open new message when click in btn-new-message
|
||||
this.btnNewMessage.on("click", this.openNewMessageModal.bind(this))
|
||||
this.btnSubmitNewDirectMessage.on("click", this.handleSubmitNewMessage.bind(this))
|
||||
this.btnSubmitNewDirectMessageCliente.on("click", this.handleSubmitNewMessageClient.bind(this))
|
||||
|
||||
$("#navs-top-align-directos-tab").on("click",()=>{
|
||||
this.messageDatatable.datatable.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-presupuestos-tab").on("click",()=>{
|
||||
this.messageDatatable.datatablePresupuestoMessage.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-pedidos-tab").on("click",()=>{
|
||||
this.messageDatatable.datatablePedidoMessage.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-facturas-tab").on("click",()=>{
|
||||
this.messageDatatable.datatableFacturaMessage.ajax.reload()
|
||||
})
|
||||
|
||||
}
|
||||
openNewMessageModal() {
|
||||
this.formNewDirectMessage.trigger("reset")
|
||||
this.selectMessageUsers.init()
|
||||
this.alert.hide()
|
||||
this.showForm()
|
||||
this.modalNewMessage.toggle()
|
||||
}
|
||||
|
||||
handleSubmitNewMessage() {
|
||||
this.btnNewMessage.addClass("loading")
|
||||
const ajax = new Ajax("/messages/direct",
|
||||
this.getNewMessageDataForm(),
|
||||
null,
|
||||
this.handleSubmitNewMessageSuccess.bind(this),
|
||||
this.handleSubmitNewMessageError.bind(this))
|
||||
ajax.post()
|
||||
}
|
||||
handleSubmitNewMessageSuccess(response) {
|
||||
this.btnNewMessage.removeClass("loading")
|
||||
this.alert.setAsSuccess()
|
||||
this.alert.setHeadingTitle(response.message)
|
||||
this.alert.show()
|
||||
this.hideForm()
|
||||
this.messageDatatable.datatable.ajax.reload()
|
||||
}
|
||||
handleSubmitNewMessageError(response) {
|
||||
const error = response.responseJSON
|
||||
this.btnNewMessage.removeClass("loading")
|
||||
this.alert.show()
|
||||
this.alert.setAsError()
|
||||
this.alert.setHeadingTitle(error.message)
|
||||
}
|
||||
handleSubmitNewMessageClient(){
|
||||
this.btnNewMessage.addClass("loading")
|
||||
const ajax = new Ajax("/messages/direct/client",
|
||||
this.getNewMessageDataFormClient(),
|
||||
null,
|
||||
this.handleSubmitNewMessageSuccess.bind(this),
|
||||
this.handleSubmitNewMessageError.bind(this))
|
||||
ajax.post()
|
||||
}
|
||||
handleSubmitNewMessageClientSuccess(){
|
||||
|
||||
}
|
||||
handleSubmitNewMessageClientError(){
|
||||
|
||||
}
|
||||
getNewMessageDataForm() {
|
||||
return {
|
||||
"title": this.formNewDirectMessage.find("#new-direct-message-title").val(),
|
||||
"message": this.formNewDirectMessage.find("#new-direct-message-text").val(),
|
||||
"users": this.selectMessageUsers.getVal()
|
||||
}
|
||||
}
|
||||
getNewMessageDataFormClient() {
|
||||
return {
|
||||
"title": this.formNewDirectMessage.find("#new-direct-message-title").val(),
|
||||
"message": this.formNewDirectMessage.find("#new-direct-message-text").val(),
|
||||
"chat_department_id": this.selectChatDepartment.getVal()
|
||||
}
|
||||
}
|
||||
hideForm() {
|
||||
this.formNewDirectMessage.addClass("d-none")
|
||||
this.btnSubmitNewDirectMessage.addClass("d-none")
|
||||
this.btnSubmitNewDirectMessageCliente.addClass("d-none")
|
||||
|
||||
}
|
||||
showForm() {
|
||||
this.formNewDirectMessage.removeClass("d-none")
|
||||
this.btnSubmitNewDirectMessage.removeClass("d-none")
|
||||
this.btnSubmitNewDirectMessageCliente.addClass("d-none")
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default MessagePage;
|
||||
@ -0,0 +1,9 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
|
||||
$(function(){
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-direct-message"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initDirectMessage()
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,9 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
|
||||
$(function(){
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-factura"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initFactura()
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,10 @@
|
||||
import InternalMessages from "../../components/internalMessagesSection.js";
|
||||
|
||||
$(function () {
|
||||
|
||||
if ($("#internal_messages_chat").length > 0) {
|
||||
const internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,9 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
|
||||
$(function(){
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-pedido"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initPedido()
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,18 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
import InternalMessages from "../../components/internalMessagesSection.js";
|
||||
|
||||
$(function () {
|
||||
|
||||
if ($("#chat-presupuesto").length > 0) {
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-presupuesto"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initPresupuesto()
|
||||
}
|
||||
|
||||
if ($("#internal_messages_chat").length > 0) {
|
||||
const internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,21 @@
|
||||
|
||||
export const newDirectMessageValidation =
|
||||
{
|
||||
fields:{
|
||||
title:{
|
||||
notEmpty:{
|
||||
message : "Título no puede estar vacío"
|
||||
},
|
||||
},
|
||||
message:{
|
||||
notEmpty:{
|
||||
message : "Mensaje no puede estar vacío"
|
||||
},
|
||||
},
|
||||
users:{
|
||||
notEmpty:{
|
||||
message : "Debe seleccionar al menos a un participante"
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user