diff --git a/ci4/app/Config/Auth.php b/ci4/app/Config/Auth.php index c917571c..57efc4ca 100644 --- a/ci4/app/Config/Auth.php +++ b/ci4/app/Config/Auth.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Config; +use App\Entities\Usuarios\UsersEntity; use App\Models\UserModel; use CodeIgniter\Shield\Authentication\Passwords\ValidationRules; use CodeIgniter\Shield\Config\Auth as ShieldAuth; diff --git a/ci4/app/Controllers/Configuracion/Users.php b/ci4/app/Controllers/Configuracion/Users.php index 5bbfedba..c78ca50d 100755 --- a/ci4/app/Controllers/Configuracion/Users.php +++ b/ci4/app/Controllers/Configuracion/Users.php @@ -150,7 +150,7 @@ class Users extends \App\Controllers\GoBaseController $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'); + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.addNewSuffix'); return $this->displayForm(__METHOD__); diff --git a/ci4/app/Controllers/Profile.php b/ci4/app/Controllers/Profile.php index 71772a74..67449c84 100755 --- a/ci4/app/Controllers/Profile.php +++ b/ci4/app/Controllers/Profile.php @@ -27,7 +27,7 @@ class Profile extends BaseController // Find by the user_id $data['obj'] = $users->findById(auth()->id()); - echo view(getenv('theme.path') . 'form/profile/index', $data); + echo view(getenv('theme.path') . 'form/profile/profileDetails', $data); } diff --git a/ci4/app/Entities/Usuarios/UserEntity.php b/ci4/app/Entities/Usuarios/UserEntity.php index 0c1d5383..61f750ce 100755 --- a/ci4/app/Entities/Usuarios/UserEntity.php +++ b/ci4/app/Entities/Usuarios/UserEntity.php @@ -24,18 +24,25 @@ class UserEntity extends \CodeIgniter\Entity\Entity "cliente_id" => "int", "active" => "boolean", ]; + /** - * Returns a full name: "first last" + * Get the full name of the user * - * @return string + * If the first name and last name are available, the full name is generated as "{first name} {last name}". + * If the first name or last name is missing, only the available name is used. + * If both the first name and last name are missing, the username is used as the full name. + * + * @return string The full name of the user */ public function getFullName() { - $fullName = - (!empty($this->attributes["first_name"]) ? trim($this->attributes["first_name"]) . " " : "") . - (!empty($this->attributes["last_name"]) ? trim($this->attributes["last_name"]) : ""); - $name = empty($fullName) ? $this->attributes["username"] : $fullName; - return $name; + $firstName = trim($this->attributes["first_name"] ?? ""); + $lastName = trim($this->attributes["last_name"] ?? ""); + $fullName = $firstName . ' ' . $lastName; + $fullName = trim($fullName); // In case first name is empty, this will remove the leading space + + // Use the username attribute if the full name is still empty after trimming + return $fullName ?: $this->attributes["username"]; } /** diff --git a/ci4/app/Entities/Usuarios/UsersEntity.php b/ci4/app/Entities/Usuarios/UsersEntity.php index 7ff93bb7..84ae01f1 100644 --- a/ci4/app/Entities/Usuarios/UsersEntity.php +++ b/ci4/app/Entities/Usuarios/UsersEntity.php @@ -1,7 +1,6 @@ attributes["first_name"] ?? ""); + $lastName = trim($this->attributes["last_name"] ?? ""); + $fullName = $firstName . ' ' . $lastName; + $fullName = trim($fullName); // In case first name is empty, this will remove the leading space + + // Use the username attribute if the full name is still empty after trimming + return $fullName ?: $this->attributes["username"]; + } + + } diff --git a/ci4/app/Models/UserModel.php b/ci4/app/Models/UserModel.php index 934604ff..63d8acfa 100644 --- a/ci4/app/Models/UserModel.php +++ b/ci4/app/Models/UserModel.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Models; +use App\Entities\Usuarios\UsersEntity; use CodeIgniter\Shield\Models\UserModel as ShieldUserModel; class UserModel extends ShieldUserModel @@ -20,6 +21,8 @@ class UserModel extends ShieldUserModel ]; } + protected $returnType = UsersEntity::class; + protected $useSoftDeletes = true; protected $useTimestamps = true; protected $createdField = 'created_at'; @@ -51,17 +54,23 @@ class UserModel extends ShieldUserModel } - public function getUsersList(){ + public function getUsersList() + { $builder = $this->db - ->table("users" . " t1") - ->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" - ); - - $builder->where('t1.deleted_at', null); - $builder->join("auth_groups_users t2", "t1.id = t2.user_id", "left"); + ->table('users t1') + ->select(' + t1.id AS id, + t1.first_name AS first_name, + t1.last_name AS last_name, + t1.email AS email, + 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(); - } + } diff --git a/ci4/app/Views/themes/vuexy/form/profile/index.php b/ci4/app/Views/themes/vuexy/form/profile/profileDetails.php similarity index 76% rename from ci4/app/Views/themes/vuexy/form/profile/index.php rename to ci4/app/Views/themes/vuexy/form/profile/profileDetails.php index bff0c49f..4a9fc610 100644 --- a/ci4/app/Views/themes/vuexy/form/profile/index.php +++ b/ci4/app/Views/themes/vuexy/form/profile/profileDetails.php @@ -1,4 +1,4 @@ -extend('themes/vuexy/main/general_settings_layout') ?> +extend('themes/vuexy/main/defaultlayout') ?> section('content'); ?> @@ -75,40 +75,12 @@
- "btn btn-danger"]) ?> + "btn btn-dark"]) ?>
- - - - get('settings'); ?> diff --git a/ci4/app/Views/themes/vuexy/form/user/_userFormItems.php b/ci4/app/Views/themes/vuexy/form/user/_userFormItems.php index ba0c3c02..f021565f 100644 --- a/ci4/app/Views/themes/vuexy/form/user/_userFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/user/_userFormItems.php @@ -1,26 +1,25 @@
-
-
+
- -
+
-
-
+ + +
+ + +
+
@@ -48,14 +64,14 @@ -
+
status); ?> - @@ -66,29 +82,29 @@ active); ?> - -
- - -
-
- -
+ +
+ + + +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/user/viewUserList.php b/ci4/app/Views/themes/vuexy/form/user/viewUserList.php index 63935bc1..b22a4c76 100644 --- a/ci4/app/Views/themes/vuexy/form/user/viewUserList.php +++ b/ci4/app/Views/themes/vuexy/form/user/viewUserList.php @@ -17,8 +17,8 @@ - - + + @@ -46,11 +46,10 @@ last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50) ?> - - group) ? "" : character_limiter(esc(lang('Users.' . $item->group)), 50) ?> - - - + + email) ? "" : character_limiter(esc(lang($item->email)), 50) ?> + + last_active) ? '' : date('d/m/Y H:m:s', strtotime($item->last_active)) ?> diff --git a/ci4/app/Views/themes/vuexy/main/activities_layout.php b/ci4/app/Views/themes/vuexy/main/activities_layout.php deleted file mode 100644 index a5534604..00000000 --- a/ci4/app/Views/themes/vuexy/main/activities_layout.php +++ /dev/null @@ -1,357 +0,0 @@ -get('token') ?? ''; -$tfa = $session->get('tfa') ?? false; -$settings = $session->get('settings'); - -$picture = "/assets/img/default-user.png"; -$pulse = session()->get('pulse'); -$notification = session()->get('notification'); - -if (!empty($token) && $tfa == false) { - //echo ""; -} -?> - - - - - - - - - - <?= config('Safekat')->appName ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - renderSection('css') ?> - - - - - - - - - - - -
-
- - - - -
- - - - - - -
- - -
-
- -
- - renderSection('content') ?> - -
- - - - - - -
-
- -
- -
- - -
- - -
-
- - -renderSection('footerAdditions') ?> - - - - - - - - - - - - -renderSection('additionalExternalJs') ?> - - - - - - - - - - - - - - diff --git a/ci4/app/Views/themes/vuexy/main/all.php b/ci4/app/Views/themes/vuexy/main/all.php deleted file mode 100644 index fd8f2ef2..00000000 --- a/ci4/app/Views/themes/vuexy/main/all.php +++ /dev/null @@ -1,570 +0,0 @@ -get('settings'); -$picture = "/assets/img/default-user.png"; -?> - - - - - - - - - <?= config('Safekat')->appName ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - - -
- -
-
- -
-

- Sample page. -

-
- - - - - - -
-
- -
- -
- - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ci4/app/Views/themes/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/vuexy/main/defaultlayout.php index 5f8ecdd7..4d03e697 100644 --- a/ci4/app/Views/themes/vuexy/main/defaultlayout.php +++ b/ci4/app/Views/themes/vuexy/main/defaultlayout.php @@ -133,7 +133,6 @@ $picture = "/assets/img/default-user.png"; title="Acceso directo a buscador de presupuestos" > - @@ -232,8 +231,8 @@ $picture = "/assets/img/default-user.png";
- get('first_name') . ' ' . $session->get('last_name') ?> - Admin + user()->getFullName(); ?> + user()->getEmail(); ?>
@@ -247,13 +246,6 @@ $picture = "/assets/img/default-user.png"; - - - - - - -
  • diff --git a/ci4/app/Views/themes/vuexy/main/demo_view.php b/ci4/app/Views/themes/vuexy/main/demo_view.php deleted file mode 100644 index e69defe8..00000000 --- a/ci4/app/Views/themes/vuexy/main/demo_view.php +++ /dev/null @@ -1,297 +0,0 @@ -get('token') ?? ''; -$tfa = $session->get('tfa') ?? false; -$settings = $session->get('settings'); - -$picture = "/assets/img/default-user.png"; -$pulse = session()->get('pulse'); -$notification = session()->get('notification'); - -if (!empty($token) && $tfa == false) { - //echo ""; -} -?> - - - - - - - - - <?= config('Safekat')->appName ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - - - - - - -
    - - -
    -

    - Safekat / - -

    -
    - -
    -
    -
    Prueba privilegios
    -
    -
    - - - -
    -
    - -
    -
    -
    - -
    - - - - - - -
    -
    - -
    - -
    - - -
    - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ci4/app/Views/themes/vuexy/main/general_settings_layout.php b/ci4/app/Views/themes/vuexy/main/general_settings_layout.php deleted file mode 100644 index b1b9aa2b..00000000 --- a/ci4/app/Views/themes/vuexy/main/general_settings_layout.php +++ /dev/null @@ -1,359 +0,0 @@ -get('token') ?? ''; -$tfa = $session->get('tfa') ?? false; -$settings = $session->get('settings'); - -$picture = "/assets/img/default-user.png"; -$pulse = session()->get('pulse'); -$notification = session()->get('notification'); - -if (!empty($token) && $tfa == false) { - //echo ""; -} -?> - - - - - - - - - - <?= config('Safekat')->appName ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - renderSection('css') ?> - - - - - - - - - - - -
    -
    - - - - -
    - - - - - - -
    - - -
    -
    - -
    - - renderSection('content') ?> - -
    - - - - - - -
    -
    - -
    - -
    - - -
    - - -
    -
    - - -renderSection('footerAdditions') ?> - - - - - - - - - - - - -renderSection('additionalExternalJs') ?> - - - - - - - - - - - - - diff --git a/ci4/app/Views/themes/vuexy/main/presupuestos_layout.php b/ci4/app/Views/themes/vuexy/main/presupuestos_layout.php index 91c4fd3b..aa7d3c7a 100644 --- a/ci4/app/Views/themes/vuexy/main/presupuestos_layout.php +++ b/ci4/app/Views/themes/vuexy/main/presupuestos_layout.php @@ -247,8 +247,8 @@ if (!empty($token) && $tfa == false) {
    - get('first_name') . ' ' . $session->get('last_name') ?> - Admin + user()->getFullName(); ?> + user()->getEmail(); ?>
    diff --git a/sk-new-branch.bat b/sk-new-branch.bat deleted file mode 100755 index 4ce0d215..00000000 --- a/sk-new-branch.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -REM Solicitar al usuario el nombre de la nueva rama -set /p nombre_rama=Nuevo nombre de la rama: - -echo %nombre_rama% - -REM Verificar si se proporciona un nombre de rama -if not "%nombre_rama%"=="" ( - REM Cambiar y actualizar la rama main - git checkout main - git pull - REM Crear nueva rama - git checkout -b %nombre_rama% - REM Hacer push de la nueva rama al repositorio remoto - git push -u origin %nombre_rama% - echo Se ha creado (a partir de la rama main) y cambiado a la nueva rama: %nombre_rama% -) else ( - echo No se proporcionó un nombre de rama. La creación de la rama ha sido omitida. -)