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 @@