static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     //Menu entry in tools
     $menu['title'] = self::getMenuName(2);
     $menu['page'] = PluginRacksRack::getSearchURL(false);
     $menu['links']['search'] = PluginRacksRack::getSearchURL(false);
     $menu['options']['racks']['links']['search'] = PluginRacksRack::getSearchURL(false);
     $menu['options']['racks']['links']['config'] = PluginRacksConfig::getFormURL(false);
     $menu['options']['config']['title'] = __('Setup');
     $menu['options']['config']['page'] = PluginRacksConfig::getSearchURL(false);
     $menu['options']['specifications']['title'] = __('Specifications', 'racks');
     $menu['options']['specifications']['page'] = PluginRacksItemSpecification::getSearchURL(false);
     $menu['options']['specifications']['links']['search'] = PluginRacksItemSpecification::getSearchURL(false);
     if (PluginRacksRack::canCreate()) {
         $menu['options']['racks']['links']['add'] = PluginRacksRack::getFormURL(false);
     }
     if (PluginRacksRackModel::canView()) {
         $menu['options']['racks']['links']['template'] = '/plugins/racks/front/setup.templates.php?add=0';
         $menu['options']['racks']['links']["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title=\"" . __('Equipments models specifications', 'racks') . "\" alt=\"" . __('Equipments models specifications', 'racks') . "\">"] = PluginRacksItemSpecification::getSearchURL(false);
     }
     return $menu;
 }
 function showTotal()
 {
     global $DB;
     $ID = $this->getID();
     $PluginRacksConfig = new PluginRacksConfig();
     $query = "SELECT SUM(`weight`) AS total_weight, SUM(`amps`) AS total_amps,\n                     SUM(`flow_rate`) AS total_flow_rate,\n                     SUM(`dissipation`) AS total_dissipation,\n                     COUNT(`first_powersupply`) AS total_alim1,\n                     COUNT(`second_powersupply`) AS total_alim2\n               FROM `glpi_plugin_racks_racks_items`\n               WHERE `plugin_racks_racks_id` = '{$ID}' ";
     $query_alim1 = "SELECT COUNT(`first_powersupply`) AS total_alim1\n                      FROM `glpi_plugin_racks_racks_items`\n                      WHERE `plugin_racks_racks_id` = '{$ID}' \n                        AND `first_powersupply` > 0 ";
     $result_alim1 = $DB->query($query_alim1);
     $query_alim2 = "SELECT COUNT(`second_powersupply`) AS total_alim2\n                      FROM `glpi_plugin_racks_racks_items`\n                      WHERE `plugin_racks_racks_id` = '{$ID}' \n                        AND `second_powersupply` > 0 ";
     $result_alim2 = $DB->query($query_alim2);
     echo "<form><div class='center'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='6'>" . __('Total') . "</th></tr><tr>";
     //echo "<th colspan='3'>".__('Equipment')."</th>";
     echo "<th>" . __('Power supplies number', 'racks') . "</th>";
     echo "<th>" . __('Total current', 'racks') . "</th>";
     // Courant consomme
     echo "<th>" . __('Calorific waste', 'racks') . "</th>";
     echo "<th>" . __('Flow rate', 'racks') . "</th>";
     echo "<th>" . __('Weight', 'racks') . "</th>";
     echo "</tr>";
     $total_cordons = 0;
     foreach ($DB->request($query_alim1) as $data_alim1) {
         $total_cordons += $data_alim1["total_alim1"];
     }
     foreach ($DB->request($query_alim2) as $data_alim2) {
         $total_cordons += $data_alim2["total_alim2"];
     }
     foreach ($DB->request($query) as $data) {
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>" . $total_cordons . "</td>";
         echo "<td class='center'><b>";
         echo Html::formatNumber($data["total_amps"], true);
         echo " " . __('amps', 'racks') . "</b></td>";
         echo "<td class='center'><b>";
         echo Html::formatNumber($data["total_dissipation"], true) . "&nbsp;";
         $PluginRacksConfig->getUnit("dissipation");
         echo "</b></td>";
         echo "<td class='center'><b>";
         echo Html::formatNumber($data["total_flow_rate"], true) . "&nbsp;";
         $PluginRacksConfig->getUnit("rate");
         echo "</b></td>";
         $total_weight = $data["total_weight"] + $this->fields['weight'];
         echo "<td class='center'><b>";
         echo Html::formatNumber($total_weight, true) . "&nbsp";
         $PluginRacksConfig->getUnit("weight");
         echo "</b></td>";
         echo "</tr>";
     }
     echo "</table></div>";
     Html::closeForm();
 }
 function showModels($itemtype, $id, $rand)
 {
     global $DB;
     $PluginRacksConfig = new PluginRacksConfig();
     $link = Toolbox::getItemTypeFormURL($itemtype);
     $table = getTableForItemType($itemtype);
     $search = Toolbox::getItemTypeSearchURL($itemtype);
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>&nbsp;</th>";
     echo "<th>" . __('Equipment', 'racks') . "</th>";
     echo "<th>" . __('Total Current', 'racks') . "<br>(" . __('amps', 'racks') . ")</th>";
     echo "<th>" . __('Power supplies number', 'racks') . "</th>";
     echo "<th>" . __('Calorific waste', 'racks') . "<br> (";
     // Dissipation calorifique
     $PluginRacksConfig->getUnit("dissipation");
     echo ")</th>";
     echo "<th>" . __('Flow Rate', 'racks') . "<br> (";
     // Débit d'air frais
     $PluginRacksConfig->getUnit("rate");
     echo ")</th>";
     echo "<th>" . __('Size') . " (" . __('U', 'racks') . ")</th>";
     echo "<th>" . __('Weight', 'racks') . "<br> (";
     // poids
     $PluginRacksConfig->getUnit("weight");
     echo ")</th>";
     echo "<th>" . __('Full-depth item', 'racks') . "</th>";
     echo "</tr>";
     $modelid = -1;
     $result = $DB->query("SELECT *\n                        FROM `" . $this->getTable() . "` " . ($itemtype != -1 ? "WHERE `itemtype` = '{$itemtype}'" : "") . " ");
     while ($data = $DB->fetch_assoc($result)) {
         $modelid = $data['model_id'];
         $id = $data['id'];
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>";
         echo "<input type='checkbox' name='item[{$id}]' value='1'>";
         echo "</td>";
         echo "<td>";
         echo "<a href=\"" . $link . "?id=" . $modelid . "\">";
         echo Dropdown::getDropdownName($table, $modelid);
         echo "</a>";
         echo "</td>";
         echo "<td>" . Html::formatNumber($data['amps'], true) . "</td>";
         echo "<td>" . $data['nb_alim'] . "</td>";
         echo "<td>" . Html::formatNumber($data['dissipation'], true) . "</td>";
         echo "<td>" . Html::formatNumber($data['flow_rate'], true) . "</td>";
         echo "<td>" . $data['size'] . "</td>";
         echo "<td>" . Html::formatNumber($data['weight'], true) . "</td>";
         echo "<td>" . Dropdown::getYesNo($data['length']) . "</td>";
     }
     echo "<tr class='tab_bg_1'><td colspan='10'>";
     if ($this->canCreate()) {
         echo "<div align='center'><a onclick= \"if ( markCheckboxes('massiveaction_form{$rand}') ) return false;\" href='#'>" . __('Check all') . "</a>";
         echo " - <a onclick= \"if ( unMarkCheckboxes('massiveaction_form{$rand}') ) return false;\" href='#'>" . __('Uncheck all') . "</a> ";
         echo "<input type='submit' name='deleteSpec' value=\"" . __s('Delete permanently') . "\" class='submit' ></div></td></tr>";
         echo "<tr class='tab_bg_1 right'><td colspan='10'>";
         echo "<a href=\"" . $search . "\">";
         echo __('Add specifications for servers models', 'racks');
         echo "</a>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
 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}'  \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() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n              AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n              AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \n               OR (`" . $this->getTable() . "`.`faces_id` ='" . PluginRacksRack::BACK_FACE . "' \n                  AND `glpi_plugin_racks_itemspecifications`.`length` = 1 ))\n              ORDER BY `" . $this->getTable() . "`.`position` ASC";
         } else {
             $query = "SELECT `" . $this->getTable() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n              AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n              AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \n               OR (`" . $this->getTable() . "`.`faces_id` ='" . PluginRacksRack::FRONT_FACE . "' \n                  AND `glpi_plugin_racks_itemspecifications`.`length` = 1 ))\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>&nbsp;</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("dissipation");
         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() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n              AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n              AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \n                  OR (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \n                     AND `glpi_plugin_racks_itemspecifications`.`length` = 1)) AND `position` ='{$j}'\n              ORDER BY `" . $this->getTable() . "`.`position` ASC";
             } else {
                 $query = "SELECT `" . $this->getTable() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n               AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n               AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \n                  OR (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \n                     AND `glpi_plugin_racks_itemspecifications`.`length` = 1)) AND `position` ='{$j}'\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`.* \n                        FROM `glpi_plugin_racks_itemspecifications` " . " LEFT JOIN `" . $model_table . "` \n                        ON (`glpi_plugin_racks_itemspecifications`.`model_id` = `" . $model_table . "`.`id`)" . " LEFT JOIN `" . $table . "` \n                        ON (`glpi_plugin_racks_itemspecifications`.`model_id` = `" . $table . "`.`" . $modelfield . "` \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 "&nbsp;<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);
                         echo "<td class='center'><a href=\"" . $linkmodel . "?id=" . $device_spec["modelid"] . "\">" . $device_spec["model"] . " (" . $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`\n                                                        FROM `glpi_plugin_racks_roomlocations`\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`\n            FROM `glpi_plugin_racks_racks`\n            LEFT JOIN `glpi_plugin_racks_roomlocations`\n            ON (`glpi_plugin_racks_roomlocations`.`id` = `glpi_plugin_racks_racks`.`plugin_racks_roomlocations_id`)\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'] . "\">\n               <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/left.png\" alt=''>&nbsp;" . __('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`\n            FROM `glpi_plugin_racks_racks`\n            LEFT JOIN `glpi_plugin_racks_roomlocations`\n            ON (`glpi_plugin_racks_roomlocations`.`id` = `glpi_plugin_racks_racks`.`plugin_racks_roomlocations_id`)\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'] . "&nbsp;<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>";
         }
     }
 }
Exemplo n.º 5
0
(at your option) any later version.

Racks is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Racks. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("config", "w");
$plugin = new Plugin();
if ($plugin->isActivated("racks")) {
    $PluginRacksConfig = new PluginRacksConfig();
    if (isset($_POST["update"])) {
        Session::checkRight("config", "w");
        $PluginRacksConfig->update($_POST);
        Html::back();
    } else {
        Html::header(PluginRacksRack::getTypeName(2), '', "plugins", "racks");
        $PluginRacksConfig->showForm($CFG_GLPI["root_doc"] . "/plugins/racks/front/config.form.php");
        Html::footer();
    }
} else {
    Html::header(__('Setup'), '', "config", "plugins");
    echo "<div align='center'><br><br>";
    echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt=\"warning\"><br><br>";
    echo "<b>" . __('Please activate the plugin', 'racks') . "</b></div>";
}
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Racks is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Racks. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("config", UPDATE);
$plugin = new Plugin();
if ($plugin->isActivated("racks")) {
    $config = new PluginRacksConfig();
    if (isset($_POST["update"])) {
        $config->update($_POST);
        Html::back();
    } else {
        Html::header(PluginRacksRack::getTypeName(2), '', "assets", "pluginracksmenu", "config");
        $config->showForm();
        Html::footer();
    }
} else {
    Html::header(__('Setup'), '', "config", "plugins");
    echo "<div align='center'><br><br>";
    echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt=\"warning\"><br><br>";
    echo "<b>" . __('Please activate the plugin', 'racks') . "</b></div>";
}