Example #1
0
function get($arr)
{
    if (isset($arr['id'], $arr['type'])) {
        $id = $arr['id'];
        $type = $arr['type'];
        switch ($type) {
            case 'plant':
                getPlant($id);
                break;
            case 'camera':
                getCamera($id);
                break;
        }
    } else {
        if (isset($arr['type'])) {
            $type = $arr['type'];
            switch ($type) {
                case 'plan':
                    getPlan();
                    break;
            }
        }
    }
}
Example #2
0
<?php

include_once "conn.php";
include_once "planDB.php";
$action = $_REQUEST["action"];
$res = "";
switch ($action) {
    case "addPlan":
        $res = addPlan($_POST);
        break;
    case "deletePlan":
        $res = deletePlan($_REQUEST["id"]);
        break;
    case "deletePlanByProjectId":
        $res = deletePlanByProjectId($_REQUEST["projectId"]);
        break;
    case "editPlan":
        $res = editPlan($_POST);
        break;
    case "getPlan":
        $res = getPlan($_REQUEST["id"]);
        break;
    case "getPlanByProjectId":
        $res = getPlanByProjectId($_REQUEST["projectId"]);
        break;
    default:
        throw new Exception("unknown action:" . $action);
}
echo json_encode($res);
Example #3
0
function loadRAWData($from, $id_plan, $id_item, $to = null, $id_host = null)
{
    $cacheAge = 60 * 60;
    $offset = getOffset();
    setTimezone();
    $cache = phpFastCache();
    //$cache->clean();
    $dt = getDates($from);
    $from = $dt[0];
    if ($to == null) {
        $to = $dt[1];
    }
    $from = str_replace("-", "/", $from);
    $to = str_replace("-", "/", $to);
    $phour = getPeakHours();
    $unit = getUnit($id_item);
    $plan = getPlan($id_plan);
    $item = getItem($id_item);
    $div = 1;
    if (strtolower($unit) == 'bps') {
        $div = 1024 * 1024;
        $unit = 'Mbps';
    }
    $rtag = "";
    foreach ($_SESSION['tag'] as $key => $value) {
        if ($key != "" && $key != "None") {
            $rtag = $rtag . ',"' . $key . '"';
        }
    }
    if ($rtag == '') {
        $rtag = 'bm_tags.tag like "%"';
    } else {
        $rtag = 'bm_tags.tag in (' . substr($rtag, 1) . ')';
    }
    if ($id_plan == 0) {
        $id_plan = '> 0';
    } else {
        $id_plan = '=' . $id_plan;
    }
    if ($id_host == null) {
        $id_host = "";
    } else {
        $id_host = " and bm_host.id_host=" . $id_host;
    }
    $hosts = 'select bm_host.id_host,bm_host.id_plan,bm_plan.plan,bm_plan.nacD,bm_plan.nacU,bm_threshold.critical,bm_threshold.warning,bm_threshold.nominal,bm_host.host
						from bm_host,bm_plan,bm_plan_groups,bm_threshold,bi_dashboard
						where bm_host.id_plan=bm_plan.id_plan
							and bm_host.groupid = ' . $_SESSION['groupid'] . '
							and bm_plan.id_plan ' . $id_plan . '
							and bm_plan_groups.id_plan = bm_plan.id_plan
							and bm_host.borrado=0
							and bm_host.id_plan=bm_plan.id_plan
							and bm_plan_groups.groupid=bm_host.groupid
							and bm_threshold.id_item=bi_dashboard.id_item
							and bm_host.id_host in (select id from bm_tags where ' . $rtag . ')
							and bi_dashboard.id_item=' . $id_item . $id_host . '
						order by bm_host.id_plan';
    //var_dump($hosts);
    // Find Percentile 5 and 95
    if (true) {
        $hostsr = mysql_query($hosts);
        while ($host = mysql_fetch_array($hostsr, MYSQL_ASSOC)) {
            $id_host = $host['id_host'];
            $hostName = $host['host'];
            $nominal = $host['nominal'];
            $critical = $host['critical'];
            $warning = $host['warning'];
            $nacD = $host['nacD'] * 1024;
            $nacU = $host['nacU'] * 1024;
            if ($nominal == -1) {
                $nominal = $nacD;
            }
            if ($nominal == -2) {
                $nominal = $nacU;
            }
            $hostList[] = array('host' => $hostName, 'id_host' => $id_host, 'nominal' => $nominal, 'critical' => $critical, 'warning' => $warning, 'nacD' => $nacD, 'nacU' => $nacU);
            $incache = true;
            unset($cachedData);
            $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days'));
            while ($dfrom != $to) {
                $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days'));
                $key = $dfrom . '-' . $id_host . '-' . $id_item;
                //if (isset($_SESSION['cache'][$key]))
                //	$obj = $_SESSION['cache'][$key];
                //else
                //echo $key . "<br>";
                $obj = $cache->get($key);
                if ($obj == null) {
                    $incache = false;
                    $_SESSION['cacheFull'] = false;
                } else {
                    $_SESSION['cachePartial'] = true;
                    foreach ($obj as $key => $value) {
                        if (isset($value['clock'])) {
                            $cachedData[] = $value;
                        }
                    }
                }
            }
            if (!isset($cachedData)) {
                $incache = false;
            }
            if ($incache) {
                foreach ($cachedData as $key => $row) {
                    $skip = false;
                    if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') {
                        $skip = true;
                    }
                    if (!$skip) {
                        $allData[] = $row['value'];
                        $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']);
                    }
                }
            } else {
                $table = 'xyz_' . str_pad($id_item, 10, "0", STR_PAD_LEFT);
                //var_dump($table);
                if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table . "'")) == 1) {
                    if ($phour['peak'] > $phour['offpeak']) {
                        $q = 'select clock,value,valid,if((date_format(from_unixtime(clock),"%H")>=0 and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ') or date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ',"P","O") as t
							from ' . $table . '
							where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and
								id_host=' . $id_host;
                    } else {
                        $q = 'select clock,value,valid,if(date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ' and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ',"P","O") as t
							from ' . $table . '
							where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and
								id_host=' . $id_host;
                    }
                    //var_dump($q);
                    $qr = mysql_query($q);
                    while ($row = mysql_fetch_array($qr, MYSQL_ASSOC)) {
                        $key = date('Y/m/d', $row['clock']);
                        $data[$key][$id_host . '-' . $id_item][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']);
                        $skip = false;
                        if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') {
                            $skip = true;
                        }
                        if (!$skip) {
                            $allData[] = $row['value'];
                            $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']);
                        }
                    }
                }
                // check miising data
                $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days'));
                while ($dfrom != $to) {
                    $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days'));
                    $key = $dfrom . '-' . $id_host . '-' . $id_item;
                    $obj = $cache->get($key);
                    if ($obj == null) {
                        $cache->set($key, array('clock' => 0, 'value' => 0, 'valid' => 0, 't' => ''), $cacheAge);
                        //$_SESSION['cache'][$key]= array('clock'=>0,'value'=>0,'valid'=>0,'t'=>'');
                    }
                }
            }
        }
    }
    if (isset($incache) && !$incache && isset($data)) {
        foreach ($data as $key => $value) {
            foreach ($value as $hkey => $hvalue) {
                $thekey = $key . '-' . $hkey;
                //echo $thekey . ' ';
                $cache->set($thekey, $hvalue, $cacheAge);
                //$_SESSION['cache'][$thekey] = $hvalue;
            }
        }
    }
    if (isset($allData)) {
        return array('allData' => $allData, 'historyList' => $historyList, 'hostList' => $hostList, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to);
    } else {
        return array('allData' => null, 'historyList' => null, 'hostList' => null, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to);
    }
}
Example #4
0
<?php

include '../scripts/funciones.php';
if (!haIniciadoSesion()) {
    header('Location: ../index.php');
}
if (isset($_GET['id'])) {
    $plan = getPlan($_GET['id']);
    if (!isset($plan)) {
        header('Location: 404.php');
    }
    $entrevistados = getEntrevistadosFull($_GET['id']);
    /* $preguntas = getPreguntas($_GET['id']); NO, PORQUE ESTÁ REGISTRANDO RECIÉN */
} else {
    header('Location: empresas.php');
}
?>
<!DOCTYPE html>
<html lang="es">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Nueva prueba de cumplimiento y sustantiva</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <!-- Bootstrap theme -->
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css">
Example #5
0
<?php

require "mealmaker.php";
$id = $_GET['plan'] ? $_GET['plan'] : 1;
getPlan($id);
function GraphPie($chart, $id_chart, $id_plan, $id_item, $tag, $from, $low, $mid, $max, $dir)
{
    $dt = getDates($from);
    $plan = getPlan($id_plan);
    $item = getItem($id_item);
    $unit = getUnit($id_item);
    $from = $dt[0];
    $to = $dt[1];
    $sum = $low + $mid + $max;
    if ($sum == 0) {
        $sum = 1.0E+18;
    }
    if ($dir == 0) {
        $data0[] = array('name' => "Not acceptable measures", 'y' => round($low / $sum * 100, 2), 'color' => 'red');
        $data0[] = array('name' => "Below acceptable measures", 'y' => round($mid / $sum * 100, 2), 'color' => '#F79E03');
        $data0[] = array('name' => "Acceptable measures", 'y' => round($max / $sum * 100, 2), 'color' => 'green');
    } else {
        $data0[] = array('name' => "Not acceptable measures", 'y' => round($low / $sum * 100, 2), 'color' => 'red');
        $data0[] = array('name' => "Below acceptable measures", 'y' => round($mid / $sum * 100, 2), 'color' => '#F79E03');
        $data0[] = array('name' => "Acceptable measures", 'y' => round($max / $sum * 100, 2), 'color' => 'green');
    }
    $title = '% de results for "' . $item . '" on plan "' . $plan . '"';
    $subtitle = 'From ' . $from . ' to ' . $to;
    $chart = chartHeader($chart, $id_chart, $title, $subtitle, 'Quantity', null);
    $chart->plotOptions->series->pointPadding = -0.333333;
    $chart->series[0]->type = 'pie';
    $chart->series[0]->data = $data0;
    $chart->series[0]->tooltip->valueSuffix = '%';
    $chart->series[0]->name = 'Number of occurencies';
    $chart->series[0]->dataLabels->enabled = true;
    $chart->series[0]->dataLabels->crop = false;
    $chart->series[0]->dataLabels->align = 'center';
    $chart->series[0]->dataLabels->y = -6;
    $chart->series[0]->dataLabels->color = 'black';
    //'#000000';
    $chart->series[0]->dataLabels->style->fontSize = '13px';
    $chart->series[0]->dataLabels->style->fontFamily = 'Verdana, sans-serif';
    $chart->series[0]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.y, 2, '.') + '%';}");
    return $chart;
}
<?php

include '../scripts/funciones.php';
if (!haIniciadoSesion()) {
    header('Location: ../index.php');
}
if (isset($_GET['plan'])) {
    $plan = getPlan($_GET['plan']);
    if (!isset($plan)) {
        header('Location: 404.php');
    }
    $prueba = getPrueba($_GET['prueba']);
    if (!isset($prueba)) {
        header('Location: 404.php');
    }
    $empresa_id = $_GET['empresa'];
    $preguntas = getPreguntas($_GET['prueba']);
} else {
    header('Location: empresas.php');
}
?>
<!DOCTYPE html>
<html lang="es">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Cuestionario</title>

    <!-- Bootstrap core CSS -->
 public function __toString()
 {
     return $this->getPeriodoTrabajo() . '_' . getPlan();
 }