コード例 #1
0
ファイル: optvalue.class.php プロジェクト: geldarr/hack-space
 function cleanDBonPurge()
 {
     $temp = new PluginAppliancesOptvalue_Item();
     $temp->deleteByCriteria(array('plugin_appliances_optvalues_id' => $this->fields['id']));
 }
コード例 #2
0
 /**
  * Show the Device associated with an applicatif
  *
  * Called from the applicatif form
  **/
 static function showForAppliance(PluginAppliancesAppliance $appli)
 {
     global $DB, $CFG_GLPI;
     $instID = $appli->fields['id'];
     if (!$appli->can($instID, "r")) {
         return false;
     }
     $rand = mt_rand();
     $canedit = $appli->can($instID, 'w');
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_plugin_appliances_appliances_items`\n                WHERE `plugin_appliances_appliances_id` = '" . $instID . "'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     echo "<form method='post' name='appliances_form{$rand}' id='appliances_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/appliances/front/appliance.form.php\">";
     echo "<div class='center'><table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='" . ($canedit ? 6 + $colsup : 5 + $colsup) . "'>" . __('Associated items', 'appliances') . "</th></tr><tr>";
     if ($canedit) {
         echo "<th>&nbsp;</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     if ($appli->fields["relationtype"]) {
         echo "<th>" . __('Item to link', 'appliances') . "<br>" . __('User fields', 'appliances') . "</th>";
     }
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $type = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($type))) {
             continue;
         }
         if ($item->canView()) {
             $column = "name";
             if ($type == 'Ticket') {
                 $column = "id";
             }
             if ($type == 'KnowbaseItem') {
                 $column = "question";
             }
             $query = "SELECT `" . $item->getTable() . "`.*,\n                             `glpi_plugin_appliances_appliances_items`.`id` AS IDD,\n                             `glpi_entities`.`id` AS entity\n                      FROM `glpi_plugin_appliances_appliances_items`, " . getTableForItemType($type) . "\n                      LEFT JOIN `glpi_entities`\n                           ON (`glpi_entities`.`id` = `" . $item->getTable() . "`.`entities_id`)\n                      WHERE `" . $item->getTable() . "`.`id`\n                                 = `glpi_plugin_appliances_appliances_items`.`items_id`\n                            AND `glpi_plugin_appliances_appliances_items`.`itemtype` = '" . $type . "'\n                            AND `glpi_plugin_appliances_appliances_items`.`plugin_appliances_appliances_id`\n                                 = '" . $instID . "' " . getEntitiesRestrictRequest(" AND ", $item->getTable());
             if ($item->maybeTemplate()) {
                 $query .= " AND `" . $item->getTable() . "`.`is_template` = '0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `" . $item->getTable() . "`.{$column}";
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     Session::initNavigateListItems($type, _n('Appliance', 'Appliances', 2, 'appliances') . "\n                                                   = " . $appli->getNameID());
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $item->getFromDB($data["id"]);
                         Session::addToNavigateListItems($type, $data["id"]);
                         //TODO $ID never user - why this part ?
                         $ID = "";
                         if ($type == 'Ticket') {
                             $data["name"] = sprintf(__('%1$s %2$s'), __('Ticket'), $data["id"]);
                         }
                         if ($type == 'KnowbaseItem') {
                             $data["name"] = $data["question"];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $name = $item->getLink();
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             $sel = "";
                             if (isset($_GET["select"]) && $_GET["select"] == "all") {
                                 $sel = "checked";
                             }
                             echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}>";
                             echo "</td>";
                         }
                         echo "<td class='center'>" . $item->getTypeName() . "</td>";
                         echo "<td class='center' " . (isset($data['deleted']) && $data['deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         if (Session::isMultiEntitiesMode()) {
                             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                         }
                         if ($appli->fields["relationtype"]) {
                             echo "<td class='center'>" . PluginAppliancesRelation::getTypeName($appli->fields["relationtype"]) . "&nbsp;:&nbsp;";
                             PluginAppliancesRelation::showList($appli->fields["relationtype"], $data["IDD"], $item->fields["entities_id"], false);
                             PluginAppliancesOptvalue_Item::showList($type, $data["id"], $instID, false);
                             echo "</td>";
                         }
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     if ($canedit) {
         echo "<tr class='tab_bg_1'><td colspan='" . (3 + $colsup) . "' class='center'>";
         echo "<input type='hidden' name='conID' value='{$instID}'>";
         Dropdown::showAllItems("item", 0, 0, $appli->fields['is_recursive'] ? -1 : $appli->fields['entities_id'], $appli->getTypes());
         echo "</td>";
         echo "<td colspan='3' class='center' class='tab_bg_2'>";
         echo "<input type='submit' name='additem' value='" . __('Add') . "' class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
         Html::openArrowMassives("appliances_form{$rand}", true);
         Html::closeArrowMassives(array('deleteitem' => __('Delete permanently')));
     } else {
         echo "</table></div>";
     }
     Html::closeForm();
 }