. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Datacenter Class **/ class Datacenter extends CommonDBTM { // From CommonDBTM public $dohistory = true; static $rightname = 'datacenter'; static function getTypeName($nb = 0) { //TRANS: Test of comment for translation (mark : //TRANS) return _n('Data center', 'Data centers', $nb); } function defineTabs($options = []) { $ong = []; $this->addDefaultFormTab($ong) ->addImpactTab($ong, $options) ->addStandardTab('DCRoom', $ong, $options); return $ong; } function showForm($ID, $options = []) { $rand = mt_rand(); $this->initForm($ID, $options); $this->showFormHeader($options); echo ""; echo ""; echo ""; Html::autocompletionTextField($this, "name", ['rand' => $rand]); echo ""; echo ""; echo ""; Location::dropdown([ 'value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"], 'rand' => $rand ]); echo ""; echo ""; $this->showFormButtons($options); return true; } function rawSearchOptions() { $tab = []; $tab[] = [ 'id' => 'common', 'name' => __('Characteristics') ]; $tab[] = [ 'id' => '1', 'table' => $this->getTable(), 'field' => 'name', 'name' => __('Name'), 'datatype' => 'itemlink', 'massiveaction' => false, // implicit key==1 'autocomplete' => true, ]; $tab[] = [ 'id' => '2', 'table' => $this->getTable(), 'field' => 'id', 'name' => __('ID'), 'massiveaction' => false, // implicit field is id 'datatype' => 'number' ]; $tab = array_merge($tab, Location::rawSearchOptionsToAdd()); $tab[] = [ 'id' => '19', 'table' => $this->getTable(), 'field' => 'date_mod', 'name' => __('Last update'), 'datatype' => 'datetime', 'massiveaction' => false ]; $tab[] = [ 'id' => '121', 'table' => $this->getTable(), 'field' => 'date_creation', 'name' => __('Creation date'), 'datatype' => 'datetime', 'massiveaction' => false ]; $tab[] = [ 'id' => '80', 'table' => 'glpi_entities', 'field' => 'completename', 'name' => Entity::getTypeName(1), 'datatype' => 'dropdown' ]; return $tab; } static public function rawSearchOptionsToAdd($itemtype) { return [ [ 'id' => 'datacenter', 'name' => _n('Data center', 'Data centers', Session::getPluralNumber()) ], [ 'id' => '178', 'table' => $itemtype::getTable(), 'field' => '_virtual_datacenter_position', // virtual field 'additionalfields' => [ 'id', 'name' ], 'name' => __('Data center position'), 'datatype' => 'specific', 'nosearch' => true, 'massiveaction' => false ], ]; } static function getAdditionalMenuLinks() { $links = []; if (static::canView()) { $rooms = "" . DCRoom::getTypeName(Session::getPluralNumber()). ""; $links[$rooms] = DCRoom::getSearchURL(false); } if (count($links)) { return $links; } return false; } static function getAdditionalMenuOptions() { if (static::canView()) { return [ 'dcroom' => [ 'title' => DCRoom::getTypeName(Session::getPluralNumber()), 'page' => DCRoom::getSearchURL(false), 'links' => [ 'add' => '/front/dcroom.form.php', 'search' => '/front/dcroom.php', ] ] ]; } } static function getIcon() { return "fas fa-warehouse"; } }