mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add maquinista change user session
This commit is contained in:
@ -41,7 +41,7 @@ foreach (glob(APPPATH . 'Config/Routes/*Routes.php') as $routeFile) {
|
||||
$routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Users::index', ['as' => 'userList']);
|
||||
$routes->get('maquinista/change/user','Users::index_maquinista_change_user',['as' => 'maquinistaUserChangeList']);
|
||||
$routes->get('maquinista/change/session/$1','Users::change_user_session/$1',['as' => 'maquinistaChangeUserSession']);
|
||||
$routes->get('maquinista/change/session/(:num)','Users::change_user_session/$1',['as' => 'maquinistaChangeUserSession']);
|
||||
$routes->get('list', 'Users::index', ['as' => 'userList2']);
|
||||
$routes->get('add', 'Users::add', ['as' => 'newUser']);
|
||||
$routes->post('add', 'Users::add', ['as' => 'createUser']);
|
||||
@ -644,6 +644,7 @@ $routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($r
|
||||
$routes->get('datatable/presupuesto', 'ChatController::datatable_presupuesto_messages', ['as' => 'getDatatablePresupuestoMessages']);
|
||||
$routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']);
|
||||
$routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']);
|
||||
$routes->get('datatable/ots', 'ChatController::datatable_ot_messages', ['as' => 'getDatatableOtMessages']);
|
||||
|
||||
$routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']);
|
||||
$routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']);
|
||||
@ -654,6 +655,8 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route
|
||||
$routes->get('presupuesto/(:num)', 'ChatController::get_chat_presupuesto_view/$1', ['as' => 'getChatPresupuestoView']);
|
||||
$routes->get('pedido/(:num)', 'ChatController::get_chat_pedido_view/$1', ['as' => 'getChatPedidoView']);
|
||||
$routes->get('factura/(:num)', 'ChatController::get_chat_factura_view/$1', ['as' => 'getChatFacturaView']);
|
||||
$routes->get('ot/(:num)', 'ChatController::get_chat_ot_view/$1', ['as' => 'getChatOtView']);
|
||||
|
||||
|
||||
$routes->get('direct/conversation/(:num)', 'ChatController::get_chat_direct/$1', ['as' => 'getChatDirect']);
|
||||
$routes->get('direct/users/select/(:num)', 'ChatController::get_chat_direct_select_users/$1', ['as' => 'getChatDirectSelectUsers']);
|
||||
|
||||
@ -222,6 +222,25 @@ class ChatController extends BaseController
|
||||
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
|
||||
}
|
||||
}
|
||||
public function get_chat_ot_view($chat_id)
|
||||
{
|
||||
$chat = $this->chatModel->find($chat_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false],
|
||||
['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true]
|
||||
];
|
||||
$this->viewData["modelId"] = $chat->orden_trabajo_id;
|
||||
$this->viewData["type"] = "ot";
|
||||
$auth_user = auth()->user();
|
||||
$this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id);
|
||||
$this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id);
|
||||
|
||||
if ($chat->chat_department_id) {
|
||||
return view(static::$viewPath . 'messageChatFactura', $this->viewData);
|
||||
} else {
|
||||
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
|
||||
}
|
||||
}
|
||||
public function get_chat(int $chat_id)
|
||||
{
|
||||
|
||||
@ -502,6 +521,23 @@ class ChatController extends BaseController
|
||||
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_ot_messages()
|
||||
{
|
||||
$auth_user_id = auth()->user()->id;
|
||||
$isAdmin = auth()->user()->inGroup('admin');
|
||||
$query = $this->chatModel->getQueryDatatableMessageOrdenTrabajo($auth_user_id);
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "")
|
||||
->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->chatMessageId))
|
||||
->add("action", fn($q) => ["type" => "ot", "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')
|
||||
]])
|
||||
|
||||
->toJson(true);
|
||||
}
|
||||
public function get_notifications_not_viewed_from_message(int $chat_message_id)
|
||||
{
|
||||
$unviewedNotifications = $this->chatModel->getUsersNotificationNotViewedFromChat($chat_message_id);
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
use App\Models\Chat\ChatDeparmentModel;
|
||||
@ -54,7 +56,6 @@ class Users extends \App\Controllers\GoBaseController
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
@ -118,11 +119,10 @@ class Users extends \App\Controllers\GoBaseController
|
||||
|
||||
} // Email is not unique!
|
||||
else {
|
||||
$this->viewData['errorMessage'] = "El correo '". $sanitizedData['email'] ."' ya está registrado en el sistema";
|
||||
$this->viewData['errorMessage'] = "El correo '" . $sanitizedData['email'] . "' ya está registrado en el sistema";
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
$successfulResult = false; // Hacked
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->viewData['errorMessage'] = $e->getMessage();
|
||||
@ -234,7 +234,6 @@ class Users extends \App\Controllers\GoBaseController
|
||||
} else {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
@ -319,8 +318,6 @@ class Users extends \App\Controllers\GoBaseController
|
||||
|
||||
$message = "Usuario eliminado correctamente";
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
|
||||
|
||||
} // end function delete(...)
|
||||
|
||||
|
||||
@ -374,9 +371,10 @@ class Users extends \App\Controllers\GoBaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
if($this->request->isAJAX()){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
@ -405,7 +403,6 @@ class Users extends \App\Controllers\GoBaseController
|
||||
$this->model->getResource([])->countAllResults(),
|
||||
$this->model->getResource($searchValues)->countAllResults()
|
||||
));
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
@ -453,18 +450,21 @@ class Users extends \App\Controllers\GoBaseController
|
||||
['title' => lang("App.menu_change_session"), 'route' => route_to('maquinistaUserChangeList'), 'active' => true]
|
||||
];
|
||||
$maquinistas = [];
|
||||
$users = auth()->getProvider()->findAll();
|
||||
$users = auth()->getProvider()->whereNotIn('id',[auth()->user()->id])->findAll();
|
||||
foreach ($users as $key => $user) {
|
||||
if($user->inGroup('maquina') && !$user->inGroup('admin','comercial','cliente-editor','cliente-admin')){
|
||||
if ($user->inGroup('maquina') && !$user->inGroup('admin', 'comercial', 'cliente-editor', 'cliente-admin')) {
|
||||
$maquinistas[] = $user;
|
||||
}
|
||||
}
|
||||
$this->viewData['maquinistas'] = $maquinistas;
|
||||
return view('/themes/vuexy/form/produccion/maquinista/viewMaquinistaCambioUserList.php',$this->viewData);
|
||||
return view('/themes/vuexy/form/produccion/maquinista/viewMaquinistaCambioUserList.php', $this->viewData);
|
||||
}
|
||||
public function change_user_session(int $user_id)
|
||||
{
|
||||
return redirect_to("maquinistaUserChangeList");
|
||||
// Check the credentials
|
||||
$user = auth()->getProvider()->findById($user_id);
|
||||
auth()->logout();
|
||||
auth()->login($user);
|
||||
return redirect("home");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -105,11 +105,11 @@ class Ordentrabajo extends BaseController
|
||||
public function update_orden_trabajo_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea");
|
||||
if ($validated) {
|
||||
$r = $this->produccionService->updateOrdenTrabajoTarea($bodyData["orden_trabajo_tarea_id"], $bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
|
||||
$tareaEntity = $this->otTarea->find($bodyData["orden_trabajo_tarea_id"]);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $tareaEntity]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div class="col-md-6 mb-2">
|
||||
<p class="mb-0">Clicks</p>
|
||||
<h4 class="mb-0" id="clicks-info"><?= $ot_tarea->click_tarea ?></h4>
|
||||
<h4 class="mb-0" id="clicks-info"><?= $ot_tarea->click_end - $ot_tarea->click_init ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -26,6 +26,9 @@ use Config\App;
|
||||
<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>
|
||||
<li class="nav-item">
|
||||
<button type="button" class="nav-link" role="tab" id="navs-top-align-ot-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-ots"><?=lang('Produccion.ots')?></button>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="tab-content" id="message-datatables-container">
|
||||
@ -41,7 +44,9 @@ use Config\App;
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-facturas">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tableFacturaMessages"]) ?>
|
||||
|
||||
</div>
|
||||
<div class="tab-pane fade show" id="navs-top-align-ots">
|
||||
<?= view("themes/vuexy/components/tables/messages_table", ["id" => "tableOtMessages"]) ?>
|
||||
</div>
|
||||
</div>
|
||||
<!--//.card -->
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (count($maquinistas) > 0): ?>
|
||||
|
||||
<?php foreach ($maquinistas as $key => $maquinista): ?>
|
||||
<tr>
|
||||
<td><?= $maquinista->id ?></td>
|
||||
@ -29,10 +31,15 @@
|
||||
<td><?= $maquinista->last_name ?></td>
|
||||
<td><?= $maquinista->getEmail() ?></td>
|
||||
<td style="color: white;">
|
||||
<a type="button" href="<?=route_to("maquinistaChangeUserSession",$maquinista->id)?>" class="btn btn-lg btn-primary h-100 w-100">Mi turno</a>
|
||||
<a type="button" href="<?= route_to("maquinistaChangeUserSession", $maquinista->id) ?>" class="btn btn-lg btn-primary h-100 w-100">Mi turno</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr class="text-center">
|
||||
<td colspan="5">No hay usuarios para cambiar turno</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -7,6 +7,8 @@ class MessagesDatatable {
|
||||
this.datatablePresupuestoMessageItem = this.item.find("#tablePresupuestoMessages")
|
||||
this.datatablePedidoMessageItem = this.item.find("#tablePedidoMessages")
|
||||
this.datatableFacturaMessageItem = this.item.find("#tableFacturaMessages")
|
||||
this.datatableOtMessageItem = this.item.find("#tableOtMessages")
|
||||
|
||||
this.focusTable = this.datatableItem
|
||||
this.columnDefs = [
|
||||
]
|
||||
@ -131,6 +133,25 @@ class MessagesDatatable {
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/messages/datatable/factura'
|
||||
});
|
||||
this.datatableOtMessage = this.datatableOtMessageItem.DataTable({
|
||||
processing: true,
|
||||
order: [[1, 'desc']],
|
||||
columnDefs : this.columnDefs,
|
||||
orderCellsTop : true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
serverSide: true,
|
||||
pageLength: 10,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/messages/datatable/ots'
|
||||
});
|
||||
this.datatablePresupuestoMessageItem.on("keyup", ".datatable-message-filter", (event) => {
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatablePresupuestoMessage.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
@ -143,6 +164,10 @@ class MessagesDatatable {
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableFacturaMessage.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
this.datatableOtMessageItem.on("keyup", ".datatable-message-filter", (event) => {
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableFacturaMessage.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -79,10 +79,14 @@ class MaquinistaTareaView {
|
||||
}
|
||||
handleUpdateClickInputSucess(response) {
|
||||
popSuccessAlert(response.message)
|
||||
this.updateContentClick(response.data.click_end - response.data.click_init)
|
||||
}
|
||||
handleUpdateClickInputError(error) {
|
||||
popErrorAlert(error)
|
||||
}
|
||||
updateContentClick(clicks){
|
||||
this.item.find('#clicks-info').empty().html(clicks)
|
||||
}
|
||||
handleDeleteTareaProgress() {
|
||||
let ajax = new Ajax('/produccion/ordentrabajo/tarea/progress/' + this.tareaId,
|
||||
null,
|
||||
@ -194,6 +198,17 @@ class MaquinistaTareaView {
|
||||
}
|
||||
})
|
||||
}
|
||||
getTarea(tarea_id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let ajax = new Ajax(`/produccion/ordentrabajo/tarea/${tarea_id}`, null, null, (response) => {
|
||||
resolve(response)
|
||||
},
|
||||
(error) => {
|
||||
resolve(error)
|
||||
})
|
||||
ajax.get()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -54,6 +54,10 @@ class MessagePage {
|
||||
this.messageDatatable.datatableFacturaMessage.ajax.reload()
|
||||
this.messageDatatable.focusTable = this.messageDatatable.datatableFacturaMessageItem
|
||||
})
|
||||
$("#navs-top-align-ot-tab").on("click",()=>{
|
||||
this.messageDatatable.datatableOtMessage.ajax.reload()
|
||||
this.messageDatatable.focusTable = this.messageDatatable.datatableOtMessageItem
|
||||
})
|
||||
|
||||
}
|
||||
openNewMessageModal() {
|
||||
|
||||
Reference in New Issue
Block a user