Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
RegistroEquipos2
/
backend
/
devolucion
:
devolucionesDashboard.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); $host = '192.200.100.40'; $db = 'sistemas'; $user = 'SANMARINO'; $pass = 'sanmarino2021*'; $charset = 'utf8mb4'; try { $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $pdo = new PDO($dsn, $user, $pass, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); // Total de devoluciones (tabla registrodevoluciones) $total = $pdo->query("SELECT COUNT(*) as total FROM registrodevoluciones")->fetch(PDO::FETCH_ASSOC); // Devoluciones por tipo (usando la columna 'tipo') $porTipo = $pdo->query("SELECT tipo, COUNT(*) as cantidad FROM registrodevoluciones GROUP BY tipo")->fetchAll(PDO::FETCH_ASSOC); // Para facilitar el gráfico, creamos un array con los tipos comunes $stats = [ 'total' => (int)($total['total'] ?? 0), 'porTipo' => [] ]; foreach ($porTipo as $row) { $stats['porTipo'][$row['tipo']] = (int)$row['cantidad']; } echo json_encode([ 'status' => 'success', 'data' => $stats ]); } catch (PDOException $e) { echo json_encode([ 'status' => 'error', 'mensaje' => 'Error de conexión: ' . $e->getMessage() ]); } ?>