diff --git a/assets.inc.php b/assets.inc.php index f98189ce8..1451c76a4 100644 --- a/assets.inc.php +++ b/assets.inc.php @@ -45,6 +45,11 @@ class Cabinet { var $MapY1; var $MapX2; var $MapY2; + var $MapXY; + var $depth; + var $width; + var $offset; + var $direction; function CreateCabinet( $db ) { $insert_sql = "insert into fac_Cabinet set DataCenterID=\"" . intval($this->DataCenterID) . "\", Location=\"" . addslashes($this->Location) . "\", AssignedTo=\"" . intval($this->AssignedTo) . "\", ZoneID=\"" . intval($this->ZoneID) . "\", CabinetHeight=\"" . intval($this->CabinetHeight) . "\", Model=\"" . addslashes($this->Model) . "\", MaxKW=\"" . floatval($this->MaxKW) . "\", MaxWeight=\"" . intval( $this->MaxWeight ). "\", InstallationDate=\"" . date( "Y-m-d", strtotime( $this->InstallationDate ) ) . "\", MapX1=\"" . intval($this->MapX1) . "\", MapY1=\"" . intval($this->MapY1) . "\", MapX2=\"" . intval($this->MapX2) . "\", MapY2=\"" . intval($this->MapY2) . "\""; @@ -60,7 +65,25 @@ function CreateCabinet( $db ) { } function UpdateCabinet( $db ) { - $update_sql = "update fac_Cabinet set DataCenterID=\"" . intval($this->DataCenterID) . "\", Location=\"" . addslashes($this->Location) . "\", AssignedTo=\"" . intval($this->AssignedTo) . "\", ZoneID=\"" . intval($this->ZoneID) . "\", CabinetHeight=\"" . intval($this->CabinetHeight) . "\", Model=\"" . addslashes($this->Model) . "\", MaxKW=\"" . floatval($this->MaxKW) . "\", MaxWeight=\"" . intval( $this->MaxWeight ) . "\", InstallationDate=\"" . date( "Y-m-d", strtotime( $this->InstallationDate ) ) . "\", MapX1=\"" . intval($this->MapX1) . "\", MapY1=\"" . intval($this->MapY1) . "\", MapX2=\"" . intval($this->MapX2) . "\", MapY2=\"" . intval($this->MapY2) . "\" where CabinetID=\"" . intval($this->CabinetID) . "\""; + $update_sql = "update fac_Cabinet set DataCenterID=\"" . intval($this->DataCenterID) . "\", + Location=\"" . addslashes($this->Location) . "\", + AssignedTo=\"" . intval($this->AssignedTo) . "\", + ZoneID=\"" . intval($this->ZoneID) . "\", + CabinetHeight=\"" . intval($this->CabinetHeight) . "\", + Model=\"" . addslashes($this->Model) . "\", + MaxKW=\"" . floatval($this->MaxKW) . "\", + MaxWeight=\"" . intval( $this->MaxWeight ) . "\", + InstallationDate=\"" . date( "Y-m-d", strtotime( $this->InstallationDate ) ) . "\", + MapX1=\"" . intval($this->MapX1) . "\", + MapY1=\"" . intval($this->MapY1) . "\", + MapX2=\"" . intval($this->MapX2) . "\", + MapY2=\"" . intval($this->MapY2) . "\", + MapXY=\"" . intval($this->MapXY) . "\", + width=\"" . intval($this->width) . "\", + depth=\"" . intval($this->depth) . "\", + offset=\"" . intval($this->offset) . "\", + direction=\"" . addslashes($this->direction) . "\" + where CabinetID=\"" . intval($this->CabinetID) . "\""; if ( ! $result = mysql_query( $update_sql, $db ) ) { return -1; @@ -107,6 +130,11 @@ function GetCabinet( $db ) { $this->MapY1 = $cabinetRow["MapY1"]; $this->MapX2 = $cabinetRow["MapX2"]; $this->MapY2 = $cabinetRow["MapY2"]; + $this->MapXY = $cabinetRow["MapXY"]; + $this->width = $cabinetRow["width"]; + $this->depth = $cabinetRow["depth"]; + $this->offset = $cabinetRow["offset"]; + $this->direction = $cabinetRow["direction"]; return 0; } @@ -138,6 +166,9 @@ function ListCabinets( $db ) { $cabinetList[ $cabID ]->MapY1 = $cabinetRow[ "MapY1" ]; $cabinetList[ $cabID ]->MapX2 = $cabinetRow[ "MapX2" ]; $cabinetList[ $cabID ]->MapY2 = $cabinetRow[ "MapY2" ]; + $cabinetList[ $cabID ]->MapXY = $cabinetRow[ "MapXY" ]; + $cabinetList[ $cabID ]->depth = $cabinetRow[ "depth" ]; + $cabinetList[ $cabID ]->direction = $cabinetRow[ "direction" ]; } return $cabinetList; diff --git a/cabinets.php b/cabinets.php index b2834e53b..c6d872424 100644 --- a/cabinets.php +++ b/cabinets.php @@ -17,7 +17,6 @@ $dc=new DataCenter(); $dc->DataCenterID=$_REQUEST['datacenterid']; $dc->GetDataCenter($facDB); - var_dump($dc); if(isset($_REQUEST['cabinetid'])){ $cab->CabinetID=$_REQUEST['cabinetid']; @@ -34,6 +33,10 @@ $cab->MaxKW=$_REQUEST['maxkw']; $cab->MaxWeight=$_REQUEST['maxweight']; $cab->InstallationDate=$_REQUEST['installationdate']; + $cab->width=$_REQUEST['width']; + $cab->depth=$_REQUEST['depth']; + $cab->offset=$_REQUEST['offset']; + $cab->direction=$_REQUEST['direction']; $rows = $dc->rows; #number of rows $cols = $dc->cols; #number of cols @@ -58,22 +61,41 @@ } $refx = $xgrid; #grid ref x $refy = $ygrid; #grid ref y -$width = 600; #in mm -$depth = 900; #in mm -$offset = 0; #for offset racks +$width = $cab->width; #in mm +$depth = $cab->depth; #in mm +$offset = $cab->offset; #for offset racks $mmpd = 600; #mm per tile -$dir = 'N'; #direction of rack; +$dir = $cab->direction; #direction of rack; if ($dir == 'N') { $x1 = ($refx+1)*$div-$offset/$mmpd*$div; $y1 = ($refy+0)*$div; $x2 = $x1-($width/$mmpd*$div); $y2 = $y1+($depth/$mmpd*$div); - $y3 = $y1+($depth*.2/$mmpd*$div);} + $xy = $y1+($depth*.2/$mmpd*$div);} +if ($dir == 'S') { + $x1 = ($refx+0)*$div+$offset/$mmpd*$div; + $y1 = ($refy+1)*$div; + $x2 = $x1+($width/$mmpd*$div); + $y2 = $y1-($depth/$mmpd*$div); + $xy = $y1-($depth*.2/$mmpd*$div);} +if ($dir == 'E') { + $x1 = ($refx+1)*$div; + $y1 = ($refy+0)*$div-$offset/$mmpd*$div; + $y2 = $y1+($width/$mmpd*$div); + $x2 = $x1-($depth/$mmpd*$div); + $xy = $x1-($depth*.2/$mmpd*$div);} +if ($dir == 'W') { + $x1 = ($refx+0)*$div; + $y1 = ($refy+0)*$div+$offset/$mmpd*$div; + $y2 = $y1+($width/$mmpd*$div); + $x2 = $x1+($depth/$mmpd*$div); + $xy = $x1+($depth*.2/$mmpd*$div);} $cab->MapX1=$x1; $cab->MapX2=$x2; $cab->MapY1=$y1; $cab->MapY2=$y2; + $cab->MapXY=$xy; $cab->UpdateCabinet($facDB); }elseif($_REQUEST['action']=='Create'){ $cab->DataCenterID=$_REQUEST['datacenterid']; @@ -84,6 +106,10 @@ $cab->MaxKW=$_REQUEST['maxkw']; $cab->MaxWeight=$_REQUEST['maxweight']; $cab->InstallationDate=$_REQUEST['installationdate']; + $cab->width=$_REQUEST['width']; + $cab->depth=$_REQUEST['depth']; + $cab->offset=$_REQUEST['offset']; + $cab->direction=$_REQUEST['direction']; $cab->CreateCabinet($facDB); } } @@ -99,6 +125,10 @@ $cab->MaxKW=null; $cab->MaxWeight=null; $cab->InstallationDate=date('m/d/Y'); + $cab->width=600; + $cab->depth=900; + $cab->offset=0; + $cab->direction="N"; } $deptList=$dept->GetDepartmentList($facDB); @@ -185,6 +215,22 @@
Date of Installation
InstallationDate)); ?>'>
+
+
Width
+
+
+
+
Depth
+
+
+
+
Offset
+
+
+
+
Direction
+
+
WriteAccess){ echo '
'; diff --git a/dc_stats.php b/dc_stats.php index e64570ab4..5793915b2 100644 --- a/dc_stats.php +++ b/dc_stats.php @@ -190,78 +190,22 @@ function uselessie(){ $cabloc[][] = ""; $cabnum = 0; foreach($cabList as $cab) { -$len = strlen($cab->Location); -if ($len == 4) { - $yref = substr($cab->Location,0,2); -} else { - $yref = substr($location,0,1); -} -$xref = substr($cab->Location, -2); -$xgrid = $xref - $start_col + 1; - -$ygrid = 1; -$i = $start_row; -while($i != $yref) { - $i++; - $ygrid++; -} +$dir = $cab->direction; -$refx = $xgrid; #grid ref x -$refy = $ygrid; #grid ref y -$width = 600; #in mm -$depth = 900; #in mm -$offset = 0; #for offset racks +#$width = 600; #in mm +$depth = $cab->depth; #in mm +#$offset = 0; #for offset racks $mmpd = 600; #mm per tile -$dir = 'N'; #direction of rack; -if ($dir == 'N') { - $x1 = ($refx+1)*$div-$offset/$mmpd*$div; - $y1 = ($refy+0)*$div; - $x2 = $x1-($width/$mmpd*$div); - $y2 = $y1+($depth/$mmpd*$div); - $y3 = $y1+($depth*.2/$mmpd*$div);} -if ($dir == 'S') { - $x1 = ($refx+0)*$div+$offset/$mmpd*$div; - $y1 = ($refy+1)*$div; - $x2 = $x1+($width/$mmpd*$div); - $y2 = $y1-($depth/$mmpd*$div); - $y3 = $y1-($depth*.2/$mmpd*$div);} -if ($dir == 'E') { - $x1 = ($refx+1)*$div; - $y1 = ($refy+0)*$div-$offset/$mmpd*$div; - $y2 = $y1+($width/$mmpd*$div); - $x2 = $x1-($depth/$mmpd*$div); - $x3 = $x1-($depth*.2/$mmpd*$div);} -if ($dir == 'W') { - $x1 = ($refx+0)*$div; - $y1 = ($refy+0)*$div+$offset/$mmpd*$div; - $y2 = $y1+($width/$mmpd*$div); - $x2 = $x1+($depth/$mmpd*$div); - $x3 = $x1+($depth*.2/$mmpd*$div);} imagefilledrectangle($img, $MapX1, $MapY1, $MapX2, $MapY2, $lightgrey); -$cabloc[$cabnum][x1] = $x1; -$cabloc[$cabnum][y1] = $y1; -$cabloc[$cabnum][x2] = $x2; -$cabloc[$cabnum][y2] = $y2; -$cabloc[$cabnum][CabinetID] = $cab->CabinetID; -$cabloc[$cabnum][Location] = $cab->Location; -$cabnum++; -#$cur_row = $start_row; -#$jt = $i; -#while ( $jt > 1) { - #$jt--; - #$cur_row++; -#} -#$cur_col = $start_col + $j - 1; -#if ($cur_col < 10) { $cur_col = "0" . $cur_col;} -$rn = ($yref ) . ($xref); -if ($dir == 'N') {imagefttext($img, $div*.5, 90, $x1-$div*.2, $y1+$depth/$mmpd*$div, $red, $font, $rn);} -if ($dir == 'S') {imagefttext($img, $div*.5, -90, $x1+$div*.2, $y1-$depth/$mmpd*$div, $red, $font, $rn);} -if ($dir == 'E') {imagefttext($img, $div*.5, 0, $x1-$depth/$mmpd*$div*.95, $y1+$div*.8, $red, $font, $rn);} -if ($dir == 'W') {imagefttext($img, $div*.5, 0, $x1+$div*.4, $y1+$div*.8, $red, $font, $rn);} +$rn = $cab->Location; +if ($dir == 'N') {imagefttext($img, $div*.5, 90, $cab->MapX1-$div*.2, $cab->MapY1+$depth/$mmpd*$div, $red, $font, $rn);} +if ($dir == 'S') {imagefttext($img, $div*.5, -90, $cab->MapX1+$div*.2, $cab->MapY1-$depth/$mmpd*$div, $red, $font, $rn);} +if ($dir == 'E') {imagefttext($img, $div*.5, 0, $cab->MapX1-$depth/$mmpd*$div*.95, $cab->MapY1+$div*.8, $red, $font, $rn);} +if ($dir == 'W') {imagefttext($img, $div*.5, 0, $cab->MapX1+$div*.4, $cab->MapY1+$div*.8, $red, $font, $rn);} if ($dir == 'N' or $dir == 'S' ) { - imagefilledrectangle($img, $x1, $y1, $x2, $y3, $green); + imagefilledrectangle($img, $cab->MapX1, $cab->MapY1, $cab->MapX2, $cab->MapXY, $green); } else { - imagefilledrectangle($img, $x1, $y1, $x3, $y2, $green); + imagefilledrectangle($img, $cab->MapX1, $cab->MapY1, $cab->MapXY, $cab->MapY2, $green); } } @@ -284,8 +228,12 @@ function uselessie(){ #while ( $cabRow = mysql_fetch_array( $result ) ) { #$mapHTML.="\"".$cabRow["Location"]."\"\n"; - foreach ( $cabloc as $cabRow ) { - $mapHTML.="\"".$cabRow["Location"]."\"\n"; + #foreach ( $cabloc as $cabRow ) { + foreach($cabList as $cabRow) { + $mapHTML.="CabinetID . "\" shape=\"rect\" coords=\"" . + $cabRow->MapX1 . ", " . $cabRow->MapY1 . ", " . + $cabRow->MapX2 . ", " . $cabRow->MapY2 . "\" + alt=\"".$cabRow->Location."\" title=\"".$cabRow->Location."\">\n"; } $mapHTML.="\n";