Tul xxx Tul
User / IP
:
216.73.217.33
Host / Server
:
45.84.207.204 / aircan.me
System
:
Linux lt-bnk-web1726.main-hosting.eu 5.14.0-611.36.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 3 11:23:52 EST 2026 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
u931257429
/
domains
/
aircan.me
/
public_html
/
siscaps
/
controllers
/
Viewing: DashboardController.php
<?php require_once __DIR__ . '/BaseController.php'; class DashboardController extends BaseController { public function index() { // Verificar autenticación y permisos requireAuth(['ADMIN', 'CAJERO', 'CLIENTE', 'LECTOR']); $user = getCurrentUser(); $role = getCurrentUserRole(); // Redirigir clientes a su portal específico y lectores a lecturas if ($role === 'CLIENTE') { redirect('cliente.dashboard'); return; } elseif ($role === 'LECTOR') { redirect('lecturas.index'); return; } require_once __DIR__ . '/../config/database.php'; $pdo = (new Database())->getConnection(); if (!$pdo) { setFlashMessage('error', 'No hay conexión a la base de datos'); $error = 'No hay conexión a la base de datos'; $this->renderView('dashboard/index', compact('error')); return; } // Fechas de inicio y fin del mes actual $startMonth = (new DateTime('first day of this month 00:00:00')); $endMonth = (new DateTime('last day of this month 23:59:59')); // Total de clientes activos $activeCustomers = (int)$pdo->query("SELECT COUNT(*) FROM customers WHERE status = 'Activo'")->fetchColumn(); // Total de facturas pendientes $pendingInvoices = (int)$pdo->query("SELECT COUNT(*) FROM invoices WHERE status = 'Pendiente'")->fetchColumn(); // Pagos del mes: cantidad y monto $stmt = $pdo->prepare("SELECT COUNT(*) AS c, COALESCE(SUM(amount),0) AS s FROM payments WHERE payment_date BETWEEN :d1 AND :d2"); $stmt->execute([ ':d1' => $startMonth->format('Y-m-d H:i:s'), ':d2' => $endMonth->format('Y-m-d H:i:s'), ]); $row = $stmt->fetch(); $paymentsCount = (int)($row['c'] ?? 0); $paymentsAmount = (float)($row['s'] ?? 0.0); // Deuda total: facturas pendientes o vencidas $debtTotal = (float)$pdo->query("SELECT COALESCE(SUM(total),0) FROM invoices WHERE status IN ('Pendiente','Vencida')")->fetchColumn(); // Consumo del mes $stmt = $pdo->prepare("SELECT COALESCE(SUM(consumption_m3),0) FROM readings WHERE reading_date BETWEEN :d1 AND :d2"); $stmt->execute([ ':d1' => $startMonth->format('Y-m-d'), ':d2' => $endMonth->format('Y-m-d'), ]); $consumptionMonth = (float)$stmt->fetchColumn(); // Consumo de los últimos 12 meses (para Chart.js) $from12 = (new DateTime('first day of -11 months'))->format('Y-m-01'); $q = $pdo->prepare("SELECT DATE_FORMAT(reading_date, '%Y-%m') ym, SUM(consumption_m3) total FROM readings WHERE reading_date >= :from GROUP BY ym ORDER BY ym ASC"); $q->execute([':from' => $from12]); $agg = []; foreach ($q->fetchAll() as $r) { $agg[$r['ym']] = (float)$r['total']; } $chartLabels = []; $chartValues = []; for ($i = 11; $i >= 0; $i--) { $dt = new DateTime("first day of -{$i} months"); $ym = $dt->format('Y-m'); $chartLabels[] = $dt->format('M Y'); $chartValues[] = isset($agg[$ym]) ? (float)$agg[$ym] : 0.0; } // Preparar datos para la vista $pageTitle = 'Dashboard - SISCAPS'; $data = compact( 'activeCustomers', 'pendingInvoices', 'paymentsCount', 'paymentsAmount', 'debtTotal', 'consumptionMonth', 'chartLabels', 'chartValues', 'pageTitle' ); $this->renderView('dashboard/index', $data); } }
Coded With 💗 by
0x6ick