예제 #1
0
 static function showTypes($item)
 {
     global $DB;
     $type = $item->getType();
     $ID = $item->getID();
     if ($type == 'PluginArchiresLocationQuery') {
         $page = "locationquery";
     } else {
         if ($type == 'PluginArchiresNetworkEquipmentQuery') {
             $page = "networkequipmentquery";
         } else {
             if ($type == 'PluginArchiresApplianceQuery') {
                 $page = "appliancequery";
             }
         }
     }
     $PluginArchiresArchires = new PluginArchiresArchires();
     if (plugin_archires_haveRight('archires', 'w')) {
         echo "<form method='post'  action=\"./" . $page . ".form.php\">";
         echo "<table class='tab_cadre' cellpadding='5' width='34%'><tr><th colspan='2'>";
         echo __('Display types of items', 'archires') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         $PluginArchiresArchires->showAllItems("type", 0, 0, $_SESSION["glpiactive_entity"]);
         echo "</td>";
         echo "<td>";
         echo "<input type='hidden' name='query' value='{$ID}'>";
         echo "<input type='submit' name='addtype' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     }
     $query = "SELECT *\n                FROM `glpi_plugin_archires_querytypes`\n                WHERE `plugin_archires_queries_id` = '{$ID}'\n                      AND `querytype` = '{$type}'\n                ORDER BY `itemtype`, `type` ASC";
     $i = 0;
     $rand = mt_rand();
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<form method='post' name='massiveaction_form{$rand}' id='massiveaction_form{$rand}' " . "action=\"./" . $page . ".form.php\">";
             echo "<div id='liste'>";
             echo "<table class='tab_cadre' cellpadding='5'>";
             echo "<tr>";
             echo "<th class='left'>" . __('Item') . "</th>";
             echo "<th class='left'>" . __('Item type') . "</th><th></th>";
             if ($number > 1) {
                 echo "<th class='left'>" . __('Item') . "</th>";
                 echo "<th class='left'>" . __('Item type') . "</th><th></th>";
             }
             echo "</tr>";
             while ($ligne = $DB->fetch_assoc($result)) {
                 $ID = $ligne["id"];
                 if ($i % 2 == 0 && $number > 1) {
                     echo "<tr class='tab_bg_1'>";
                 }
                 if ($number == 1) {
                     echo "<tr class='tab_bg_1'>";
                 }
                 $item = new $ligne["itemtype"]();
                 echo "<td>" . $item->getTypeName() . "</td>";
                 $class = $ligne["itemtype"] . "Type";
                 $typeclass = new $class();
                 $typeclass->getFromDB($ligne["type"]);
                 echo "<td>" . $typeclass->fields["name"] . "</td>";
                 echo "<td>";
                 echo "<input type='hidden' name='id' value='{$ID}'>";
                 echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
                 echo "</td>";
                 $i++;
                 if ($i == $number && $number % 2 != 0 && $number > 1) {
                     echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
                 }
             }
             if (plugin_archires_haveRight('archires', 'w')) {
                 echo "<tr class='tab_bg_1'>";
                 if ($number > 1) {
                     echo "<td colspan='6' class='center'>";
                 } else {
                     echo "<td colspan='3' class='center'>";
                 }
                 echo "<a onclick= \"if (markCheckboxes('massiveaction_form{$rand}')) return false;\"\n                     href='#'>" . __('Select all') . "</a>";
                 echo " - <a onclick= \"if (unMarkCheckboxes('massiveaction_form{$rand}')) return false;\"\n                     href='#'>" . __('Deselect all') . "</a> ";
                 Html::closeArrowMassives(array('deletetype' => _sx('button', 'Delete permanently')));
             } else {
                 echo "</table>";
             }
             echo "</div>";
             Html::closeForm();
         }
     }
 }