Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DanielRivera03/SistemaBancario/llms.txt

Use this file to discover all available pages before exploring further.

CashMan H.A. uses two PHP front controllers that route all requests via GET parameters. Rather than a URL-rewriting framework, each controller reads a single query-string key and dispatches to the appropriate logic through a switch statement. cIniciosSesionesUsuarios.php owns everything before a session exists; once authenticated, every subsequent action flows through cGestionesCashman.php.

cIniciosSesionesUsuarios.php

Location: controlador/cIniciosSesionesUsuarios.php

Purpose

Handles all pre-authentication operations: login validation, session creation, password recovery via emailed security codes, new password submission, and logout.

Routing Parameter

?cashmanha=<action>
Default value when the parameter is absent: iniciarsesion.

Dependencies

require '../PHPMailer/Exception.php';
require '../PHPMailer/PHPMailer.php';
require '../PHPMailer/SMTP.php';
require('../modelo/conexion.php');
require('../modelo/mRecuperacionCuentas.php');

$Usuarios = new RecuperacionCuentas();
DependencyRole
PHPMailer/Exception.phpPHPMailer exception class
PHPMailer/PHPMailer.phpCore mailer class
PHPMailer/SMTP.phpSMTP transport
modelo/conexion.phpOpens $conectarsistema and auxiliary MySQLi connections
modelo/mRecuperacionCuentas.phpRecuperacionCuentas model — account recovery DB operations

Global Configuration

$UrlGlobal = "http://" . $_SERVER['SERVER_NAME'] . ":90" . "/CashManHA" . '/';
$UrlGlobal is used in email body HTML to construct absolute links back to the application (e.g., the “Change Password” button href). The :90 port prefix matches the default development server configuration and must be updated for any other environment.

PHPMailer SMTP Settings

The controller configures PHPMailer inline within the recuperar-cuentas and cambiar-contrasenia-recuperacion cases. Key properties that must be set for your environment:
$mail->isSMTP();
$mail->Host     = '';       // e.g. 'smtp.mailtrap.io' or your mail server
$mail->SMTPAuth = true;
$mail->Port     = 2525;     // default; 587 or 465 for production
$mail->Username = '';       // SMTP username
$mail->Password = '';       // SMTP password
$mail->CharSet  = 'UTF-8';
$mail->SMTPDebug = 0;       // set to 2 for verbose SMTP debugging
The project was developed using Papercut SMTP for local email capture. For production, configure a real SMTP provider (e.g., Mailtrap, SendGrid, or an institutional mail server) and consult the PHPMailer documentation.

Key Operations

1

Login Validation (`validar-sesiones`)

Receives val-username and val-password via POST. Hashes the password with SHA-1 + crypt(), calls IniciarSesionUsuarios() on the connection, and redirects to the role-appropriate dashboard. Optionally sets a 30-day cookie for “remember me”.
2

Recovery Code Generation (`recuperar-cuentas`)

Generates a 5-digit random code with rand(10000, 99999) and a 10-character hex token with random_bytes(5) + bin2hex(). Stores both in $_SESSION and calls RecuperarCuentasUsuarios() to persist them in the database. Sends the code by email — the clickable link in the email includes the token as a URL parameter.
3

Code Validation (`cambio-estado-token`)

Reads the code from session and upgrades $_SESSION['EstadoCodigos'] from BloquearCodigoAcceso to ValidarCodigoAcceso, gating access to the new-password form.
4

Password Reset (`cambiar-contrasenia-recuperacion`)

Accepts the new password via POST, hashes it identically to the login flow, calls CambioContraseniaRecuperacion(), sends a confirmation email, then destroys the session.
5

Logout (`cerrarsesion`)

Calls session_unset() followed by session_destroy(), then redirects to iniciarsesion.

cGestionesCashman.php

Location: controlador/cGestionesCashman.php

Purpose

Handles all post-login business logic: dashboards, user management, credit lifecycle, savings accounts, transfers, messaging, notifications, products, and PDF generation.

Routing Parameter

?cashmanhagestion=<action>
Default value when the parameter is absent: inicioadministradores.

Dependencies

require '../PHPMailer/Exception.php';
require '../PHPMailer/PHPMailer.php';
require '../PHPMailer/SMTP.php';
require('../modelo/conexion.php');
require('../modelo/mGestionesCashman.php');

$Gestiones = new GestionesClientes();
DependencyRole
PHPMailer (3 files)Email delivery for transfer security codes and notifications
modelo/conexion.phpOpens $conectarsistema through $conectarsistema7
modelo/mGestionesCashman.phpGestionesClientes model — all business logic DB calls

Timezone

Set at the very top of the file, before any routing:
date_default_timezone_set('America/El_Salvador');
This sets the application clock to UTC−6 (El Salvador). All date() calls in this controller — including installment due-date calculations and file-upload timestamps — use this timezone.

Global Configuration

Identical $UrlGlobal pattern as in cIniciosSesionesUsuarios.php:
$UrlGlobal = "http://" . $_SERVER['SERVER_NAME'] . ":90" . "/CashManHA" . '/';

Access Control Pattern

Every switch case checks the session role before executing any logic:
case "gestion-creditos-primer-paso-gerencia":
    if ($_SESSION['id_rol'] == 3 || $_SESSION['id_rol'] == 1) {
        // ... execute logic ...
    } else {
        header('location:cGestionesCashman.php?cashmanhagestion=redirecciones-sistema-cashmanha');
    }
    break;
An incorrect role always redirects to redirecciones-sistema-cashmanha, which itself routes the user to their own role-appropriate home page. There is no unauthenticated access path in this controller.

AJAX Response Pattern

Write operations return echo json_encode($result) directly for AJAX-compatible responses. The model methods return the string "OK" on success or "ERROR" on failure, which is then JSON-encoded and sent to the browser:
$consulta = $Gestiones->DesactivarUsuariosClientes($conectarsistema, $IdUsuarios);
echo json_encode($consulta);
// Outputs: "OK" or "ERROR"
The calling JavaScript (jQuery) reads this JSON payload to determine success or failure and triggers SweetAlert2 or Toastr notifications accordingly.

Multi-Connection Strategy

Because PHP’s MySQLi extension does not natively support running multiple stored-procedure result sets in parallel on a single connection, cGestionesCashman.php opens up to seven independent connections from conexion.php ($conectarsistema through $conectarsistema7). Dashboard pages that need several result sets simultaneously assign each query to a separate connection:
case "inicioadministradores":
    if ($_SESSION['id_rol'] == 1) {
        $consulta  = $Gestiones->MostrarListadoNotificacionesRecortadaRecibidasUsuarios($conectarsistema,  $IdUsuarios);
        $consulta1 = $Gestiones->ConsultarDetallesRegistros_Administradores($conectarsistema3);
        $consulta2 = $Gestiones->ConsultaListadoGeneralUltimasTransaccionesClientes($conectarsistema4);
        require("../vista/Administradores/inicio-administradores.php");
        $conectarsistema->close();
        $conectarsistema1->close();
        $conectarsistema2->close();
        $conectarsistema3->close();
        $conectarsistema4->close();
    }
Every connection opened must be explicitly closed at the end of the case.

modelo/mGestionesCashman.phpGestionesClientes Class

Location: modelo/mGestionesCashman.php

Architecture

GestionesClientes is a PHP class with private properties for all entity fields and public methods that map 1:1 to stored procedures in the cashmanha database schema. No raw SQL is written inline in the application code — every database operation is a CALL ProcedureName(...) statement.

Pattern

Each method uses the setter/call pattern:
  1. The controller calls a setter to populate a private property.
  2. The method builds a CALL ProcedureName(...) string using the interpolated private properties.
  3. mysqli_query() executes the call on the connection passed as an argument.
  4. The raw MySQLi result is returned to the controller.
  5. The controller (or the view) calls mysqli_fetch_assoc(), mysqli_fetch_array(), or iterates with while to extract rows.

Representative Method Signatures

class GestionesClientes {
    private $IdUsuarios;
    private $NombresUsuarios;
    private $ApellidosUsuarios;
    private $CodigoUsuarios;
    private $CorreoUsuarios;
    // ... many more private properties for every entity field ...

    public function setIdUsuarios($IdUsuarios) {
        $this->IdUsuarios = $IdUsuarios;
    }

    // Stored procedure call — populates private properties via setters on result
    public function ConsultarConfiguracionCuentaUsuarios($conectarsistema1, $IdUsuarios) {
        $resultado = mysqli_query(
            $conectarsistema1,
            "CALL ConsultarConfiguracionCuentaUsuarios('$IdUsuarios');"
        );
        // ... populates $this properties from result row if rows exist ...
    }

    // Returns "OK" or "ERROR" string (not a MySQLi result object)
    public function DesactivarUsuariosClientes($conectarsistema, $IdUsuarios) {
        $resultado = mysqli_query(
            $conectarsistema,
            "CALL DesactivarUsuarios_Clientes('$IdUsuarios');"
        );
        if ($resultado) { return "OK"; } else { return "ERROR"; }
    }

    public function RegistroClientesAdministradores(
        $conexion,
        $NombresUsuarios, $ApellidosUsuarios,
        $CodigoUsuarios, $ContraseniaUsuarios,
        $CorreoUsuarios, $IdRolUsuarios,
        $QuienRegistroUsuario
    ) {
        // ... sets properties, builds CALL string ...
        return mysqli_query($conexion, "CALL RegistroClientesAdministradores(...)");
    }
}

Private Properties Declared

The class declares private properties covering all entity fields across every module:
GroupProperties
User account$IdUsuarios, $NombresUsuarios, $ApellidosUsuarios, $CodigoUsuarios, $CorreoUsuarios, $IdRolUsuarios, $FotoUsuarios, $EstadoUsuarios
User details$DuiUsuarios, $NitUsuarios, $TelefonoUsuarios, $CelularUsuarios, $TelefonoTrabajoUsuarios, $DireccionUsuarios, $EmpresaUsuarios, $CargoEmpresaUsuarios, $DireccionTrabajoUsuarios, $FechaNacimientoUsuarios, $GeneroUsuarios, $EstadoCivilUsuarios
Documents$FotoDuiFrontalUsuarios, $FotoDuiReversoUsuarios, $FotoNitUsuarios, $FotoFirmaUsuarios
Roles$NombreRolUsuario, $DescripcionRolUsuario
Products$IdProductos, $CodigoProductos, $NombreProductos, $DescripcionProductos, $RequisitosProductos, $EstadoProductos
Credits$IdCreditos, $TipoClienteCreditos, $MontoFinanciamientoCreditos, $TasaInteresCreditos, and many more
The database schema backing GestionesClientes contains 148 stored procedures, 67 views, 21 triggers, and 5 scheduled events across 21 tables. Every public method in the model corresponds to one of those stored procedures.

Build docs developers (and LLMs) love