Get translated value for a field in a particular language
static public getTranslatedValue ( $ID, $itemtype, $field = 'name', $language, $value = '' ) : the | ||
$ID | dropdown item's id | |
$itemtype | dropdown itemtype | |
$field | the field to look for (default 'name') | |
$language | get translation for this language | |
$value | default value for the field (default '') | |
return | the | translated value of the value in the default language |
// Last parent is not the good one need to display arbo if (!isset($last_level_displayed[$level - 1]) || $last_level_displayed[$level - 1] != $data[$item->getForeignKeyField()]) { $work_level = $level - 1; $work_parentID = $data[$item->getForeignKeyField()]; $parent_datas = array(); do { // Get parent if ($item->getFromDB($work_parentID)) { // Do not do for first item for next page load if (!$firstitem) { $title = $item->fields['completename']; if (isset($item->fields["comment"])) { $addcomment = DropdownTranslation::getTranslatedValue($ID, $_POST['itemtype'], 'comment', $_SESSION['glpilanguage'], $item->fields['comment']); $title = sprintf(__('%1$s - %2$s'), $title, $addcomment); } $output2 = DropdownTranslation::getTranslatedValue($item->fields['id'], $_POST['itemtype'], 'name', $_SESSION['glpilanguage'], $item->fields['name']); // $output2 = $item->getName(); $temp = array('id' => $ID, 'text' => $output2, 'level' => $work_level, 'disabled' => true); if ($_POST['permit_select_parent']) { unset($temp['disabled']); } array_unshift($parent_datas, $temp); } $last_level_displayed[$work_level] = $item->fields['id']; $work_level--; $work_parentID = $item->fields[$item->getForeignKeyField()]; } else { // Error getting item : stop $work_level = -1; } } while ($work_level >= 1 && (!isset($last_level_displayed[$work_level]) || $last_level_displayed[$work_level] != $work_parentID));
// Need to check if parent is the good one // Do not do if only get one item if ($level > 1 && $one_item < 0) { // Last parent is not the good one need to display arbo if (!isset($last_level_displayed[$level - 1]) || $last_level_displayed[$level - 1] != $data[$item->getForeignKeyField()]) { $work_level = $level - 1; $work_parentID = $data[$item->getForeignKeyField()]; $to_display = ''; do { // Get parent if ($item->getFromDB($work_parentID)) { // Do not do for first item for next page load if (!$firstitem) { $title = $item->fields['completename']; if (isset($item->fields["comment"])) { $addcomment = DropdownTranslation::getTranslatedValue($ID, $_GET['itemtype'], 'comment', $_SESSION['glpilanguage'], $item->fields['comment']); $title = sprintf(__('%1$s - %2$s'), $title, $addcomment); } $output2 = $item->getName(); $temp = array('id' => $ID, 'text' => $output2, 'level' => $work_level, 'disabled' => true); if ($_GET['permit_select_parent']) { unset($temp['disabled']); } array_push($datastoadd, $temp); } $last_level_displayed[$work_level] = $item->fields['id']; $work_level--; $work_parentID = $item->fields[$item->getForeignKeyField()]; } else { // Error getting item : stop $work_level = -1;
public function showResult($output_type, $limit = 0, $params = array()) { global $DB; $arrayRet = $this->execQuery($_REQUEST); $result = $arrayRet['query_result']; $query = $arrayRet['query']; $nbtot = $result ? $DB->numrows($result) : 0; if ($limit) { $start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0; if ($start >= $nbtot) { $start = 0; } if ($start > 0 || $start + $limit < $nbtot) { $result = $DB->query($query . " LIMIT {$start},{$limit}"); } } else { $start = 0; } $nbCols = $DB->num_fields($result); $nbrows = $DB->numrows($result); $groupByRackName = true; if (isset($_REQUEST['groupByRackName']) && $_REQUEST['groupByRackName'] == "on") { $groupByRackName = false; } $title = date("d/m/Y H:i"); if ($nbtot == 0) { echo "<div class='center'><font class='red b'>" . __("No item found") . "</font></div>"; Html::footer(); } else { if ($output_type == Search::HTML_OUTPUT) { echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>{$title}</th></tr>\n"; echo "<tr class='tab_bg_2 center'><td class='center'>"; $parameters = null; $parameters .= Toolbox::append_params($_REQUEST, '&'); $this->printPager($start, $nbtot, $_SERVER["PHP_SELF"], $parameters, 'PluginRacksRack'); } } if ($nbtot > 0) { if ($output_type == Search::HTML_OUTPUT) { echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n"; } echo Search::showHeader($output_type, $nbrows, $nbCols, true); echo Search::showNewLine($output_type); $showAllFieds = true; $listFields = array(); $cptField = 0; $showAllFieds = (!isset($_REQUEST['cb_object_name']) || $_REQUEST['cb_object_name'] != "on") && (!isset($_REQUEST['cb_object_location']) || $_REQUEST['cb_object_location'] != "on") && (!isset($_REQUEST['cb_group']) || $_REQUEST['cb_group'] != "on") && (!isset($_REQUEST['cb_manufacturer']) || $_REQUEST['cb_manufacturer'] != "on") && (!isset($_REQUEST['cb_model']) || $_REQUEST['cb_model'] != "on") && (!isset($_REQUEST['cb_serial_number']) || $_REQUEST['cb_serial_number'] != "on"); $num = 1; $cptRow = 1; if (!$showAllFieds) { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'name', false, $params); $cptField++; $this->showTitle($output_type, $num, __("Location"), 'location', false, $params); $cptField++; $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'roomlocation', false, $params); $cptField++; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false, $params); $cptField++; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . _x('Rack enclosure', 'Back', 'racks'), 'front_rear', false, $params); $cptField++; if (isset($_REQUEST['cb_object_name']) && $_REQUEST['cb_object_name'] == "on") { $listFields['object_name'] = $_REQUEST['cb_object_name']; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false, $params); $cptField++; } // Lieu if (isset($_REQUEST['cb_object_location']) && $_REQUEST['cb_object_location'] == "on") { $listFields['object_location'] = $_REQUEST['cb_object_location']; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false, $params); $cptField++; } // Groupe if (isset($_REQUEST['cb_group']) && $_REQUEST['cb_group'] == "on") { $listFields['group'] = $_REQUEST['cb_group']; $this->showTitle($output_type, $num, __("Group"), 'group', false, $params); $cptField++; } // Fabricant if (isset($_REQUEST['cb_manufacturer']) && $_REQUEST['cb_manufacturer'] == "on") { $listFields['manufacturer'] = $_REQUEST['cb_manufacturer']; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false, $params); $cptField++; } // Modèle if (isset($_REQUEST['cb_model']) && $_REQUEST['cb_model'] == "on") { $listFields['model'] = $_REQUEST['cb_model']; $this->showTitle($output_type, $num, __("Model"), 'model', false, $params); $cptField++; } // Numéro de série if (isset($_REQUEST['cb_serial_number']) && $_REQUEST['cb_serial_number'] == "on") { $listFields['serial_number'] = $_REQUEST['cb_serial_number']; $this->showTitle($output_type, $num, __("Serial number"), 'group', false, $params); $cptField++; } } else { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'rack_name', false, $params); $listFields['rack_name'] = true; $this->showTitle($output_type, $num, __("Location"), 'location', false, $params); $listFields['location'] = true; $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'roomlocation', false, $params); $listFields['roomlocation'] = true; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false, $params); $listFields['u'] = true; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . _x('Rack enclosure', 'Back', 'racks'), 'front_rear', false, $params); $listFields['front_rear'] = true; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false, $params); $listFields['object_name'] = true; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false, $params); $listFields['object_location'] = true; $this->showTitle($output_type, $num, __("Group"), 'group', false, $params); $listFields['group'] = true; $this->showTitle($output_type, $num, __("Type"), 'type', false, $params); $listFields['type'] = true; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false, $params); $listFields['manufacturer'] = true; $this->showTitle($output_type, $num, __("Model"), 'model', false, $params); $listFields['model'] = true; $this->showTitle($output_type, $num, __("Serial number"), 'serial_number', false, $params); $listFields['serial_number'] = true; $this->showTitle($output_type, $num, __("Inventory number"), 'other_serial', false, $params); $listFields['other_serial'] = true; $cptField = 13; } echo self::showEndLine($output_type, $params); $num = 1; $cptRow = 1; $currentRack = -1; while ($row = $DB->fetch_array($result)) { // itemtype $itemtype = $row['itemtype']; $num = 1; $cptRow++; echo Search::showNewLine($output_type); if (isset($row['itemtype']) && $row['itemtype'] != "") { $class = substr($itemtype, 0, -5); $item = new $class(); $table = getTableForItemType($class); $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' "); $device = $DB->fetch_array($r); } // nom $link = Toolbox::getItemTypeFormURL("PluginRacksRack"); if ($groupByRackName || $currentRack != $row['id']) { if ($output_type == Search::HTML_OUTPUT) { echo self::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow, null, $params); } else { echo self::showItem($output_type, $row["name"], $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } // lieu if ($groupByRackName || $currentRack != $row['id']) { if (isset($row['locations_id'])) { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $row['locations_id']), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } // Emplacement if ($groupByRackName || $currentRack != $row['id']) { $tmpId = $row['plugin_racks_roomlocations_id']; $tmpId = $row['plugin_racks_roomlocations_id']; $tmpObj = new PluginRacksRoomLocation(); $trans_name = ""; if ($tmpObj->getFromDB($tmpId)) { $trans_name = $tmpObj->fields['name']; } $trans = DropdownTranslation::getTranslatedValue($tmpId, "PluginRacksRoomLocation", 'name', $_SESSION['glpilanguage']); if (!empty($trans)) { $trans_name = $trans; } if (isset($tmpId)) { echo self::showItem($output_type, $trans_name, $num, $cptRow, null, $params); } else { echo self::showItem($output_type, ' ', $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } if (isset($row['itemtype']) && $row['itemtype'] != "") { // U if (isset($row['position']) && $row['position'] != "") { echo self::showItem($output_type, $row['position'], $num, $cptRow, null, $params); } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } // avant / arrière if ($row['faces_id'] == 1) { echo self::showItem($output_type, __("Front", "racks"), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, _x('Rack enclosure', 'Back', 'racks'), $num, $cptRow, null, $params); } // Nom de l'objet if (array_key_exists("object_name", $listFields)) { $link = Toolbox::getItemTypeFormURL(substr($itemtype, 0, -5)); if ($itemtype != 'PluginRacksOtherModel') { if ($output_type == Search::HTML_OUTPUT) { echo self::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["items_id"] . "\">" . $device["name"] . "</a>", $num, $cptRow, null, $params); } else { echo self::showItem($output_type, $device["name"], $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, $device["name"], $num, $cptRow, null, $params); } } // Lieu de l'objet if (array_key_exists("object_location", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $device["locations_id"]), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // Groupe if (array_key_exists("group", $listFields)) { // Groupe if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $device["groups_id_tech"]), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // type if (array_key_exists("type", $listFields)) { echo self::showItem($output_type, $item->getTypeName(), $num, $cptRow, null, $params); } // fabricant if (array_key_exists("manufacturer", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_manufacturers", $device["manufacturers_id"]), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // modèle if (array_key_exists("model", $listFields)) { $model_table = getTableForItemType($itemtype); $modelfield = getForeignKeyFieldForTable(getTableForItemType($itemtype)); echo self::showItem($output_type, Dropdown::getDropdownName($model_table, $device[$modelfield]), $num, $cptRow, null, $params); } // numéro de série if (array_key_exists("serial_number", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, $device['serial'], $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // numéro d'inventaire if (array_key_exists("other_serial", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, $device['otherserial'], $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } $currentRack = $row['id']; } else { for ($k = 0; $k < $cptField - 3; $k++) { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } } echo self::showEndLine($output_type, $params); } echo self::showFooter($output_type, $title, $params); if ($output_type == Search::HTML_OUTPUT) { Html::closeForm(); } } }
function showItemFromPlugin($instID, $face) { global $DB, $CFG_GLPI; if (!$this->canView()) { return false; } $rand = mt_rand(); $PluginRacksRack = new PluginRacksRack(); $PluginRacksConfig = new PluginRacksConfig(); if ($PluginRacksRack->getFromDB($instID)) { $canedit = $PluginRacksRack->can($instID, UPDATE); if ($canedit) { $this->AddItemToRack($PluginRacksRack, $instID, $face); } //LIST echo "<form method='post' name='racks_form{$rand}' id='racks_form{$rand}' \r\n action=\"" . PluginRacksRack::getFormURL(true) . "\">"; echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='12'>" . __('Rack enclosure arrangement', 'racks') . ":</th></tr><tr>"; if ($face == PluginRacksRack::FRONT_FACE) { $query = "SELECT `" . $this->getTable() . "`.*\r\n FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\r\n WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \r\n AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\r\n AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \r\n OR (`" . $this->getTable() . "`.`faces_id` ='" . PluginRacksRack::BACK_FACE . "' \r\n AND `glpi_plugin_racks_itemspecifications`.`length` = 1 ))\r\n ORDER BY `" . $this->getTable() . "`.`position` ASC"; } else { $query = "SELECT `" . $this->getTable() . "`.*\r\n FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\r\n WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \r\n AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\r\n AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \r\n OR (`" . $this->getTable() . "`.`faces_id` ='" . PluginRacksRack::FRONT_FACE . "' \r\n AND `glpi_plugin_racks_itemspecifications`.`length` = 1 ))\r\n ORDER BY `" . $this->getTable() . "`.`position` ASC"; } $result = $DB->query($query); $number = $DB->numrows($result); $amps_tot = 0; $flow_rate_tot = 0; $dissip_tot = 0; $weight_tot = $PluginRacksRack->fields["weight"]; $nbcordons = 0; $nbcordons_tot = 0; $cordons_amps_tot = 0; $computer_tot = 0; $computer_size_tot = 0; $networking_tot = 0; $networking_size_tot = 0; $peripheral_tot = 0; $peripheral_size_tot = 0; $others_tot = 0; $others_size_tot = 0; $next = 0; $device_size = 0; echo "<th> </th>"; echo "<th>" . __('Position', 'racks') . "</th>"; echo "<th>" . __('Name') . "</th>"; // nom echo "<th>" . __('Type') . "</th>"; // type de materiel echo "<th>" . __('Model') . "</th>"; echo "<th>" . __('Power supply 1', 'racks') . "</th>"; //alim1 echo "<th>" . __('Power supply 2', 'racks') . "</th>"; //alim2 echo "<th>" . __('C13 Power Cord Quantity', 'racks') . "</th>"; // nb cordons echo "<th>" . __('Total Current', 'racks') . "<br>(" . __('amps', 'racks') . ")</th>"; // Courant consommé echo "<th>" . __('Calorific waste', 'racks') . "<br>"; // Dissipation calorifique echo " ("; $PluginRacksConfig->getUnit("dissipation"); echo ")</th>"; echo "<th>" . __('Flow Rate', 'racks') . "<br>"; // Débit d'air frais echo " ("; $PluginRacksConfig->getUnit("rate"); echo ")</th>"; echo "<th>" . __('Weight', 'racks') . "<br>"; // poids echo " ("; $PluginRacksConfig->getUnit("weight"); echo ")</th>"; echo "</tr>"; for ($i = $PluginRacksRack->fields['rack_size']; $i >= 1; $i--) { $alim1 = 0; $alim2 = 0; $j = $i; if ($i < 10) { $j = "0" . $i; } if ($face == PluginRacksRack::FRONT_FACE) { // recherche de l'equipement a la position courante $query = "SELECT `" . $this->getTable() . "`.*\r\n FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\r\n WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \r\n AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\r\n AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \r\n OR (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \r\n AND `glpi_plugin_racks_itemspecifications`.`length` = 1)) AND `position` ='{$j}'\r\n ORDER BY `" . $this->getTable() . "`.`position` ASC"; } else { $query = "SELECT `" . $this->getTable() . "`.*\r\n FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\r\n WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \r\n AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\r\n AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \r\n OR (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \r\n AND `glpi_plugin_racks_itemspecifications`.`length` = 1)) AND `position` ='{$j}'\r\n ORDER BY `" . $this->getTable() . "`.`position` ASC"; } $result = $DB->query($query); $number = $DB->numrows($result); // Si equipement if ($number != 0) { $data = $DB->fetch_array($result); $class = substr($data["itemtype"], 0, -5); $item = new $class(); $table = getTableForItemType($class); $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $data["items_id"] . "' "); $device = $DB->fetch_array($r); $modelclass = $data["itemtype"]; $model_table = getTableForItemType($modelclass); $modelfield = getForeignKeyFieldForTable(getTableForItemType($modelclass)); $query = "SELECT `" . $model_table . "`.`name` AS model,`" . $model_table . "`.`id` AS modelid, `glpi_plugin_racks_itemspecifications`.* \r\n FROM `glpi_plugin_racks_itemspecifications` " . " LEFT JOIN `" . $model_table . "` \r\n ON (`glpi_plugin_racks_itemspecifications`.`model_id` = `" . $model_table . "`.`id`)" . " LEFT JOIN `" . $table . "` \r\n ON (`glpi_plugin_racks_itemspecifications`.`model_id` = `" . $table . "`.`" . $modelfield . "` \r\n AND `glpi_plugin_racks_itemspecifications`.`itemtype` = '" . $modelclass . "')" . " WHERE `" . $table . "`.`id` = '" . $data["items_id"] . "' "; //Rack recursivity .getEntitiesRestrictRequest(" AND ",$table,'','',$item->maybeRecursive()) $res = $DB->query($query); $device_spec = $DB->fetch_array($res); $device_size = $device_spec["size"]; if ($data["first_powersupply"] > 0) { $nbcordons += 1; $nbcordons_tot += 1; } if ($data["second_powersupply"] > 0) { $nbcordons += 1; $nbcordons_tot += 1; } if ($data["itemtype"] == 'ComputerModel') { $computer_tot += 1; $computer_size_tot += $device_spec["size"]; } else { if ($data["itemtype"] == 'PeripheralModel') { $peripheral_tot += 1; $peripheral_size_tot += $device_spec["size"]; } else { if ($data["itemtype"] == 'NetworkEquipmentModel') { $networking_tot += 1; $networking_size_tot += $device_spec["size"]; } else { if ($data["itemtype"] == 'PluginRacksOtherModel') { $others_tot += 1; $others_size_tot += $device_spec["size"]; } } } } for ($t = 0; $t < $device_size; $t++) { if ($t == 0) { if ($data["itemtype"] == 'ComputerModel') { echo "<tr class='plugin_racks_device_computers_color'>"; } else { if ($data["itemtype"] == 'PeripheralModel') { echo "<tr class='plugin_racks_device_peripherals_color'>"; } else { if ($data["itemtype"] == 'NetworkEquipmentModel') { echo "<tr class='plugin_racks_device_networking_color'>"; } else { if ($data["itemtype"] == 'PluginRacksOtherModel') { echo "<tr class='plugin_racks_device_others_color'>"; } } } } echo "<td width='10' rowspan='" . $device_size . "'>"; $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>"; echo "</td>"; echo "<td class='center'>U"; if ($canedit) { echo "<input type='text' size='3' name='position" . $data["id"] . "' value='{$j}'>"; echo " <input type='image' name='updateDevice[" . $data["id"] . "]' value=\"" . _sx('button', 'Save') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' class='calendrier'>"; } else { echo $j; } echo "</td>"; $link = Toolbox::getItemTypeFormURL(substr($data["itemtype"], 0, -5)); if ($data["itemtype"] != 'PluginRacksOtherModel') { $name = "<a href=\"" . $link . "?id=" . $data["items_id"] . "\">" . $device["name"] . "</a>"; } else { $name = $device["name"]; } echo "<input type='hidden' name='plugin_racks_racks_id' value='" . $PluginRacksRack->fields['id'] . "'>"; echo "<input type='hidden' name='rack_size' value='" . $PluginRacksRack->fields['rack_size'] . "'>"; echo "<input type='hidden' name='type" . $data["id"] . "' value='" . $data["itemtype"] . "'>"; echo "<input type='hidden' name='items_id" . $data["id"] . "' value='" . $data["items_id"] . "'>"; echo "<input type='hidden' name='plugin_racks_itemspecifications_id" . $data["id"] . "' value='" . $data["plugin_racks_itemspecifications_id"] . "'>"; echo "<input type='hidden' name='update_server' value='1'>"; echo "<input type='hidden' name='faces_id' value='" . $face . "'>"; if ($data["itemtype"] != 'PluginRacksOtherModel') { echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . " >" . $name . "</td>"; } else { $PluginRacksOther = new PluginRacksOther(); $PluginRacksOther->GetfromDB($data["items_id"]); echo "<td class='center'><input type='text' name='name" . $data["id"] . "' value='" . $PluginRacksOther->fields["name"] . "' size='10'></td>"; } echo "<td class='center'>" . $item::getTypeName(2) . "</td>"; $linkmodel = Toolbox::getItemTypeFormURL($modelclass); $trans = DropdownTranslation::getTranslatedValue($device_spec["modelid"], $modelclass, 'name', $_SESSION['glpilanguage']); $trans_name = $device_spec["model"]; if (!empty($trans)) { $trans_name = $trans; } echo "<td class='center'><a href=\"" . $linkmodel . "?id=" . $device_spec["modelid"] . "\">" . $trans_name . " (" . $device_spec["size"] . "U)</a></td>"; echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_plugin_racks_connections", $data["first_powersupply"]); echo "</td>"; echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_plugin_racks_connections", $data["second_powersupply"]); echo "</td>"; echo "<td class='center'>" . $nbcordons . "</td>"; if ($data["amps"] == '0.0000') { $amps = $device_spec["amps"]; } else { $amps = $data["amps"]; } $cordons_amps_tot += $amps * $nbcordons; echo "<td class='center'>" . Html::formatNumber($amps, true) . "</td>"; if ($data["dissipation"] == '0.0000') { $dissipation = $device_spec["dissipation"]; } else { $dissipation = $data["dissipation"]; } echo "<td class='center'>" . Html::formatNumber($dissipation, true) . "</td>"; if ($data["flow_rate"] == '0.0000') { $flow_rate = $device_spec["flow_rate"]; } else { $flow_rate = $data["flow_rate"]; } echo "<td class='center'>" . Html::formatNumber($flow_rate, true) . "</td>"; if ($data["weight"] == '0.0000') { $weight = $device_spec["weight"]; } else { $weight = $data["weight"]; } echo "<td class='center'>" . Html::formatNumber($weight, true) . "</td>"; echo "</tr>"; if ($data["amps"] == '0.0000') { $amps_tot += $device_spec["amps"]; } else { $amps_tot += $data["amps"]; } if ($data["flow_rate"] == '0.0000') { $flow_rate_tot += $device_spec["flow_rate"]; } else { $flow_rate_tot += $data["flow_rate"]; } if ($data["dissipation"] == '0.0000') { $dissip_tot += $device_spec["dissipation"]; } else { $dissip_tot += $data["dissipation"]; } if ($data["weight"] == '0.0000') { $weight_tot += $device_spec["weight"]; } else { $weight_tot += $data["weight"]; } } else { $name = $j - $t; if ($data["itemtype"] == 'ComputerModel') { echo "<tr class='plugin_racks_device_computers_color'>"; } else { if ($data["itemtype"] == 'PeripheralModel') { echo "<tr class='plugin_racks_device_peripherals_color'>"; } else { if ($data["itemtype"] == 'NetworkEquipmentModel') { echo "<tr class='plugin_racks_device_networking_color'>"; } else { if ($data["itemtype"] == 'PluginRacksOtherModel') { echo "<tr class='plugin_racks_device_others_color'>"; } } } } echo "<td class='center'>U{$name}</td><td colspan='10'></td></tr>"; } } if ($device_size > 1) { for ($d = 1; $d < $device_size; $d++) { $i--; } } } else { // Si pas d'equipement a la position courante echo "<tr class='tab_bg_1'><td></td><td class='center'>" . __('U', 'racks') . $j; echo "</td><td colspan='10'></td></tr>"; } $nbcordons = 0; } echo "<tr class='tab_bg_1'>"; echo "<td></td>"; echo "<td class='center'><b>" . __('Total') . "</b></td>"; echo "<td colspan='3' class='center'><b>"; if ($computer_tot != 0) { echo __('Total Servers', 'racks') . " : " . $computer_tot . " (" . $computer_size_tot . __('U', 'racks') . ")<br>"; } if ($networking_tot != 0) { echo __('Total Network equipements', 'racks') . " : " . $networking_tot . " (" . $networking_size_tot . __('U', 'racks') . ")<br>"; } if ($peripheral_tot != 0) { echo __('Total Peripherals', 'racks') . " : " . $peripheral_tot . " (" . $peripheral_size_tot . __('U', 'racks') . ")<br>"; } if ($others_tot != 0) { echo __('Total Others', 'racks') . " : " . $others_tot . " (" . $others_size_tot . __('U', 'racks') . ")<br>"; } //number of U availables $available = $PluginRacksRack->fields['rack_size'] - $computer_size_tot - $networking_size_tot - $peripheral_size_tot - $others_size_tot; if ($available > 0) { echo "<font color='green'>" . $available . " " . __('U availables', 'racks') . "</font>"; } else { echo "<font color='red'>" . $available . " " . __('U availables', 'racks') . "</font>"; } echo "</b></td>"; echo "<td colspan='3' class='center'><b>" . __('Total power Cords', 'racks') . " : " . $nbcordons_tot . "</b><br>"; echo "<b>" . __('Amperage on power Cords', 'racks') . " : " . $cordons_amps_tot . " " . __('amps', 'racks') . "</b></td>"; echo "<td class='center'><b>" . Html::formatNumber($amps_tot, true) . " " . __('amps', 'racks') . "</b></td>"; echo "<td class='center'><b>" . Html::formatNumber($dissip_tot, true) . " "; $PluginRacksConfig->getUnit("dissipation"); echo "</b></td>"; echo "<td class='center'><b>" . Html::formatNumber($flow_rate_tot, true) . " "; $PluginRacksConfig->getUnit("rate"); echo "</b></td>"; echo "<td class='center'><b>" . Html::formatNumber($weight_tot, true) . " "; $PluginRacksConfig->getUnit("weight"); echo "</b></td>"; echo "</tr>"; echo "</table></div>"; if ($canedit) { Html::openArrowMassives("racks_form{$rand}", true); Html::closeArrowMassives(array('deleteDevice' => _sx('button', 'Delete permanently'))); } else { echo "<input type='hidden' name='rack_size' value='" . $PluginRacksRack->fields['rack_size'] . "'>"; echo "</table></div>"; } Html::closeForm(); //////////////////////////////////////////////////// // Recherche des racks a gauche et a droite // Recuperation de la rangee $qPos = "SELECT `name`\r\n FROM `glpi_plugin_racks_roomlocations`\r\n WHERE `id` = '" . $PluginRacksRack->fields['plugin_racks_roomlocations_id'] . "' "; $rPos = $DB->query($qPos); $nbPos = $DB->numrows($rPos); $pos = ""; $next = ""; $prev = ""; if ($nbPos != 0) { $dataPos = $DB->fetch_array($rPos); $pos = $dataPos['name']; } // Incrementation & docrementation de la lettre de rang if (!empty($pos)) { // Z is the last letter... if ($pos[0] != "Z") { $next = chr(ord($pos[0]) + 1); for ($h = 1; $h < strlen($pos); $h++) { $next .= $pos[$h]; } } // A is the first letter.... if ($pos[0] != "A") { $prev = chr(ord($pos[0]) - 1); for ($h = 1; $h < strlen($pos); $h++) { $prev .= $pos[$h]; } } $qLeft = "SELECT `glpi_plugin_racks_racks`.`id`, `glpi_plugin_racks_roomlocations`.`name`\r\n FROM `glpi_plugin_racks_racks`\r\n LEFT JOIN `glpi_plugin_racks_roomlocations`\r\n ON (`glpi_plugin_racks_roomlocations`.`id` = `glpi_plugin_racks_racks`.`plugin_racks_roomlocations_id`)\r\n WHERE `glpi_plugin_racks_racks`.`is_deleted` = '0' AND `glpi_plugin_racks_roomlocations`.`name` = '" . $prev . "' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_racks_racks", '', '', $PluginRacksRack->maybeRecursive()); $rLeft = $DB->query($qLeft); $nb = $DB->numrows($rLeft); echo "<br><br>"; echo "<div align='center'><table border='0' width='950px'><tr><td class='left'>"; if ($nb != 0) { $left_racks = $DB->fetch_array($rLeft); echo "<a href =\"" . $CFG_GLPI["root_doc"] . "/plugins/racks/front/rack.form.php?id=" . $left_racks['id'] . "\">\r\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/left.png\" alt=''> " . __('Left rack enclosure', 'racks') . " " . $left_racks['name'] . "</a>"; } else { echo __('No rack enclosure on the left', 'racks'); } echo "</td>"; echo "<td>"; echo "</td>"; echo "<td class='right'>"; $qRight = "SELECT `glpi_plugin_racks_racks`.`id`, `glpi_plugin_racks_roomlocations`.`name`\r\n FROM `glpi_plugin_racks_racks`\r\n LEFT JOIN `glpi_plugin_racks_roomlocations`\r\n ON (`glpi_plugin_racks_roomlocations`.`id` = `glpi_plugin_racks_racks`.`plugin_racks_roomlocations_id`)\r\n WHERE `glpi_plugin_racks_racks`.`is_deleted` = '0' AND `glpi_plugin_racks_roomlocations`.`name` = '" . $next . "' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_racks_racks", '', '', $PluginRacksRack->maybeRecursive()); $rRight = $DB->query($qRight); $nb = $DB->numrows($rRight); if ($nb != 0) { $right_racks = $DB->fetch_array($rRight); echo "<a href =\"" . $CFG_GLPI["root_doc"] . "/plugins/racks/front/rack.form.php?id=" . $right_racks['id'] . "\">" . __('Right rack enclosure', 'racks') . " " . $right_racks['name'] . " <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/right.png\" alt=''></a>"; } else { echo __('No rack enclosure on the right', 'racks'); } echo "</td></tr></table></div>"; } } }