$(document).ready(function() {
    cargarEstadisticas();
});

function cargarEstadisticas() {
    const endpoints = [
        { url: "../../controller/dashboard.php?op=total_usuarios", target: "#lbl_usuarios" },
        { url: "../../controller/dashboard.php?op=total_equipos", target: "#lbl_total_equipos" },
        { url: "../../controller/dashboard.php?op=total_asignados", target: "#lbl_equipos_asignados" },
        { url: "../../controller/dashboard.php?op=count_total_alumnos", target: "#lbl_count_total_alumnos" },
        { url: "../../controller/dashboard.php?op=count_total_pacientes", target: "#lbl_count_total_pacientes" },
        { url: "../../controller/dashboard.php?op=total_alumnos_valor_mes", target: "#lbl_total_alumnos_valor_mes" },
        { url: "../../controller/dashboard.php?op=sessiones_total", target: "#lbl_sessiones_total" },
        { url: "../../controller/dashboard.php?op=sessiones_pagas", target: "#lbl_sessiones_pagas" },
        { url: "../../controller/dashboard.php?op=sessiones_pagas_s", target: "#lbl_sessiones_pagas_s" },

    ];

    endpoints.forEach(function(item) {
        $.ajax({
            url: item.url,
            type: "GET",
            dataType: "json",
            success: function(data) {
                $(item.target).text(data.total || 0);
            },
            error: function() {
                $(item.target).text("0");
            }
        });
    });
}
