mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido opcion de crear contraseña en interfaz de administrador
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
<?php namespace App\Controllers\Configuracion;
|
<?php namespace App\Controllers\Configuracion;
|
||||||
|
|
||||||
|
|
||||||
use App\Entities\Usuarios\UserEntity;
|
use App\Entities\Usuarios\UserEntity;
|
||||||
@ -8,15 +8,17 @@ use App\Models\Usuarios\GroupModel;
|
|||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use App\Models\Usuarios\GroupsUsersModel;
|
use App\Models\Usuarios\GroupsUsersModel;
|
||||||
use CodeIgniter\Shield\Entities\User;
|
use CodeIgniter\Shield\Entities\User;
|
||||||
|
use function PHPUnit\Framework\isNull;
|
||||||
|
|
||||||
class Users extends \App\Controllers\GoBaseController {
|
class Users extends \App\Controllers\GoBaseController
|
||||||
|
{
|
||||||
|
|
||||||
private $group_model;
|
private $group_model;
|
||||||
private $group_user_model;
|
private $group_user_model;
|
||||||
private $user_model;
|
private $user_model;
|
||||||
|
|
||||||
|
|
||||||
use \CodeIgniter\API\ResponseTrait;
|
use \CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
protected static $primaryModelName = 'App\Models\UserModel';
|
protected static $primaryModelName = 'App\Models\UserModel';
|
||||||
|
|
||||||
@ -30,8 +32,8 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
protected $indexRoute = 'userList';
|
protected $indexRoute = 'userList';
|
||||||
|
|
||||||
|
|
||||||
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
{
|
||||||
|
|
||||||
$this->group_model = new GroupModel();
|
$this->group_model = new GroupModel();
|
||||||
$this->group_user_model = new GroupsUsersModel();
|
$this->group_user_model = new GroupsUsersModel();
|
||||||
@ -49,28 +51,36 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
$this->viewData['usingClientSideDataTable'] = true;
|
$this->viewData['usingClientSideDataTable'] = true;
|
||||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]);
|
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]);
|
||||||
$this->viewData['user_model'] = $this->user_model;
|
$this->viewData['user_model'] = $this->user_model;
|
||||||
|
|
||||||
$this->viewData['userList2'] = $this->user_model->getUsersList();
|
$this->viewData['userList2'] = auth()->getProvider()->findAll();
|
||||||
|
|
||||||
parent::index();
|
parent::index();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add() {
|
public function add()
|
||||||
|
{
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()) :
|
||||||
|
|
||||||
$postData = $this->request->getPost();
|
$postData = $this->request->getPost();
|
||||||
|
|
||||||
$currentGroups = $postData['group']??[];
|
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||||
|
if (empty($postData['password'])) {
|
||||||
|
$postData['password'] = 'Safekat2024'; // Contraseña por defecto
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentGroups = $postData['group'] ?? [];
|
||||||
unset($postData['group']);
|
unset($postData['group']);
|
||||||
|
|
||||||
$postData['username'] = strstr($postData['email'], '@', true);
|
$postData['username'] = strstr($postData['email'], '@', true);
|
||||||
$sanitizedData = $this->sanitized($postData, true);
|
$sanitizedData = $this->sanitized($postData, true);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
|
|
||||||
@ -78,40 +88,40 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
|
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()) :
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$user = new User([
|
$user = new User([
|
||||||
'username' => $sanitizedData['username'],
|
'username' => $sanitizedData['username'],
|
||||||
'first_name' => $sanitizedData['first_name'],
|
'first_name' => $sanitizedData['first_name'],
|
||||||
'last_name' => $sanitizedData['last_name'],
|
'last_name' => $sanitizedData['last_name'],
|
||||||
'email' => $sanitizedData['email'],
|
'email' => $sanitizedData['email'],
|
||||||
'password' => 'Safekat2024',
|
'password' => $sanitizedData['password'],
|
||||||
'status' => $sanitizedData['status']??0,
|
'status' => $sanitizedData['status'] ?? 0,
|
||||||
'active' => $sanitizedData['active']??0,
|
'active' => $sanitizedData['active'] ?? 0,
|
||||||
]);
|
]);
|
||||||
$users->save($user);
|
$users->save($user);
|
||||||
$successfulResult = true; // Hacked
|
$successfulResult = true; // Hacked
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$noException = false;
|
$noException = false;
|
||||||
//$this->dealWithException($e);
|
//$this->dealWithException($e);
|
||||||
if (strpos($e->getMessage(), 'correo duplicado') !== false) {
|
if (strpos($e->getMessage(), 'correo duplicado') !== false) {
|
||||||
$this->viewData['errorMessage'] = "El correo electrónico ya está registrado en el sistema";
|
$this->viewData['errorMessage'] = "El correo electrónico ya está registrado en el sistema";
|
||||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult) :
|
||||||
|
|
||||||
$id = $users->getInsertID();
|
$id = $users->getInsertID();
|
||||||
$this->group_user_model->where('user_id', $id)->delete();
|
$this->group_user_model->where('user_id', $id)->delete();
|
||||||
foreach($currentGroups as $group){
|
foreach ($currentGroups as $group) {
|
||||||
$group_user_data = [
|
$group_user_data = [
|
||||||
'user_id' => $id,
|
'user_id' => $id,
|
||||||
'group' => $group
|
'group' => $group
|
||||||
@ -119,8 +129,7 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
$this->group_user_model->insert($group_user_data);
|
$this->group_user_model->insert($group_user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Users.user'))]) . 'Downloads';
|
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Users.user'))]) . '.';
|
||||||
$message .= anchor(route_to('editUser', $id), lang('Basic.global.continueEditing').'?');
|
|
||||||
$message = ucfirst(str_replace("'", "\'", $message));
|
$message = ucfirst(str_replace("'", "\'", $message));
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect) :
|
||||||
@ -141,78 +150,82 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
$this->viewData['clienteList'] = $this->getClienteListItems();
|
$this->viewData['clienteList'] = $this->getClienteListItems();
|
||||||
$this->viewData['formAction'] = route_to('createUser');
|
$this->viewData['formAction'] = route_to('createUser');
|
||||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') .lang('Users.user').' '.lang('Basic.global.addNewSuffix');
|
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . lang('Users.user') . ' ' . lang('Basic.global.addNewSuffix');
|
||||||
|
|
||||||
|
|
||||||
return $this->displayForm(__METHOD__);
|
return $this->displayForm(__METHOD__);
|
||||||
} // end function add()
|
} // end function add()
|
||||||
|
|
||||||
public function edit($requestedId = null) {
|
public function edit($requestedId = null)
|
||||||
|
{
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null) {
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
endif;
|
}
|
||||||
|
|
||||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||||
$user = $this->model->find($id);
|
$users = auth()->getProvider();
|
||||||
|
$user = $users->findById($id);
|
||||||
|
|
||||||
if ($user == false) :
|
if ($user == false) :
|
||||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Users.user')), $id]);
|
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Users.user')), $id]);
|
||||||
return $this->redirect2listView('errorMessage', $message);
|
return $this->redirect2listView('errorMessage', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()) :
|
||||||
|
|
||||||
$postData = $this->request->getPost();
|
$postData = $this->request->getPost();
|
||||||
|
|
||||||
$currentGroups = $postData['group'];
|
$currentGroups = $postData['group'] ?? [];
|
||||||
unset($postData['group']);
|
unset($postData['group']);
|
||||||
|
|
||||||
|
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||||
|
if (empty($postData['password'])) {
|
||||||
|
unset($postData['password']);
|
||||||
|
}
|
||||||
|
|
||||||
$sanitizedData = $this->sanitized($postData, true);
|
$sanitizedData = $this->sanitized($postData, true);
|
||||||
|
|
||||||
if ($this->request->getPost('status') == 0 ) {
|
if ($this->request->getPost('status') == 0) {
|
||||||
$sanitizedData['status'] = null;
|
$sanitizedData['status'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()) :
|
||||||
|
|
||||||
|
if ($this->canValidate()) :
|
||||||
|
try {
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
|
||||||
try {
|
|
||||||
if (in_array('cliente-editor', $currentGroups) || in_array('cliente-administrador', $currentGroups)) {
|
if (in_array('cliente-editor', $currentGroups) || in_array('cliente-administrador', $currentGroups)) {
|
||||||
if(!array_key_exists('cliente_id', $sanitizedData) || is_null($sanitizedData['cliente_id'])) {
|
if (!array_key_exists('cliente_id', $sanitizedData) || is_null($sanitizedData['cliente_id'])) {
|
||||||
$this->viewData['errorMessage'] = lang('Users.errors.cliente_sin_clienteID');
|
$this->viewData['errorMessage'] = lang('Users.errors.cliente_sin_clienteID');
|
||||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||||
|
|
||||||
$successfulResult = false;
|
$successfulResult = false;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$noException = false;
|
||||||
|
$this->dealWithException($e);
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||||
|
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
endif;
|
||||||
$noException = false;
|
|
||||||
$this->dealWithException($e);
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
|
||||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
|
||||||
|
|
||||||
endif;
|
$user->fill($sanitizedData);
|
||||||
|
$users->save($user);
|
||||||
$user->fill($sanitizedData);
|
$thenRedirect = false;
|
||||||
$thenRedirect = false;
|
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult) :
|
||||||
|
|
||||||
$this->group_user_model->where('user_id', $user->id)->delete();
|
$this->group_user_model->where('user_id', $user->id)->delete();
|
||||||
foreach($currentGroups as $group){
|
foreach ($currentGroups as $group) {
|
||||||
$group_user_data = [
|
$group_user_data = [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'group' => $group
|
'group' => $group
|
||||||
@ -221,8 +234,7 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id = $user->id ?? $id;
|
$id = $user->id ?? $id;
|
||||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Users.user'))]) . 'Downloads';
|
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Users.user'))]) . '.';
|
||||||
$message .= anchor(route_to('editUser', $id), lang('Basic.global.continueEditing').'?');
|
|
||||||
$message = ucfirst(str_replace("'", "\'", $message));
|
$message = ucfirst(str_replace("'", "\'", $message));
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect) :
|
||||||
@ -243,13 +255,14 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
$this->viewData['formAction'] = route_to('updateUser', $id);
|
$this->viewData['formAction'] = route_to('updateUser', $id);
|
||||||
$this->viewData['selectedGroups'] = $this->group_model->getUsersRoles($requestedId);
|
$this->viewData['selectedGroups'] = $this->group_model->getUsersRoles($requestedId);
|
||||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') .lang('Users.user').' '.lang('Basic.global.edit3');
|
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.edit3');
|
||||||
|
|
||||||
return $this->displayForm(__METHOD__, $id);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
} // end function edit(...)
|
} // end function edit(...)
|
||||||
|
|
||||||
|
|
||||||
public function delete($requestedId = null, bool $deletePermanently = true) {
|
public function delete($requestedId = null, bool $deletePermanently = true)
|
||||||
|
{
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null) :
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
@ -264,26 +277,25 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
$users = auth()->getProvider();
|
$users = auth()->getProvider();
|
||||||
$users->delete($user->id, $deletePermanently);
|
$users->delete($user->id);
|
||||||
|
|
||||||
$message = "Usuario eliminado correctamente";
|
$message = "Usuario eliminado correctamente";
|
||||||
return $this->redirect2listView('successMessage', $message);
|
return $this->redirect2listView('successMessage', $message);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end function delete(...)
|
} // end function delete(...)
|
||||||
|
|
||||||
|
|
||||||
|
public function allItemsSelect()
|
||||||
public function allItemsSelect() {
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$onlyActiveOnes = true;
|
$onlyActiveOnes = true;
|
||||||
$reqVal = $this->request->getPost('val') ?? 'id_user';
|
$reqVal = $this->request->getPost('val') ?? 'id_user';
|
||||||
$menu = $this->model->getAllForMenu($reqVal.', first_name', 'first_name', $onlyActiveOnes, false);
|
$menu = $this->model->getAllForMenu($reqVal . ', first_name', 'first_name', $onlyActiveOnes, false);
|
||||||
$nonItem = new \stdClass;
|
$nonItem = new \stdClass;
|
||||||
$nonItem->id_user = '';
|
$nonItem->id_user = '';
|
||||||
$nonItem->first_name = '- '.lang('Basic.global.None').' -';
|
$nonItem->first_name = '- ' . lang('Basic.global.None') . ' -';
|
||||||
array_unshift($menu , $nonItem);
|
array_unshift($menu, $nonItem);
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
@ -297,7 +309,8 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function menuItems() {
|
public function menuItems()
|
||||||
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||||
@ -308,8 +321,8 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||||
$nonItem = new \stdClass;
|
$nonItem = new \stdClass;
|
||||||
$nonItem->id = '';
|
$nonItem->id = '';
|
||||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||||
array_unshift($menu , $nonItem);
|
array_unshift($menu, $nonItem);
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
@ -323,7 +336,8 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMenuComerciales(){
|
public function getMenuComerciales()
|
||||||
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$comerciales = $this->model->getComerciales();
|
$comerciales = $this->model->getComerciales();
|
||||||
|
|
||||||
@ -340,14 +354,15 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getPaisListItems() {
|
protected function getPaisListItems()
|
||||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
{
|
||||||
|
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
||||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||||
|
|
||||||
$registers = $paisModel->findAll();
|
$registers = $paisModel->findAll();
|
||||||
|
|
||||||
return $registers;
|
return $registers;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getClienteListItems($selId = null)
|
protected function getClienteListItems($selId = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,17 +51,23 @@ class UserModel extends ShieldUserModel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsersList(){
|
public function getUsersList()
|
||||||
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table("users" . " t1")
|
->table('users t1')
|
||||||
->select(
|
->select('
|
||||||
"t1.id AS id, t1.first_name AS first_name, t1.last_name AS last_name, t1.last_active AS last_active, t2.group AS group"
|
t1.id AS id,
|
||||||
);
|
t1.first_name AS first_name,
|
||||||
|
t1.last_name AS last_name,
|
||||||
$builder->where('t1.deleted_at', null);
|
t1.email AS email,
|
||||||
$builder->join("auth_groups_users t2", "t1.id = t2.user_id", "left");
|
t1.last_active AS last_active,
|
||||||
|
GROUP_CONCAT(DISTINCT t2.`group` SEPARATOR ", ") AS `group`
|
||||||
|
')
|
||||||
|
->join('auth_groups_users t2', 't1.id = t2.user_id', 'left')
|
||||||
|
->where('t1.deleted_at', null)
|
||||||
|
->groupBy('t1.id, t1.first_name, t1.last_name, t1.email, t1.last_active');
|
||||||
|
|
||||||
return $builder->get()->getResult();
|
return $builder->get()->getResult();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,25 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-6 px-4">
|
<div class="col-md-12 col-lg-6 px-4">
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="firstName" class="form-label">
|
<label for="firstName" class="form-label">
|
||||||
<?= lang('Users.firstName') ?>
|
<?= lang('Users.firstName') ?>
|
||||||
</label>
|
</label>
|
||||||
<input tabindex="1" type="text" id="firstName" name="first_name" maxLength="150" class="form-control"
|
<input tabindex="1" type="text" id="firstName" name="first_name" maxLength="150" class="form-control"
|
||||||
value="<?= old('first_name', $user->first_name) ?>">
|
value="<?= old('first_name', $user->first_name) ?>">
|
||||||
</div><!--//.mb-3 -->
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="email" class="form-label">
|
<label for="email" class="form-label">
|
||||||
<?= lang('Users.email') ?>*
|
<?= lang('Users.email') ?>*
|
||||||
</label>
|
</label>
|
||||||
<input tabindex="13" type="email" id="email" name="email" maxLength="150" class="form-control"
|
<input tabindex="3" type="email" id="email" name="email" maxLength="150" class="form-control"
|
||||||
value="<?= old('email', $user->email) ?>">
|
value="<?= old('email', $user->email) ?>">
|
||||||
</div><!--//.mb-3 -->
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="group" class="form-label"> <?= lang('Users.group') ?></label>
|
<label for="group" class="form-label"> <?= lang('Users.group') ?></label>
|
||||||
<select tabindex="17" name="group[]" id="group" multiple="multiple"
|
<select tabindex="5" name="group[]" id="group" multiple="multiple"
|
||||||
class="form-control select2 form-select">
|
class="form-control select2 form-select">
|
||||||
<option value=""><?= lang('Basic.global.pleaseSelectA', [lang('Users.group')]) ?></option>
|
<option value=""><?= lang('Basic.global.pleaseSelectA', [lang('Users.group')]) ?></option>
|
||||||
<?php
|
<?php
|
||||||
@ -36,10 +35,27 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div><!--//.mb-3 -->
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="cliente_id" class="form-label">
|
||||||
|
<?= lang('Presupuestos.clienteId') ?>
|
||||||
|
</label>
|
||||||
|
<select tabindex="7" id="cliente_id" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
|
||||||
|
|
||||||
|
<?php if (isset($clienteList) && is_array($clienteList) && !empty($clienteList)) :
|
||||||
|
foreach ($clienteList as $k => $v) : ?>
|
||||||
|
<option value="<?= $k ?>" <?= $k == $user->cliente_id ? ' selected' : '' ?>>
|
||||||
|
<?= $v ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach;
|
||||||
|
endif; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
<div class="col-md-12 col-lg-6 px-4">
|
<div class="col-md-12 col-lg-6 px-4">
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@ -48,14 +64,14 @@
|
|||||||
</label>
|
</label>
|
||||||
<input tabindex="2" type="text" id="lastName" name="last_name" maxLength="150" class="form-control"
|
<input tabindex="2" type="text" id="lastName" name="last_name" maxLength="150" class="form-control"
|
||||||
value="<?= old('last_name', $user->last_name) ?>">
|
value="<?= old('last_name', $user->last_name) ?>">
|
||||||
</div><!--//.mb-3 -->
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="status" class="form-label">
|
<label for="status" class="form-label">
|
||||||
<?= lang('Users.blocked') ?>
|
<?= lang('Users.blocked') ?>
|
||||||
</label>
|
</label>
|
||||||
<?php $isBanned = old('blocked', $user->status); ?>
|
<?php $isBanned = old('blocked', $user->status); ?>
|
||||||
<select tabindex="12" name="status" id="status" class="select2 form-control">
|
<select tabindex="4" name="status" id="status" class="select2 form-control">
|
||||||
<option value="0" <?= is_null($isBanned) ? 'selected' : '' ?>><?= lang("Users.non_blocked") ?></option>
|
<option value="0" <?= is_null($isBanned) ? 'selected' : '' ?>><?= lang("Users.non_blocked") ?></option>
|
||||||
<option value="1" <?= $isBanned === "banned" ? 'selected' : '' ?>><?= lang("Users.blocked") ?></option>
|
<option value="1" <?= $isBanned === "banned" ? 'selected' : '' ?>><?= lang("Users.blocked") ?></option>
|
||||||
</select>
|
</select>
|
||||||
@ -66,29 +82,29 @@
|
|||||||
<?= lang('Users.status') ?>
|
<?= lang('Users.status') ?>
|
||||||
</label>
|
</label>
|
||||||
<?php $isActive = old('status', $user->active); ?>
|
<?php $isActive = old('status', $user->active); ?>
|
||||||
<select tabindex="16" name="active" id="active" class="select2 form-control">
|
<select tabindex="6" name="active" id="active" class="select2 form-control">
|
||||||
<option value="1" <?= $isActive ? 'selected' : '' ?>><?= lang("Users.global_active") ?></option>
|
<option value="1" <?= $isActive ? 'selected' : '' ?>><?= lang("Users.global_active") ?></option>
|
||||||
<option value="0" <?= $isActive ? '' : 'selected' ?>><?= lang("Users.global_inactive") ?></option>
|
<option value="0" <?= $isActive ? '' : 'selected' ?>><?= lang("Users.global_inactive") ?></option>
|
||||||
</select>
|
</select>
|
||||||
</div><!--//.mb-3 -->
|
|
||||||
|
|
||||||
</div><!--//.col -->
|
|
||||||
<div class="col-md-12 col-lg-6 px-4">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="cliente_id" class="form-label">
|
|
||||||
<?= lang('Presupuestos.clienteId') ?>
|
|
||||||
</label>
|
|
||||||
<select id="cliente_id" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
|
|
||||||
|
|
||||||
<?php if (isset($clienteList) && is_array($clienteList) && !empty($clienteList)) :
|
|
||||||
foreach ($clienteList as $k => $v) : ?>
|
|
||||||
<option value="<?= $k ?>" <?= $k == $user->cliente_id ? ' selected' : '' ?>>
|
|
||||||
<?= $v ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach;
|
|
||||||
endif; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">
|
||||||
|
<?= lang('Users.password') ?>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
tabindex="8"
|
||||||
|
type="text"
|
||||||
|
id="password"
|
||||||
|
name="password"
|
||||||
|
maxLength="50"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Introduzca contraseña para cambiarla"
|
||||||
|
value=""
|
||||||
|
>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
|
|
||||||
</div><!-- //.row -->
|
</div><!-- //.row -->
|
||||||
@ -17,8 +17,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th><?= lang('Users.firstName') ?></th>
|
<th><?= lang('Users.firstName') ?></th>
|
||||||
<th><?= lang('Users.lastName') ?></th>
|
<th><?= lang('Users.lastName') ?></th>
|
||||||
<th><?= lang('Users.group') ?></th>
|
<th><?= lang('Users.email') ?></th>
|
||||||
<th><?= lang('Users.lastAccess') ?></th>
|
<th><?= lang('Users.lastAccess') ?></th>
|
||||||
<?php /*
|
<?php /*
|
||||||
<th><?= lang('Users.mobile') ?></th>
|
<th><?= lang('Users.mobile') ?></th>
|
||||||
<th><?= lang('Users.email') ?></th>
|
<th><?= lang('Users.email') ?></th>
|
||||||
@ -46,11 +46,10 @@
|
|||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<?= empty($item->last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50) ?>
|
<?= empty($item->last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50) ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<?= empty($item->group) ? "" : character_limiter(esc(lang('Users.' . $item->group)), 50) ?>
|
<?= empty($item->email) ? "" : character_limiter(esc(lang($item->email)), 50) ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="align-middle text-nowrap">
|
||||||
<td class="align-middle text-nowrap">
|
|
||||||
<?= empty($item->last_active) ? '' : date('d/m/Y H:m:s', strtotime($item->last_active)) ?>
|
<?= empty($item->last_active) ? '' : date('d/m/Y H:m:s', strtotime($item->last_active)) ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user