mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/anadir_ficheros_presu'
Main See merge request jjimenez/safekat!262
This commit is contained in:
@ -66,6 +66,7 @@ $routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], functi
|
||||
$routes->get('delete/(:num)', 'Users::delete/$1', ['as' => 'deleteUser']);
|
||||
$routes->post('allmenuitems', 'Users::allItemsSelect', ['as' => 'select2ItemsOfUsers']);
|
||||
$routes->post('menuitems', 'Users::menuItems', ['as' => 'menuItemsOfUsers']);
|
||||
$routes->post('getMenuComerciales', 'Users::getMenuComerciales', ['as' => 'menuItemsComerciales']);
|
||||
});
|
||||
|
||||
$routes->group('group', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
@ -354,10 +355,10 @@ $routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function
|
||||
$routes->resource('cliente', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Cliente', 'except' => 'show,new,create,update']);*/
|
||||
|
||||
$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->post('datatable', 'Clienteprecios::datatable', ['as' => 'dataTableOfClienteprecios']);
|
||||
$routes->post('datatable_editor', 'Clienteprecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
|
||||
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'dataTableOfClienteprecios']);
|
||||
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
|
||||
});
|
||||
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteprecios', 'except' => 'show,new,create,update']);
|
||||
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'ClientePrecios', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
|
||||
@ -67,7 +67,7 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
|
||||
$currentGroups = $postData['group']??[];
|
||||
unset($postData['group']);
|
||||
|
||||
$postData['username'] = strstr($postData['email'], '@', true);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
@ -75,20 +75,28 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
$users = auth()->getProvider();
|
||||
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
|
||||
$user = new User([
|
||||
'username' => strstr($sanitizedData['email'], '@', true),
|
||||
'username' => $sanitizedData['username'],
|
||||
'first_name' => $sanitizedData['first_name'],
|
||||
'last_name' => $sanitizedData['last_name'],
|
||||
'email' => $sanitizedData['email'],
|
||||
'password' => 'Safekat2024',
|
||||
'status' => $sanitizedData['status']??0,
|
||||
'active' => $sanitizedData['active']??0,
|
||||
]);
|
||||
$users->save($user);
|
||||
$successfulResult = true; // Hacked
|
||||
$successfulResult = true; // Hacked
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
//$this->dealWithException($e);
|
||||
if (strpos($e->getMessage(), 'correo duplicado') !== false) {
|
||||
$this->viewData['errorMessage'] = "El correo electrónico ya está registrado en el sistema";
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
}
|
||||
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||
@ -100,10 +108,10 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $users->getInsertID();
|
||||
$this->group_user_model->where('user_id', $user->id)->delete();
|
||||
$this->group_user_model->where('user_id', $id)->delete();
|
||||
foreach($currentGroups as $group){
|
||||
$group_user_data = [
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $id,
|
||||
'group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
@ -296,6 +304,22 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public function getMenuComerciales(){
|
||||
if ($this->request->isAJAX()) {
|
||||
$comerciales = $this->model->getComerciales();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $comerciales,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems() {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
||||
|
||||
@ -19,11 +19,27 @@ class UserModel extends ShieldUserModel
|
||||
];
|
||||
}
|
||||
|
||||
/*protected $validationRules = [
|
||||
"email" => [
|
||||
"label" => "RolesPermisos.email",
|
||||
"rules" => "required|max_length[150]",
|
||||
protected $validationRules = [
|
||||
"username" => [
|
||||
"label" => "correo duplicado",
|
||||
"rules" => "is_unique[users.username]",
|
||||
]
|
||||
|
||||
];*/
|
||||
];
|
||||
|
||||
public function getComerciales(){
|
||||
|
||||
$builder = $this->db
|
||||
->table("users" . " t1")
|
||||
->select(
|
||||
"t1.id AS id, CONCAT(t1.first_name, ' ', t1.last_name) AS text"
|
||||
);
|
||||
|
||||
$builder->where('t1.deleted_at', null);
|
||||
$builder->where("t2.group", "comercial");
|
||||
$builder->join("auth_groups_users t2", "t1.id = t2.user_id", "left");
|
||||
|
||||
return $builder->get()->getResult();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,7 +1513,7 @@ function delete_direccion_envio(dataId){
|
||||
<?=$this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.bootstrap5.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-bs5/dataTables.bootstrap5.min.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-bs5/datatables.bootstrap5.css") ?>">
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
$('#soporteId').select2({
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '<?= route_to("menuItemsOfUsers") ?>',
|
||||
url: '<?= route_to("menuItemsComerciales") ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
|
||||
@ -200,14 +200,14 @@
|
||||
$('#comercialId').select2({
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '<?= route_to("menuItemsOfUsers") ?>',
|
||||
url: '<?= route_to("menuItemsComerciales") ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
|
||||
data: function (params) {
|
||||
return {
|
||||
id: 'id_user',
|
||||
text: 'first_name',
|
||||
id: 'id',
|
||||
text: 'text',
|
||||
searchTerm: params.term,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user