Example #1
0
<div class="col-md-12">

<?php 
$where = ' WHERE 1 ';
$where .= generate_query_permitted(array('device'), array('device_table' => 'E'));
$form_items = array();
// Select devices only with Inventory parts
foreach (dbFetchRows('SELECT E.`device_id` AS `device_id`, `hostname`, `entPhysicalModelName`
                     FROM `entPhysical` AS E
                     INNER JOIN `devices` AS D ON D.`device_id` = E.`device_id`' . $where . 'GROUP BY `device_id`, `entPhysicalModelName`;') as $data) {
    $form_devices[] = $data['device_id'];
    if ($data['entPhysicalModelName'] != '') {
        $form_items['parts'][$data['entPhysicalModelName']] = $data['entPhysicalModelName'];
    }
}
$where_array = build_devices_where_array($vars);
$query_permitted = generate_query_permitted(array('device'), array('device_table' => 'devices'));
$where = ' WHERE 1 ';
$where .= implode('', $where_array);
// Generate array with form elements
//foreach (array('os', 'hardware', 'version', 'features', 'type') as $entry)
foreach (array('os') as $entry) {
    $query = "SELECT `{$entry}` FROM `devices`";
    if (isset($where_array[$entry])) {
        $tmp = $where_array[$entry];
        unset($where_array[$entry]);
        $query .= ' WHERE 1 ' . implode('', $where_array);
        $where_array[$entry] = $tmp;
    } else {
        $query .= $where;
    }
Example #2
0
// Print options related to graphs.
//$menu_options = array('bits'      => 'Bits',
//                      'processor' => 'CPU',
//                      'mempool'   => 'Memory',
//                      'uptime'    => 'Uptime',
//                      'storage'   => 'Storage',
//                      'diskio'    => 'Disk I/O',
//                      'poller_perf' => 'Poll Time'
//                      );
foreach (array('graphs') as $type) {
    /// FIXME. Weird graph menu, they too long and not actual for all devices,
    /// but here also not posible use sql query from `device_graphs` because here not stored all graphs
    /// FIXME - We need to register all graphs in `device_graphs` :D
    $vars_graphs = $vars;
    unset($vars_graphs['graph']);
    $where_graphs = build_devices_where_array($vars_graphs);
    $where_graphs = ' WHERE 1 ' . implode('', $where_graphs);
    $query = 'SELECT `graph` FROM `device_graphs` LEFT JOIN `devices` USING (`device_id`)';
    $query .= $where_graphs . $query_permitted . ' AND `device_graphs`.`enabled` = 1 GROUP BY `graph`';
    foreach (dbFetchColumn($query) as $option) {
        $data = $config['graph_types']['device'][$option];
        /*
          foreach ($config['graph_types']['device'] as $option => $data)
          { */
        if (!isset($data['descr'])) {
            $data['descr'] = nicecase($option);
        }
        if ($vars['format'] == $type && $vars['graph'] == $option) {
            $navbar['options'][$type]['suboptions'][$option]['class'] = 'active';
            $navbar['options'][$type]['text'] .= " (" . $data['descr'] . ')';
        }