Exemplo n.º 1
0
$subheader = __("Data Center Cabinet Inventory");
// Get the list of departments that this user is a member of
$viewList = $person->isMemberOf();
$cab = new Cabinet();
$head = $legend = $zeroheight = $body = $deptcolor = "";
$deptswithcolor = array();
$dev = new Device();
$templ = new DeviceTemplate();
$tempDept = new Department();
$dc = new DataCenter();
$cabrow = new CabRow();
$cabrow->CabRowID = $_REQUEST['row'];
$cabrow->GetCabRow();
$cab->CabRowID = $cabrow->CabRowID;
$cabinets = $cab->GetCabinetsByRow();
$frontedge = $cabrow->GetCabRowFrontEdge();
if (isset($_GET["rear"])) {
    //opposite view
    $cabinets = array_reverse($cabinets);
}
//start loop to parse all cabinets in the row
foreach ($cabinets as $index => $cabinet) {
    $currentHeight = $cabinet->CabinetHeight;
    if ($config->ParameterArray["ReservedColor"] != "#FFFFFF" || $config->ParameterArray["FreeSpaceColor"] != "#FFFFFF") {
        $head .= "\t\t<style type=\"text/css\">\n\t\t\t.reserved{background-color: {$config->ParameterArray['ReservedColor']};}\n\t\t\t.freespace{background-color: {$config->ParameterArray['FreeSpaceColor']};}\n";
    }
    $side = null;
    if ($frontedge == "Top" || $frontedge == "Bottom") {
        $side = $cabinet->FrontEdge == "Left" || $cabinet->FrontEdge == "Right" ? true : null;
    } else {
        // else it's Left or Right
Exemplo n.º 2
0
 function GetCabinetsByRow($rear = false)
 {
     global $dbh;
     $this->MakeSafe();
     $cabrow = new CabRow();
     $cabrow->CabRowID = $this->CabRowID;
     $sql = "SELECT MIN(MapX1) AS MapX1, MAX(MapX2) AS MapX2, MIN(MapY1) AS MapY1, \r\n\t\t\tMAX(MapY2) AS MapY2, AVG(MapX1) AS AvgX1, AVG(MapX2) AS AvgX2, COUNT(*) AS \r\n\t\t\tCabCount FROM fac_Cabinet WHERE CabRowID={$cabrow->CabRowID} AND MapX1>0 \r\n\t\t\tAND MapX2>0 AND MapY1>0 and MapY2>0;";
     $shape = $dbh->query($sql)->fetch();
     // size of average cabinet
     $sX = $shape["AvgX2"] - $shape["AvgX1"];
     // change in x and y to give overall shape of row
     $cX = $shape["MapX2"] - $shape["MapX1"];
     $cY = $shape["MapY2"] - $shape["MapY1"];
     /*
      * In rows with more than one cabinet we can determine the layout based on
      * their size.  The side of a row will be close to the change in x or y while
      * the front/rear of a row will be equal to the average of the sides 
      * multiplied by the number of objects in the set
      *
      * change = size * number of cabinets
      */
     $layout = $cX == $sX * $shape["CabCount"] || $cX > $cY ? "Horizontal" : "Vertical";
     $order = $layout == "Horizontal" ? "MapX1," : "MapY1,";
     $frontedge = $cabrow->GetCabRowFrontEdge($layout);
     // Order first by row layout then by natural sort
     $sql = "SELECT * FROM fac_Cabinet WHERE CabRowID={$cabrow->CabRowID} ORDER BY {$order} \r\n\t\t\tLocationSortable ASC;";
     $cabinetList = array();
     foreach ($dbh->query($sql) as $cabinetRow) {
         $cabinetList[] = Cabinet::RowToObject($cabinetRow);
     }
     if ($frontedge == "Right" || $frontedge == "Top") {
         $cabinetList = array_reverse($cabinetList);
     }
     return $cabinetList;
 }