From f1b58a03f35a99da3a83c9173dc0ed9d6ea1e4eb Mon Sep 17 00:00:00 2001 From: JKA Network Date: Tue, 9 Jan 2018 13:26:26 +0100 Subject: [PATCH] More info for checks activated --- assets/html/panel/p_index.twig | 6 +-- assets/html/panel/p_viewhist.twig | 84 +++++++++++++++++++++++++++++++ assets/translations/en.php | 1 + assets/translations/es.php | 1 + index.php | 2 +- panel.php | 27 ++++++++++ 6 files changed, 117 insertions(+), 4 deletions(-) create mode 100755 assets/html/panel/p_viewhist.twig diff --git a/assets/html/panel/p_index.twig b/assets/html/panel/p_index.twig index 2e1d486..a5bda34 100755 --- a/assets/html/panel/p_index.twig +++ b/assets/html/panel/p_index.twig @@ -39,7 +39,7 @@
    @@ -48,9 +48,9 @@
  • {{fail.date}}{{fail.hour}}
    diff --git a/assets/html/panel/p_viewhist.twig b/assets/html/panel/p_viewhist.twig new file mode 100755 index 0000000..6a20535 --- /dev/null +++ b/assets/html/panel/p_viewhist.twig @@ -0,0 +1,84 @@ +{% include 'panel/p_header.twig' %} + + +
    +
    +
    +
    +

    Historial de los últimos {{pagedata.cant}} checks de {{pagedata.name}} - {{pagedata.group}}

    +
    +
    +
    +
    + +
    + +

    {{T_.lastest_fails}}

    + + + + + + + + {% for err in pagedata.fails %} + + + + + {% endfor %} + +
    Fecha
    {{err}}
    + + + + +
    +
    +
    +
    +
    + +{% include 'footer.twig' %} diff --git a/assets/translations/en.php b/assets/translations/en.php index 86fbee5..d93f4bf 100755 --- a/assets/translations/en.php +++ b/assets/translations/en.php @@ -38,4 +38,5 @@ $T_['VISIT_COUNT'] = 'Visit counter'; $T_['DATABASE'] = 'Database check'; $T_['add_grp_to_add_chk'] = 'Add a group for start adding checks'; $T_['view_hist'] = 'View history'; +$T_['lastest_fails'] = 'Lastest fails'; ?> \ No newline at end of file diff --git a/assets/translations/es.php b/assets/translations/es.php index a55d4df..9013dfe 100755 --- a/assets/translations/es.php +++ b/assets/translations/es.php @@ -38,4 +38,5 @@ $T_['VISIT_COUNT'] = 'Contador de visitas'; $T_['DATABASE'] = 'Conexión a base de datos'; $T_['add_grp_to_add_chk'] = 'Añade un grupo para empezar a añadir checks'; $T_['view_hist'] = 'Ver histórico'; +$T_['lastest_fails'] = 'Ultimos errores'; ?> \ No newline at end of file diff --git a/index.php b/index.php index ac2275c..22daf7b 100755 --- a/index.php +++ b/index.php @@ -29,7 +29,7 @@ while ($onechk = dbw_fetch_array($db_conn,$results)){ $chks[$idchk]['failedLastChk'] = $consul['code']; - $lastErr = dbw_query_fetch_array($db_conn, "SELECT MIN(`timestamp`) FROM CHKHIST WHERE ID_C = '$idchk' AND code != 0")[0]; //Record last error, for showing if there are any. + $lastErr = dbw_query_fetch_array($db_conn, "SELECT MAX(`timestamp`) FROM CHKHIST WHERE ID_C = '$idchk' AND code != 0")[0]; //Record last error, for showing if there are any. if ($lastErr != false){ $chks[$idchk]['dateLastErr'] = date('d/m H:i',$lastErr); } diff --git a/panel.php b/panel.php index 367e2d1..193b2dc 100755 --- a/panel.php +++ b/panel.php @@ -271,6 +271,32 @@ switch($page){ header('Location: panel.php?page=users'); break; + + //History of checks for a ID_C + case 'viewhist': + //All page data + $ID_C = (int)$_GET['ID_C']; + $page = dbw_query_fetch_array($db_conn,"SELECT name FROM CHECKS WHERE ID_C='$ID_C'"); + $cant = 100; + $results = dbw_query($db_conn,"SELECT * FROM CHKHIST WHERE ID_C='$ID_C' ORDER BY `timestamp` DESC LIMIT $cant"); + + //TODO TIMESTAMPS FAILS + $cgood = 0;$cbad = 0; $fails = array(); + while ($us = dbw_fetch_array($db_conn,$results)){ + if ($us['code'] == 0){ + $cgood++; + }else{ + $cbad++; + $fails[] = date('d/m/Y H:i',$us['timestamp']); //Record timestamps + } + } + + $group = nameGroupFromIDG($db_conn,IDGFromIDC($db_conn,$ID_C)); + $pagedata = array('cgood' => $cgood,'cbad' => $cbad,'name' => nameFromIDC($db_conn,$ID_C), 'group' => $group,'cant' => $cant,'fails' => $fails); + + echo $twig->render('panel/p_viewhist.twig', array('T_' => $T_, 'mpage' => 'viewhist', 'you' => $you,'pagedata' => $pagedata)); + break; + // Página principal case 'status': default: @@ -283,6 +309,7 @@ switch($page){ if ($failssql != false){ while ($fail = dbw_fetch_array($db_conn,$failssql)){ //Create array $fails[] = array ( + 'ID_C' => $fail['ID_C'], 'name' => nameFromIDC($db_conn,$fail['ID_C']), 'groupName' => nameGroupFromIDG($db_conn,IDGFromIDC($db_conn,$fail['ID_C'])), 'typeCheck' => textTypeChk($T_,$fail['ID_TC']),