mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add all message datatable and alertboxes instead of toast
This commit is contained in:
@ -443,16 +443,17 @@ class ChatController extends BaseController
|
||||
{
|
||||
$auth_user_id = auth()->user()->id;
|
||||
$isAdmin = auth()->user()->inGroup('admin');
|
||||
$query = $this->chatModel->getQueryDatatable($auth_user_id);
|
||||
$query = $this->chatModel->getQueryDatatable();
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i"))
|
||||
->edit('updated_at', fn($q) => Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i"))
|
||||
->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName)
|
||||
->edit("creator",fn($q) => $q->userId == $auth_user_id ? '<span class="badge text-bg-success w-100">'.lang("App.me").'</span>' : $q->creator)
|
||||
->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id))
|
||||
->add("action", fn($q) => [
|
||||
"type" => "direct",
|
||||
"modelId" => $q->id,
|
||||
"isAdmin" => $isAdmin,
|
||||
"chatMessageId" => $q->chatMessageId,
|
||||
"lang" => [
|
||||
"view_chat" => lang('Chat.view_chat'),
|
||||
"view_by_alt_message" => lang('Chat.view_by_alt_message')
|
||||
|
||||
@ -35,6 +35,7 @@ return [
|
||||
"global_next" => "Siguiente",
|
||||
"global_save_file" => "Guardar ficheros",
|
||||
"global_upload_files" => "Subir ficheros",
|
||||
"global_all" => "Todos",
|
||||
// LOGIN - Index
|
||||
"login_title" => "Iniciar sesión en su cuenta",
|
||||
"login_email" => "Correo Electrónico",
|
||||
|
||||
@ -712,30 +712,39 @@ class ChatModel extends Model
|
||||
->get()->getResultArray();
|
||||
return $q;
|
||||
}
|
||||
public function getQueryDatatable(int $user_id): BaseBuilder
|
||||
public function getQueryDatatable(): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select([
|
||||
"chats.id",
|
||||
"cm.id as chatMessageId",
|
||||
"u.id as userId",
|
||||
"cm.message",
|
||||
"chats.created_at",
|
||||
"cm.updated_at",
|
||||
"chats.title",
|
||||
"
|
||||
(
|
||||
SELECT cm2.updated_at
|
||||
FROM chat_messages cm2
|
||||
WHERE cm2.chat_id = chats.id
|
||||
ORDER BY cm2.updated_at DESC LIMIT 1
|
||||
) as updated_at",
|
||||
"CONCAT(u.first_name,' ',u.last_name) as creator",
|
||||
"chats.title as title",
|
||||
])
|
||||
->join("chat_users", "chat_users.chat_id = chats.id", "left")
|
||||
->join("presupuestos", "presupuestos.id = chats.presupuesto_id", 'left')
|
||||
->join("chat_messages cm", "chats.id = cm.chat_id", "left")
|
||||
->where("chat_department_id", null)
|
||||
->where("pedido_id", null)
|
||||
->where("presupuesto_id", null)
|
||||
->where("factura_id", null)
|
||||
->where("chat_users.user_id", $user_id)
|
||||
->where("cm.updated_at = (
|
||||
SELECT cm2.updated_at
|
||||
FROM chat_messages cm2
|
||||
WHERE cm2.chat_id = chats.id
|
||||
ORDER BY cm2.updated_at DESC LIMIT 1
|
||||
)");
|
||||
->join("users u", "u.id = cm.sender_id", 'left')
|
||||
->groupStart()
|
||||
->orWhere("chats.presupuesto_id is NOT NULL", NULL, FALSE)
|
||||
->orWhere("chats.pedido_id is NOT NULL", NULL, FALSE)
|
||||
->orWhere("chats.factura_id is NOT NULL", NULL, FALSE)
|
||||
->groupEnd();
|
||||
|
||||
return $query;
|
||||
if (auth()->user()->inGroup("admin") == false) {
|
||||
$query->where('presupuestos.cliente_id', auth()->user()->cliente_id)
|
||||
->where("chats.chat_department_id is NOT NULL", NULL, FALSE);
|
||||
}
|
||||
return $query->groupBy('chatMessageId');
|
||||
}
|
||||
public function getQueryDatatableMessagePresupuesto(int $user_id): BaseBuilder
|
||||
{
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<div class="accordion accordion-bordered" id="accordionChatDepartmentUser">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header">
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
<!--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/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<?= view("themes/vuexy/components/forms/chat_department", ["id" => "chatDepartmentForm", "entity" => $chat_department]) ?>
|
||||
</div>
|
||||
|
||||
@ -35,4 +35,4 @@
|
||||
<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() ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,3 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Config\App;
|
||||
?>
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
@ -10,23 +14,25 @@
|
||||
<div class="col-md-12">
|
||||
<div class="nav-tabs-shadow nav-align-top">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<!-- <li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" id="navs-top-align-directos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-directos">Directos</button>
|
||||
</li> -->
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link active" role="tab" id="navs-top-align-presupuestos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-presupuestos">Presupuestos</button>
|
||||
<button type="button" class="nav-link active" role="tab" id="navs-top-align-all-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-all"><?=lang('App.global_all')?></button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-pedidos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-pedidos">Pedidos</button>
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-presupuestos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-presupuestos"><?=lang('App.permisos_presupuestos')?></button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-facturas-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-facturas">Facturas</button>
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-pedidos-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-pedidos"><?=lang('App.permisos_pedidos')?></button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-facturas-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-facturas"><?=lang('App.menu_facturas')?></button>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="tab-content" id="message-datatables-container">
|
||||
|
||||
<div class="tab-pane fade show active" id="navs-top-align-presupuestos">
|
||||
<div class="tab-pane fade show active" id="navs-top-align-all">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tableAllMessages"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-presupuestos">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tablePresupuestoMessages"]) ?>
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-pedidos">
|
||||
|
||||
@ -59,10 +59,12 @@ export class ChatDepartmentDatatable {
|
||||
}
|
||||
deleteChatDepartmentSuccess(response) {
|
||||
this.datatable.ajax.reload()
|
||||
alertSuccess(response.message).fire()
|
||||
popSuccessAlert(response.message);
|
||||
|
||||
}
|
||||
deleteChatDepartmentError(response) {
|
||||
alertError(response.message).fire()
|
||||
popErrorAlert(response.message);
|
||||
|
||||
}
|
||||
storeNewChatDepartment() {
|
||||
this.btnStoreChatDepartment.attr("disabled")
|
||||
@ -85,11 +87,12 @@ export class ChatDepartmentDatatable {
|
||||
}
|
||||
storeNewChatDepartmentSuccess(response) {
|
||||
this.datatable.ajax.reload()
|
||||
alertSuccess(response.message).fire()
|
||||
popSuccessAlert(response.message);
|
||||
}
|
||||
storeNewChatDepartmentError(response) {
|
||||
console.log(response)
|
||||
alertError(response.message).fire()
|
||||
popErrorAlert(response.message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -147,10 +150,12 @@ export class ChatDepartmentUserDatatable {
|
||||
}
|
||||
deleteRowSuccess(response) {
|
||||
this.datatable.ajax.reload();
|
||||
alertSuccess(response.message).fire()
|
||||
popSuccessAlert(response.message);
|
||||
|
||||
}
|
||||
deleteRowError(response) {
|
||||
alertError(response?.message).fire()
|
||||
popErrorAlert(response.message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import Ajax from "../ajax.js";
|
||||
class MessagesDatatable {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.datatableItem = this.item.find("#tableMessages")
|
||||
this.datatableItem = this.item.find("#tableAllMessages")
|
||||
this.datatablePresupuestoMessageItem = this.item.find("#tablePresupuestoMessages")
|
||||
this.datatablePedidoMessageItem = this.item.find("#tablePedidoMessages")
|
||||
this.datatableFacturaMessageItem = this.item.find("#tableFacturaMessages")
|
||||
|
||||
@ -52,11 +52,11 @@ class ChatDepartmentForm {
|
||||
_handleUserToDepartmentSuccess(response) {
|
||||
this.btnAddUserToDepartment.removeAttr("disabled")
|
||||
this.chatDepartmentUsersDatatable.datatable.ajax.reload()
|
||||
alertSuccess(response.message).fire()
|
||||
popSuccessAlert(response.message);
|
||||
this.seletChatDepartmentUser.reset()
|
||||
}
|
||||
_handleUserToDepartmentError(response) {
|
||||
alertError(response.message ?? "").fire()
|
||||
popErrorAlert(response.message);
|
||||
this.btnAddUserToDepartment.removeAttr("disabled")
|
||||
|
||||
}
|
||||
@ -76,12 +76,12 @@ class ChatDepartmentForm {
|
||||
}
|
||||
__handleUpdateDepartmentSuccess(response) {
|
||||
this.btnUpdate.removeAttr("disabled")
|
||||
alertSuccess(response.message).fire()
|
||||
popSuccessAlert(response.message);
|
||||
this.updateFormData(response.data)
|
||||
}
|
||||
_handleUpdateDepartmentError(response) {
|
||||
this.btnUpdate.removeAttr("disabled")
|
||||
alertError(response.message ?? "").fire()
|
||||
popErrorAlert(response.message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ class MessagePage {
|
||||
this.btnSubmitNewDirectMessage.on("click", this.handleSubmitNewMessage.bind(this))
|
||||
this.btnSubmitNewDirectMessageCliente.on("click", this.handleSubmitNewMessageClient.bind(this))
|
||||
|
||||
$("#navs-top-align-directos-tab").on("click",()=>{
|
||||
$("#navs-top-align-all-tab").on("click",()=>{
|
||||
this.messageDatatable.datatable.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-presupuestos-tab").on("click",()=>{
|
||||
|
||||
Reference in New Issue
Block a user