diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 95ae5dbf..8aa63598 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -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']); diff --git a/ci4/app/Controllers/Chat/ChatController.php b/ci4/app/Controllers/Chat/ChatController.php index 71ee0d2d..1df0f469 100755 --- a/ci4/app/Controllers/Chat/ChatController.php +++ b/ci4/app/Controllers/Chat/ChatController.php @@ -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 ? ''.lang("App.me").'' : $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); diff --git a/ci4/app/Controllers/Configuracion/Users.php b/ci4/app/Controllers/Configuracion/Users.php index 82526665..923f0007 100755 --- a/ci4/app/Controllers/Configuracion/Users.php +++ b/ci4/app/Controllers/Configuracion/Users.php @@ -1,4 +1,6 @@ -sanitized($postData, true); - + $noException = true; // Obtener proveedor de usuarios @@ -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"); } - } diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index efd40659..45aa3a7d 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -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); } diff --git a/ci4/app/Views/themes/vuexy/components/cards/tarea_card_actions.php b/ci4/app/Views/themes/vuexy/components/cards/tarea_card_actions.php index f29ca2f5..bd119b74 100644 --- a/ci4/app/Views/themes/vuexy/components/cards/tarea_card_actions.php +++ b/ci4/app/Views/themes/vuexy/components/cards/tarea_card_actions.php @@ -12,7 +12,7 @@
Clicks
-