Skip to content

Commit

Permalink
feact: Agregar vista de perfil de usuario
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusSan1 committed Nov 27, 2024
1 parent 059acac commit 6ad26e8
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use App\Controllers\ConfiguracionController;
use App\Controllers\Dashboard;
use App\Controllers\Home;
use App\Controllers\PerfilController;
use App\Controllers\Recuperar;
use App\Controllers\Reestablecer;
use App\Controllers\Verificar;
Expand Down Expand Up @@ -32,3 +33,6 @@

$routes->get('configuracion', [ConfiguracionController::class, 'index'], ['filter' => 'auth']);
$routes->put('update-configuracion/(:num)', [ConfiguracionController::class, 'update/$1'], ['filter' => 'auth']);

$routes->get('perfil', [PerfilController::class, 'index'], ['filter' => 'auth']);
$routes->put('update-profile/(:num)', [PerfilController::class, 'update/$1'], ['filter' => 'auth']);
28 changes: 28 additions & 0 deletions app/Controllers/PerfilController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Controllers;

use App\Controllers\BaseController;
use App\Models\UsuarioModel;

class PerfilController extends BaseController
{
private $usuario;
private $session;

public function __construct()
{
$this->usuario = model(UsuarioModel::class);
$this->session = \Config\Services::session();
}
public function index()
{
return view('perfil/index', [
'users' => $this->usuario->where('id', $this->session->get('id'))->find(),
]);
}
public function update(int $id = 1)
{
dd('Datos actualizados correctamente');
}
}
3 changes: 2 additions & 1 deletion app/Views/ajustesEmpresa/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Ajustes de empresa
<?=$this->endSection();?>
<?=$this->section('contenido');?>
<?=link_tag('assets/css/btn-custom.css')?>
<div class="container-fluid py-4">
<div class="row">
<div class="col-md-12">
Expand Down Expand Up @@ -57,7 +58,7 @@
<div class="col-md-4"></div>
<div class="col-md-4 text-center">
<div class="form-group">
<?=form_submit('send', 'Guardar los datos', ['class' => 'btn bg-gradient-primary rounded-pill rounded-5 btn-sm shadow-lg'])?>
<?=form_submit('send', 'Guardar los datos', ['class' => 'btn-custom btn bg-gradient-primary rounded-pill rounded-5 btn-sm shadow-lg'])?>
</div>
</div>
<div class="col-md-4"></div>
Expand Down
3 changes: 2 additions & 1 deletion app/Views/configuracion/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Configuración
<?=$this->endSection();?>
<?=$this->section('contenido');?>
<?=link_tag('assets/css/btn-custom.css')?>
<div class="container-fluid py-4">
<div class="row">
<div class="col-md-12">
Expand Down Expand Up @@ -47,7 +48,7 @@
<div class="col-md-4"></div>
<div class="col-md-4 text-center">
<div class="form-group">
<?=form_submit('send', 'Guardar los datos', ['class' => 'btn bg-gradient-primary rounded-pill rounded-5 btn-sm shadow-lg'])?>
<?=form_submit('send', 'Guardar los datos', ['class' => 'btn-custom btn bg-gradient-primary rounded-pill rounded-5 btn-sm shadow-lg'])?>
</div>
</div>
<div class="col-md-4"></div>
Expand Down
31 changes: 28 additions & 3 deletions app/Views/layouts/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class="sidenav bg-white navbar navbar-vertical navbar-expand-xs border-0 border-
<div
class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
<i
class="ni ni-tv-2 <?= basename(uri_string()) == 'dashboard' ? 'text-light' : 'text-primary' ?> text-sm opacity-10"></i>
class="ni ni-tv-2 <?=basename(uri_string()) == 'dashboard' ? 'text-light' : 'text-primary'?> text-sm opacity-10"></i>
</div>
<span
class="nav-link-text ms-1 <?=basename(uri_string()) == 'dashboard' ? 'text-white' : ''?>">Menú
Expand All @@ -65,7 +65,7 @@ class="nav-link-text ms-1 <?=basename(uri_string()) == 'dashboard' ? 'text-white
<div
class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
<i
class="ni ni-settings <?= basename(uri_string()) == 'ajuste-empresa' ? 'text-light' : 'text-primary' ?> text-sm opacity-10"></i>
class="ni ni-settings <?=basename(uri_string()) == 'ajuste-empresa' ? 'text-light' : 'text-primary'?> text-sm opacity-10"></i>
</div>
<span
class="nav-link-text ms-1 <?=basename(uri_string()) == 'ajuste-empresa' ? 'text-white' : ''?>">Ajuste
Expand All @@ -78,12 +78,25 @@ class="nav-link-text ms-1 <?=basename(uri_string()) == 'ajuste-empresa' ? 'text-
<div
class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
<i
class="ni ni-settings-gear-65 <?= basename(uri_string()) == 'configuracion' ? 'text-light' : 'text-primary' ?> text-sm opacity-10"></i>
class="ni ni-settings-gear-65 <?=basename(uri_string()) == 'configuracion' ? 'text-light' : 'text-primary'?> text-sm opacity-10"></i>
</div>
<span
class="nav-link-text ms-1 <?=basename(uri_string()) == 'configuracion' ? 'text-white' : ''?>">Configuración</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?=basename(uri_string()) == 'perfil' ? 'bg-dark rounded active' : ''?>"
href="<?=base_url('perfil')?>">
<div
class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
<i
class="ni ni-single-02 <?=basename(uri_string()) == 'perfil' ? 'text-light' : 'text-primary'?> text-sm opacity-10"></i>
</div>
<span
class="nav-link-text ms-1 <?=basename(uri_string()) == 'perfil' ? 'text-white' : ''?>">Perfil
de usuario</span>
</a>
</li>
</ul>
</div>
<div class="sidenav-footer mx-3 ">
Expand All @@ -105,6 +118,18 @@ class="nav-link-text ms-1 <?=basename(uri_string()) == 'configuracion' ? 'text-w
<div class="input-group">
</div>
</div>
<div class="ms-md-auto pe-md-3 d-flex align-items-center">
<div class="input-group">
<ul class="navbar-nav justify-content-end">
<li class="nav-item d-flex align-items-center">
<a href="<?=base_url('perfil')?>" class="nav-link text-white font-weight-bold px-0">
<i class="ni ni-single-02"></i>
<span class="d-sm-inline d-none">Perfil de usuario</span>
</a>
</li>
</ul>
</div>
</div>
<ul class="navbar-nav justify-content-end">
<li class="nav-item d-flex align-items-center">
<a href="<?=base_url('salir')?>" class="nav-link text-white font-weight-bold px-0">
Expand Down
114 changes: 114 additions & 0 deletions app/Views/perfil/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?=$this->extend('layouts/dashboard');?>
<?=$this->section('titulo');?>
Perfil de usuario
<?=$this->endSection();?>
<?=$this->section('contenido');?>
<?=link_tag('assets/css/btn-custom.css')?>
<div class='container-fluid py-4'>
<div class="card">
<div class="card-body">
<?php if (session('success')): ?>
<?=$this->include('errors/success')?>
<?php endif;?>
<?php foreach ($users as $user): ?>
<?=form_open(base_url('update-profile/') . $user['id'])?>
<?=form_hidden('_method', 'PUT')?>
<p class="text-uppercase text-sm">Información del usuario</p>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<?=form_label('Nombre(s)', 'name', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'text', 'class' => session('list.name') ? 'form-control is-invalid' : 'form-control', 'id' => 'name', 'value' => old('name', $user['nombre']), 'name' => 'name'])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.name')?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<?=form_label('Apellido paterno', 'paternal-name', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'text', 'class' => session('list.paternal-name') ? 'form-control is-invalid' : 'form-control', 'id' => 'paternal-name', 'name' => 'paternal-name', 'value' => old('paternnal-name', $user['apepat'])])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.paternal-name')?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<?=form_label('Apellido materno', 'maternal-name', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'text', 'class' => session('list.maternal-name') ? 'form-control is-invalid' : 'form-control', 'id' => 'maternal-name', 'name' => 'maternal-name', 'value' => old('maternal-name', $user['apemat'])])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.maternal-name')?>
</div>
</div>
</div>
</div>
<hr class="horizontal dark">
<p class="text-uppercase text-sm">Información de la cuenta</p>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<?=form_label('Nombre de usuario', 'username', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'text', 'class' => session('list.username') ? 'form-control is-invalid' : 'form-control', 'id' => 'username', 'name' => 'username', 'value' => old('username', $user['usuario'])])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.user')?>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<?=form_label('Correo electronico', 'email', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'text', 'class' => session('list.email') ? 'form-control is-invalid' : 'form-control', 'id' => 'email', 'name' => 'email', 'value' => old('email', $user['email'])])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.email')?>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<?=form_label('Contraseña', 'password', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'password', 'class' => session('list.password') ? 'form-control is-invalid' : 'form-control', 'id' => 'password', 'name' => 'password'])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.password')?>
</div>
</div>
</div>
</div>
<hr class="horizontal dark">
<p class="text-uppercase text-sm">Información de contacto</p>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<?=form_label('Direccion', 'address', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'text', 'class' => session('list.address') ? 'form-control is-invalid' : 'form-control', 'id' => 'address', 'name' => 'address', 'value' => old('address', $user['direccion'])])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.address')?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<?=form_label('Telefono', 'phone', ['class' => 'form-control-label'])?>
<?=form_input(['type' => 'tel', 'class' => session('list.phone') ? 'form-control is-invalid' : 'form-control', 'id' => 'phone', 'name' => 'phone', 'value' => old('phone', $user['telefono'])])?>
<div id="userFeedback" class="invalid-feedback">
<?=session('list.phone')?>
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-4"></div>
<div class="col-md-4 text-center">
<div class="mb-3">
<?=form_submit('send', 'Guardar los datos', ['class' => 'btn-custom btn bg-gradient-primary rounded-pill rounded-5 btn-sm shadow-lg px-4 py-2'])?>
</div>

</div>
<div class="col-md-4"></div>
</div>
<?=form_close()?>
<?php endforeach;?>
</div>
</div>
</div class='container'>
<?=$this->endSection();?>
10 changes: 10 additions & 0 deletions public/assets/css/btn-custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.btn-custom {
transition: transform 0.4s, font-size 0.4s;
/* Agregamos transición para el tamaño de fuente */
}

.btn-custom:hover {
transform: scale(1.2);
font-weight: bold;
font-size: 14px;
}

0 comments on commit 6ad26e8

Please sign in to comment.