mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido cliente id a users
This commit is contained in:
@ -55,6 +55,8 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]);
|
||||
$this->viewData['user_model'] = $this->user_model;
|
||||
|
||||
$this->viewData['userList2'] = $this->user_model->getUsersList();
|
||||
|
||||
parent::index();
|
||||
|
||||
}
|
||||
@ -136,6 +138,7 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['user'] = isset($sanitizedData) ? new UserEntity($sanitizedData) : new UserEntity();
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems();
|
||||
$this->viewData['formAction'] = route_to('createUser');
|
||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') .lang('Users.user').' '.lang('Basic.global.addNewSuffix');
|
||||
@ -176,7 +179,22 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
if (in_array('cliente-editor', $currentGroups) || in_array('cliente-administrador', $currentGroups)) {
|
||||
if(!array_key_exists('cliente_id', $sanitizedData) || is_null($sanitizedData['cliente_id'])) {
|
||||
$this->viewData['errorMessage'] = lang('Users.errors.cliente_sin_clienteID');
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
$successfulResult = false;
|
||||
}
|
||||
else{
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
@ -221,6 +239,7 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['user'] = $user;
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($user->cliente_id);
|
||||
$this->viewData['formAction'] = route_to('updateUser', $id);
|
||||
$this->viewData['selectedGroups'] = $this->group_model->getUsersRoles($requestedId);
|
||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||
@ -329,5 +348,19 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
|
||||
return $registers;
|
||||
}
|
||||
|
||||
protected function getClienteListItems($selId = null)
|
||||
{
|
||||
$data = ['' => ""];
|
||||
if (!empty($selId)) :
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
|
||||
$selOption = $clienteModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user