Пример #1
0
<?php

require_once 'db.inc.php';
require_once 'facilities.inc.php';
$subheader = __("Inventory Reporting By Tag");
$tagsList = Tags::FindAll();
$body = "";
if (isset($_REQUEST['tagid'])) {
    $tag = isset($_POST['tagid']) ? $_POST['tagid'] : $_GET['tagid'];
    if ($tag != '') {
        $tag = intval($tag);
        if ($tag == 0) {
            $sql = "SELECT dev.Label, dc.Name as DC, c.Location as Rack, dept.Name as Owner, t.Name as Tag, dev.Notes FROM fac_Tags t, fac_Device dev, fac_Cabinet c, fac_DataCenter dc, fac_DeviceTags dt, fac_Department dept WHERE t.TagID=dt.TagID AND dt.DeviceID=dev.DeviceID AND dev.Cabinet=c.CabinetID AND dc.DataCenterID=c.DataCenterID AND dept.DeptID=dev.Owner ORDER BY dev.Label ASC, Tag ASC;";
        } else {
            $sql = "SELECT dev.Label, dc.Name as DC, c.Location as Rack, dept.Name as Owner, t.Name as Tag, dev.Notes FROM fac_Tags t, fac_Device dev, fac_Cabinet c, fac_DataCenter dc, fac_DeviceTags dt, fac_Department dept WHERE t.TagID=dt.TagID AND dt.DeviceID=dev.DeviceID AND dev.Cabinet=c.CabinetID AND dc.DataCenterID=c.DataCenterID AND dept.DeptID=dev.Owner AND dt.TagID={$tag} ORDER BY dev.Label ASC, Tag ASC;";
        }
        $result = $dbh->query($sql);
    } else {
        $result = array();
    }
    // Left these expanded in case we need to add or remove columns.  Otherwise I would have just collapsed entirely.
    $body = "<table id=\"export\" class=\"display\">\n\t<thead>\n\t\t<tr>\n\n\t\t\t\t<th>" . __("Device Label") . "</th>\n\t\t\t\t<th>" . __("Datacenter") . "</th>\n\t\t\t\t<th>" . __("Rack") . "</th>\n\t\t\t\t<th>" . __("Owner") . "</th>\n\t\t\t\t<th>" . __("Tag") . "</th>\n\t\t\t\t<th>" . __("Notes") . "</th>\n\t\t\t</tr>\n\t</thead>\n\t<tbody>\n";
    // suppressing errors for when there is a fake data set in place
    foreach ($result as $row) {
        $body .= "\t\t<tr>\n\t\t\t\t<td>{$row["Label"]}</td>\n\t\t\t\t<td>{$row["DC"]}</td>\n\t\t\t\t<td>{$row["Rack"]}</td>\n\t\t\t\t<td>{$row["Owner"]}</td>\n\t\t\t\t<td>{$row["Tag"]}</td>\n\t\t\t\t<td>" . strip_tags($row["Notes"]) . "</td>\n\t\t\t\t\t</tr>\n";
    }
    $body .= "\t\t</tbody>\n\t</table>\n";
    if (isset($_REQUEST['ajax'])) {
        echo $body;
        exit;
    }
Пример #2
0
         $options[$cabrow->CabRowID] = $cabrow->Name;
     }
 } elseif ($containmentType == 4) {
     # filter by cabinet
     $cList = new Cabinet();
     $cList = $cList->ListCabinets();
     $body .= "<select name=cabid id=cabid>";
     foreach ($cList as $cabinet) {
         $dc = new DataCenter();
         $dc->DataCenterID = $cabinet->DataCenterID;
         $dc->GetDataCenter();
         $options[$cabinet->CabinetID] = $dc->Name . "::" . $cabinet->Location;
     }
 } elseif ($containmentType == 5) {
     # filter by custom tag
     $tList = Tags::FindAll();
     $body .= "<select name=tagname id=tagname>";
     foreach ($tList as $TagID => $Name) {
         $options[$Name] = $Name;
     }
 }
 # sort and output the options based on the name of the option
 asort($options);
 foreach ($options as $key => $val) {
     $body .= "<option value=" . $key . ">" . $val . "</option>";
 }
 $body .= "</select>" . "<select name=mediaid id=mediaid>" . "<option value=-1>All Media Types</option>" . "<option value=0>Unknown Media Types</option>";
 foreach (MediaTypes::GetMediaTypeList() as $mt) {
     $body .= "<option value=" . $mt->MediaID . ">" . $mt->MediaType . "</option>";
 }
 $body .= "</select>" . "<select name=colortype id=colortype>" . "<option value=0>Try to use colors from the database</option>" . "<option value=1>Randomize colors, per color</option>" . "<option value=2>Randomize colors, per mediatype</option>" . "<option value=3 selected>Randomize colors, per color and mediatype</option>" . "</select>" . "<input type=\"checkbox\" name=edgelabels checked value=true>Label Cables" . "<select name=format id=format onchange='this.form.submit()'>" . "<option value=''>Select format</option>" . "<option value=0>SVG</option>" . "<option value=1>PNG</option>" . "<option value=2>JPG</option>" . "<option value=3>DOT</option>" . "</select>" . "</form>";