diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2019-12-18 16:58:31 +0100 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2019-12-18 16:58:31 +0100 |
commit | 66bf79d4b7cd5adadecf1497288e92f4b9789861 (patch) | |
tree | 5d47b5ede4527a018069f1d27641e13c2d96bbe4 | |
parent | d6a008427c1710bedd527029596e0fb397ed54dd (diff) |
#947: New web page with Organization Unit statistics obtained from de database.
-rw-r--r-- | admin/WebConsole/idiomas/php/cat/estadisticas_cat.php | 28 | ||||
-rw-r--r-- | admin/WebConsole/idiomas/php/eng/estadisticas_eng.php | 28 | ||||
-rw-r--r-- | admin/WebConsole/idiomas/php/esp/estadisticas_esp.php | 28 | ||||
-rw-r--r-- | admin/WebConsole/principal/estadisticas.php | 127 |
4 files changed, 211 insertions, 0 deletions
diff --git a/admin/WebConsole/idiomas/php/cat/estadisticas_cat.php b/admin/WebConsole/idiomas/php/cat/estadisticas_cat.php new file mode 100644 index 00000000..2ac726a5 --- /dev/null +++ b/admin/WebConsole/idiomas/php/cat/estadisticas_cat.php @@ -0,0 +1,28 @@ +<?php +//________________________________________________________ +// +// Fichero de idiomas php: estadisticas_cat.php +// Idioma: Català +//________________________________________________________ +if (empty($TbMsg)) $TbMsg = []; +$TbMsg += [ + "TITLE_STATS" => 'Estadísticas de la Unidad Organizativa', + "LABEL_LABS" => 'Aulas definidas', + "LABEL_HASPROF" => 'Aulas con ordenador de profesor', + "LABEL_REMOTELAB" => 'Aulas con acceso remoto habilitado', + "LABEL_CLIENTS" => 'Ordenadores definidos', + "LABEL_HASCONFIG" => 'Ordenadores con configuración guardada', + "LABEL_HASREPO" => 'Ordenadores con repositorio asignado', + "LABEL_HASHARD" => "Ordenadores con perfil de hardware", + "LABEL_HASSERIAL" => 'Ordenadores con número de serie', + "LABEL_REPOS" => 'Repositorios de imágenes definidos', + "LABEL_IMAGES" => 'Imágenes definidas', + "LABEL_MONOIMG" => 'Imágenes monolíticas', + "LABEL_HASSOFT" => 'Imágenes con perfil de software', + "LABEL_REMOTEIMG" => 'Imágenes con acceso remoto habilitado', + "LABEL_OSES" => 'Sistemas operativos distintos', + "LABEL_MENUS" => 'Menús definidos', + "LABEL_PROCS" => 'Procedimientos definidos', + "LABEL_TASKS" => 'Tareas definidas', + "MSG_UNAVAILABLE" => 'Estadísticas no disponibles', + ]; diff --git a/admin/WebConsole/idiomas/php/eng/estadisticas_eng.php b/admin/WebConsole/idiomas/php/eng/estadisticas_eng.php new file mode 100644 index 00000000..40d71b3c --- /dev/null +++ b/admin/WebConsole/idiomas/php/eng/estadisticas_eng.php @@ -0,0 +1,28 @@ +<?php +//________________________________________________________ +// +// Php language file: estadisticas_eng.php +// Language: English +//________________________________________________________ +if (empty($TbMsg)) $TbMsg = []; +$TbMsg += [ + "TITLE_STATS" => 'Statístics of the Organizational Unit', + "LABEL_LABS" => 'Defined labs', + "LABEL_HASPROF" => "Labs with teacher's computer", + "LABEL_REMOTELAB" => 'Labs with remote access enabled', + "LABEL_CLIENTS" => 'Defined computers', + "LABEL_HASCONFIG" => 'Computers with saved configuration', + "LABEL_HASREPO" => 'Computers assigned to a repository', + "LABEL_HASHARD" => "Computers with hardware profile", + "LABEL_HASSERIAL" => 'Computers with serial number', + "LABEL_REPOS" => 'Defined image repositories', + "LABEL_IMAGES" => 'Defined images', + "LABEL_MONOIMG" => 'Imágenes monolíticas', + "LABEL_HASSOFT" => 'Images with software profile', + "LABEL_REMOTEIMG" => 'Images with remote access enabled', + "LABEL_OSES" => 'Different operating systems', + "LABEL_MENUS" => 'Defined menus', + "LABEL_PROCS" => 'Defined procedures', + "LABEL_TASKS" => 'Defined tasks', + "MSG_UNAVAILABLE" => 'Statistics are not available', + ]; diff --git a/admin/WebConsole/idiomas/php/esp/estadisticas_esp.php b/admin/WebConsole/idiomas/php/esp/estadisticas_esp.php new file mode 100644 index 00000000..2344f6ba --- /dev/null +++ b/admin/WebConsole/idiomas/php/esp/estadisticas_esp.php @@ -0,0 +1,28 @@ +<?php +//________________________________________________________ +// +// Fichero de idiomas php: estadisticas_esp.php +// Idioma: Español +//________________________________________________________ +if (empty($TbMsg)) $TbMsg = []; +$TbMsg += [ + "TITLE_STATS" => 'Estadísticas de la Unidad Organizativa', + "LABEL_LABS" => 'Aulas definidas', + "LABEL_HASPROF" => 'Aulas con ordenador de profesor', + "LABEL_REMOTELAB" => 'Aulas con acceso remoto habilitado', + "LABEL_CLIENTS" => 'Ordenadores definidos', + "LABEL_HASCONFIG" => 'Ordenadores con configuración guardada', + "LABEL_HASREPO" => 'Ordenadores con repositorio asignado', + "LABEL_HASHARD" => "Ordenadores con perfil de hardware", + "LABEL_HASSERIAL" => 'Ordenadores con número de serie', + "LABEL_REPOS" => 'Repositorios de imágenes definidos', + "LABEL_IMAGES" => 'Imágenes definidas', + "LABEL_MONOIMG" => 'Imágenes monolíticas', + "LABEL_HASSOFT" => 'Imágenes con perfil de software', + "LABEL_REMOTEIMG" => 'Imágenes con acceso remoto habilitado', + "LABEL_OSES" => 'Sistemas operativos distintos', + "LABEL_MENUS" => 'Menús definidos', + "LABEL_PROCS" => 'Procedimientos definidos', + "LABEL_TASKS" => 'Tareas definidas', + "MSG_UNAVAILABLE" => 'Estadísticas no disponibles', + ]; diff --git a/admin/WebConsole/principal/estadisticas.php b/admin/WebConsole/principal/estadisticas.php new file mode 100644 index 00000000..eede5aaf --- /dev/null +++ b/admin/WebConsole/principal/estadisticas.php @@ -0,0 +1,127 @@ +<?php +/* + * + */ + +include_once(__DIR__ . "/../includes/ctrlacc.php"); +include_once(__DIR__ . "/../includes/CreaComando.php"); +include_once(__DIR__ . "/../clases/AdoPhp.php"); +include_once(__DIR__ . "/../idiomas/php/$idioma/estadisticas_$idioma.php"); + +$cmd=CreaComando($cadenaconexion); +if (!$cmd) { + header('Location: '.$pagerror.'?herror=2'); // Database connection error +} +// Retrieving statistics from the database. +$data = get_statistics($cmd, $idcentro); + +?> +<html lang="es"> +<head> + <title>Administración web de aulas</title> + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> + <link rel="stylesheet" type="text/css" href="../estilos.css"> +</head> +<body> +<div align="center" class="cabeceras"><?php echo $TbMsg['TITLE_STATS'] ?></div> +<?php if ($data) { ?> + <div align="center" class="subcabeceras"><?php echo $data["ou"] ?></div> + <p> + <table align="center" class="tabla_listados_sin"> + <?php + print_data_row($TbMsg['LABEL_LABS'], $data['labs']); + if ($data['labs'] > 0) { + print_data_row($TbMsg['LABEL_HASPROF'], $data['hasprof'], $data['labs']); + print_data_row($TbMsg['LABEL_REMOTELAB'], $data['remotelab'], $data['labs']); + print_data_row($TbMsg['LABEL_CLIENTS'], $data['clients']); + print_data_row($TbMsg['LABEL_HASCONFIG'], $data['hasconfig'], $data['clients']); + print_data_row($TbMsg['LABEL_HASREPO'], $data['hasrepo'], $data['clients']); + print_data_row($TbMsg['LABEL_HASHARD'], $data['hashard'], $data['clients']); + print_data_row($TbMsg['LABEL_HASSERIAL'], $data['hasserial'], $data['clients']); + } + print_data_row($TbMsg['LABEL_REPOS'], $data['repos']); + if ($data['repos'] > 0) { + print_data_row($TbMsg['LABEL_IMAGES'], $data['images']); + if ($data['images'] > 0) { + print_data_row($TbMsg['LABEL_MONOIMG'], $data['monoimg'], $data['images']); + print_data_row($TbMsg['LABEL_HASSOFT'], $data['hassoft'], $data['images']); + print_data_row($TbMsg['LABEL_REMOTEIMG'], $data['remoteimg'], $data['images']); + print_data_row($TbMsg['LABEL_OSES'], $data['oses']); + } + } + print_data_row($TbMsg['LABEL_MENUS'], $data['menus']); + print_data_row($TbMsg['LABEL_PROCS'], $data['procs']); + print_data_row($TbMsg['LABEL_TASKS'], $data['tasks']); + ?> + </table> +<?php } else {?> + <p align="center"><?php echo $TbMsg['MSG_UNAVAILABLE'] ?></p> +<?php } ?> +<div align="center" class="pie"><a href="javascript:history.go(-1)">Volver</a></div> +</body> +</html> +<?php +/** + * @function get_statistics + * @param $cmd + * @param $id + * @return array + */ +function get_statistics($cmd, $id) { + $rs=new Recordset; + $cmd->texto = <<<EOT +SELECT * + FROM (SELECT nombrecentro AS ou, + COUNT(DISTINCT idaula) AS labs, + COUNT(DISTINCT IF(idordprofesor > 0, idaula, NULL)) AS hasprof, + COUNT(IF(inremotepc = 1, 1, NULL)) AS remotelab, + COUNT(idordenador) AS clients, + COUNT(numserie) AS hasconfig, + COUNT(IF(idrepositorio > 0, 1, NULL)) AS hasrepo, + COUNT(IF(idperfilhard > 0, 1, NULL)) AS hashard, + COUNT(IF(numserie = '', NULL, 1)) AS hasserial + FROM centros + LEFT JOIN aulas USING(idcentro) + LEFT JOIN ordenadores USING(idaula) + WHERE idcentro = $id) AS t1, + (SELECT COUNT(*) AS repos + FROM repositorios + WHERE idcentro = $id) AS t2, + (SELECT COUNT(*) AS images, + COUNT(IF(tipo = 1, 1, NULL)) AS monoimg, + COUNT(IF(idperfilsoft > 0, 1, NULL)) AS hassoft, + COUNT(IF(inremotepc = 1, 1, NULL)) AS remoteimg, + COUNT(DISTINCT idnombreso) AS oses + FROM imagenes + LEFT JOIN perfilessoft USING(idperfilsoft) + LEFT JOIN nombresos USING(idnombreso) + WHERE imagenes.idcentro = $id) AS t3, + (SELECT COUNT(*) AS menus + FROM menus + WHERE idcentro = $id) AS t4, + (SELECT COUNT(*) as procs + FROM procedimientos + WHERE idcentro = $id) AS t5, + (SELECT COUNT(*) as tasks + FROM tareas + WHERE idcentro = $id) AS t6; +EOT; + $rs->Comando=&$cmd; + if (!$rs->Abrir()) { + return(null); // Error opening the record set + } + $rs->Primero(); + $data = $rs->campos; + $rs->Cerrar(); + return($data); +} + +/** + * @param string $label + * @param int $value + * @param int $total + */ +function print_data_row($label, $value, $total=0) { + echo "\t\t<tr><th> $label: </th><td> $value" . + ($total>0 ? " (".intval($value*100/$total)."%)" : "") . " </td></tr>\n"; +}
\ No newline at end of file |