messages departments section

This commit is contained in:
amazuecos
2025-03-20 08:20:50 +01:00
parent d417db18e2
commit 6e96beeec8
26 changed files with 1045 additions and 306 deletions

View File

@ -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]);
}
}
}