Exemplo n.º 1
0
 public function select($path)
 {
     // Checks if...
     if (!$path['id'] && is_array($path['parameter']) && count($path['parameter']) >= 2 && $path['parameter'][0] == 'plan') {
         $plan = DataCenterDB::getPlan($path['parameter'][1]);
         $space = $plan->getSpace();
         // Gets rack links which are linked to this plan
         $rackLinks = DataCenterDB::getAssetLinks(array_merge_recursive(DataCenterDB::buildCondition('link', 'asset', 'plan', $plan->getId()), DataCenterDB::buildCondition('link', 'asset', 'asset_type', 'rack')));
         $existsTable = array();
         foreach ($rackLinks as $rackLink) {
             $existsTable[$rackLink->get('asset_id')] = true;
         }
         // Gets rack from database in two varieties, local and remote
         $racks = array('local' => DataCenterDB::getAssets('rack', array_merge_recursive(DataCenterDB::buildCondition('asset', 'rack', 'location', $space->get('location')), DataCenterDB::buildJoin('facility', 'location', 'id', 'asset', 'rack', 'location', array('name' => 'location_name', 'region' => 'location_region')))), 'remote' => DataCenterDB::getAssets('rack', array_merge_recursive(DataCenterDB::buildCondition('asset', 'rack', 'location', $space->get('location'), '!='), DataCenterDB::buildJoin('facility', 'location', 'id', 'asset', 'rack', 'location', array('name' => 'location_name', 'region' => 'location_region')))));
         $tables = array();
         foreach ($racks as $groupName => $rackGroup) {
             foreach ($rackGroup as $key => $rack) {
                 if ($rack->get('tense') == 'past' || isset($existsTable[$rack->getId()])) {
                     unset($rackGroup[$key]);
                 } else {
                     $rackModel = $rack->getModel();
                     $rack->set($rackModel->get(array('name', 'manufacturer')));
                 }
             }
             if (count($rackGroup) > 0) {
                 $tabs[$groupName] = DataCenterUI::renderWidget('table', array('rows' => $rackGroup, 'fields' => array('manufacturer', 'model' => array('field' => 'name'), 'serial', 'asset', 'location' => array('fields' => array('location_name', 'location_region'), 'glue' => ' / ')), 'link' => array('page' => 'plans', 'type' => 'rack', 'id' => $path['id'], 'action' => 'attach', 'parameter' => array('plan', $path['parameter'][1], '#id'))));
             } else {
                 $tabs[$groupName] = null;
             }
         }
         // Returns 2 columm layout with a form and a scene
         return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'select-attach-type', 'type' => 'rack')), DataCenterUI::renderLayout('tabs', $tabs)))));
     }
 }
Exemplo n.º 2
0
 private static function markerOptions(array $parameters, $location)
 {
     // Begins window
     $xmlOutput = DataCenterXml::open('div', array('class' => 'window'));
     // Adds heading
     $xmlOutput .= DataCenterXml::div(array('class' => 'heading'), DataCenterXml::link($location->get('name'), array('page' => 'facilities', 'type' => 'location', 'action' => 'view', 'id' => $location->getId())));
     // Gets number of spaces in location
     $numSpaces = DataCenterDB::numSpaces(DataCenterDB::buildCondition('facility', 'space', 'location', $location->getId()));
     // Adds body
     $xmlOutput .= DataCenterXml::div(array('class' => 'body'), DataCenterXml::div(array('class' => 'region'), $location->get('region')) . DataCenterXml::div(array('class' => 'spaces'), DataCenterUI::message('label', 'num-spaces', $numSpaces)));
     // Ends window
     $xmlOutput .= DataCenterXml::close('div');
     // Returns JavaScript object of options
     return DataCenterJs::toObject(array('content' => $xmlOutput));
 }
Exemplo n.º 3
0
 public function select($path)
 {
     // Checks if...
     if (!$path['id'] && is_array($path['parameter']) && count($path['parameter']) >= 2 && $path['parameter'][0] == 'rack') {
         $rackLink = DataCenterDB::getAssetLink($path['parameter'][1]);
         $plan = DataCenterDB::getPlan($rackLink->get('plan'));
         $space = $plan->getSpace();
         // Gets object links which are linked to this rack
         $objectLinks = DataCenterDB::getAssetLinks(array_merge_recursive(DataCenterDB::buildCondition('link', 'asset', 'plan', $plan->getId()), DataCenterDB::buildCondition('link', 'asset', 'parent_link', $rackLink->getId()), DataCenterDB::buildCondition('link', 'asset', 'asset_type', 'object')));
         $existsTable = array();
         foreach ($objectLinks as $objectLink) {
             $existsTable[$objectLink->get('asset_id')] = true;
         }
         // Additional filters for racking objects
         $conditions = array();
         if ($path['parameter'][0] == 'rack') {
             $conditions = DataCenterDB::buildCondition('model', 'object', 'form_factor', 'rackunit');
         }
         // Gets objects from database in two varieties, local and remote
         $objects = array('local' => DataCenterDB::getAssets('object', array_merge_recursive($conditions, DataCenterDB::buildCondition('asset', 'object', 'location', $space->get('location')), DataCenterDB::buildJoin('model', 'object', 'id', 'asset', 'object', 'model', array('name', 'manufacturer')), DataCenterDB::buildJoin('facility', 'location', 'id', 'asset', 'object', 'location', array('name' => 'location_name', 'region' => 'location_region')))), 'remote' => DataCenterDB::getAssets('object', array_merge_recursive($conditions, DataCenterDB::buildCondition('asset', 'object', 'location', $space->get('location'), '!='), DataCenterDB::buildJoin('model', 'object', 'id', 'asset', 'object', 'model', array('name', 'manufacturer')), DataCenterDB::buildJoin('facility', 'location', 'id', 'asset', 'object', 'location', array('name' => 'location_name', 'region' => 'location_region')))));
         $tabs = array();
         foreach ($objects as $groupName => $objectGroup) {
             // Removes objects which are already in use
             foreach ($objectGroup as $key => $object) {
                 if (isset($existsTable[$object->getId()])) {
                     unset($objectGroup[$key]);
                 }
             }
             // Checks if there are any objects to display
             if (count($objectGroup) > 0) {
                 // Builds table
                 $tabs[$groupName] = DataCenterUI::renderWidget('table', array('rows' => $objectGroup, 'fields' => array('manufacturer', 'model' => array('field' => 'name'), 'serial', 'asset', 'location' => array('fields' => array('location_name', 'location_region'), 'glue' => ' / ')), 'link' => array('page' => 'plans', 'type' => 'object', 'id' => $path['id'], 'action' => 'attach', 'parameter' => array($path['parameter'][0], $path['parameter'][1], '#id'))));
             } else {
                 $tabs[$groupName] = null;
             }
         }
         // Returns 2 columm layout with a form and a scene
         return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'select-attach-type', 'type' => 'object')), DataCenterUI::renderLayout('tabs', $tabs)))));
     }
 }
 /**
  * Gets structure of links
  */
 public function getStructure(array $options = array())
 {
     if (!$this->structure) {
         $links = DataCenterDB::getRows('DataCenterDBAssetLink', 'link', 'asset', array_merge_recursive($options, DataCenterDB::buildCondition('link', 'asset', 'plan', $this->getId())));
         $this->structure = array();
         foreach ($links as $link) {
             if ($link->get('parent_link') == null) {
                 $link->buildStructure($links);
                 $this->structure[] = $link;
             }
         }
     }
     return $this->structure;
 }