mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
messages departments section
This commit is contained in:
@ -133,6 +133,9 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
|
||||
$routes->get('edit/(:num)', 'MaquinaTarea::viewForm/$1', ['as' => 'maquinaTareaViewForm']);
|
||||
$routes->get('datatable', 'MaquinaTarea::datatable', ['as' => 'maquinaTareaDatatable']);
|
||||
});
|
||||
$routes->group("messages", ["namespace" => 'App\Controllers\Chat'], function ($routes) {
|
||||
$routes->get('', 'ChatController::config_view', ['as' => 'configMessagesIndex']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -892,17 +895,25 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route
|
||||
$routes->post('direct/messages/unread/(:num)', 'ChatController::update_chat_direct_message_unread/$1', ['as' => 'updateChatDirectMessageUnread']);
|
||||
|
||||
|
||||
$routes->post('department', 'ChatController::store_chat_department', ['as' => 'storeChatDepartment']);
|
||||
$routes->delete('department/(:num)', 'ChatController::delete_chat_department/$1', ['as' => 'deleteChatDepartment']);
|
||||
$routes->post('department/update/(:num)', 'ChatController::update_chat_department/$1', ['as' => 'updateChatDepartment']);
|
||||
$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']);
|
||||
$routes->get('department/users/presupuesto/(:num)/(:num)', 'ChatController::get_chat_department_presupuesto_users/$1/$2', ['as' => 'getPresupuestoChatDepartmentUsers']);
|
||||
$routes->get('department/datatable', 'ChatController::chat_department_datatable', ['as' => 'chatDepartmentDatatable']);
|
||||
$routes->get('department/edit/(:num)', 'ChatController::chat_department_edit/$1', ['as' => 'chatDepartmentEditView']);
|
||||
$routes->get('department/users/datatable/(:num)', 'ChatController::chat_department_user_datatable/$1', ['as' => 'chatDepartmentUsersDatatable']);
|
||||
$routes->get('department/users/pedido/(:num)/(:num)', 'ChatController::get_chat_department_pedido_users/$1/$2', ['as' => 'getPedidoChatDepartmentUsers']);
|
||||
$routes->get('department/users/factura/(:num)/(:num)', 'ChatController::get_chat_department_factura_users/$1/$2', ['as' => 'getFacturaChatDepartmentUsers']);
|
||||
|
||||
$routes->get('department/users/select/add/(:num)', 'ChatController::select_users_not_in_chat_department/$1', ['as' => 'selectUsersNotInChatDepartment']);
|
||||
$routes->post('department/user', 'ChatController::subscribe_to_chat_deparment/$1', ['as' => 'subscribeToChatDepartment']);
|
||||
$routes->post('department/subscribe/admin/user', 'ChatController::subscribe_admin_to_department', ['as' => 'subscribeAdminToChatDepartment']);
|
||||
$routes->delete('department/user/(:num)', 'ChatController::delete_user_from_department/$1', ['as' => 'deleteUserFromDepartment']);
|
||||
$routes->delete('department/admin/user/(:num)/(:num)', 'ChatController::delete_user_admin_from_department/$1/$2', ['as' => 'deleteUserAdminFromDepartment']);
|
||||
|
||||
|
||||
$routes->get('(:num)', 'ChatController::get_chat/$1', ['as' => 'getChat']);
|
||||
|
||||
@ -162,4 +162,15 @@ class Validation extends BaseConfig
|
||||
],
|
||||
|
||||
];
|
||||
public array $chat_department =
|
||||
[
|
||||
"display" => [
|
||||
"rules" => "required|string",
|
||||
"label" => "tarifa acabado",
|
||||
],
|
||||
"description" => [
|
||||
"rules" => "permit_empty",
|
||||
"label" => "maquina",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ use CodeIgniter\Log\Logger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
|
||||
class ChatController extends BaseController
|
||||
{
|
||||
@ -32,6 +33,8 @@ class ChatController extends BaseController
|
||||
protected ClienteModel $clienteModel;
|
||||
protected ChatUser $chatUserModel;
|
||||
protected ChatNotification $chatNotificationModel;
|
||||
protected Validation $validation;
|
||||
|
||||
protected array $viewData;
|
||||
protected static $viewPath = 'themes/vuexy/form/mensajes/';
|
||||
|
||||
@ -52,6 +55,7 @@ class ChatController extends BaseController
|
||||
$this->clienteModel = model(ClienteModel::class);
|
||||
$this->chatUserModel = model(ChatUser::class);
|
||||
$this->chatNotificationModel = model(ChatNotification::class);
|
||||
$this->validation = service("validation");
|
||||
}
|
||||
public function index() {}
|
||||
public function get_chat_departments()
|
||||
@ -77,6 +81,7 @@ class ChatController extends BaseController
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat->id, auth()->user()->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
@ -94,6 +99,8 @@ class ChatController extends BaseController
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat->id, auth()->user()->id);
|
||||
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
@ -111,6 +118,7 @@ class ChatController extends BaseController
|
||||
if ($chat) {
|
||||
$data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id);
|
||||
$this->chatMessageModel->set_chat_department_messages_as_read($chat->id);
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat->id, auth()->user()->id);
|
||||
$data["count"] = count($data["messages"]);
|
||||
}
|
||||
$data["chat"] = $chat;
|
||||
@ -207,19 +215,18 @@ 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"]);
|
||||
$chatExternalUsers = $this->chatDeparmentModel->getChatDeparmentPresupuestoUsers($data["chat_department_id"],$data["model_id"]);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $data['client']]);
|
||||
$cliente_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id',$data["chat_department_id"])->where('user_id',$data['client'])->where('presupuesto_id',$data['model_id'])->countAllResults();
|
||||
$auth_user_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id',$data["chat_department_id"])->where('user_id',auth()->user()->id)->countAllResults();
|
||||
if($cliente_in_department_count == 0){
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"],'user_id' => $data['client'],'presupuesto_id' => $data['model_id']]);
|
||||
}
|
||||
if($auth_user_in_department_count){
|
||||
$users_always_in_department = array_map(fn($q) => $q->id,$chatDepartmentUsers);
|
||||
if(!in_array(auth()->user()->id,$users_always_in_department)){
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"],'user_id' => auth()->user()->id,'presupuesto_id' => $data['model_id']]);
|
||||
if (auth()->user()->inGroup('admin')) {
|
||||
$cliente_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id', $data["chat_department_id"])->where('user_id', $data['client'])->where('presupuesto_id', $data['model_id'])->countAllResults();
|
||||
if ($cliente_in_department_count == 0) {
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"], 'user_id' => $data['client'], 'presupuesto_id' => $data['model_id']]);
|
||||
}
|
||||
}
|
||||
$chatExternalUsers = $this->chatDeparmentModel->getChatDeparmentPresupuestoUsers($data["chat_department_id"], $data["model_id"]);
|
||||
$auth_user_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id', $data["chat_department_id"])->where('user_id', auth()->user()->id)->countAllResults();
|
||||
|
||||
if ($auth_user_in_department_count) {
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"], 'user_id' => auth()->user()->id, 'presupuesto_id' => $data['model_id']]);
|
||||
}
|
||||
|
||||
foreach ($chatDepartmentUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
@ -227,9 +234,7 @@ class ChatController extends BaseController
|
||||
}
|
||||
}
|
||||
foreach ($chatExternalUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
@ -247,20 +252,17 @@ 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"]);
|
||||
$chatExternalUsers = $this->chatDeparmentModel->getChatDeparmentPedidoUsers($data["chat_department_id"],$data["model_id"]);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $data['client']]);
|
||||
$cliente_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id',$data["chat_department_id"])->where('user_id',$data['client'])->where('pedido_id',$data['model_id'])->countAllResults();
|
||||
$auth_user_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id',$data["chat_department_id"])->where('user_id',auth()->user()->id)->countAllResults();
|
||||
if($cliente_in_department_count == 0){
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"],'user_id' => $data['client'],'pedido_id' => $data['model_id']]);
|
||||
}
|
||||
if($auth_user_in_department_count){
|
||||
$users_always_in_department = array_map(fn($q) => $q->id,$chatDepartmentUsers);
|
||||
if(!in_array(auth()->user()->id,$users_always_in_department)){
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"],'user_id' => auth()->user()->id,'pedido_id' => $data['model_id']]);
|
||||
|
||||
if (auth()->user()->inGroup('admin')) {
|
||||
$cliente_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id', $data["chat_department_id"])->where('user_id', $data['client'])->where('pedido_id', $data['model_id'])->countAllResults();
|
||||
if ($cliente_in_department_count == 0) {
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"], 'user_id' => $data['client'], 'pedido_id' => $data['model_id']]);
|
||||
}
|
||||
}
|
||||
$chatExternalUsers = $this->chatDeparmentModel->getChatDeparmentPedidoUsers($data["chat_department_id"], $data["model_id"]);
|
||||
$auth_user_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id', $data["chat_department_id"])->where('user_id', auth()->user()->id)->countAllResults();
|
||||
if ($auth_user_in_department_count == 0) {
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"], 'user_id' => auth()->user()->id, 'pedido_id' => $data['model_id']]);
|
||||
}
|
||||
|
||||
foreach ($chatDepartmentUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
@ -268,40 +270,34 @@ class ChatController extends BaseController
|
||||
}
|
||||
}
|
||||
foreach ($chatExternalUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $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()
|
||||
{
|
||||
|
||||
$data = $this->request->getPost();
|
||||
$existChat = $this->chatModel->existChatFactura($data["chat_department_id"], $data["model_id"]);
|
||||
$existChat = $this->chatModel->existChatPedido($data["chat_department_id"], $data["model_id"]);
|
||||
if ($existChat == false) {
|
||||
$chatId = $this->chatModel->createChatFactura($data["chat_department_id"], $data["model_id"]);
|
||||
$chatId = $this->chatModel->createChatPedido($data["chat_department_id"], $data["model_id"]);
|
||||
} else {
|
||||
$chat = $this->chatModel->getChatFactura($data["chat_department_id"], $data["model_id"]);
|
||||
$chat = $this->chatModel->getChatPedido($data["chat_department_id"], $data["model_id"]);
|
||||
$chatId = $chat->id;
|
||||
}
|
||||
$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"]);
|
||||
$chatExternalUsers = $this->chatDeparmentModel->getChatDeparmentFacturaUsers($data["chat_department_id"],$data["model_id"]);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $data['client']]);
|
||||
$cliente_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id',$data["chat_department_id"])->where('user_id',$data['client'])->where('factura_id',$data['model_id'])->countAllResults();
|
||||
$auth_user_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id',$data["chat_department_id"])->where('user_id',auth()->user()->id)->countAllResults();
|
||||
if($cliente_in_department_count == 0){
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"],'user_id' => $data['client'],'factura_id' => $data['model_id']]);
|
||||
}
|
||||
if($auth_user_in_department_count){
|
||||
$users_always_in_department = array_map(fn($q) => $q->id,$chatDepartmentUsers);
|
||||
if(!in_array(auth()->user()->id,$users_always_in_department)){
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"],'user_id' => auth()->user()->id,'factura_id' => $data['model_id']]);
|
||||
|
||||
if (auth()->user()->inGroup('admin')) {
|
||||
$cliente_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id', $data["chat_department_id"])->where('user_id', $data['client'])->where('pedido_id', $data['model_id'])->countAllResults();
|
||||
if ($cliente_in_department_count == 0) {
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"], 'user_id' => $data['client'], 'factura_id' => $data['model_id']]);
|
||||
}
|
||||
}
|
||||
$chatExternalUsers = $this->chatDeparmentModel->getChatDeparmentPedidoUsers($data["chat_department_id"], $data["model_id"]);
|
||||
$auth_user_in_department_count = $this->chatDeparmentUserModel->where('chat_department_id', $data["chat_department_id"])->where('user_id', auth()->user()->id)->countAllResults();
|
||||
if ($auth_user_in_department_count == 0) {
|
||||
$this->chatDeparmentUserModel->insert(['chat_department_id' => $data["chat_department_id"], 'user_id' => auth()->user()->id, 'pedido_id' => $data['model_id']]);
|
||||
}
|
||||
|
||||
foreach ($chatDepartmentUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
@ -309,9 +305,7 @@ class ChatController extends BaseController
|
||||
}
|
||||
}
|
||||
foreach ($chatExternalUsers as $user) {
|
||||
if ($user->id != auth()->user()->id) {
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]);
|
||||
}
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
@ -377,7 +371,7 @@ class ChatController extends BaseController
|
||||
$cliente_id = auth()->user()->cliente_id;
|
||||
$response = [];
|
||||
if ($cliente_id) {
|
||||
$data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id);
|
||||
// $data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id);
|
||||
$response["internals"] = $this->chatModel->getChatDepartmentNotifications();
|
||||
$response["totalMessages"] = 0;
|
||||
$mensajes_directos = $this->chatModel->getChatDirectMessageNotifications();
|
||||
@ -389,10 +383,10 @@ class ChatController extends BaseController
|
||||
// foreach ($response["chatPresupuestos"] as $key => $value) {
|
||||
// $response["totalMessages"] += $value->unreadMessages;
|
||||
// }
|
||||
// foreach ($mensajes_directos as $value) {
|
||||
// $response["internals"][] = $value;
|
||||
// $response["totalMessages"] += $value->unreadMessages;
|
||||
// }
|
||||
foreach ($mensajes_directos as $value) {
|
||||
$response["internals"][] = $value;
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
// $response["chatPedidos"] = $this->chatModel->getClienteChatPedidos($data["pedidos"]);
|
||||
// foreach ($response["chatPedidos"] as $key => $value) {
|
||||
// $response["totalMessages"] += $value->unreadMessages;
|
||||
@ -420,23 +414,23 @@ class ChatController extends BaseController
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
public function get_chat_department_presupuesto_users(int $chat_department_id,int $presupuesto_id)
|
||||
public function get_chat_department_presupuesto_users(int $chat_department_id, int $presupuesto_id)
|
||||
{
|
||||
$adminUsers = $this->chatDeparmentModel->getChatDepartmentUsers($chat_department_id);
|
||||
$externalUsers = $this->chatDeparmentModel->getChatDeparmentPresupuestoUsers($chat_department_id,$presupuesto_id);
|
||||
return $this->response->setJSON(['admin_users' => $adminUsers,'external_users' => $externalUsers]);
|
||||
$externalUsers = $this->chatDeparmentModel->getChatDeparmentPresupuestoUsers($chat_department_id, $presupuesto_id);
|
||||
return $this->response->setJSON(['admin_users' => $adminUsers, 'external_users' => $externalUsers]);
|
||||
}
|
||||
public function get_chat_department_pedido_users(int $chat_department_id,$pedido_id)
|
||||
public function get_chat_department_pedido_users(int $chat_department_id, $pedido_id)
|
||||
{
|
||||
$adminUsers = $this->chatDeparmentModel->getChatDepartmentUsers($chat_department_id);
|
||||
$externalUsers = $this->chatDeparmentModel->getChatDeparmentPedidoUsers($chat_department_id,$pedido_id);
|
||||
return $this->response->setJSON(['admin_users' => $adminUsers,'external_users' => $externalUsers]);
|
||||
$externalUsers = $this->chatDeparmentModel->getChatDeparmentPedidoUsers($chat_department_id, $pedido_id);
|
||||
return $this->response->setJSON(['admin_users' => $adminUsers, 'external_users' => $externalUsers]);
|
||||
}
|
||||
public function get_chat_department_factura_users(int $chat_department_id,$factura_id)
|
||||
public function get_chat_department_factura_users(int $chat_department_id, $factura_id)
|
||||
{
|
||||
$adminUsers = $this->chatDeparmentModel->getChatDepartmentUsers($chat_department_id);
|
||||
$externalUsers = $this->chatDeparmentModel->getChatDeparmentFacturaUsers($chat_department_id,$factura_id);
|
||||
return $this->response->setJSON(['admin_users' => $adminUsers,'external_users' => $externalUsers]);
|
||||
$externalUsers = $this->chatDeparmentModel->getChatDeparmentFacturaUsers($chat_department_id, $factura_id);
|
||||
return $this->response->setJSON(['admin_users' => $adminUsers, 'external_users' => $externalUsers]);
|
||||
}
|
||||
public function get_chat_users_internal()
|
||||
{
|
||||
@ -766,8 +760,18 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function get_notifications_not_viewed_from_chat(int $chat_id)
|
||||
{
|
||||
$data = $this->chatModel->getUsersNotificationNotViewedFromChat($chat_id);
|
||||
return $this->response->setJSON(["data" => $data, "chat_id" => $chat_id]);
|
||||
$unviewedNotifications = $this->chatModel->getUsersNotificationNotViewedFromChat($chat_id);
|
||||
$viewedNotifications = $this->chatModel->getUsersNotificationViewedFromChat($chat_id);
|
||||
|
||||
return $this->response->setJSON(
|
||||
[
|
||||
"data" => [
|
||||
"unviewedNotifications" => $unviewedNotifications,
|
||||
"viewedNotifications" => $viewedNotifications
|
||||
],
|
||||
"chat_id" => $chat_id
|
||||
]
|
||||
);
|
||||
}
|
||||
public function store_new_direct_message()
|
||||
{
|
||||
@ -878,46 +882,142 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function delete_user_from_department($chat_department_id)
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$data = $this->request->getRawInput();
|
||||
$user_id = auth()->user()->id;
|
||||
$adminExist = $this->chatDeparmentUserModel->where('chat_department_id',$chat_department_id)
|
||||
->where('user_id',$user_id)
|
||||
->where('pedido_id',null)
|
||||
->where('factura_id',null)
|
||||
->where('presupuesto_id',null)->countAllResults();
|
||||
if($adminExist)
|
||||
{
|
||||
return $this->response->setJSON(["message" => lang('Chat.exit_admin_chat_wrong'),"status" => false]);
|
||||
$adminExist = $this->chatDeparmentUserModel->where('chat_department_id', $chat_department_id)
|
||||
->where('user_id', $user_id)
|
||||
->where('pedido_id', null)
|
||||
->where('factura_id', null)
|
||||
->where('presupuesto_id', null)->countAllResults();
|
||||
if ($adminExist) {
|
||||
return $this->response->setJSON(["message" => lang('Chat.exit_admin_chat_wrong'), "status" => false]);
|
||||
}
|
||||
$chatDepartmentUserEntity = $this->chatDeparmentUserModel->where('chat_department_id',$chat_department_id)->where('user_id',$user_id)->where($data['model_fk'],$data['model_id_fk']);
|
||||
if($chatDepartmentUserEntity->countAllResults() > 0)
|
||||
{
|
||||
$deleted = $this->chatDeparmentUserModel->where('chat_department_id',$chat_department_id)->where('user_id',$user_id)->delete();
|
||||
$chatDepartmentUserEntity = $this->chatDeparmentUserModel->where('chat_department_id', $chat_department_id)->where('user_id', $user_id)->where($data['model_fk'], $data['model_id_fk']);
|
||||
if ($chatDepartmentUserEntity->countAllResults() > 0) {
|
||||
$deleted = $this->chatDeparmentUserModel->where('chat_department_id', $chat_department_id)->where('user_id', $user_id)->delete(purge: true);
|
||||
return $this->response->setJSON(["message" => lang('Chat.exit_chat_ok'), "status" => true]);
|
||||
}else{
|
||||
return $this->response->setJSON(["message" => lang('Chat.exit_chat_wrong'),"status" => false]);
|
||||
} else {
|
||||
return $this->response->setJSON(["message" => lang('Chat.exit_chat_wrong'), "status" => false]);
|
||||
}
|
||||
}
|
||||
public function delete_user_admin_from_department($chat_department_id, $user_id)
|
||||
{
|
||||
$this->chatDeparmentUserModel->where('chat_department_id', $chat_department_id)->where('user_id', $user_id)->delete();
|
||||
return $this->response->setJSON(["message" => lang('Chat.user_deleted_ok'), "status" => true]);
|
||||
}
|
||||
public function subscribe_to_chat_deparment()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$user_id = auth()->user()->id;
|
||||
$adminExist = $this->chatDeparmentUserModel->where('chat_department_id',$data['chat_department_id'])
|
||||
->where('user_id',$user_id)
|
||||
->where('pedido_id',null)
|
||||
->where('factura_id',null)
|
||||
->where('presupuesto_id',null)->countAllResults();
|
||||
if($adminExist)
|
||||
{
|
||||
return $this->response->setJSON(["message" => lang('Chat.subscribe_chat_wrong'),"status" => false]);
|
||||
$adminExist = $this->chatDeparmentUserModel->where('chat_department_id', $data['chat_department_id'])
|
||||
->where('user_id', $user_id)
|
||||
->where('pedido_id', null)
|
||||
->where('factura_id', null)
|
||||
->where('presupuesto_id', null)->countAllResults();
|
||||
if ($adminExist) {
|
||||
return $this->response->setJSON(["message" => lang('Chat.subscribe_chat_wrong'), "status" => false]);
|
||||
}
|
||||
$chatDepartmentUserEntity = $this->chatDeparmentUserModel->where('chat_department_id',$data['chat_department_id'])->where('user_id',$user_id)->where($data['model_fk'],$data['model_id_fk']);
|
||||
if($chatDepartmentUserEntity->countAllResults() > 0)
|
||||
{
|
||||
return $this->response->setJSON(["message" => lang('Chat.subscribe_chat_wrong'),"status" => false]);
|
||||
}else{
|
||||
$this->chatDeparmentUserModel->insert(["chat_department_id" => $data["chat_department_id"],"user_id" => $user_id,$data['model_fk'] => $data['model_id_fk']]);
|
||||
$chatDepartmentUserEntity = $this->chatDeparmentUserModel->where('chat_department_id', $data['chat_department_id'])->where('user_id', $user_id)->where($data['model_fk'], $data['model_id_fk']);
|
||||
if ($chatDepartmentUserEntity->countAllResults() > 0) {
|
||||
return $this->response->setJSON(["message" => lang('Chat.subscribe_chat_wrong'), "status" => false]);
|
||||
} else {
|
||||
$this->chatDeparmentUserModel->insert(["chat_department_id" => $data["chat_department_id"], "user_id" => $user_id, $data['model_fk'] => $data['model_id_fk']]);
|
||||
return $this->response->setJSON(["message" => lang('Chat.subscribe_chat_ok'), "status" => true]);
|
||||
}
|
||||
}
|
||||
public function subscribe_admin_to_department()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
if ($data['user_id']) {
|
||||
|
||||
$this->chatDeparmentUserModel
|
||||
->insert(
|
||||
[
|
||||
"chat_department_id" => $data["chat_department_id"],
|
||||
"user_id" => $data["user_id"],
|
||||
]
|
||||
);
|
||||
return $this->response->setJSON(["message" => lang('Chat.subscribe_admin_chat_ok'), "status" => true]);
|
||||
} else {
|
||||
return $this->response->setStatusCode(422)->setJSON(["message" => lang('Chat.subscribe_admin_chat_wrong'), "status" => false]);
|
||||
}
|
||||
}
|
||||
public function config_view()
|
||||
{
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => 'javascript:void(0);', 'active' => false],
|
||||
['title' => lang("App.menu_config_messages"), 'route' => route_to("configMessagesIndex"), 'active' => true]
|
||||
];
|
||||
|
||||
return view('themes/vuexy/form/configuracion/messages/configView', $this->viewData);
|
||||
}
|
||||
public function chat_department_edit($chat_department_id)
|
||||
{
|
||||
$chatDepartment = $this->chatDeparmentModel->find($chat_department_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => 'javascript:void(0);', 'active' => false],
|
||||
['title' => lang("App.menu_config_messages"), 'route' => route_to("configMessagesIndex"), 'active' => false],
|
||||
['title' => $chatDepartment->display, 'route' => route_to("chatDepartmentEditView", $chat_department_id), 'active' => true]
|
||||
|
||||
];
|
||||
$this->viewData["chat_department"] = $chatDepartment;
|
||||
return view('themes/vuexy/form/configuracion/messages/editChatDepartmentForm', $this->viewData);
|
||||
}
|
||||
public function chat_department_datatable()
|
||||
{
|
||||
$q = $this->chatDeparmentModel->datatableQuery();
|
||||
return DataTable::of($q)
|
||||
->add('action', fn($r) => $r->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function chat_department_user_datatable(int $chat_department_id)
|
||||
{
|
||||
$q = $this->chatDeparmentUserModel->datatableQuery($chat_department_id);
|
||||
$datatable = DataTable::of($q);
|
||||
if (auth()->user()->inGroup('admin')) {
|
||||
$datatable->add('action', fn($r) => $r->userId);
|
||||
}
|
||||
return $datatable->toJson(true);
|
||||
}
|
||||
public function select_users_not_in_chat_department(int $chat_department_id)
|
||||
{
|
||||
$paramQuery = $this->request->getGet("q");
|
||||
$data = $this->chatDeparmentUserModel->querySelectUsersNotInDepartment($chat_department_id, $paramQuery);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function store_chat_department()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$validated = $this->validation->run($data, 'chat_department');
|
||||
if ($validated) {
|
||||
$dataValidated = $this->validation->getValidated();
|
||||
$dataValidated['name'] = newUUID();
|
||||
$this->chatDeparmentModel->insert($dataValidated);
|
||||
return $this->response->setJSON(["message" => lang('App.global_alert_save_success'), "status" => true, "data" => $dataValidated]);
|
||||
} else {
|
||||
return $this->response->setStatusCode(422)->setJSON(["message" => lang('App.global_alert_save_success'), "status" => false, "errors" => $this->validation->getErrors()]);
|
||||
}
|
||||
return $this->response->setJSON(["message" => lang('App.global_alert_save_success'), "status" => true]);
|
||||
}
|
||||
public function update_chat_department(int $chat_department_id)
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$validated = $this->validation->run($data, 'chat_department');
|
||||
if ($validated) {
|
||||
$dataValidated = $this->validation->getValidated();
|
||||
$this->chatDeparmentModel->update($chat_department_id, $dataValidated);
|
||||
return $this->response->setJSON(["message" => lang('App.global_alert_save_success'), "status" => true, "data" => $dataValidated]);
|
||||
} else {
|
||||
return $this->response->setStatusCode(422)->setJSON(["message" => lang('App.global_alert_save_success'), "status" => false, "errors" => $this->validation->getErrors()]);
|
||||
}
|
||||
}
|
||||
public function delete_chat_department($chat_department_id)
|
||||
{
|
||||
if (auth()->user()->inGroup('admin')) {
|
||||
$this->chatDeparmentModel->delete($chat_department_id);
|
||||
return $this->response->setJSON(["message" => lang('App.user_alert_delete'), "status" => true]);
|
||||
} else {
|
||||
return $this->response->setStatusCode(403)->setJSON(["message" => lang('App.user_alert_forbidden'), "status" => false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,14 @@ return [
|
||||
"viewed" => "Viewed",
|
||||
|
||||
],
|
||||
"datatable_departments" => [
|
||||
"name" => "Name",
|
||||
"description" => "Description",
|
||||
],
|
||||
"datatable_department_users" => [
|
||||
"name" => "Name",
|
||||
"user" => "User",
|
||||
],
|
||||
"new_message_ok" => "Message sent successfully",
|
||||
"participants" => "Participants",
|
||||
"choose_department" => "Choose a deparment",
|
||||
@ -42,4 +50,12 @@ return [
|
||||
"exit_chat_wrong" => "You can't exit the chat because you don't belong to it.",
|
||||
"subscribe_chat_ok" => "You've subscribed to chat successfully. Now on you'll receive notifications.",
|
||||
"subscribe_chat_wrong" => "You already belong to this chat.",
|
||||
];
|
||||
"message_configuration" => "Messages configuration",
|
||||
"new_chat_department" => "New chat department",
|
||||
"user_deleted_ok" => "User deleted succesfully",
|
||||
"subscribe_admin_chat_ok" => "User added successfully",
|
||||
"subscribe_admin_chat_wrong" => "You must select a user",
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@ -226,6 +226,8 @@ return [
|
||||
"user_alert_add" => "¡Agregado exitosamente!",
|
||||
"user_alert_edit" => "¡Editado con éxito!",
|
||||
"user_alert_delete" => "¡Eliminado con éxito!",
|
||||
"user_alert_forbidden" => "No tienes permiso para realizar esta acción",
|
||||
|
||||
|
||||
// USER - form
|
||||
"user_add_title" => "Nuevo Usuario",
|
||||
@ -686,6 +688,7 @@ return [
|
||||
|
||||
"menu_configuration" => "Configuración",
|
||||
"menu_variables" => "Variables sistema",
|
||||
"menu_config_messages" => "Mensajería",
|
||||
"menu_error_presupuesto" => "Errores presupuesto",
|
||||
"menu_calendario" => "Calendario",
|
||||
"menu_paises" => "Paises",
|
||||
|
||||
@ -24,6 +24,14 @@ return [
|
||||
"viewed" => "Leído",
|
||||
|
||||
],
|
||||
"datatable_departments" => [
|
||||
"name" => "Nombre",
|
||||
"description" => "Descripción",
|
||||
],
|
||||
"datatable_department_users" => [
|
||||
"name" => "Nombre",
|
||||
"user" => "Usuario",
|
||||
],
|
||||
"new_message_ok" => "Mensaje enviado correctamente",
|
||||
"participants" => "Participantes",
|
||||
"choose_department" => "Elige un departamento",
|
||||
@ -43,4 +51,14 @@ return [
|
||||
"exit_admin_chat_wrong" => "Perteneces como personal a este chat y no puedes salirte. Contacta administrador para ello.",
|
||||
"subscribe_chat_ok" => "Te has subscrito al chat correctamente. Ahora recibirás notificaciones cuando lleguen mensajes.",
|
||||
"subscribe_chat_wrong" => "Ya perteneces a este chat.",
|
||||
"message_configuration" => "Configuración mensajería",
|
||||
"new_chat_department" => "Nuevo departamento",
|
||||
"user_deleted_ok" => "Usuario eliminado con éxito",
|
||||
"department_users" => "Usuarios departamento",
|
||||
"subscribe_admin_chat_ok" => "Usuario añadido correctamente.",
|
||||
"subscribe_admin_chat_wrong" => "Tienes que seleccionar un usuario.",
|
||||
"help_select_chat_department_user" => "Solamente son listados los usuarios que pertenecen al personal. Los clientes no son listados, para añadirlos a la conversación se realiza desde la sección de mensajería de las diferentes secciones(presupuesto,pedido,factura ...)",
|
||||
"store_department" => "Crear departamento",
|
||||
|
||||
|
||||
];
|
||||
@ -108,7 +108,7 @@ class ChatDeparmentModel extends Model
|
||||
|
||||
public function getChatDeparmentUserQuery(int $chat_deparment_id)
|
||||
{
|
||||
$query = $this->builder()
|
||||
$query = $this
|
||||
->select(
|
||||
[
|
||||
"users.*"
|
||||
@ -123,20 +123,21 @@ class ChatDeparmentModel extends Model
|
||||
"users",
|
||||
"chat_department_users.user_id = users.id",
|
||||
'left'
|
||||
)->where("chat_departments.id", $chat_deparment_id)
|
||||
->where("chat_department_users.deleted_at", null)
|
||||
|
||||
->where("users.deleted_at", null);
|
||||
)
|
||||
->where("chat_department_users.chat_department_id", $chat_deparment_id)
|
||||
->where("chat_department_users.deleted_at",null)
|
||||
->where("users.deleted_at",null);
|
||||
return $query;
|
||||
}
|
||||
public function getChatDepartmentUsers(int $chat_deparment_id)
|
||||
{
|
||||
$result = $this->getChatDeparmentUserQuery($chat_deparment_id)
|
||||
->where('chat_department_users.presupuesto_id', null)
|
||||
->where('chat_department_users.pedido_id', null)
|
||||
->where('chat_department_users.factura_id', null)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
->where('chat_department_users.presupuesto_id',null)
|
||||
->where('chat_department_users.pedido_id',null)
|
||||
->where('chat_department_users.factura_id',null)
|
||||
->get();
|
||||
|
||||
return $result->getResultObject() ?: [];
|
||||
}
|
||||
public function getChatDeparmentPresupuestoUsers(int $chat_deparment_id, int $presupuesto_id)
|
||||
{
|
||||
@ -163,7 +164,7 @@ class ChatDeparmentModel extends Model
|
||||
{
|
||||
return $this->find($chat_deparment_id)->display;
|
||||
}
|
||||
public function getChatDepartmentSelect(string $query = null)
|
||||
public function getChatDepartmentSelect(?string $query)
|
||||
{
|
||||
$q = $this->builder()->select([
|
||||
"id",
|
||||
@ -176,4 +177,8 @@ class ChatDeparmentModel extends Model
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
public function datatableQuery()
|
||||
{
|
||||
return $this->select(['id','display','description'])->where('deleted_at',null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChatDeparmentUserModel extends Model
|
||||
@ -53,11 +53,55 @@ class ChatDeparmentUserModel extends Model
|
||||
|
||||
public function getChatDepartmentUser(int $user_id)
|
||||
{
|
||||
return $this->db->table($this->table." t1")
|
||||
->select("chat_departments.*")
|
||||
->join("chat_departments","t1.chat_department_id = chat_departments.id","left")
|
||||
->where("t1.user_id",$user_id)
|
||||
->where("t1.deleted_at",null)
|
||||
->get()->getResultObject();
|
||||
return $this->db->table($this->table . " t1")
|
||||
->select("chat_departments.*")
|
||||
->join("chat_departments", "t1.chat_department_id = chat_departments.id", "left")
|
||||
->where("t1.user_id", $user_id)
|
||||
->where("t1.deleted_at", null)
|
||||
->get()->getResultObject();
|
||||
}
|
||||
public function datatableQuery(int $chat_department_id)
|
||||
{
|
||||
return $this->builder()->select(
|
||||
[
|
||||
'users.id as userId',
|
||||
'CONCAT(users.first_name," ",users.last_name) as userFullName',
|
||||
'users.username'
|
||||
]
|
||||
)
|
||||
->join('users', 'users.id = chat_department_users.user_id', 'left')
|
||||
->join('chat_departments', 'chat_departments.id = chat_department_users.chat_department_id', 'left')
|
||||
->where('chat_departments.id', $chat_department_id)
|
||||
->where('chat_department_users.pedido_id', null)
|
||||
->where('chat_department_users.presupuesto_id', null)
|
||||
->where('chat_department_users.factura_id', null)
|
||||
->where('chat_department_users.deleted_at', null);
|
||||
}
|
||||
public function querySelectUsersNotInDepartment(int $chat_department_id, ?string $q): array
|
||||
{
|
||||
$query = $this->builder()->select([
|
||||
'users.id as userId',
|
||||
])
|
||||
->join('users', 'users.id = chat_department_users.user_id', 'left')
|
||||
->join('chat_departments', 'chat_departments.id = chat_department_users.chat_department_id', 'left')
|
||||
->where('chat_departments.id', $chat_department_id)
|
||||
->where('chat_department_users.deleted_at', null);
|
||||
|
||||
$usersInDepartment = array_map(fn($q) => $q->userId, $query->get()->getResultObject());
|
||||
$userModel = model(UserModel::class);
|
||||
$queryUser = $userModel->builder()->select([
|
||||
'id',
|
||||
'CONCAT(first_name," ",last_name) as name',
|
||||
'username as description',
|
||||
])
|
||||
->where('cliente_id',null)
|
||||
->where('deleted_at', null);
|
||||
if ($usersInDepartment) {
|
||||
$queryUser->whereNotIn("id", $usersInDepartment);
|
||||
}
|
||||
if ($q) {
|
||||
$queryUser->like('CONCAT(first_name," ",last_name)', $q);
|
||||
}
|
||||
return $queryUser->get()->getResultArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,18 +329,19 @@ class ChatModel extends Model
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.factura_id as facturaId",
|
||||
"chats.title as chatDisplay",
|
||||
"COUNT(chat_notifications.viewed) as unreadMessages"
|
||||
])
|
||||
->join("chat_messages", "chat_messages.chat_id = chats.id", "left")
|
||||
->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left")
|
||||
->where("chat_notifications.user_id", auth()->user()->id)
|
||||
->where("chat_notifications.viewed", false)
|
||||
->where("chats.chat_department_id is NOT NULL", NULL, FALSE);
|
||||
->where("chats.chat_department_id is NOT NULL", NULL, FALSE)
|
||||
->groupBy('chats.id');
|
||||
|
||||
$rows = $q->get()->getResultObject();
|
||||
$auth_user = auth()->user();
|
||||
$rows_new = [];
|
||||
foreach ($rows as $row) {
|
||||
$row->unreadMessages = 0;
|
||||
if ($row->presupuestoId) {
|
||||
$row->model = $presupuestoModel->find($row->presupuestoId);
|
||||
if ($auth_user->cliente_id) {
|
||||
@ -355,7 +356,6 @@ class ChatModel extends Model
|
||||
$row->chatDisplay .= "[INTERNAL]";
|
||||
}
|
||||
$row->avatar = "PRE";
|
||||
$row->unreadMessages = $this->countUnreadMessagePresupuesto($row->presupuestoId);
|
||||
$rows_new[] = $row;
|
||||
} elseif ($row->pedidoId) {
|
||||
$row->model = $pedidoModel->find($row->pedidoId);
|
||||
@ -365,7 +365,6 @@ class ChatModel extends Model
|
||||
$row->chatDisplay .= "[INTERNAL]";
|
||||
}
|
||||
$row->avatar = "P";
|
||||
$row->unreadMessages = $this->countUnreadMessagePedido($row->pedidoId);
|
||||
$rows_new[] = $row;
|
||||
} elseif ($row->facturaId) {
|
||||
$row->model = $facturaModel->find($row->facturaId);
|
||||
@ -375,7 +374,6 @@ class ChatModel extends Model
|
||||
$row->chatDisplay .= "[INTERNAL]";
|
||||
}
|
||||
$row->title = $row->facturaId;
|
||||
$row->unreadMessages = $this->countUnreadMessageFactura($row->facturaId);
|
||||
$rows_new[] = $row;
|
||||
}
|
||||
}
|
||||
@ -587,7 +585,7 @@ class ChatModel extends Model
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function countUnreadMessagePresupuesto($presupuesto_id): int|string
|
||||
public function countUnreadMessagePresupuesto(int $presupuesto_id,int $chat_department_id): int|string
|
||||
{
|
||||
return $this->builder()->select()
|
||||
->join("chat_messages", "chat_messages.chat_id = chats.id", "left")
|
||||
@ -595,6 +593,7 @@ class ChatModel extends Model
|
||||
->where("chats.presupuesto_id", $presupuesto_id)
|
||||
->where("chat_notifications.viewed", false)
|
||||
->where("chat_notifications.user_id", auth()->user()->id)
|
||||
->where('chats.chat_department_id',$chat_department_id)
|
||||
->countAllResults();
|
||||
}
|
||||
public function countUnreadMessagePedido($pedido_id): int|string
|
||||
@ -711,9 +710,7 @@ class ChatModel extends Model
|
||||
[
|
||||
"CONCAT(users.first_name,' ',users.last_name) as userFullName",
|
||||
"users.username as userName",
|
||||
"SUM(chat_notifications.viewed) as viewed_count",
|
||||
"COUNT(chat_notifications.id) as notification_count"
|
||||
|
||||
"chat_notifications.viewed"
|
||||
]
|
||||
|
||||
)
|
||||
@ -722,6 +719,26 @@ class ChatModel extends Model
|
||||
->join("users", "users.id = chat_notifications.user_id", 'left')
|
||||
->where("chats.id", $chat_id)
|
||||
->where("chat_notifications.deleted_at", null)
|
||||
->where('chat_notifications.viewed',false)
|
||||
->get()->getResultArray();
|
||||
return $q;
|
||||
}
|
||||
public function getUsersNotificationViewedFromChat(int $chat_id): array
|
||||
{
|
||||
$q = $this->builder()->distinct()->select(
|
||||
[
|
||||
"CONCAT(users.first_name,' ',users.last_name) as userFullName",
|
||||
"users.username as userName",
|
||||
"chat_notifications.viewed"
|
||||
]
|
||||
|
||||
)
|
||||
->join("chat_messages", "chat_messages.chat_id = chats.id", 'left')
|
||||
->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", 'left')
|
||||
->join("users", "users.id = chat_notifications.user_id", 'left')
|
||||
->where("chats.id", $chat_id)
|
||||
->where("chat_notifications.deleted_at", null)
|
||||
->where('chat_notifications.viewed',true)
|
||||
->get()->getResultArray();
|
||||
return $q;
|
||||
}
|
||||
@ -903,16 +920,17 @@ class ChatModel extends Model
|
||||
public function setAsViewedChatUserNotifications(int $chat_id, int $user_id)
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select("chat_messages.id")
|
||||
->select("chat_notifications.id as notificationId")
|
||||
->join('chat_messages', 'chat_messages.chat_id = chats.id', 'left')
|
||||
->join('chat_notifications', 'chat_notifications.chat_message_id = chat_messages.id', 'left')
|
||||
->where('chat_notifications.user_id',$user_id)
|
||||
->where('chat_messages.chat_id', $chat_id)
|
||||
->get()->getResultObject();
|
||||
$chat_messages_ids = array_map(fn($q) => $q->id, $query);
|
||||
|
||||
$this->db->table("chat_notifications")
|
||||
->where("user_id", $user_id)
|
||||
->whereIn("chat_message_id", $chat_messages_ids)
|
||||
->update(["viewed" => true]);
|
||||
$chat_messages_ids = array_map(fn($q) => $q->notificationId, $query);
|
||||
$chatNotificationModel = model(ChatNotification::class);
|
||||
if($chat_messages_ids){
|
||||
$chatNotificationModel->setNotificationsAsViewed($chat_messages_ids);
|
||||
}
|
||||
}
|
||||
public function setAsViewedChatUserMessages(int $chat_id, int $user_id)
|
||||
{
|
||||
@ -924,16 +942,17 @@ class ChatModel extends Model
|
||||
public function setAsUnviewedChatUserNotifications(int $chat_id, int $user_id)
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select("chat_messages.id")
|
||||
->select("chat_notifications.id as notificationId")
|
||||
->join('chat_messages', 'chat_messages.chat_id = chats.id', 'left')
|
||||
->join('chat_notifications', 'chat_notifications.chat_message_id = chat_messages.id', 'left')
|
||||
->where('chat_notifications.user_id',$user_id)
|
||||
->where('chat_messages.chat_id', $chat_id)
|
||||
->get()->getResultObject();
|
||||
$chat_messages_ids = array_map(fn($q) => $q->id, $query);
|
||||
|
||||
$this->db->table("chat_notifications")
|
||||
->where("user_id", $user_id)
|
||||
->whereIn("chat_message_id", $chat_messages_ids)
|
||||
->update(["viewed" => false]);
|
||||
$chat_messages_ids = array_map(fn($q) => $q->notificationId, $query);
|
||||
$chatNotificationModel = model(ChatNotification::class);
|
||||
if($chat_messages_ids){
|
||||
$chatNotificationModel->setNotificationsAsUnViewed($chat_messages_ids);
|
||||
}
|
||||
}
|
||||
|
||||
public function setAsUnviewedChatUserMessages(int $chat_id, int $user_id)
|
||||
|
||||
@ -59,4 +59,12 @@ class ChatNotification extends Model
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
public function setNotificationsAsViewed(array $notificationIds) : bool
|
||||
{
|
||||
return $this->update($notificationIds,["viewed" => 1]);
|
||||
}
|
||||
public function setNotificationsAsUnViewed(array $notificationIds) : bool
|
||||
{
|
||||
return $this->update($notificationIds,["viewed" => 0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,11 +26,11 @@
|
||||
</div>
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
<div class="mb-0 px-4 pt-3 pb-2">
|
||||
<select class="form-control chat-search-client"></select>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
</div>
|
||||
@ -68,18 +68,22 @@
|
||||
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-danger btn-sm exit-chat">
|
||||
<i class="ti ti-trash"></i>
|
||||
<?= lang('Chat.exit_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-success btn-sm subscribe-chat">
|
||||
<i class="ti ti-plus"></i>
|
||||
<?= lang('Chat.subscribe_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-danger btn-sm exit-chat">
|
||||
<i class="ti ti-trash"></i>
|
||||
<?= lang('Chat.exit_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-success btn-sm subscribe-chat">
|
||||
<i class="ti ti-plus"></i>
|
||||
<?= lang('Chat.subscribe_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
@ -117,11 +121,19 @@
|
||||
placeholder="<?= lang('Chat.write_message_placeholder') ?>" />
|
||||
<div class="message-actions d-flex align-items-center">
|
||||
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment" disabled>
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment" disabled>
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment-client">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -27,9 +27,11 @@
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<div class="mb-0 px-4 pt-3 pb-2">
|
||||
<select class="form-control chat-search-client"></select>
|
||||
</div>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
<div class="mb-0 px-4 pt-3 pb-2">
|
||||
<select class="form-control chat-search-client"></select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="chat-contact-list-item-title">
|
||||
<h5 class="text-primary mb-0 px-4 pt-3 pb-2">Departamentos</h5>
|
||||
@ -65,18 +67,21 @@
|
||||
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-danger btn-sm exit-chat">
|
||||
<i class="ti ti-trash"></i>
|
||||
<?= lang('Chat.exit_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-success btn-sm subscribe-chat">
|
||||
<i class="ti ti-plus"></i>
|
||||
<?= lang('Chat.subscribe_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-danger btn-sm exit-chat">
|
||||
<i class="ti ti-trash"></i>
|
||||
<?= lang('Chat.exit_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-success btn-sm subscribe-chat">
|
||||
<i class="ti ti-plus"></i>
|
||||
<?= lang('Chat.subscribe_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
@ -113,12 +118,19 @@
|
||||
<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">
|
||||
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment" disabled>
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment" disabled>
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment-client">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -26,9 +26,11 @@
|
||||
<hr class="container-m-nx m-0" />
|
||||
<div class="sidebar-body">
|
||||
<div class="chat-contact-list-item-title">
|
||||
<div class="mb-0 px-4 pt-3 pb-2">
|
||||
<select class="form-control chat-search-client"></select>
|
||||
</div>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
<div class="mb-0 px-4 pt-3 pb-2">
|
||||
<select class="form-control chat-search-client"></select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="chat-contact-list-item-title">
|
||||
@ -67,18 +69,21 @@
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-danger btn-sm exit-chat">
|
||||
<i class="ti ti-trash"></i>
|
||||
<?= lang('Chat.exit_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-success btn-sm subscribe-chat">
|
||||
<i class="ti ti-plus"></i>
|
||||
<?= lang('Chat.subscribe_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-danger btn-sm exit-chat">
|
||||
<i class="ti ti-trash"></i>
|
||||
<?= lang('Chat.exit_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-2 px-2">
|
||||
<button type="button" class="btn btn-success btn-sm subscribe-chat">
|
||||
<i class="ti ti-plus"></i>
|
||||
<?= lang('Chat.subscribe_chat') ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="dropdown d-flex align-self-center ml-2 px-2 d-none" id="chat-header-dropdown-users">
|
||||
<button type="button" class="btn btn-primary btn-icon rounded-pill dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
<i class="ti ti-users"></i>
|
||||
@ -112,12 +117,20 @@
|
||||
<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">
|
||||
<?php if (auth()->user()->inGroup('admin')): ?>
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment" disabled>
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment-client">
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<button type="button" class="btn btn-primary d-flex send-msg-btn" style="color:white"
|
||||
id="send-msg-btn-deparment" disabled>
|
||||
<i class="ti ti-send me-md-1 me-0"></i>
|
||||
<span class="align-middle d-md-inline-block">Enviar</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
<form id="<?=$id?>" data-id="<?= $entity->id ?>">
|
||||
<div class="row">
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="chat-department-display"><?= lang('Chat.datatable_departments.name') ?></label>
|
||||
<input type="text" name="display" id="chat-department-display" value="<?= $entity->display ?>" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="chat-department-description"><?= lang('Chat.datatable_departments.description') ?></label>
|
||||
<textarea rows="5" cols="5" type="text" name="description" id="chat-department-description" class="form-control"><?= $entity->description ?></textarea>
|
||||
</div>
|
||||
<div class="col-md-12 mb-5">
|
||||
<button type="button" class="btn btn-primary w-100" id="btn-chat-department-update"><i class="ti icon-base ti-refresh me-2"></i>
|
||||
<?= lang("App.global_save") ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<div class="accordion accordion-bordered" id="accordionChatDepartmentUser">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionChatDepartmentUserTip" aria-expanded="false"
|
||||
aria-controls="accordionChatDepartmentUserTip">
|
||||
<h4><?= lang("Chat.department_users") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionChatDepartmentUserTip" class="accordion-collapse"
|
||||
data-bs-parent="#accordionChatDepartment">
|
||||
<div class="accordion-body">
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-10">
|
||||
<select id="selectChatDepartmentUser" class="select2 form-select" data-allow-clear="true"></select>
|
||||
<div id="floatingInputHelp" class="form-text"><?=lang('Chat.help_select_chat_department_user')?></div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-primary w-100" id="add-user-admin-chat-department"><i class="ti icon-base ti-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<?= view("themes/vuexy/components/tables/chat_department_users_table", ["id" => "tableChatDepartmentUsers", "entity" => $entity]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -0,0 +1,12 @@
|
||||
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;" data-id="<?= $entity->id ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Chat.datatable_department_users.name') ?></th>
|
||||
<th><?= lang('Chat.datatable_department_users.user') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@ -0,0 +1,13 @@
|
||||
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?= lang('Chat.datatable_departments.name') ?></th>
|
||||
<th><?= lang('Chat.datatable_departments.description') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@ -0,0 +1,54 @@
|
||||
<?= $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">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('Chat.message_configuration') ?></h3>
|
||||
</div>
|
||||
<!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<h4 class="card-title"><?= lang('Chat.store_department') ?></h4>
|
||||
<div class="row d-flex align-item-center">
|
||||
<div class="col-md-10 mb-2">
|
||||
<label for="chat-department-display"><?= lang('Chat.datatable_departments.name') ?></label>
|
||||
<input type="text" name="display" id="chat-department-display" class="form-control" placeholder="<?= lang('Chat.datatable_departments.name') ?>" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="btn-add-new-chat-department"> </label>
|
||||
<button type="button" class="btn btn-primary btn-sm w-100" id="btn-add-new-chat-department">
|
||||
<span class="icon-base ti ti-plus icon-xs me-1"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?= view("themes/vuexy/components/tables/chat_departments_table", ["id" => "tableChatDepartments"]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</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/libs/sweetalert2/sweetalert2.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/popper/popper.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 src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/messages/configView.js') ?>"></script>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,38 @@
|
||||
<?= $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" id="chatDepartmentEditContainer">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $chat_department->display ?></h3>
|
||||
</div>
|
||||
<!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view("themes/vuexy/components/forms/chat_department", ["id" => "chatDepartmentForm", "entity" => $chat_department]) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</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/libs/sweetalert2/sweetalert2.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/popper/popper.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 src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/messages/editChatDepartmentView.js') ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -120,6 +120,13 @@ if (
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to('configMessagesIndex') ?>" class="menu-link">
|
||||
<?= lang("App.menu_config_messages") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
@ -12,6 +12,7 @@ class Chat {
|
||||
this.modelId = this.domItem.data("id")
|
||||
this.chatHistoryBody = this.domItem.find(".chat-history-body")
|
||||
this.sendBtnMessageDepartment = this.domItem.find("#send-msg-btn-deparment")
|
||||
this.sendBtnMessageDepartmentClient = this.domItem.find("#send-msg-btn-deparment-client")
|
||||
this.sendBtnMessageInternal = this.domItem.find("#send-msg-btn-internal")
|
||||
this.chatSidebarLeftUserAbout = this.domItem.find('.chat-sidebar-left-user-about'),
|
||||
this.messageInput = this.domItem.find(".message-input")
|
||||
@ -126,11 +127,15 @@ class Chat {
|
||||
this.chatType = "general"
|
||||
this._handleGetChatList()
|
||||
this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this))
|
||||
this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this))
|
||||
|
||||
}
|
||||
initPresupuesto() {
|
||||
this.chatType = "presupuesto"
|
||||
this._handleGetChatList()
|
||||
this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this))
|
||||
this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this))
|
||||
|
||||
this.messageInput.on("keypress", this._sendMessagePressKey.bind(this))
|
||||
this.initSelectClient()
|
||||
|
||||
@ -141,6 +146,7 @@ class Chat {
|
||||
this.chatType = "pedido"
|
||||
this._handleGetChatList()
|
||||
this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this))
|
||||
this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this))
|
||||
this.messageInput.on("keypress", this._sendMessagePressKey.bind(this))
|
||||
this.initSelectClient()
|
||||
|
||||
@ -150,6 +156,7 @@ class Chat {
|
||||
this.chatType = "factura"
|
||||
this._handleGetChatList()
|
||||
this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this))
|
||||
this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this))
|
||||
this.messageInput.on("keypress", this._sendMessagePressKey.bind(this))
|
||||
this.initSelectClient()
|
||||
|
||||
@ -215,10 +222,14 @@ class Chat {
|
||||
this._getChatMessage()
|
||||
this._getChatTotalMessages(row.name)
|
||||
this._getChatDeparmentUsers()
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
this.chatList.find(`#chat__produccion`).trigger("click");
|
||||
if (Object.values(data)) {
|
||||
const firstDepartment = Object.values(data)[0]
|
||||
this.chatList.find(`#chat_${firstDepartment.name}`).trigger("click");
|
||||
}
|
||||
}
|
||||
_handleGetChatListError(error) {
|
||||
console.error(error)
|
||||
@ -356,10 +367,9 @@ class Chat {
|
||||
</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?.user?.first_name + " " + chatMessage?.user?.last_name}</small>
|
||||
</div>
|
||||
<i class="ti ${chatMessage?.viewed ? "ti-checks" : "ti-check"} ti-xs me-1 text-success"></i>
|
||||
<i class="ti ${chatMessage?.viewed == 1 ? "ti-checks" : "ti-check"} ti-xs me-1 text-success"></i>
|
||||
<small>${chatMessage.created_at}</small>
|
||||
</div>
|
||||
|
||||
@ -426,7 +436,7 @@ class Chat {
|
||||
message: messageText,
|
||||
chat_department_id: this.chatDeparmentId,
|
||||
user: this.userId,
|
||||
client: this.selectClientUser.getVal(),
|
||||
client: this.selectClientUser.getVal() ?? null,
|
||||
model_id: this.modelId
|
||||
}
|
||||
if (messageText) {
|
||||
@ -745,7 +755,7 @@ class Chat {
|
||||
_handleRequestExitChatDeparment() {
|
||||
const ajax = new Ajax('/chat/department/user/' + this.chatDeparmentId,
|
||||
{
|
||||
model_fk: this.chatType,
|
||||
model_fk: this.chatType + "_id",
|
||||
model_id_fk: this.modelId
|
||||
},
|
||||
null,
|
||||
@ -768,7 +778,7 @@ class Chat {
|
||||
const ajax = new Ajax('/chat/department/user',
|
||||
{
|
||||
chat_department_id: this.chatDeparmentId,
|
||||
model_fk: this.chatType,
|
||||
model_fk: this.chatType + "_id",
|
||||
model_id_fk: this.modelId
|
||||
},
|
||||
null,
|
||||
|
||||
@ -0,0 +1,160 @@
|
||||
import Ajax from "../ajax.js";
|
||||
import { alertConfirmationDelete, alertSuccess, alertError, alertConfirmAction } from '../alerts/sweetAlert.js'
|
||||
export class ChatDepartmentDatatable {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.chatDepartmentDisplay = $("#chat-department-display")
|
||||
this.btnStoreChatDepartment = $("#btn-add-new-chat-department")
|
||||
|
||||
this.datatableColumns = [
|
||||
{ data: 'id', searchable: false, sortable: true },
|
||||
{ data: 'display', searchable: true, sortable: true },
|
||||
{ data: 'description', searchable: true, sortable: true },
|
||||
{
|
||||
data: 'action', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
return `<div class="btn-group btn-group-sm">
|
||||
<a href="/chat/department/edit/${d}" class="chat-department-edit" ><i class="ti ti-eye ti-sm mx-2"></i></a>
|
||||
<a href="javascript:void(0);" class="chat-department-delete" data-id="${d}" ><i class="ti ti-trash ti-sm mx-2"></i></a>
|
||||
</div>`
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
init() {
|
||||
this.btnStoreChatDepartment.on('click', this.storeNewChatDepartment.bind(this))
|
||||
this.item.on('click', '.chat-department-delete', this.deleteChatDepartment.bind(this))
|
||||
|
||||
this.datatable = this.item.DataTable({
|
||||
processing: true,
|
||||
order: [[0, 'asc']],
|
||||
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: '/chat/department/datatable'
|
||||
});
|
||||
}
|
||||
deleteChatDepartment(event) {
|
||||
const ajax = new Ajax(
|
||||
`/chat/department/${$(event.currentTarget).data("id")}`,
|
||||
null,
|
||||
null,
|
||||
this.deleteChatDepartmentSuccess.bind(this),
|
||||
this.deleteChatDepartmentError.bind(this)
|
||||
)
|
||||
alertConfirmationDelete().then(result => {
|
||||
if (result.isConfirmed) {
|
||||
ajax.delete()
|
||||
}
|
||||
})
|
||||
}
|
||||
deleteChatDepartmentSuccess(response) {
|
||||
this.datatable.ajax.reload()
|
||||
alertSuccess(response.message).fire()
|
||||
}
|
||||
deleteChatDepartmentError(response) {
|
||||
alertError(response.message).fire()
|
||||
}
|
||||
storeNewChatDepartment() {
|
||||
this.btnStoreChatDepartment.attr("disabled")
|
||||
const ajax = new Ajax("/chat/department", {
|
||||
display: this.chatDepartmentDisplay.val()
|
||||
},
|
||||
null,
|
||||
this.storeNewChatDepartmentSuccess.bind(this),
|
||||
this.storeNewChatDepartmentError.bind(this)
|
||||
)
|
||||
if (this.chatDepartmentDisplay.val()) {
|
||||
alertConfirmAction().then(result => {
|
||||
if (result.isConfirmed) {
|
||||
ajax.post()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.btnStoreChatDepartment.removeAttr("disabled")
|
||||
}
|
||||
}
|
||||
storeNewChatDepartmentSuccess(response) {
|
||||
this.datatable.ajax.reload()
|
||||
alertSuccess(response.message).fire()
|
||||
}
|
||||
storeNewChatDepartmentError(response) {
|
||||
console.log(response)
|
||||
alertError(response.message).fire()
|
||||
}
|
||||
|
||||
}
|
||||
export class ChatDepartmentUserDatatable {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.datatableColumns = [
|
||||
{ data: 'userFullName', searchable: true, sortable: true },
|
||||
{ data: 'username', searchable: true, sortable: true },
|
||||
{
|
||||
data: 'action', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
return `<div class="btn-group btn-group-sm">
|
||||
<a type="button" href="javascript:void(0);" data-id="${d}" class="chat-department-user-delete"><i class="ti ti-trash ti-sm mx-2"></i></a>
|
||||
</div>`
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
init() {
|
||||
this.actions()
|
||||
this.datatable = this.item.DataTable({
|
||||
processing: true,
|
||||
order: [[0, 'desc']],
|
||||
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: '/chat/department/users/datatable/' + this.item.data('id')
|
||||
});
|
||||
}
|
||||
actions() {
|
||||
this.item.on("click", ".chat-department-user-delete", this.deleteRow.bind(this))
|
||||
}
|
||||
deleteRow(event) {
|
||||
const ajax = new Ajax(`/chat/department/admin/user/${this.item.data('id')}/${$(event.currentTarget).data("id")}`,
|
||||
null,
|
||||
null,
|
||||
this.deleteRowSuccess.bind(this),
|
||||
this.deleteRowError.bind(this),
|
||||
)
|
||||
alertConfirmationDelete().then(result => {
|
||||
if (result.isConfirmed) {
|
||||
ajax.delete()
|
||||
}
|
||||
})
|
||||
}
|
||||
deleteRowSuccess(response) {
|
||||
this.datatable.ajax.reload();
|
||||
alertSuccess(response.message).fire()
|
||||
}
|
||||
deleteRowError(response) {
|
||||
alertError(response?.message).fire()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -134,33 +134,49 @@ class MessagesDatatable {
|
||||
}
|
||||
handleDropUpSuccess(response) {
|
||||
const chatId = response.chat_id
|
||||
const users = response.data
|
||||
if (users.length > 0) {
|
||||
const unviewedNotifications = response.data.unviewedNotifications
|
||||
const viewedNotifications = response.data.viewedNotifications
|
||||
|
||||
users.forEach(user => {
|
||||
const viewed = (user.notification_count - user.viewed_count) == 0
|
||||
if (unviewedNotifications.length > 0) {
|
||||
|
||||
unviewedNotifications.forEach(user => {
|
||||
if (user.userFullName || user.userName) {
|
||||
|
||||
$(`#dropdown-viewed-${chatId}`)
|
||||
.append(`
|
||||
<li >
|
||||
<a class="d-flex flex-row justify-content-start align-items-center dropdown-item px-2 gap-2" href="javascript:void(0);" >
|
||||
<span> ${user.userFullName ?? user.userName} </span>
|
||||
<span class="badge badge-center rounded-pill text-bg-secondary">
|
||||
<i class="ti ti-xs ti-${viewed ? "eye-check" : "eye-off"} "></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
`)
|
||||
.append(this.addDropUpItem(user))
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
$(`#dropdown-viewed-${chatId}`).append(`<li><a class="dropdown-item" href="javascript:void(0);" >Visto</a></li>`)
|
||||
}
|
||||
if (viewedNotifications.length > 0) {
|
||||
|
||||
viewedNotifications.forEach(user => {
|
||||
if (user.userFullName || user.userName) {
|
||||
|
||||
$(`#dropdown-viewed-${chatId}`)
|
||||
.append(this.addDropUpItem(user))
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
handleDropUpError() { }
|
||||
|
||||
addDropUpItem(user)
|
||||
{
|
||||
return `
|
||||
<li >
|
||||
<a type="button" class="d-flex flex-row justify-content-between align-items-center dropdown-item px-2 gap-2" href="javascript:void(0);" >
|
||||
<span> ${user.userFullName ?? user.userName} </span>
|
||||
<span class="badge badge-center rounded-pill text-bg-${
|
||||
user.viewed == 1 ? 'success' : 'danger'
|
||||
}">
|
||||
<i class="ti ti-xs ti-${
|
||||
user.viewed == 1 ? 'eye-check' : 'eye-off'
|
||||
} "></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
import ClassSelect from "../select2.js"
|
||||
import { ChatDepartmentUserDatatable } from '../datatables/ChatDepartmentDatatable.js'
|
||||
import Ajax from "../ajax.js"
|
||||
import { alertConfirmAction, alertError, alertSuccess } from "../alerts/sweetAlert.js"
|
||||
|
||||
class ChatDepartmentForm {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.chatDepartmentId = this.item.data("id")
|
||||
this.btnAddUserToDepartment = this.item.find("#add-user-admin-chat-department")
|
||||
this.btnUpdate = this.item.find("#btn-chat-department-update")
|
||||
this.chatDepartmentUsersDatatable = new ChatDepartmentUserDatatable($("#tableChatDepartmentUsers"))
|
||||
this.seletChatDepartmentUserItem = this.item.find("#selectChatDepartmentUser")
|
||||
this.seletChatDepartmentUser = new ClassSelect(
|
||||
this.seletChatDepartmentUserItem,
|
||||
`/chat/department/users/select/add/${this.chatDepartmentId}`
|
||||
)
|
||||
}
|
||||
init() {
|
||||
this.seletChatDepartmentUser.init()
|
||||
this.chatDepartmentUsersDatatable.init()
|
||||
this.btnAddUserToDepartment.on('click', this._handleUserToDepartment.bind(this))
|
||||
this.btnUpdate.on("click", this._handleUpdateDepartment.bind(this))
|
||||
}
|
||||
getFormData() {
|
||||
return {
|
||||
display: this.item.find("#chat-department-display").val(),
|
||||
description: this.item.find("#chat-department-description").val()
|
||||
}
|
||||
}
|
||||
updateFormData(data) {
|
||||
this.item.find("#chat-department-display").val(data.display)
|
||||
this.item.find("#chat-department-description").val(data.description)
|
||||
}
|
||||
_handleUserToDepartment() {
|
||||
this.btnAddUserToDepartment.attr("disabled", "disabled")
|
||||
const ajax = new Ajax("/chat/department/subscribe/admin/user",
|
||||
{
|
||||
user_id: this.seletChatDepartmentUser.getVal(),
|
||||
chat_department_id: this.chatDepartmentId
|
||||
},
|
||||
null,
|
||||
this._handleUserToDepartmentSuccess.bind(this),
|
||||
this._handleUserToDepartmentError.bind(this)
|
||||
)
|
||||
if (this.seletChatDepartmentUser.getVal()) {
|
||||
ajax.post();
|
||||
} else {
|
||||
this.btnAddUserToDepartment.removeAttr("disabled")
|
||||
}
|
||||
}
|
||||
_handleUserToDepartmentSuccess(response) {
|
||||
this.btnAddUserToDepartment.removeAttr("disabled")
|
||||
this.chatDepartmentUsersDatatable.datatable.ajax.reload()
|
||||
alertSuccess(response.message).fire()
|
||||
this.seletChatDepartmentUser.reset()
|
||||
}
|
||||
_handleUserToDepartmentError(response) {
|
||||
alertError(response.message ?? "").fire()
|
||||
this.btnAddUserToDepartment.removeAttr("disabled")
|
||||
|
||||
}
|
||||
_handleUpdateDepartment() {
|
||||
this.btnUpdate.attr("disabled")
|
||||
const ajax = new Ajax("/chat/department/update/" + this.chatDepartmentId,
|
||||
this.getFormData(),
|
||||
null,
|
||||
this._handleUserToDepartmentSuccess.bind(this),
|
||||
this._handleUserToDepartmentError.bind(this)
|
||||
)
|
||||
if (this.getFormData()) {
|
||||
ajax.post();
|
||||
} else {
|
||||
this.btnUpdate.removeAttr("disabled")
|
||||
}
|
||||
}
|
||||
__handleUpdateDepartmentSuccess(response) {
|
||||
this.btnUpdate.removeAttr("disabled")
|
||||
alertSuccess(response.message).fire()
|
||||
this.updateFormData(response.data)
|
||||
}
|
||||
_handleUpdateDepartmentError(response) {
|
||||
this.btnUpdate.removeAttr("disabled")
|
||||
alertError(response.message ?? "").fire()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default ChatDepartmentForm
|
||||
@ -5,97 +5,96 @@
|
||||
* @param {String} placeholder
|
||||
*/
|
||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "", hideSearch = false) {
|
||||
this.url = url;
|
||||
this.item = domItem;
|
||||
this.params = params;
|
||||
this.dropdownParent = dropdownParent;
|
||||
this.hideSearch = hideSearch;
|
||||
this.url = url;
|
||||
this.item = domItem;
|
||||
this.params = params;
|
||||
this.dropdownParent = dropdownParent;
|
||||
this.hideSearch = hideSearch;
|
||||
|
||||
this.config = {
|
||||
placeholder: placeholder,
|
||||
allowClear: allowClear,
|
||||
dropdownParent: dropdownParent!=""?dropdownParent:domItem.parent(),
|
||||
language: "es",
|
||||
ajax: {
|
||||
url: () => {
|
||||
return this.url;
|
||||
},
|
||||
data: (params) => {
|
||||
let q = $.trim(params.term);
|
||||
let d = {
|
||||
q: q,
|
||||
page: params.page || 1,
|
||||
};
|
||||
|
||||
for (let key in this.params) {
|
||||
d[key] = this.params[key];
|
||||
}
|
||||
|
||||
return d;
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: $.map(data, function (obj) {
|
||||
return {
|
||||
id: obj.id,
|
||||
text: obj.nombre ?? obj.name,
|
||||
desc: obj.description,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
cache: true,
|
||||
this.config = {
|
||||
placeholder: placeholder,
|
||||
allowClear: allowClear,
|
||||
dropdownParent: dropdownParent != "" ? dropdownParent : domItem.parent(),
|
||||
language: "es",
|
||||
ajax: {
|
||||
url: () => {
|
||||
return this.url;
|
||||
},
|
||||
};
|
||||
this.init = function () {
|
||||
if (this.item.length) {
|
||||
data: (params) => {
|
||||
let q = $.trim(params.term);
|
||||
let d = {
|
||||
q: q,
|
||||
page: params.page || 1,
|
||||
};
|
||||
|
||||
if(this.hideSearch){
|
||||
this.config.minimumResultsForSearch = -1;
|
||||
for (let key in this.params) {
|
||||
d[key] = this.params[key];
|
||||
}
|
||||
|
||||
this.item = this.item.select2(this.config);
|
||||
// $.fn.modal.Constructor.prototype.enforceFocus = function () {};
|
||||
}
|
||||
};
|
||||
this.setOption = function (id, nombre) {
|
||||
var newOption = new Option(nombre , id, false, false);
|
||||
this.item.append(newOption);
|
||||
this.item.val(id).trigger("change");
|
||||
};
|
||||
this.reset = function () {
|
||||
this.item.val(null).trigger("change");
|
||||
};
|
||||
this.setParams = function(params){
|
||||
this.params = params;
|
||||
};
|
||||
this.getVal = function () {
|
||||
return this.item.val();
|
||||
};
|
||||
this.setVal = function (val) {
|
||||
return this.item.val(val).trigger("change");
|
||||
};
|
||||
this.empty = function () {
|
||||
return this.item.empty().trigger("change");
|
||||
};
|
||||
this.readOnly = function () {
|
||||
this.item.enable(false);
|
||||
};
|
||||
this.enable = () => {
|
||||
this.item.enable(true);
|
||||
};
|
||||
this.fixWithScroll = function () {};
|
||||
this.getText = () => {
|
||||
return this.item.find(":selected").text();
|
||||
};
|
||||
this.onChange = function(callback) {
|
||||
this.item.on('change', callback);
|
||||
};
|
||||
this.offChange = function() {
|
||||
this.item.off('change');
|
||||
};
|
||||
|
||||
return d;
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: $.map(data, function (obj) {
|
||||
return {
|
||||
id: obj.id,
|
||||
text: obj.nombre ?? obj.name,
|
||||
desc: obj.description,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
};
|
||||
|
||||
this.init = function () {
|
||||
if (this.item.length) {
|
||||
|
||||
if (this.hideSearch) {
|
||||
this.config.minimumResultsForSearch = -1;
|
||||
}
|
||||
|
||||
this.item = this.item.select2(this.config);
|
||||
// $.fn.modal.Constructor.prototype.enforceFocus = function () {};
|
||||
}
|
||||
};
|
||||
this.setOption = function (id, nombre) {
|
||||
var newOption = new Option(nombre, id, false, false);
|
||||
this.item.append(newOption);
|
||||
this.item.val(id).trigger("change");
|
||||
};
|
||||
this.reset = function () {
|
||||
this.item.val(null).trigger("change");
|
||||
};
|
||||
this.setParams = function (params) {
|
||||
this.params = params;
|
||||
};
|
||||
this.getVal = function () {
|
||||
return this.item.val();
|
||||
};
|
||||
this.setVal = function (val) {
|
||||
return this.item.val(val).trigger("change");
|
||||
};
|
||||
this.empty = function () {
|
||||
return this.item.empty().trigger("change");
|
||||
};
|
||||
this.readOnly = function () {
|
||||
this.item.enable(false);
|
||||
};
|
||||
this.enable = () => {
|
||||
this.item.enable(true);
|
||||
};
|
||||
this.fixWithScroll = function () { };
|
||||
this.getText = () => {
|
||||
return this.item.find(":selected").text();
|
||||
};
|
||||
this.onChange = function (callback) {
|
||||
this.item.on('change', callback);
|
||||
};
|
||||
this.offChange = function () {
|
||||
this.item.off('change');
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
export default ClassSelect;
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
|
||||
import Ajax from '../../../components/ajax.js'
|
||||
import { ChatDepartmentDatatable } from '../../../components/datatables/ChatDepartmentDatatable.js'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$(() => {
|
||||
const chatDepartmentDatatable = new ChatDepartmentDatatable($("#tableChatDepartments"))
|
||||
chatDepartmentDatatable.init()
|
||||
})
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import ChatDepartmentForm from '../../../components/forms/chatDepartmentForm.js'
|
||||
|
||||
$(() => {
|
||||
|
||||
const chatDepartmentForm = new ChatDepartmentForm($("#chatDepartmentForm"))
|
||||
chatDepartmentForm.init()
|
||||
})
|
||||
Reference in New Issue
Block a user