[66bf79d] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | include_once(__DIR__ . "/../includes/ctrlacc.php"); |
---|
| 7 | include_once(__DIR__ . "/../includes/CreaComando.php"); |
---|
| 8 | include_once(__DIR__ . "/../clases/AdoPhp.php"); |
---|
| 9 | include_once(__DIR__ . "/../idiomas/php/$idioma/estadisticas_$idioma.php"); |
---|
| 10 | |
---|
| 11 | $cmd=CreaComando($cadenaconexion); |
---|
| 12 | if (!$cmd) { |
---|
| 13 | header('Location: '.$pagerror.'?herror=2'); // Database connection error |
---|
| 14 | } |
---|
| 15 | // Retrieving statistics from the database. |
---|
| 16 | $data = get_statistics($cmd, $idcentro); |
---|
| 17 | |
---|
| 18 | ?> |
---|
| 19 | <html lang="es"> |
---|
| 20 | <head> |
---|
| 21 | <title>Administración web de aulas</title> |
---|
| 22 | <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
| 23 | <link rel="stylesheet" type="text/css" href="../estilos.css"> |
---|
| 24 | </head> |
---|
| 25 | <body> |
---|
| 26 | <div align="center" class="cabeceras"><?php echo $TbMsg['TITLE_STATS'] ?></div> |
---|
| 27 | <?php if ($data) { ?> |
---|
| 28 | <div align="center" class="subcabeceras"><?php echo $data["ou"] ?></div> |
---|
| 29 | <p> |
---|
| 30 | <table align="center" class="tabla_listados_sin"> |
---|
| 31 | <?php |
---|
| 32 | print_data_row($TbMsg['LABEL_LABS'], $data['labs']); |
---|
| 33 | if ($data['labs'] > 0) { |
---|
| 34 | print_data_row($TbMsg['LABEL_HASPROF'], $data['hasprof'], $data['labs']); |
---|
| 35 | print_data_row($TbMsg['LABEL_REMOTELAB'], $data['remotelab'], $data['labs']); |
---|
| 36 | print_data_row($TbMsg['LABEL_CLIENTS'], $data['clients']); |
---|
| 37 | print_data_row($TbMsg['LABEL_HASCONFIG'], $data['hasconfig'], $data['clients']); |
---|
| 38 | print_data_row($TbMsg['LABEL_HASREPO'], $data['hasrepo'], $data['clients']); |
---|
| 39 | print_data_row($TbMsg['LABEL_HASHARD'], $data['hashard'], $data['clients']); |
---|
| 40 | print_data_row($TbMsg['LABEL_HASSERIAL'], $data['hasserial'], $data['clients']); |
---|
| 41 | } |
---|
| 42 | print_data_row($TbMsg['LABEL_REPOS'], $data['repos']); |
---|
| 43 | if ($data['repos'] > 0) { |
---|
| 44 | print_data_row($TbMsg['LABEL_IMAGES'], $data['images']); |
---|
| 45 | if ($data['images'] > 0) { |
---|
| 46 | print_data_row($TbMsg['LABEL_MONOIMG'], $data['monoimg'], $data['images']); |
---|
| 47 | print_data_row($TbMsg['LABEL_HASSOFT'], $data['hassoft'], $data['images']); |
---|
| 48 | print_data_row($TbMsg['LABEL_REMOTEIMG'], $data['remoteimg'], $data['images']); |
---|
| 49 | print_data_row($TbMsg['LABEL_OSES'], $data['oses']); |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | print_data_row($TbMsg['LABEL_MENUS'], $data['menus']); |
---|
| 53 | print_data_row($TbMsg['LABEL_PROCS'], $data['procs']); |
---|
| 54 | print_data_row($TbMsg['LABEL_TASKS'], $data['tasks']); |
---|
| 55 | ?> |
---|
| 56 | </table> |
---|
| 57 | <?php } else {?> |
---|
| 58 | <p align="center"><?php echo $TbMsg['MSG_UNAVAILABLE'] ?></p> |
---|
| 59 | <?php } ?> |
---|
| 60 | <div align="center" class="pie"><a href="javascript:history.go(-1)">Volver</a></div> |
---|
| 61 | </body> |
---|
| 62 | </html> |
---|
| 63 | <?php |
---|
| 64 | /** |
---|
| 65 | * @function get_statistics |
---|
| 66 | * @param $cmd |
---|
| 67 | * @param $id |
---|
| 68 | * @return array |
---|
| 69 | */ |
---|
| 70 | function get_statistics($cmd, $id) { |
---|
| 71 | $rs=new Recordset; |
---|
| 72 | $cmd->texto = <<<EOT |
---|
| 73 | SELECT * |
---|
| 74 | FROM (SELECT nombrecentro AS ou, |
---|
| 75 | COUNT(DISTINCT idaula) AS labs, |
---|
| 76 | COUNT(DISTINCT IF(idordprofesor > 0, idaula, NULL)) AS hasprof, |
---|
[a70996f] | 77 | COUNT(DISTINCT IF(inremotepc = 1, idaula, NULL)) AS remotelab, |
---|
[66bf79d] | 78 | COUNT(idordenador) AS clients, |
---|
| 79 | COUNT(numserie) AS hasconfig, |
---|
| 80 | COUNT(IF(idrepositorio > 0, 1, NULL)) AS hasrepo, |
---|
| 81 | COUNT(IF(idperfilhard > 0, 1, NULL)) AS hashard, |
---|
| 82 | COUNT(IF(numserie = '', NULL, 1)) AS hasserial |
---|
| 83 | FROM centros |
---|
| 84 | LEFT JOIN aulas USING(idcentro) |
---|
| 85 | LEFT JOIN ordenadores USING(idaula) |
---|
| 86 | WHERE idcentro = $id) AS t1, |
---|
| 87 | (SELECT COUNT(*) AS repos |
---|
| 88 | FROM repositorios |
---|
| 89 | WHERE idcentro = $id) AS t2, |
---|
| 90 | (SELECT COUNT(*) AS images, |
---|
| 91 | COUNT(IF(tipo = 1, 1, NULL)) AS monoimg, |
---|
| 92 | COUNT(IF(idperfilsoft > 0, 1, NULL)) AS hassoft, |
---|
| 93 | COUNT(IF(inremotepc = 1, 1, NULL)) AS remoteimg, |
---|
| 94 | COUNT(DISTINCT idnombreso) AS oses |
---|
| 95 | FROM imagenes |
---|
| 96 | LEFT JOIN perfilessoft USING(idperfilsoft) |
---|
| 97 | LEFT JOIN nombresos USING(idnombreso) |
---|
| 98 | WHERE imagenes.idcentro = $id) AS t3, |
---|
| 99 | (SELECT COUNT(*) AS menus |
---|
| 100 | FROM menus |
---|
| 101 | WHERE idcentro = $id) AS t4, |
---|
| 102 | (SELECT COUNT(*) as procs |
---|
| 103 | FROM procedimientos |
---|
| 104 | WHERE idcentro = $id) AS t5, |
---|
| 105 | (SELECT COUNT(*) as tasks |
---|
| 106 | FROM tareas |
---|
| 107 | WHERE idcentro = $id) AS t6; |
---|
| 108 | EOT; |
---|
| 109 | $rs->Comando=&$cmd; |
---|
| 110 | if (!$rs->Abrir()) { |
---|
| 111 | return(null); // Error opening the record set |
---|
| 112 | } |
---|
| 113 | $rs->Primero(); |
---|
| 114 | $data = $rs->campos; |
---|
| 115 | $rs->Cerrar(); |
---|
| 116 | return($data); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | /** |
---|
| 120 | * @param string $label |
---|
| 121 | * @param int $value |
---|
| 122 | * @param int $total |
---|
| 123 | */ |
---|
| 124 | function print_data_row($label, $value, $total=0) { |
---|
| 125 | echo "\t\t<tr><th> $label: </th><td> $value" . |
---|
| 126 | ($total>0 ? " (".intval($value*100/$total)."%)" : "") . " </td></tr>\n"; |
---|
[a70996f] | 127 | } |
---|