function showComponents($componentscatalogs_id)
 {
     global $DB, $LANG, $CFG_GLPI;
     $this->addComponent($componentscatalogs_id);
     $rand = mt_rand();
     $pmComponent = new PluginMonitoringComponent();
     $pmCommand = new PluginMonitoringCommand();
     $pmCheck = new PluginMonitoringCheck();
     $calendar = new Calendar();
     echo "<form method='post' name='componentscatalog_component_form{$rand}' id='componentscatalog_component_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/componentscatalog_component.form.php\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>";
     echo $LANG['plugin_monitoring']['component'][2];
     echo "</th>";
     echo "</tr>";
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['plugin_monitoring']['command'][2] . "</th>";
     echo "<th>" . $LANG['plugin_monitoring']['check'][0] . "</th>";
     echo "<th>" . $LANG['plugin_monitoring']['host'][9] . "</th>";
     echo "<th>" . $LANG['plugin_monitoring']['service'][8] . "</th>";
     echo "</tr>";
     $used = array();
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $used[] = $data['plugin_monitoring_components_id'];
         $pmComponent->getFromDB($data['plugin_monitoring_components_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $pmComponent->getLink(1);
         echo "</td>";
         echo "<td class='center'>";
         $pmCommand->getFromDB($pmComponent->fields['plugin_monitoring_commands_id']);
         echo $pmCommand->getLink();
         echo "</td>";
         echo "<td class='center'>";
         $pmCheck->getFromDB($pmComponent->fields['plugin_monitoring_checks_id']);
         echo $pmCheck->getLink();
         echo "</td>";
         echo "<td class='center'>";
         $calendar->getFromDB($pmComponent->fields['calendars_id']);
         echo $calendar->getLink();
         echo "</td>";
         echo "<td class='center'>";
         if ($pmComponent->fields['remotesystem'] == '') {
             echo "-";
         } else {
             echo $pmComponent->fields['remotesystem'];
         }
         echo "</td>";
         echo "</tr>";
     }
     openArrowMassive("componentscatalog_host_form{$rand}", true);
     closeArrowMassive('deleteitem', $LANG['buttons'][6]);
     echo "</table>";
 }
 function showSummary(NotificationTemplate $template, $options = array())
 {
     global $DB, $LANG, $CFG_GLPI;
     $nID = $template->getField('id');
     $canedit = haveRight("config", "w");
     if ($canedit) {
         echo "<div class='center'>" . "<a href='" . getItemTypeFormURL('NotificationTemplateTranslation') . "?notificationtemplates_id=" . $nID . "'>" . $LANG['mailing'][124] . "</a></div><br>";
     }
     echo "<div class='center' id='tabsbody'>";
     initNavigateListItems('NotificationTemplateTranslation', $template->getTypeName() . " = " . $template->fields["name"]);
     echo "<form name='form_language' id='form_language' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th></th><th>" . $LANG['setup'][41] . "</th></tr>";
     foreach ($DB->request('glpi_notificationtemplatetranslations', array('notificationtemplates_id' => $nID)) as $data) {
         if ($this->getFromDB($data['id'])) {
             addToNavigateListItems('NotificationTemplateTranslation', $data['id']);
             echo "<tr class='tab_bg_1'><td class='center'>";
             echo "<input type='checkbox' name=\"languages[" . $data['id'] . "]\"></td>";
             echo "<td class='center'>";
             echo "<a href='" . getItemTypeFormURL('NotificationTemplateTranslation') . "?id=" . $data['id'] . "&notificationtemplates_id=" . $nID . "'>";
             if ($data['language'] != '') {
                 echo $CFG_GLPI['languages'][$data['language']][0];
             } else {
                 echo $LANG['mailing'][125];
             }
             echo "</a></td></tr>";
         }
     }
     echo "</table>";
     if ($canedit) {
         openArrowMassive("form_language", true);
         closeArrowMassive("delete_languages", $LANG["buttons"][6]);
     }
 }
Пример #3
0
 /**
  * Show items for the group
  */
 function showItems()
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $this->fields['id'];
     echo "<div class='spaced'>";
     echo "<form name='group_form' id='group_form' method='post' action='" . $this->getFormURL() . "'>";
     echo "<table class='tab_cadre_fixe'><tr><th width='10'>&nbsp</th>";
     echo "<th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th><th>" . $LANG['entity'][0] . "</th></tr>";
     foreach ($CFG_GLPI["linkgroup_types"] as $itemtype) {
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         $query = "SELECT *\n                   FROM `" . $item->getTable() . "`\n                   WHERE `groups_id` = '{$ID}'" . getEntitiesRestrictRequest(" AND ", getTableForItemType($itemtype), '', '', $item->maybeRecursive());
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             $type_name = $item->getTypeName();
             $cansee = $item->canView();
             $canedit = $item->canUpdate();
             while ($data = $DB->fetch_array($result)) {
                 echo "<tr class='tab_bg_1'><td>";
                 if ($canedit) {
                     echo "<input type='checkbox' name='item[{$itemtype}][" . $data["id"] . "]' value='1'>";
                 }
                 $link = $data["name"] ? $data["name"] : "(" . $data["id"] . ")";
                 if ($cansee) {
                     $link = "<a href='" . $item->getFormURL() . "?id=" . $data["id"] . "'>" . $link . "</a>";
                 }
                 echo "</td><td>{$type_name}</td><td>{$link}</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']);
                 echo "</td></tr>";
             }
         }
     }
     echo "</table>";
     openArrowMassive("group_form", true);
     echo $LANG['common'][35] . "&nbsp;:&nbsp;";
     Dropdown::show('Group', array('entity' => $this->fields["entities_id"], 'used' => array($this->fields["id"])));
     echo "&nbsp;";
     closeArrowMassive('changegroup', $LANG['buttons'][20]);
     echo "</form></div>";
 }
 /**
  * Display category footer for Computer_SoftwareVersion::showForComputer function
  *
  * @param $cat current category ID
  * @param $rand random for unicity
  * @param $canedit boolean
  *
  * @return new category ID
  **/
 private static function displayCategoryFooter($cat, $rand, $canedit)
 {
     global $LANG;
     // Close old one
     if ($cat != -1) {
         echo "</table>";
         if ($canedit) {
             openArrowMassive("lic_form{$cat}{$rand}", true);
             if (isset($cat)) {
                 closeArrowMassive('massuninstall', $LANG['buttons'][5]);
             } else {
                 closeArrowMassive('massinstall', $LANG['buttons'][4]);
             }
         }
         echo "</form>";
         echo "</div></td></tr>";
     }
 }
 /**
  * Show computers linked to a License
  *
  * @param $license SoftwareLicense object
  *
  * @return nothing
  **/
 static function showForLicense(SoftwareLicense $license)
 {
     global $DB, $CFG_GLPI, $LANG;
     $searchID = $license->getField('id');
     if (!haveRight("software", "r") || !$searchID) {
         return false;
     }
     $canedit = haveRight("software", "w");
     $canshowcomputer = haveRight("computer", "r");
     if (isset($_REQUEST["start"])) {
         $start = $_REQUEST["start"];
     } else {
         $start = 0;
     }
     if (isset($_REQUEST["order"]) && $_REQUEST["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     if (isset($_REQUEST["sort"]) && !empty($_REQUEST["sort"])) {
         // manage several param like location,compname : order first
         $tmp = explode(",", $_REQUEST["sort"]);
         $sort = "`" . implode("` {$order},`", $tmp) . "`";
     } else {
         $sort = "`entity` {$order}, `compname`";
     }
     //SoftwareLicense ID
     $query_number = "SELECT COUNT(*) AS cpt\n                       FROM `glpi_computers_softwarelicenses`\n                       INNER JOIN `glpi_computers`\n                           ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n                       WHERE `glpi_computers_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                             AND `glpi_computers`.`is_deleted` = '0'\n                             AND `glpi_computers`.`is_template` = '0'";
     $number = 0;
     if ($result = $DB->query($query_number)) {
         $number = $DB->result($result, 0, 0);
     }
     echo "<div class='center'>";
     if ($canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'>";
         echo "<td>";
         Dropdown::show('Computer', array('entity' => $license->fields['entities_id'], 'entity_sons' => $license->fields['is_recursive']));
         echo "</td>";
         echo "<td><input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></form>";
     }
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . $LANG['search'][15] . "</th></tr>";
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     printAjaxPager($LANG['software'][9], $start, $number);
     $query = "SELECT `glpi_computers_softwarelicenses`.*,\n                       `glpi_computers`.`name` AS compname,\n                       `glpi_computers`.`id` AS cID,\n                       `glpi_computers`.`serial`,\n                       `glpi_computers`.`otherserial`,\n                       `glpi_users`.`name` AS username,\n                       `glpi_softwarelicenses`.`name` AS license,\n                       `glpi_softwarelicenses`.`id` AS vID,\n                       `glpi_softwarelicenses`.`name` AS vername,\n                       `glpi_entities`.`completename` AS entity,\n                       `glpi_locations`.`completename` AS location,\n                       `glpi_states`.`name` AS state,\n                       `glpi_groups`.`name` AS groupe,\n                       `glpi_softwarelicenses`.`name` AS lname,\n                       `glpi_softwarelicenses`.`id` AS lID\n                FROM `glpi_computers_softwarelicenses`\n                INNER JOIN `glpi_softwarelicenses`\n                     ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                          = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_computers`\n                     ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n                LEFT JOIN `glpi_locations`\n                     ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n                LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n                LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n                WHERE (`glpi_softwarelicenses`.`id` = '{$searchID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                       AND `glpi_computers`.`is_deleted` = '0'\n                       AND `glpi_computers`.`is_template` = '0'\n                ORDER BY {$sort} {$order}\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $rand = mt_rand();
     if ($result = $DB->query($query)) {
         if ($data = $DB->fetch_assoc($result)) {
             $soft = new Software();
             $soft->getFromDB($license->fields['softwares_id']);
             $showEntity = $license->isRecursive();
             $title = $LANG['help'][31] . " = " . $soft->fields["name"] . " - " . $data["vername"];
             initNavigateListItems('Computer', $title);
             $sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt='' title=''>";
             if ($canedit) {
                 echo "<form name='softinstall" . $rand . "' id='softinstall" . $rand . "' method='post'\n                      action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
                 echo "<table class='tab_cadre_fixehov'><tr>";
                 echo "<th>&nbsp;</th>";
             } else {
                 echo "<table class='tab_cadre_fixehov'><tr>";
             }
             echo "<th>" . ($sort == "`compname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][16] . "</a></th>";
             if ($showEntity) {
                 echo "<th>" . (strstr($sort, "entity") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=entity,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['entity'][0] . "</a></th>";
             }
             echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][19] . "</a></th>";
             echo "<th>" . ($sort == "`otherserial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=otherserial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][20] . "</a></th>";
             echo "<th>" . (strstr($sort, "`location`") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=location,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][15] . "</a></th>";
             echo "<th>" . (strstr($sort, "state") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=state,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['state'][0] . "</a></th>";
             echo "<th>" . (strstr($sort, "groupe") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=groupe,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][35] . "</a></th>";
             echo "<th>" . (strstr($sort, "username") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=username,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][34] . "</a></th>";
             echo "</tr>\n";
             do {
                 addToNavigateListItems('Computer', $data["cID"]);
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td><input type='checkbox' name='item[" . $data["id"] . "]' value='1'></td>";
                 }
                 $compname = $data['compname'];
                 if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
                     $compname .= " (" . $data['cID'] . ")";
                 }
                 if ($canshowcomputer) {
                     echo "<td><a href='computer.form.php?id=" . $data['cID'] . "'>{$compname}</a></td>";
                 } else {
                     echo "<td>" . $compname . "</td>";
                 }
                 if ($showEntity) {
                     echo "<td>" . (empty($data['entity']) ? $LANG['entity'][2] : $data['entity']) . "</td>";
                 }
                 echo "<td>" . $data['serial'] . "</td>";
                 echo "<td>" . $data['otherserial'] . "</td>";
                 echo "<td>" . $data['location'] . "</td>";
                 echo "<td>" . $data['state'] . "</td>";
                 echo "<td>" . $data['groupe'] . "</td>";
                 echo "<td>" . $data['username'] . "</td>";
                 echo "</tr>\n";
             } while ($data = $DB->fetch_assoc($result));
             echo "</table>\n";
             if ($canedit) {
                 openArrowMassive("softinstall" . $rand . "", true);
                 Dropdown::show('SoftwareLicense', array('condition' => "`glpi_softwarelicenses`.`softwares_id`\n                                                      = '" . $license->fields['softwares_id'] . "'", 'used' => array($searchID)));
                 echo "&nbsp;<input type='submit' name='move' value=\"" . $LANG['buttons'][20] . "\" class='submit'>&nbsp;";
                 closeArrowMassive('delete', $LANG['buttons'][6]);
                 echo "</form>";
             }
         } else {
             // Not found
             echo $LANG['search'][15];
         }
     }
     // Query
     echo "</div>\n";
 }
 function showContacts($itemtype, $items_id)
 {
     global $DB, $LANG, $CFG_GLPI;
     $this->addContact($itemtype, $items_id);
     $group = new Group();
     $user = new User();
     $rand = mt_rand();
     echo "<form method='post' name='contact_item_form{$rand}' id='contact_item_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/contact_item.form.php\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>";
     echo $LANG['plugin_monitoring']['contact'][20];
     echo "</th>";
     echo "</tr>";
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . $LANG['common'][35] . " - " . $LANG['common'][16] . "</th>";
     echo "<th colspan='3'></th>";
     echo "</tr>";
     $used = array();
     // Display groups first
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `items_id`='" . $items_id . "'\n            AND `itemtype`='" . $itemtype . "'\n            AND `groups_id` > 0";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $group->getFromDB($data['groups_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $group->getLink(1);
         echo "</td>";
         echo "<td colspan='3'>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . $LANG['common'][34] . " - " . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['setup'][14] . "</th>";
     echo "<th>" . $LANG['help'][35] . "</th>";
     echo "</tr>";
     $entity = new Entity();
     $used = array();
     // Display Users
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `items_id`='" . $items_id . "'\n            AND `itemtype`='" . $itemtype . "'\n            AND `users_id` > 0";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $user->getFromDB($data['users_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->getLink(1);
         echo "</td>";
         $entity->getFromDB($data['entities_id']);
         echo "<td class='center'>";
         echo $entity->getName() . " <strong>(R)</strong>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['email'];
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['phone'];
         echo "</td>";
         echo "</tr>";
     }
     openArrowMassive("contact_item_form{$rand}", true);
     closeArrowMassive('deleteitem', $LANG['buttons'][6]);
     echo "</table>";
 }
 /**
  * Show the User having a profile, in allowed Entity
  *
  * @param $prof object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB, $LANG, $CFG_GLPI;
     $ID = $prof->fields['id'];
     $canedit = haveRight("user", "w");
     if (!$prof->can($ID, 'r')) {
         return false;
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixe'><tr>";
     echo "<th>" . $LANG['profiles'][22] . "&nbsp;:<span class='small_space'>" . $prof->fields["name"] . "</span></th></tr>\n";
     echo "<tr><th colspan='2'>" . $LANG['Menu'][14] . " (D=" . $LANG['profiles'][29] . ", R=" . $LANG['profiles'][28] . ")</th></tr>";
     echo "</table>\n";
     $query = "SELECT `glpi_users`.*,\n                       `glpi_profiles_users`.`entities_id` AS entity,\n                       `glpi_profiles_users`.`id` AS linkID,\n                       `glpi_profiles_users`.`is_dynamic`,\n                       `glpi_profiles_users`.`is_recursive`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_entities`.`id`=`glpi_profiles_users`.`entities_id`)\n                LEFT JOIN `glpi_users`\n                     ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`profiles_id` = '{$ID}'\n                      AND `glpi_users`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_profiles_users", 'entities_id', $_SESSION['glpiactiveentities'], true) . "\n                ORDER BY `glpi_entities`.`completename`";
     echo "<table class='tab_cadre_fixe'>";
     $i = 0;
     $nb_per_line = 3;
     $rand = mt_rand();
     // Just to avoid IDE warning
     $canedit_entity = false;
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result) != 0) {
             $temp = -1;
             while ($data = $DB->fetch_array($result)) {
                 if ($data["entity"] != $temp) {
                     while ($i % $nb_per_line != 0) {
                         if ($canedit_entity) {
                             echo "<td width='10'>&nbsp;</td>";
                         }
                         echo "<td class='tab_bg_1'>&nbsp;</td>\n";
                         $i++;
                     }
                     if ($i != 0) {
                         echo "</table>";
                         if ($canedit_entity) {
                             openArrowMassive("profileuser_form" . $rand . "_{$temp}", true);
                             Dropdown::show('Entity', array('entity' => $_SESSION['glpiactiveentities']));
                             echo "&nbsp;<input type='submit' name='moveentity' value='" . $LANG['buttons'][20] . "' class='submit'>&nbsp;";
                             closeArrowMassive('delete', $LANG['buttons'][6]);
                         }
                         echo "</div></form></td></tr>\n";
                     }
                     // New entity
                     $i = 0;
                     $temp = $data["entity"];
                     $canedit_entity = $canedit && in_array($temp, $_SESSION['glpiactiveentities']);
                     $rand = mt_rand();
                     echo "<tr class='tab_bg_2'>";
                     echo "<td class='left'>";
                     echo "<a href=\"javascript:showHideDiv('entity{$temp}{$rand}','imgcat{$temp}', '" . GLPI_ROOT . "/pics/folder.png','" . GLPI_ROOT . "/pics/folder-open.png');\">";
                     echo "<img alt='' name='imgcat{$temp}' src=\"" . GLPI_ROOT . "/pics/folder.png\">&nbsp;";
                     echo "<strong>" . Dropdown::getDropdownName('glpi_entities', $data["entity"]) . "</strong>";
                     echo "</a></td></tr>\n";
                     echo "<tr><td>";
                     echo "<form name='profileuser_form" . $rand . "_{$temp}' id='profileuser_form" . $rand . "_{$temp}' method='post' action='" . getItemTypeFormURL(__CLASS__) . "'>";
                     echo "<div class='center' id='entity{$temp}{$rand}' style='display:none;'>\n";
                     echo "<table class='tab_cadre_fixe'>\n";
                 }
                 if ($i % $nb_per_line == 0) {
                     if ($i != 0) {
                         echo "</tr>\n";
                     }
                     echo "<tr class='tab_bg_1'>\n";
                     $i = 0;
                 }
                 if ($canedit_entity) {
                     echo "<td width='10'>";
                     $sel = "";
                     if (isset($_GET["select"]) && $_GET["select"] == "all") {
                         $sel = "checked";
                     }
                     echo "<input type='checkbox' name='item[" . $data["linkID"] . "]' value='1' {$sel}>";
                     echo "</td>";
                 }
                 echo "<td class='tab_bg_1'>" . formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
                 if ($data["is_dynamic"] || $data["is_recursive"]) {
                     echo "<strong>&nbsp;(";
                     if ($data["is_dynamic"]) {
                         echo "D";
                     }
                     if ($data["is_dynamic"] && $data["is_recursive"]) {
                         echo ", ";
                     }
                     if ($data["is_recursive"]) {
                         echo "R";
                     }
                     echo ")</strong>";
                 }
                 echo "</td>\n";
                 $i++;
             }
             if ($i % $nb_per_line != 0) {
                 while ($i % $nb_per_line != 0) {
                     if ($canedit_entity) {
                         echo "<td width='10'>&nbsp;</td>";
                     }
                     echo "<td class='tab_bg_1'>" . DROPDOWN_EMPTY_VALUE . "</td>";
                     $i++;
                 }
             }
             if ($i != 0) {
                 echo "</table>\n";
                 if ($canedit_entity) {
                     openArrowMassive("profileuser_form" . $rand . "_{$temp}", true);
                     Dropdown::show('Entity', array('entity' => $_SESSION['glpiactiveentities']));
                     echo "&nbsp;<input type='submit' name='moveentity' value='" . $LANG['buttons'][20] . "' class='submit'>&nbsp;";
                     closeArrowMassive('delete', $LANG['buttons'][6]);
                 }
                 echo "</div></form></td></tr>\n";
             }
         } else {
             echo "<tr><td class='tab_bg_1 center'>" . $LANG['profiles'][33] . "</td></tr>\n";
         }
     }
     echo "</table></div>\n";
 }
Пример #8
0
 /**
  * Print the HTML array of the Netpoint associated to a Location
  *
  *@param $ID of the Location
  *
  *@return Nothing (display)
  **/
 function showNetpoints($ID)
 {
     global $DB, $CFG_GLPI, $LANG;
     $netpoint = new Netpoint();
     $this->check($ID, 'r');
     $canedit = $this->can($ID, 'w');
     if (isset($_REQUEST["start"])) {
         $start = $_REQUEST["start"];
     } else {
         $start = 0;
     }
     $number = countElementsInTable('glpi_netpoints', "`locations_id`='{$ID}'");
     echo "<br><div class='center'>";
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan>" . $LANG['networking'][51] . " - " . $LANG['search'][15] . "</th></tr>";
         echo "</table>\n";
     } else {
         printAjaxPager($this->getTreeLink() . " - " . $LANG['networking'][51], $start, $number);
         if ($canedit) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action='" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php'>";
         }
         echo "<table class='tab_cadre_fixe'><tr>";
         if ($canedit) {
             echo "<th width='10'>&nbsp;</th>";
         }
         echo "<th>" . $LANG['common'][16] . "</th>";
         // Name
         echo "<th>" . $LANG['common'][25] . "</th>";
         // Comment
         echo "</tr>\n";
         $crit = array('locations_id' => $ID, 'ORDER' => 'name', 'START' => $start, 'LIMIT' => $_SESSION['glpilist_limit']);
         initNavigateListItems('Netpoint', $this->getTypeName() . "= " . $this->fields['name']);
         foreach ($DB->request('glpi_netpoints', $crit) as $data) {
             addToNavigateListItems('Netpoint', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td><input type='checkbox' name='item[" . $data["id"] . "]' value='1'></td>";
             }
             echo "<td><a href='" . $netpoint->getFormURL();
             echo '?id=' . $data['id'] . "'>" . $data['name'] . "</a></td>";
             echo "<td>" . $data['comment'] . "</td>";
             echo "</tr>\n";
         }
         echo "</table>\n";
         if ($canedit) {
             openArrowMassive("massiveaction_form", true);
             echo "<input type='hidden' name='itemtype' value='Netpoint'>";
             echo "<input type='hidden' name='action' value='delete'>";
             closeArrowMassive('massiveaction', $LANG['buttons'][6]);
             echo "</form>\n";
         }
     }
     if ($canedit) {
         // Minimal form for quick input.
         echo "<form action='" . $netpoint->getFormURL() . "' method='post'>";
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'><td class='b'>" . $LANG['common'][87] . "</td>";
         echo "<td>" . $LANG['common'][16] . "&nbsp;: ";
         autocompletionTextField($this, "name", array('value' => ''));
         echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>";
         echo "<input type='hidden' name='locations_id' value='{$ID}'></td>";
         echo "<td><input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table></form>\n";
         // Minimal form for massive input.
         echo "<form action='" . $netpoint->getFormURL() . "' method='post'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'><td class='b'>" . $LANG['common'][87] . "</td>";
         echo "<td>" . $LANG['common'][16] . "&nbsp;: ";
         echo "<input type='text' maxlength='100' size='10' name='_before'>&nbsp;";
         Dropdown::showInteger('_from', 0, 0, 400);
         echo "&nbsp;-->&nbsp;";
         Dropdown::showInteger('_to', 0, 0, 400);
         echo "&nbsp;<input type='text' maxlength='100' size='10' name='_after'><br>";
         echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>";
         echo "<input type='hidden' name='locations_id' value='{$ID}'></td>";
         echo "<input type='hidden' name='_method' value='addMulti'></td>";
         echo "<td><input type='submit' name='execute' value=\"" . $LANG['buttons'][8] . "\"\n                    class='submit'>";
         echo "</td></tr>\n";
         echo "</table></form>\n";
     }
     echo "</div>\n";
 }
Пример #9
0
 /**
  * Show users of a group
  *
  * @param $target string : where to go on action
  * @param $group the group
  **/
 static function showForGroup($target, Group $group)
 {
     global $DB, $LANG;
     $ID = $group->fields['id'];
     if (!haveRight("user", "r") || !$group->can($ID, 'r')) {
         return false;
     }
     // Have right to manage members
     $canedit = $group->can($ID, 'r') && $group->canUpdate();
     $rand = mt_rand();
     $nb_per_line = 3;
     $query = "SELECT `glpi_users`.*,\n                       `glpi_groups_users`.`id` AS linkID,\n                       `glpi_groups_users`.`is_dynamic` AS is_dynamic\n                FROM `glpi_groups_users`\n                LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_groups_users`.`users_id`)\n                WHERE `glpi_groups_users`.`groups_id`='{$ID}'\n                ORDER BY `glpi_users`.`name`,\n                         `glpi_users`.`realname`,\n                         `glpi_users`.`firstname`";
     $used = array();
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_array($result)) {
             $used[$data["id"]] = $data;
         }
     }
     $used_ids = array_keys($used);
     if ($canedit) {
         $headerspan = $nb_per_line * 2;
         echo "<form name='groupuser_form{$rand}' id='groupuser_form{$rand}' method='post'\n                action='{$target}'>";
         echo "<input type='hidden' name='groups_id' value='{$ID}'>";
         if ($group->fields['is_recursive']) {
             $entityrestrict = getSonsOf('glpi_entities', $group->fields['entities_id']);
             // active entity could be a child of object entity
             if ($_SESSION['glpiactive_entity'] != $group->fields['entities_id'] && in_array($_SESSION['glpiactive_entity'], $entityrestrict)) {
                 $entityrestrict = getSonsOf('glpi_entities', $_SESSION['glpiactive_entity']);
             }
         } else {
             $entityrestrict = $group->fields['entities_id'];
         }
         $res = User::getSqlSearchResult(true, "all", $entityrestrict, 0, $used_ids);
         $nb = $res ? $DB->result($res, 0, "CPT") : 0;
         if ($nb) {
             echo "<div class='firstbloc'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'><th colspan='2'>" . $LANG['setup'][603] . "</tr>";
             echo "<tr><td class='tab_bg_2 center'>";
             User::dropdown(array('right' => "all", 'entity' => $entityrestrict, 'used' => $used_ids));
             echo "</td><td class='tab_bg_2 center'>";
             echo "<input type='hidden' name'is_dynamic' value='0'>";
             echo "<input type='submit' name='adduser' value=\"" . $LANG['buttons'][8] . "\"\n                   class='submit'>";
             echo "</td></tr>";
             echo "</table></div>";
         }
     } else {
         $headerspan = $nb_per_line;
     }
     if (count($used)) {
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='{$headerspan}'>" . $LANG['Menu'][14] . " (D=" . $LANG['profiles'][29] . ")";
         echo "</th></tr>";
         initNavigateListItems('User', $group->getTypeName() . " = " . $group->getName());
         $i = 0;
         $user = new User();
         foreach ($used as $id => $data) {
             if (!$user->can($id, 'r')) {
                 // For recursive group, could be in another (sister) entity
                 continue;
             }
             addToNavigateListItems('User', $data["id"]);
             if ($i % $nb_per_line == 0) {
                 if ($i != 0) {
                     echo "</tr>";
                 }
                 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["linkID"] . "]' value='1' {$sel}>";
                 echo "</td>";
             }
             echo "<td>";
             echo $user->getLink();
             if ($data["is_dynamic"]) {
                 echo "<strong>&nbsp;(D)</strong>";
             }
             echo "</td>";
             $i++;
         }
         while ($i % $nb_per_line != 0) {
             echo "<td>&nbsp;</td>";
             if ($canedit) {
                 echo "<td>&nbsp;</td>";
             }
             $i++;
         }
         echo "</tr>";
         echo "</table>";
         if ($canedit) {
             openArrowMassive("groupuser_form{$rand}", true);
             closeArrowMassive('deleteuser', $LANG['buttons'][6]);
         }
         echo "</div>";
     }
     if ($canedit) {
         echo "</form>";
     }
 }
 /**
  * Show holidays for a calendar
  *
  * @param $calendar Calendar object
  **/
 static function showForCalendar(Calendar $calendar)
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $calendar->getField('id');
     if (!$calendar->can($ID, 'r')) {
         return false;
     }
     $canedit = $calendar->can($ID, 'w');
     $rand = mt_rand();
     echo "<form name='calendarholiday_form{$rand}' id='calendarholiday_form{$rand}' method='post'\n             action='";
     echo getItemTypeFormURL(__CLASS__) . "'>";
     echo "<div class='center'><table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='2'>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['buttons'][33] . "</th>";
     echo "<th>" . $LANG['buttons'][32] . "</th>";
     echo "<th>" . $LANG['calendar'][3] . "</th>";
     echo "</tr>";
     $query = "SELECT DISTINCT `glpi_calendars_holidays`.`id` AS linkID,\n                                `glpi_holidays`.*\n                FROM `glpi_calendars_holidays`\n                LEFT JOIN `glpi_holidays`\n                     ON (`glpi_calendars_holidays`.`holidays_id` = `glpi_holidays`.`id`)\n                WHERE `glpi_calendars_holidays`.`calendars_id` = '{$ID}'\n                ORDER BY `glpi_holidays`.`name`";
     $result = $DB->query($query);
     $used = array();
     if ($DB->numrows($result) > 0) {
         initNavigateListItems('Holiday', $LANG['buttons'][15] . " = " . $calendar->fields["name"]);
         while ($data = $DB->fetch_array($result)) {
             addToNavigateListItems('Holiday', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10'>";
             if ($canedit) {
                 echo "<input type='checkbox' name='item[" . $data["linkID"] . "]' value='1'>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             $used[] = $data['id'];
             echo "<td><a href='" . getItemTypeFormURL('Holiday') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>";
             echo "<td>" . convDate($data["begin_date"]) . "</td>";
             echo "<td>" . convDate($data["end_date"]) . "</td>";
             echo "<td>" . Dropdown::getYesNo($data["is_perpetual"]) . "</td>";
             echo "</tr>";
         }
     }
     if ($canedit) {
         echo "<tr class='tab_bg_2'><td class='right'  colspan='4'>";
         echo "<input type='hidden' name='calendars_id' value='{$ID}'>";
         Dropdown::show('Holiday', array('used' => $used, 'entity' => $calendar->fields["entities_id"]));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
     }
     echo "</table></div>";
     if ($canedit) {
         openArrowMassive("calendarholiday_form{$rand}", true);
         closeArrowMassive('delete', $LANG['buttons'][6]);
     }
     echo "</form>";
 }
Пример #11
0
 /**
  * Show softwares candidates to be merged with the current
  *
  * @return nothing
  **/
 function showMergeCandidates()
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $this->getField('id');
     $this->check($ID, "w");
     $rand = mt_rand();
     echo "<div class='center'>";
     $sql = "SELECT `glpi_softwares`.`id`,\n                     `glpi_softwares`.`name`,\n                     `glpi_entities`.`completename` AS entity\n              FROM `glpi_softwares`\n              LEFT JOIN `glpi_entities` ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)\n              WHERE (`glpi_softwares`.`id` != '{$ID}'\n                     AND `glpi_softwares`.`name` = '" . addslashes($this->fields["name"]) . "'\n                     AND `glpi_softwares`.`is_deleted` = '0'\n                     AND `glpi_softwares`.`is_template` = '0' " . getEntitiesRestrictRequest('AND', 'glpi_softwares', 'entities_id', getSonsOf("glpi_entities", $this->fields["entities_id"]), false) . ")\n              ORDER BY `entity`";
     $req = $DB->request($sql);
     if ($req->numrows()) {
         $link = getItemTypeFormURL('Software');
         echo "<form method='post' name='mergesoftware_form{$rand}' id='mergesoftware_form{$rand}'\n                action='" . $link . "'>";
         echo "<table class='tab_cadre_fixehov'><tr><th>&nbsp;</th>";
         echo "<th>" . $LANG['common'][16] . "</th>";
         echo "<th>" . $LANG['entity'][0] . "</th>";
         echo "<th>" . $LANG['software'][19] . "</th>";
         echo "<th>" . $LANG['software'][11] . "</th></tr>";
         foreach ($req as $data) {
             echo "<tr class='tab_bg_2'>";
             echo "<td><input type='checkbox' name='item[" . $data["id"] . "]' value='1'></td>";
             echo "<td<a href='" . $link . "?id=" . $data["id"] . "'>" . $data["name"] . "</a></td>";
             echo "<td>" . $data["entity"] . "</td>";
             echo "<td class='right'>" . Computer_SoftwareVersion::countForSoftware($data["id"]) . "</td>";
             echo "<td class='right'>" . SoftwareLicense::countForSoftware($data["id"]) . "</td></tr>\n";
         }
         echo "</table>\n";
         openArrowMassive("mergesoftware_form{$rand}", true);
         echo "<input type='hidden' name='id' value='{$ID}'>";
         closeArrowMassive('mergesoftware', $LANG['software'][48]);
         echo "</form>";
     } else {
         echo $LANG['search'][15];
     }
     echo "</div>";
 }
Пример #12
0
 function showAndAddRuleForm($item)
 {
     global $LANG;
     $canedit = haveRight($this->right, "w");
     if ($canedit && $item->getType() == 'Entity') {
         $this->showNewRuleForm($item->getField('id'));
     }
     //Get all rules and actions
     $crit = array('field' => getForeignKeyFieldForTable($item->getTable()), 'value' => $item->getField('id'));
     $rules = $this->getRulesForCriteria($crit);
     echo "<div class='spaced'>";
     if (empty($rules)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th>" . $LANG['search'][15] . "</th>";
         echo "</tr>\n";
         echo "</table>\n";
     } else {
         if ($canedit) {
             $formname = $item->getType() . "_" . $this->getType() . "_form";
             echo "\n<form name='{$formname}' id='{$formname}' method='post' " . "action='" . getItemTypeSearchURL(get_class($this)) . "'>";
         }
         echo "<table class='tab_cadre_fixehov'><tr>";
         if ($canedit) {
             echo "<th></th>";
         }
         echo "<th>" . $this->getTitle() . "</th>";
         echo "<th>" . $LANG['joblist'][6] . "</th>";
         echo "<th>" . $LANG['common'][60] . "</th>";
         echo "</tr>\n";
         initNavigateListItems(get_class($this), $item->getTypeName() . "=" . $item->getName());
         foreach ($rules as $rule) {
             addToNavigateListItems(get_class($this), $rule->fields["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 echo "<input type='checkbox' name='item[" . $rule->fields["id"] . "]' value='1'>";
                 echo "</td>";
                 echo "<td><a href='" . getItemTypeFormURL(get_class($this)) . "?id=" . $rule->fields["id"] . "&amp;onglet=1'>" . $rule->fields["name"] . "</a></td>";
             } else {
                 echo "<td>" . $rule->fields["name"] . "</td>";
             }
             echo "<td>" . $rule->fields["description"] . "</td>";
             echo "<td>" . Dropdown::getYesNo($rule->fields["is_active"]) . "</td>";
             echo "</tr>\n";
         }
         echo "</table>\n";
         if ($canedit) {
             openArrowMassive($formname, true);
             echo "<input type='hidden' name='action' value='delete'>";
             closeArrowMassive('massiveaction', $LANG['buttons'][6]);
             echo "</form>";
         }
     }
     echo "</div>";
 }
Пример #13
0
 /**
     * Generic Search and list function
     *
     * Build the query, make the search and list items after a search.
     *
     * @param $itemtype item type
     * @param $params parameters array may include field, contains, searchtype, sort, order, start,
                      deleted, link, link2, contains2, field2, itemtype2, searchtype2
     *
     * @return Nothing (display)
    **/
 static function showList($itemtype, $params)
 {
     global $DB, $CFG_GLPI, $LANG;
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     if ($p['export_all']) {
         $p['start'] = 0;
     }
     // Manage defautll seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     $target = getItemTypeSearchURL($itemtype);
     $limitsearchopt = self::getCleanedOptions($itemtype);
     if (isset($CFG_GLPI['union_search_type'][$itemtype])) {
         $itemtable = $CFG_GLPI['union_search_type'][$itemtype];
     } else {
         $itemtable = getTableForItemType($itemtype);
     }
     $LIST_LIMIT = $_SESSION['glpilist_limit'];
     // Set display type for export if define
     $output_type = HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == GLOBAL_SEARCH) {
             $LIST_LIMIT = GLOBAL_SEARCH_DISPLAY_COUNT;
         }
     }
     // hack for States
     if (isset($CFG_GLPI['union_search_type'][$itemtype])) {
         $entity_restrict = true;
     } else {
         $entity_restrict = $item->isEntityAssign();
     }
     $metanames = array();
     // Get the items to display
     $toview = self::addDefaultToView($itemtype);
     // Add items to display depending of personal prefs
     $displaypref = DisplayPreference::getForTypeUser($itemtype, getLoginUserID());
     if (count($displaypref)) {
         foreach ($displaypref as $val) {
             array_push($toview, $val);
         }
     }
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
     // Add order item
     if (!in_array($p['sort'], $toview)) {
         array_push($toview, $p['sort']);
     }
     // Special case for Ticket : put ID in front
     if ($itemtype == 'Ticket') {
         array_unshift($toview, 2);
     }
     // Clean toview array
     $toview = array_unique($toview);
     foreach ($toview as $key => $val) {
         if (!isset($limitsearchopt[$val])) {
             unset($toview[$key]);
         }
     }
     $toview_count = count($toview);
     // Construct the request
     //// 1 - SELECT
     // request currentuser for SQL supervision, not displayed
     $SELECT = "SELECT '" . $_SESSION['glpiname'] . "' AS currentuser, " . self::addDefaultSelect($itemtype);
     // Add select for all toview item
     foreach ($toview as $key => $val) {
         $SELECT .= self::addSelect($itemtype, $val, $key, 0);
     }
     //// 2 - FROM AND LEFT JOIN
     // Set reference table
     $FROM = " FROM `{$itemtable}`";
     // Init already linked tables array in order not to link a table several times
     $already_link_tables = array();
     // Put reference table
     array_push($already_link_tables, $itemtable);
     // Add default join
     $COMMONLEFTJOIN = self::addDefaultJoin($itemtype, $itemtable, $already_link_tables);
     $FROM .= $COMMONLEFTJOIN;
     $searchopt = array();
     $searchopt[$itemtype] =& self::getOptions($itemtype);
     // Add all table for toview items
     foreach ($toview as $key => $val) {
         $FROM .= self::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]);
     }
     // Search all case :
     if (in_array("all", $p['field'])) {
         foreach ($searchopt[$itemtype] as $key => $val) {
             // Do not search on Group Name
             if (is_array($val)) {
                 $FROM .= self::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]);
             }
         }
     }
     //// 3 - WHERE
     // default string
     $COMMONWHERE = self::addDefaultWhere($itemtype);
     $first = empty($COMMONWHERE);
     // Add deleted if item have it
     if ($item && $item->maybeDeleted()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $COMMONWHERE .= $LINK . "`{$itemtable}`.`is_deleted` = '" . $p['is_deleted'] . "' ";
     }
     // Remove template items
     if ($item && $item->maybeTemplate()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $COMMONWHERE .= $LINK . "`{$itemtable}`.`is_template` = '0' ";
     }
     // Add Restrict to current entities
     if ($entity_restrict) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         if ($itemtype == 'Entity') {
             $COMMONWHERE .= getEntitiesRestrictRequest($LINK, $itemtable, 'id', '', true);
         } else {
             if (isset($CFG_GLPI["union_search_type"][$itemtype])) {
                 // Will be replace below in Union/Recursivity Hack
                 $COMMONWHERE .= $LINK . " ENTITYRESTRICT ";
             } else {
                 $COMMONWHERE .= getEntitiesRestrictRequest($LINK, $itemtable, '', '', $item->maybeRecursive());
             }
         }
     }
     $WHERE = "";
     $HAVING = "";
     // Add search conditions
     // If there is search items
     if ($_SESSION["glpisearchcount"][$itemtype] > 0 && count($p['contains']) > 0) {
         for ($key = 0; $key < $_SESSION["glpisearchcount"][$itemtype]; $key++) {
             // if real search (strlen >0) and not all and view search
             if (isset($p['contains'][$key]) && strlen($p['contains'][$key]) > 0) {
                 // common search
                 if ($p['field'][$key] != "all" && $p['field'][$key] != "view") {
                     $LINK = " ";
                     $NOT = 0;
                     $tmplink = "";
                     if (is_array($p['link']) && isset($p['link'][$key])) {
                         if (strstr($p['link'][$key], "NOT")) {
                             $tmplink = " " . str_replace(" NOT", "", $p['link'][$key]);
                             $NOT = 1;
                         } else {
                             $tmplink = " " . $p['link'][$key];
                         }
                     } else {
                         $tmplink = " AND ";
                     }
                     if (isset($searchopt[$itemtype][$p['field'][$key]]["usehaving"])) {
                         // Manage Link if not first item
                         if (!empty($HAVING)) {
                             $LINK = $tmplink;
                         }
                         // Find key
                         $item_num = array_search($p['field'][$key], $toview);
                         $HAVING .= self::addHaving($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key], 0, $item_num);
                     } else {
                         // Manage Link if not first item
                         if (!empty($WHERE)) {
                             $LINK = $tmplink;
                         }
                         $WHERE .= self::addWhere($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key]);
                     }
                     // view and all search
                 } else {
                     $LINK = " OR ";
                     $NOT = 0;
                     $globallink = " AND ";
                     if (is_array($p['link']) && isset($p['link'][$key])) {
                         switch ($p['link'][$key]) {
                             case "AND":
                                 $LINK = " OR ";
                                 $globallink = " AND ";
                                 break;
                             case "AND NOT":
                                 $LINK = " AND ";
                                 $NOT = 1;
                                 $globallink = " AND ";
                                 break;
                             case "OR":
                                 $LINK = " OR ";
                                 $globallink = " OR ";
                                 break;
                             case "OR NOT":
                                 $LINK = " AND ";
                                 $NOT = 1;
                                 $globallink = " OR ";
                                 break;
                         }
                     } else {
                         $tmplink = "  AND ";
                     }
                     // Manage Link if not first item
                     if (!empty($WHERE)) {
                         $WHERE .= $globallink;
                     }
                     $WHERE .= " ( ";
                     $first2 = true;
                     $items = array();
                     if ($p['field'][$key] == "all") {
                         $items = $searchopt[$itemtype];
                     } else {
                         // toview case : populate toview
                         foreach ($toview as $key2 => $val2) {
                             $items[$val2] = $searchopt[$itemtype][$val2];
                         }
                     }
                     foreach ($items as $key2 => $val2) {
                         if (is_array($val2)) {
                             // Add Where clause if not to be done in HAVING CLAUSE
                             if (!isset($val2["usehaving"])) {
                                 $tmplink = $LINK;
                                 if ($first2) {
                                     $tmplink = " ";
                                     $first2 = false;
                                 }
                                 $WHERE .= self::addWhere($tmplink, $NOT, $itemtype, $key2, $p['searchtype'][$key], $p['contains'][$key]);
                             }
                         }
                     }
                     $WHERE .= " ) ";
                 }
             }
         }
     }
     //// 4 - ORDER
     $ORDER = " ORDER BY `id` ";
     foreach ($toview as $key => $val) {
         if ($p['sort'] == $val) {
             $ORDER = self::addOrderBy($itemtype, $p['sort'], $p['order'], $key);
         }
     }
     //// 5 - META SEARCH
     // Preprocessing
     if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && is_array($p['itemtype2'])) {
         // a - SELECT
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                 $SELECT .= self::addSelect($p['itemtype2'][$i], $p['field2'][$i], $i, 1, $p['itemtype2'][$i]);
             }
         }
         // b - ADD LEFT JOIN
         // Already link meta table in order not to linked a table several times
         $already_link_tables2 = array();
         // Link reference tables
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                 if (!in_array(getTableForItemType($p['itemtype2'][$i]), $already_link_tables2)) {
                     $FROM .= self::addMetaLeftJoin($itemtype, $p['itemtype2'][$i], $already_link_tables2, $p['contains2'][$i] == "NULL" || strstr($p['link2'][$i], "NOT"));
                 }
             }
         }
         // Link items tables
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                 if (!isset($searchopt[$p['itemtype2'][$i]])) {
                     $searchopt[$p['itemtype2'][$i]] =& self::getOptions($p['itemtype2'][$i]);
                 }
                 if (!in_array($searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["table"] . "_" . $p['itemtype2'][$i], $already_link_tables2)) {
                     $FROM .= self::addLeftJoin($p['itemtype2'][$i], getTableForItemType($p['itemtype2'][$i]), $already_link_tables2, $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["table"], $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["linkfield"], 1, $p['itemtype2'][$i], $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["joinparams"]);
                 }
             }
         }
     }
     //// 6 - Add item ID
     // Add ID to the select
     if (!empty($itemtable)) {
         $SELECT .= "`{$itemtable}`.`id` AS id ";
     }
     //// 7 - Manage GROUP BY
     $GROUPBY = "";
     // Meta Search / Search All / Count tickets
     if ($_SESSION["glpisearchcount2"][$itemtype] > 0 || !empty($HAVING) || in_array('all', $p['field'])) {
         $GROUPBY = " GROUP BY `{$itemtable}`.`id`";
     }
     if (empty($GROUPBY)) {
         foreach ($toview as $key2 => $val2) {
             if (!empty($GROUPBY)) {
                 break;
             }
             if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) {
                 $GROUPBY = " GROUP BY `{$itemtable}`.`id`";
             }
         }
     }
     // Specific search for others item linked  (META search)
     if (is_array($p['itemtype2'])) {
         for ($key = 0; $key < $_SESSION["glpisearchcount2"][$itemtype]; $key++) {
             if (isset($p['itemtype2'][$key]) && !empty($p['itemtype2'][$key]) && isset($p['contains2'][$key]) && strlen($p['contains2'][$key]) > 0) {
                 $LINK = "";
                 // For AND NOT statement need to take into account all the group by items
                 if (strstr($p['link2'][$key], "AND NOT") || isset($searchopt[$p['itemtype2'][$key]][$p['field2'][$key]]["usehaving"])) {
                     $NOT = 0;
                     if (strstr($p['link2'][$key], "NOT")) {
                         $tmplink = " " . str_replace(" NOT", "", $p['link2'][$key]);
                         $NOT = 1;
                     } else {
                         $tmplink = " " . $p['link2'][$key];
                     }
                     if (!empty($HAVING)) {
                         $LINK = $tmplink;
                     }
                     $HAVING .= self::addHaving($LINK, $NOT, $p['itemtype2'][$key], $p['field2'][$key], $p['searchtype2'][$key], $p['contains2'][$key], 1, $key);
                 } else {
                     // Meta Where Search
                     $LINK = " ";
                     $NOT = 0;
                     // Manage Link if not first item
                     if (is_array($p['link2']) && isset($p['link2'][$key]) && strstr($p['link2'][$key], "NOT")) {
                         $tmplink = " " . str_replace(" NOT", "", $p['link2'][$key]);
                         $NOT = 1;
                     } else {
                         if (is_array($p['link2']) && isset($p['link2'][$key])) {
                             $tmplink = " " . $p['link2'][$key];
                         } else {
                             $tmplink = " AND ";
                         }
                     }
                     if (!empty($WHERE)) {
                         $LINK = $tmplink;
                     }
                     $WHERE .= self::addWhere($LINK, $NOT, $p['itemtype2'][$key], $p['field2'][$key], $p['searchtype2'][$key], $p['contains2'][$key], 1);
                 }
             }
         }
     }
     // Use a ReadOnly connection if available and configured to be used
     $DBread = DBConnection::getReadConnection();
     // If no research limit research to display item and compute number of item using simple request
     $nosearch = true;
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         if (isset($p['contains'][$i]) && strlen($p['contains'][$i]) > 0) {
             $nosearch = false;
         }
     }
     if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
         $nosearch = false;
     }
     $LIMIT = "";
     $numrows = 0;
     //No search : count number of items using a simple count(ID) request and LIMIT search
     if ($nosearch) {
         $LIMIT = " LIMIT " . $p['start'] . ", " . $LIST_LIMIT;
         // Force group by for all the type -> need to count only on table ID
         if (!isset($searchopt[$itemtype][1]['forcegroupby'])) {
             $count = "count(*)";
         } else {
             $count = "count(DISTINCT `{$itemtable}`.`id`)";
         }
         // request currentuser for SQL supervision, not displayed
         $query_num = "SELECT {$count}, '" . $_SESSION['glpiname'] . "' AS currentuser\n                       FROM `{$itemtable}`" . $COMMONLEFTJOIN;
         $first = true;
         if (!empty($COMMONWHERE)) {
             $LINK = " AND ";
             if ($first) {
                 $LINK = " WHERE ";
                 $first = false;
             }
             $query_num .= $LINK . $COMMONWHERE;
         }
         // Union Search :
         if (isset($CFG_GLPI["union_search_type"][$itemtype])) {
             $tmpquery = $query_num;
             $numrows = 0;
             foreach ($CFG_GLPI[$CFG_GLPI["union_search_type"][$itemtype]] as $ctype) {
                 $ctable = getTableForItemType($ctype);
                 $citem = new $ctype();
                 if ($citem->canView()) {
                     // State case
                     if ($itemtype == 'States') {
                         $query_num = str_replace($CFG_GLPI["union_search_type"][$itemtype], $ctable, $tmpquery);
                         $query_num .= " AND {$ctable}.`states_id` > '0' ";
                         // Add deleted if item have it
                         if ($citem && $citem->maybeDeleted()) {
                             $query_num .= " AND `{$ctable}`.`is_deleted` = '0' ";
                         }
                         // Remove template items
                         if ($citem && $citem->maybeTemplate()) {
                             $query_num .= " AND `{$ctable}`.`is_template` = '0' ";
                         }
                     } else {
                         // Ref table case
                         $reftable = getTableForItemType($itemtype);
                         $replace = "FROM `{$reftable}`\n                                  INNER JOIN `{$ctable}`\n                                       ON (`{$reftable}`.`items_id` =`{$ctable}`.`id`\n                                           AND `{$reftable}`.`itemtype` = '{$ctype}')";
                         $query_num = str_replace("FROM `" . $CFG_GLPI["union_search_type"][$itemtype] . "`", $replace, $tmpquery);
                         $query_num = str_replace($CFG_GLPI["union_search_type"][$itemtype], $ctable, $query_num);
                     }
                     $query_num = str_replace("ENTITYRESTRICT", getEntitiesRestrictRequest('', $ctable, '', '', $citem->maybeRecursive()), $query_num);
                     $result_num = $DBread->query($query_num);
                     $numrows += $DBread->result($result_num, 0, 0);
                 }
             }
         } else {
             $result_num = $DBread->query($query_num);
             $numrows = $DBread->result($result_num, 0, 0);
         }
     }
     // If export_all reset LIMIT condition
     if ($p['export_all']) {
         $LIMIT = "";
     }
     if (!empty($WHERE) || !empty($COMMONWHERE)) {
         if (!empty($COMMONWHERE)) {
             $WHERE = ' WHERE ' . $COMMONWHERE . (!empty($WHERE) ? ' AND ( ' . $WHERE . ' )' : '');
         } else {
             $WHERE = ' WHERE ' . $WHERE . ' ';
         }
         $first = false;
     }
     if (!empty($HAVING)) {
         $HAVING = ' HAVING ' . $HAVING;
     }
     // Create QUERY
     if (isset($CFG_GLPI["union_search_type"][$itemtype])) {
         $first = true;
         $QUERY = "";
         foreach ($CFG_GLPI[$CFG_GLPI["union_search_type"][$itemtype]] as $ctype) {
             $ctable = getTableForItemType($ctype);
             $citem = new $ctype();
             if ($citem->canView()) {
                 if ($first) {
                     $first = false;
                 } else {
                     $QUERY .= " UNION ";
                 }
                 $tmpquery = "";
                 // State case
                 if ($itemtype == 'States') {
                     $tmpquery = $SELECT . ", '{$ctype}' AS TYPE " . $FROM . $WHERE;
                     $tmpquery = str_replace($CFG_GLPI["union_search_type"][$itemtype], $ctable, $tmpquery);
                     $tmpquery .= " AND `{$ctable}`.`states_id` > '0' ";
                     // Add deleted if item have it
                     if ($citem && $citem->maybeDeleted()) {
                         $tmpquery .= " AND `{$ctable}`.`is_deleted` = '0' ";
                     }
                     // Remove template items
                     if ($citem && $citem->maybeTemplate()) {
                         $tmpquery .= " AND `{$ctable}`.`is_template` = '0' ";
                     }
                 } else {
                     // Ref table case
                     $reftable = getTableForItemType($itemtype);
                     $tmpquery = $SELECT . ", '{$ctype}' AS TYPE,\n                                      `{$reftable}`.`id` AS refID, " . "\n                                      `{$ctable}`.`entities_id` AS ENTITY " . $FROM . $WHERE;
                     $replace = "FROM `{$reftable}`" . "\n                              INNER JOIN `{$ctable}`" . "\n                                 ON (`{$reftable}`.`items_id`=`{$ctable}`.`id`" . "\n                                     AND `{$reftable}`.`itemtype` = '{$ctype}')";
                     $tmpquery = str_replace("FROM `" . $CFG_GLPI["union_search_type"][$itemtype] . "`", $replace, $tmpquery);
                     $tmpquery = str_replace($CFG_GLPI["union_search_type"][$itemtype], $ctable, $tmpquery);
                 }
                 $tmpquery = str_replace("ENTITYRESTRICT", getEntitiesRestrictRequest('', $ctable, '', '', $citem->maybeRecursive()), $tmpquery);
                 // SOFTWARE HACK
                 if ($ctype == 'Software') {
                     $tmpquery = str_replace("glpi_softwares.serial", "''", $tmpquery);
                     $tmpquery = str_replace("glpi_softwares.otherserial", "''", $tmpquery);
                 }
                 $QUERY .= $tmpquery;
             }
         }
         if (empty($QUERY)) {
             echo self::showError($output_type);
             return;
         }
         $QUERY .= str_replace($CFG_GLPI["union_search_type"][$itemtype] . ".", "", $ORDER) . $LIMIT;
     } else {
         $QUERY = $SELECT . $FROM . $WHERE . $GROUPBY . $HAVING . $ORDER . $LIMIT;
     }
     $DBread->query("SET SESSION group_concat_max_len = 4096;");
     $result = $DBread->query($QUERY);
     /// Check group concat limit : if warning : increase limit
     if ($result2 = $DBread->query('SHOW WARNINGS')) {
         if ($DBread->numrows($result2) > 0) {
             $data = $DBread->fetch_assoc($result2);
             if ($data['Code'] == 1260) {
                 $DBread->query("SET SESSION group_concat_max_len = 4194304;");
                 $result = $DBread->query($QUERY);
             }
         }
     }
     // Get it from database and DISPLAY
     if ($result) {
         // if real search or complete export : get numrows from request
         if (!$nosearch || $p['export_all']) {
             $numrows = $DBread->numrows($result);
         }
         // Contruct Pager parameters
         $globallinkto = self::getArrayUrlLink("field", $p['field']) . self::getArrayUrlLink("link", $p['link']) . self::getArrayUrlLink("contains", $p['contains']) . self::getArrayUrlLink("searchtype", $p['searchtype']) . self::getArrayUrlLink("field2", $p['field2']) . self::getArrayUrlLink("contains2", $p['contains2']) . self::getArrayUrlLink("itemtype2", $p['itemtype2']) . self::getArrayUrlLink("searchtype2", $p['searchtype2']) . self::getArrayUrlLink("link2", $p['link2']);
         $parameters = "sort=" . $p['sort'] . "&amp;order=" . $p['order'] . $globallinkto;
         // Not more used : clean pages : try to comment it
         /*
         $tmp=explode('?',$target,2);
         if (count($tmp)>1) {
            $target = $tmp[0];
            $parameters = $tmp[1].'&amp;'.$parameters;
         }
         */
         if ($output_type == GLOBAL_SEARCH) {
             if (class_exists($itemtype)) {
                 echo "<div class='center'><h2>" . $item->getTypeName();
                 // More items
                 if ($numrows > $p['start'] + GLOBAL_SEARCH_DISPLAY_COUNT) {
                     echo " <a href='{$target}?{$parameters}'>" . $LANG['common'][66] . "</a>";
                 }
                 echo "</h2></div>\n";
             } else {
                 return false;
             }
         }
         // If the begin of the view is before the number of items
         if ($p['start'] < $numrows) {
             // Display pager only for HTML
             if ($output_type == HTML_OUTPUT) {
                 // For plugin add new parameter if available
                 if ($plug = isPluginItemType($itemtype)) {
                     $function = 'plugin_' . $plug['plugin'] . '_addParamFordynamicReport';
                     if (function_exists($function)) {
                         $out = $function($itemtype);
                         if (is_array($out) && count($out)) {
                             foreach ($out as $key => $val) {
                                 if (is_array($val)) {
                                     $parameters .= self::getArrayUrlLink($key, $val);
                                 } else {
                                     $parameters .= "&amp;{$key}={$val}";
                                 }
                             }
                         }
                     }
                 }
                 printPager($p['start'], $numrows, $target, $parameters, $itemtype);
             }
             // Form to massive actions
             $isadmin = $item && $item->canUpdate();
             if (!$isadmin && in_array($itemtype, $CFG_GLPI["infocom_types"])) {
                 $infoc = new Infocom();
                 $isadmin = $infoc->canUpdate() || $infoc->canCreate();
             }
             if ($isadmin && $output_type == HTML_OUTPUT) {
                 echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php\">";
             }
             // Compute number of columns to display
             // Add toview elements
             $nbcols = $toview_count;
             $already_printed = array();
             // Add meta search elements if real search (strlen>0) or only NOT search
             if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && is_array($p['itemtype2'])) {
                 for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
                     if (isset($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0 && !empty($p['itemtype2'][$i]) && (!isset($p['link2'][$i]) || !strstr($p['link2'][$i], "NOT"))) {
                         if (!isset($already_printed[$p['itemtype2'][$i] . $p['field2'][$i]])) {
                             $nbcols++;
                             $already_printed[$p['itemtype2'][$i] . $p['field2'][$i]] = 1;
                         }
                     }
                 }
             }
             if ($output_type == HTML_OUTPUT) {
                 // HTML display - massive modif
                 $nbcols++;
             }
             // Define begin and end var for loop
             // Search case
             $begin_display = $p['start'];
             $end_display = $p['start'] + $LIST_LIMIT;
             // No search Case
             if ($nosearch) {
                 $begin_display = 0;
                 $end_display = min($numrows - $p['start'], $LIST_LIMIT);
             }
             // Export All case
             if ($p['export_all']) {
                 $begin_display = 0;
                 $end_display = $numrows;
             }
             // Display List Header
             echo self::showHeader($output_type, $end_display - $begin_display + 1, $nbcols);
             // New Line for Header Items Line
             echo self::showNewLine($output_type);
             $header_num = 1;
             if ($output_type == HTML_OUTPUT) {
                 // HTML display - massive modif
                 $search_config = "";
                 if (haveRight("search_config", "w") || haveRight("search_config_global", "w")) {
                     $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&amp;itemtype={$itemtype}' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes'); w.focus();\"";
                     $search_config = "<img alt=\"" . $LANG['setup'][252] . "\" title=\"" . $LANG['setup'][252] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' ";
                     $search_config .= $tmp . ">";
                 }
                 echo self::showHeaderItem($output_type, $search_config, $header_num, "", 0, $p['order']);
             }
             // Display column Headers for toview items
             foreach ($toview as $key => $val) {
                 $linkto = '';
                 if (!isset($searchopt[$itemtype][$val]['nosort']) || !$searchopt[$itemtype][$val]['nosort']) {
                     $linkto = "{$target}?itemtype={$itemtype}&amp;sort=" . $val . "&amp;order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&amp;start=" . $p['start'] . $globallinkto;
                 }
                 echo self::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']);
             }
             // Display columns Headers for meta items
             $already_printed = array();
             if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && is_array($p['itemtype2'])) {
                 for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
                     if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                         if (!isset($already_printed[$p['itemtype2'][$i] . $p['field2'][$i]])) {
                             if (!isset($metanames[$p['itemtype2'][$i]])) {
                                 $metaitem = new $p['itemtype2'][$i]();
                                 $metanames[$p['itemtype2'][$i]] = $metaitem->getTypeName();
                             }
                             echo self::showHeaderItem($output_type, $metanames[$p['itemtype2'][$i]] . " - " . $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["name"], $header_num);
                             $already_printed[$p['itemtype2'][$i] . $p['field2'][$i]] = 1;
                         }
                     }
                 }
             }
             // Add specific column Header
             if ($itemtype == 'CartridgeItem') {
                 echo self::showHeaderItem($output_type, $LANG['cartridges'][0], $header_num);
             }
             if ($itemtype == 'ConsumableItem') {
                 echo self::showHeaderItem($output_type, $LANG['consumables'][0], $header_num);
             }
             if ($itemtype == 'States' || $itemtype == 'ReservationItem') {
                 echo self::showHeaderItem($output_type, $LANG['state'][6], $header_num);
             }
             if ($itemtype == 'ReservationItem' && $output_type == HTML_OUTPUT) {
                 if (haveRight("reservation_central", "w")) {
                     echo self::showHeaderItem($output_type, $LANG['reservation'][4], $header_num);
                     echo self::showHeaderItem($output_type, "&nbsp;", $header_num);
                 }
                 echo self::showHeaderItem($output_type, "&nbsp;", $header_num);
             }
             // End Line for column headers
             echo self::showEndLine($output_type);
             // if real search seek to begin of items to display (because of complete search)
             if (!$nosearch) {
                 $DBread->data_seek($result, $p['start']);
             }
             // Define begin and end var for loop
             // Search case
             $i = $begin_display;
             // Init list of items displayed
             if ($output_type == HTML_OUTPUT) {
                 initNavigateListItems($itemtype);
             }
             // Num of the row (1=header_line)
             $row_num = 1;
             // Display Loop
             while ($i < $numrows && $i < $end_display) {
                 // Column num
                 $item_num = 1;
                 // Get data and increment loop variables
                 $data = $DBread->fetch_assoc($result);
                 $i++;
                 $row_num++;
                 // New line
                 echo self::showNewLine($output_type, $i % 2, $p['is_deleted']);
                 // Add item in item list
                 addToNavigateListItems($itemtype, $data["id"]);
                 if ($output_type == HTML_OUTPUT) {
                     // HTML display - massive modif
                     $tmpcheck = "";
                     if ($isadmin) {
                         if ($itemtype == 'Entity' && !in_array($data["id"], $_SESSION["glpiactiveentities"])) {
                             $tmpcheck = "&nbsp;";
                         } else {
                             if ($item->maybeRecursive() && !in_array($data["entities_id"], $_SESSION["glpiactiveentities"])) {
                                 $tmpcheck = "&nbsp;";
                             } else {
                                 $sel = "";
                                 if (isset($_GET["select"]) && $_GET["select"] == "all") {
                                     $sel = "checked";
                                 }
                                 if (isset($_SESSION['glpimassiveactionselected'][$data["id"]])) {
                                     $sel = "checked";
                                 }
                                 $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'\n                                      {$sel}>";
                             }
                         }
                     }
                     echo self::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'");
                 }
                 // Print other toview items
                 foreach ($toview as $key => $val) {
                     echo self::showItem($output_type, self::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, self::displayConfigItem($itemtype, $val, $data, $key));
                 }
                 // Print Meta Item
                 $already_printed = array();
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && is_array($p['itemtype2'])) {
                     for ($j = 0; $j < $_SESSION["glpisearchcount2"][$itemtype]; $j++) {
                         if (isset($p['itemtype2'][$j]) && !empty($p['itemtype2'][$j]) && isset($p['contains2'][$j]) && strlen($p['contains2'][$j]) > 0) {
                             if (!isset($already_printed[$p['itemtype2'][$j] . $p['field2'][$j]])) {
                                 // General case
                                 if (strpos($data["META_{$j}"], "\$\$\$\$") === false) {
                                     $out = self::giveItem($p['itemtype2'][$j], $p['field2'][$j], $data, $j, 1);
                                     echo self::showItem($output_type, $out, $item_num, $row_num);
                                     // Case of GROUP_CONCAT item : split item and multilline display
                                 } else {
                                     $split = explode("\$\$\$\$", $data["META_{$j}"]);
                                     $count_display = 0;
                                     $out = "";
                                     $unit = "";
                                     $separate = '<br>';
                                     if (isset($searchopt[$p['itemtype2'][$j]][$p['field2'][$j]]['splititems']) && $searchopt[$p['itemtype2'][$j]][$p['field2'][$j]]['splititems']) {
                                         $separate = '<hr>';
                                     }
                                     if (isset($searchopt[$p['itemtype2'][$j]][$p['field2'][$j]]['unit'])) {
                                         $unit = $searchopt[$p['itemtype2'][$j]][$p['field2'][$j]]['unit'];
                                     }
                                     for ($k = 0; $k < count($split); $k++) {
                                         if ($p['contains2'][$j] == "NULL" || strlen($p['contains2'][$j]) == 0 || preg_match('/' . $p['contains2'][$j] . '/i', $split[$k]) || isset($searchopt[$p['itemtype2'][$j]][$p['field2'][$j]]['forcegroupby'])) {
                                             if ($count_display) {
                                                 $out .= $separate;
                                             }
                                             $count_display++;
                                             // Manage Link to item
                                             $split2 = explode("\$\$", $split[$k]);
                                             if (isset($split2[1])) {
                                                 $out .= "<a id='" . $p['itemtype2'][$j] . '_' . $data["id"] . '_' . $split2[1] . "' ";
                                                 $out .= "href=\"" . getItemTypeFormURL($p['itemtype2'][$j]) . "?id=" . $p['itemtype2'][$j] . "\">";
                                                 $out .= $split2[0] . $unit;
                                                 if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
                                                     $out .= " (" . $split2[1] . ")";
                                                 }
                                                 $out .= "</a>";
                                             } else {
                                                 $out .= $split[$k] . $unit;
                                             }
                                         }
                                     }
                                     echo self::showItem($output_type, $out, $item_num, $row_num);
                                 }
                                 $already_printed[$p['itemtype2'][$j] . $p['field2'][$j]] = 1;
                             }
                         }
                     }
                 }
                 // Specific column display
                 if ($itemtype == 'CartridgeItem') {
                     echo self::showItem($output_type, Cartridge::getCount($data["id"], $data["ALARM"], $output_type != HTML_OUTPUT), $item_num, $row_num);
                 }
                 if ($itemtype == 'ConsumableItem') {
                     echo self::showItem($output_type, Consumable::getCount($data["id"], $data["ALARM"], $output_type != HTML_OUTPUT), $item_num, $row_num);
                 }
                 if ($itemtype == 'States' || $itemtype == 'ReservationItem') {
                     $typename = $data["TYPE"];
                     if (class_exists($data["TYPE"])) {
                         $itemtmp = new $data["TYPE"]();
                         $typename = $itemtmp->getTypeName();
                     }
                     echo self::showItem($output_type, $typename, $item_num, $row_num);
                 }
                 if ($itemtype == 'ReservationItem' && $output_type == HTML_OUTPUT) {
                     if (haveRight("reservation_central", "w")) {
                         if (!haveAccessToEntity($data["ENTITY"])) {
                             echo self::showItem($output_type, "&nbsp;", $item_num, $row_num);
                             echo self::showItem($output_type, "&nbsp;", $item_num, $row_num);
                         } else {
                             echo self::showItem($output_type, "<a href=\"" . getItemTypeFormURL($itemtype) . "?id=" . $data["refID"] . "&amp;is_active=" . ($data["ACTIVE"] ? 0 : 1) . "&amp;update=update\" " . "title=\"" . ($data["ACTIVE"] ? $LANG['buttons'][42] : $LANG['buttons'][41]) . "\">" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($data["ACTIVE"] ? "moins" : "plus") . ".png\" alt=''\n                                                title=''></a>", $item_num, $row_num, "class='center'");
                             echo self::showItem($output_type, "<a href='" . getItemTypeFormURL($itemtype) . "?id=" . $data["refID"] . "&amp;delete=delete' " . addConfirmationOnAction(array($LANG['reservation'][38], $LANG['reservation'][39])) . " title=\"" . $LANG['reservation'][6] . "\">" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png'\n                                                alt='' title=''></a>", $item_num, $row_num, "class='center'");
                         }
                     }
                     if ($data["ACTIVE"]) {
                         echo self::showItem($output_type, "<a href='reservation.php?reservationitems_id=" . $data["refID"] . "' title=\"" . $LANG['reservation'][21] . "\">" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''></a>", $item_num, $row_num, "class='center'");
                     } else {
                         echo self::showItem($output_type, "&nbsp;", $item_num, $row_num);
                     }
                 }
                 // End Line
                 echo self::showEndLine($output_type);
             }
             $title = "";
             // Create title
             if ($output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 if ($_SESSION["glpisearchcount"][$itemtype] > 0 && count($p['contains']) > 0) {
                     for ($key = 0; $key < $_SESSION["glpisearchcount"][$itemtype]; $key++) {
                         if (strlen($p['contains'][$key]) > 0) {
                             if (isset($p["link"][$key])) {
                                 $title .= " " . $p["link"][$key] . " ";
                             }
                             switch ($p['field'][$key]) {
                                 case "all":
                                     $title .= $LANG['common'][66];
                                     break;
                                 case "view":
                                     $title .= $LANG['search'][11];
                                     break;
                                 default:
                                     $title .= $searchopt[$itemtype][$p['field'][$key]]["name"];
                             }
                             switch ($p['searchtype'][$key]) {
                                 case "equals":
                                     if (in_array($searchopt[$itemtype][$p['field'][$key]]["field"], array('name', 'completename'))) {
                                         $title .= ' = ' . Dropdown::getDropdownName($searchopt[$itemtype][$p['field'][$key]]["table"], $p['contains'][$key]);
                                     } else {
                                         $title .= ' = ' . $p['contains'][$key];
                                     }
                                     break;
                                 case "notequals":
                                     if (in_array($searchopt[$itemtype][$p['field'][$key]]["field"], array('name', 'completename'))) {
                                         $title .= ' <> ' . Dropdown::getDropdownName($searchopt[$itemtype][$p['field'][$key]]["table"], $p['contains'][$key]);
                                     } else {
                                         $title .= ' <> ' . $p['contains'][$key];
                                     }
                                     break;
                                 case "lessthan":
                                     $title .= ' < ' . $p['contains'][$key];
                                     break;
                                 case "morethan":
                                     $title .= ' > ' . $p['contains'][$key];
                                     break;
                                 case "contains":
                                     $title .= ' = %' . $p['contains'][$key] . '%';
                                     break;
                                 default:
                                     $title .= ' = ' . $p['contains'][$key];
                                     break;
                             }
                         }
                     }
                 }
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && count($p['contains2']) > 0) {
                     for ($key = 0; $key < $_SESSION["glpisearchcount2"][$itemtype]; $key++) {
                         if (strlen($p['contains2'][$key]) > 0) {
                             if (isset($p['link2'][$key])) {
                                 $title .= " " . $p['link2'][$key] . " ";
                             }
                             $title .= $metanames[$p['itemtype2'][$key]] . "/";
                             $title .= $searchopt[$p['itemtype2'][$key]][$p['field2'][$key]]["name"];
                             switch ($p['searchtype2'][$key]) {
                                 case "equals":
                                     if (in_array($searchopt[$p['itemtype2'][$key]][$p['field2'][$key]]["field"], array('name', 'completename'))) {
                                         $title .= ' = ' . Dropdown::getDropdownName($searchopt[$p['itemtype2'][$key]][$p['field2'][$key]]["table"], $p['contains2'][$key]);
                                     } else {
                                         $title .= ' = ' . $p['contains2'][$key];
                                     }
                                     break;
                                 case "notequals":
                                     if (in_array($searchopt[$p['itemtype2'][$key]][$p['field2'][$key]]["field"], array('name', 'completename'))) {
                                         $title .= ' <> ' . Dropdown::getDropdownName($searchopt[$p['itemtype2'][$key]][$p['field2'][$key]]["table"], $p['contains2'][$key]);
                                     } else {
                                         $title .= ' <> ' . $p['contains2'][$key];
                                     }
                                     break;
                                 case "lessthan":
                                     $title .= ' < ' . $p['contains2'][$key];
                                     break;
                                 case "morethan":
                                     $title .= ' > ' . $p['contains2'][$key];
                                     break;
                                 case "contains":
                                     $title .= ' = %' . $p['contains2'][$key] . '%';
                                     break;
                                 default:
                                     $title .= ' = ' . $p['contains2'][$key];
                                     break;
                             }
                         }
                     }
                 }
             }
             // Display footer
             echo self::showFooter($output_type, $title);
             // Delete selected item
             if ($output_type == HTML_OUTPUT) {
                 if ($isadmin) {
                     openArrowMassive("massiveaction_form");
                     Dropdown::showForMassiveAction($itemtype, $p['is_deleted']);
                     closeArrowMassive();
                     // End form for delete item
                     echo "</form>\n";
                 } else {
                     echo "<br>";
                 }
             }
             if ($output_type == HTML_OUTPUT) {
                 // In case of HTML display
                 printPager($p['start'], $numrows, $target, $parameters);
             }
         } else {
             echo self::showError($output_type);
         }
     } else {
         echo $DBread->error();
     }
     // Clean selection
     $_SESSION['glpimassiveactionselected'] = array();
 }
Пример #14
0
 /**
  * Show bookmarks list
  *
  * @param $target target to use for links
  * @param $is_private show private of public bookmarks ?
  *
  * @return nothing
  **/
 function showBookmarkList($target, $is_private = 1)
 {
     global $DB, $LANG, $CFG_GLPI;
     if (!$is_private && !haveRight('bookmark_public', 'r')) {
         return false;
     }
     $query = "SELECT `" . $this->getTable() . "`.*,\n                       `glpi_bookmarks_users`.`id` AS IS_DEFAULT\n                FROM `" . $this->getTable() . "`\n                LEFT JOIN `glpi_bookmarks_users`\n                  ON (`" . $this->getTable() . "`.`itemtype` = `glpi_bookmarks_users`.`itemtype`\n                      AND `" . $this->getTable() . "`.`id` = `glpi_bookmarks_users`.`bookmarks_id`)\n                WHERE ";
     if ($is_private) {
         $query .= "(`" . $this->getTable() . "`.`is_private`='1'\n                     AND `" . $this->getTable() . "`.`users_id`='" . getLoginUserID() . "') ";
     } else {
         $query .= "(`" . $this->getTable() . "`.`is_private`='0' " . getEntitiesRestrictRequest("AND", $this->getTable(), "", "", true) . ")";
     }
     $query .= " ORDER BY `itemtype`, `name`";
     if ($result = $DB->query($query)) {
         $rand = mt_rand();
         echo "<form method='post' id='form_load_bookmark{$rand}' action=\"{$target}\">";
         echo "<div class='center' id='tabsbody' >";
         echo "<table class='tab_cadrehov' width='" . self::WIDTH . "px'>";
         echo "<tr>";
         echo "<th class='center' colspan='3'>" . $LANG['buttons'][52] . " " . $LANG['bookmark'][1] . "</th>";
         echo "<th width='20px'>&nbsp;</th>";
         echo "<th>" . $LANG['bookmark'][6] . "</th></tr>";
         if ($DB->numrows($result)) {
             $current_type = -1;
             $current_type_name = NOT_AVAILABLE;
             while ($this->fields = $DB->fetch_assoc($result)) {
                 if ($current_type != $this->fields['itemtype']) {
                     $current_type = $this->fields['itemtype'];
                     $current_type_name = NOT_AVAILABLE;
                     if ($current_type == "States") {
                         $current_type_name = $LANG['state'][0];
                     } else {
                         if (class_exists($current_type)) {
                             $item = new $current_type();
                             $current_type_name = $item->getTypeName();
                         }
                     }
                 }
                 $canedit = $this->can($this->fields["id"], "w");
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10px'>";
                 if ($canedit) {
                     $sel = "";
                     if (isset($_GET["select"]) && $_GET["select"] == "all") {
                         $sel = "checked";
                     }
                     echo "<input type='checkbox' name='bookmark[" . $this->fields["id"] . "]'" . $sel . ">";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 echo "<td>{$current_type_name}</td>";
                 echo "<td><a href=\"" . GLPI_ROOT . "/front/popup.php?popup=load_bookmark&amp;id=" . $this->fields["id"] . "\">" . $this->fields["name"] . "</a></td>";
                 if ($canedit) {
                     echo "<td><a href=\"" . GLPI_ROOT . "/front/popup.php?popup=edit_bookmark&amp;id=" . $this->fields["id"] . "\">\n                            <img src='" . $CFG_GLPI["root_doc"] . "/pics/edit.png' alt='" . $LANG['buttons'][14] . "'></a></td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 echo "<td class='center'>";
                 if ($this->fields['type'] == BOOKMARK_SEARCH) {
                     if (is_null($this->fields['IS_DEFAULT'])) {
                         echo "<a href=\"" . GLPI_ROOT . "/front/popup.php?popup=edit_bookmark&amp;\n                            mark_default=1&amp;id=" . $this->fields["id"] . "\">" . $LANG['choice'][0] . "</a>";
                     } else {
                         echo "<a href=\"" . GLPI_ROOT . "/front/popup.php?popup=edit_bookmark&amp;\n                            mark_default=0&amp;id=" . $this->fields["id"] . "\">" . $LANG['choice'][1] . "</a>";
                     }
                 }
                 echo "</td></tr>";
             }
             echo "</table></div>";
             openArrowMassive("form_load_bookmark{$rand}");
             closeArrowMassive('delete_several', $LANG['buttons'][6]);
         } else {
             echo "<tr class='tab_bg_1'><td colspan='5'>" . $LANG['bookmark'][3] . "</td></tr></table>";
         }
         echo '</form>';
     }
 }
Пример #15
0
 function showForSLA(SLA $sla)
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $sla->getField('id');
     if (!$sla->can($ID, 'r')) {
         return false;
     }
     $canedit = $sla->can($ID, 'w');
     $rand = mt_rand();
     echo "<form name='slalevel_form{$rand}' id='slalevel_form{$rand}' method='post' action='";
     echo getItemTypeFormURL(__CLASS__) . "'>";
     if ($canedit) {
         echo "<div class='center first-bloc'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['sla'][4] . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>" . $LANG['common'][16] . "&nbsp;: ";
         echo "<input type='hidden' name='slas_id' value='{$ID}'>";
         echo "<input type='hidden' name='entities_id' value='" . $sla->getEntityID() . "'>";
         echo "<input type='hidden' name='is_recursive' value='" . $sla->isRecursive() . "'>";
         echo "<input  name='name' value=''>";
         echo "</td><td class='center'>" . $LANG['sla'][3] . "&nbsp;: ";
         self::dropdownExecutionTime('execution_time', array('max_time' => $sla->fields['resolution_time'], 'used' => self::getAlreadyUsedExecutionTime($sla->fields['id'])));
         echo "</td><td class='center'>" . $LANG['common'][60] . "&nbsp;: ";
         Dropdown::showYesNo("is_active", array('value' => 1));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
         $query = "SELECT *\n                  FROM `glpi_slalevels`\n                  WHERE `slas_id` = '{$ID}'\n                  ORDER BY `execution_time`";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             echo "<div class='center'><table class='tab_cadre_fixehov'>";
             echo "<tr><th colspan='2'>" . $LANG['common'][16] . "</th>";
             echo "<th>" . $LANG['sla'][3] . "</th>";
             echo "<th>" . $LANG['common'][60] . "</th>";
             echo "</tr>";
             initNavigateListItems('SlaLevel', $LANG['sla'][1] . " - " . $sla->getName());
             while ($data = $DB->fetch_array($result)) {
                 addToNavigateListItems('SlaLevel', $data["id"]);
                 echo "<tr class='tab_bg_2'>";
                 echo "<td width='10'>";
                 if ($canedit) {
                     echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 echo "<td>";
                 if ($canedit) {
                     echo "<a href='" . getItemTypeFormURL('SlaLevel') . "?id=" . $data["id"] . "'>";
                 }
                 echo $data["name"];
                 if (empty($data["name"])) {
                     echo "(" . $data['id'] . ")";
                 }
                 if ($canedit) {
                     echo "</a>";
                 }
                 echo "</td>";
                 echo "<td>" . ($data["execution_time"] != 0 ? timestampToString($data["execution_time"], false) : $LANG['sla'][5]) . "</td>";
                 echo "<td>" . Dropdown::getYesNo($data["is_active"]) . "</td>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'><td colspan='4'>";
                 $this->getRuleWithCriteriasAndActions($data['id'], 0, 1);
                 $this->showActionsList($data["id"], array('readonly' => true));
                 echo "</td></tr>";
             }
             openArrowMassive("slalevel_form{$rand}", true);
             closeArrowMassive('delete', $LANG['buttons'][6]);
             echo "</table></div>";
         }
     }
     echo "</form>";
 }
 function showHosts($componentscatalogs_id, $static)
 {
     global $DB, $LANG, $CFG_GLPI;
     if ($static == '1') {
         $this->addHost($componentscatalogs_id);
     }
     $rand = mt_rand();
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'\n            AND `is_static`='" . $static . "'";
     $result = $DB->query($query);
     echo "<form method='post' name='componentscatalog_host_form{$rand}' id='componentscatalog_host_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/componentscatalog_host.form.php\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='5'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['document'][13];
     } else {
         echo $LANG['document'][19];
     }
     echo "</th>";
     echo "</tr>";
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['common'][19] . "</th>";
     echo "<th>" . $LANG['common'][20] . "</th>";
     echo "</tr>";
     while ($data = $DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         $item->getFromDB($data['items_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $item->getTypeName();
         echo "</td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName("glpi_entities", $item->fields['entities_id']) . "</td>";
         echo "<td class='center" . (isset($item->fields['is_deleted']) && $item->fields['is_deleted'] ? " tab_bg_2_2'" : "'");
         echo ">" . $item->getLink() . "</td>";
         echo "<td class='center'>" . (isset($item->fields["serial"]) ? "" . $item->fields["serial"] . "" : "-") . "</td>";
         echo "<td class='center'>" . (isset($item->fields["otherserial"]) ? "" . $item->fields["otherserial"] . "" : "-") . "</td>";
         echo "</tr>";
     }
     if ($static == '1') {
         openArrowMassive("componentscatalog_host_form{$rand}", true);
         closeArrowMassive('deleteitem', $LANG['buttons'][6]);
     }
     echo "</table>";
 }
 /**
  * Show Licenses of a software
  *
  * @param $software software object
  *
  * @return nothing
  **/
 static function showForSoftware($software)
 {
     global $DB, $CFG_GLPI, $LANG;
     $softwares_id = $software->getField('id');
     $license = new SoftwareLicense();
     $computer = new Computer();
     if (!$software->can($softwares_id, "r")) {
         return false;
     }
     if (isset($_REQUEST["start"])) {
         $start = $_REQUEST["start"];
     } else {
         $start = 0;
     }
     if (isset($_REQUEST["order"]) && $_REQUEST["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     if (isset($_REQUEST["sort"]) && !empty($_REQUEST["sort"])) {
         $sort = "`" . $_REQUEST["sort"] . "`";
     } else {
         $sort = "`entity` {$order}, `name`";
     }
     // Righ type is enough. Can add a License on a software we have Read access
     $canedit = haveRight("software", "w");
     // Total Number of events
     $number = countElementsInTable("glpi_softwarelicenses", "glpi_softwarelicenses.softwares_id = {$softwares_id} " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true));
     echo "<div class='spaced'>";
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . $LANG['search'][15] . "</th></tr>\n";
         if ($canedit) {
             echo "<tr class='tab_bg_2'><td class='center'>";
             echo "<a href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . $LANG['software'][8] . "</a>";
             echo "</td></tr>\n";
         }
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     printAjaxPager($LANG['software'][11], $start, $number);
     $rand = mt_rand();
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `buyvers`.`name` AS buyname,\n                       `usevers`.`name` AS usename,\n                       `glpi_entities`.`completename` AS entity,\n                       `glpi_softwarelicensetypes`.`name` AS typename\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_softwareversions` AS buyvers\n                     ON (`buyvers`.`id` = `glpi_softwarelicenses`.`softwareversions_id_buy`)\n                LEFT JOIN `glpi_softwareversions` AS usevers\n                     ON (`usevers`.`id` = `glpi_softwarelicenses`.`softwareversions_id_use`)\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_entities`.`id` = `glpi_softwarelicenses`.`entities_id`)\n                LEFT JOIN `glpi_softwarelicensetypes`\n                     ON (`glpi_softwarelicensetypes`.`id`\n                          = `glpi_softwarelicenses`.`softwarelicensetypes_id`)\n                WHERE (`glpi_softwarelicenses`.`softwares_id` = '{$softwares_id}') " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true) . "\n                ORDER BY {$sort} {$order}\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     initNavigateListItems('SoftwareLicense', $LANG['help'][31] . " = " . $software->fields["name"]);
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result)) {
             if ($canedit) {
                 echo "<form method='post' name='massiveactionlicense_form{$rand}' id='" . "massiveactionlicense_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php\">";
             }
             $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
             echo "<table class='tab_cadre_fixehov'><tr>";
             echo "<th>&nbsp;</th>";
             echo "<th>" . ($sort == "`name`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=name&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][16] . "</a></th>";
             if ($software->isRecursive()) {
                 // Ereg to search entity in string for match default order
                 echo "<th>" . (strstr($sort, "entity") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=entity&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['entity'][0] . "</a></th>";
             }
             echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][19] . "</a></th>";
             echo "<th>" . ($sort == "`number`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=number&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['tracking'][29] . "</a></th>";
             echo "<th>" . $LANG['software'][9] . "</th>";
             echo "<th>" . ($sort == "`typename`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=typename&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['common'][17] . "</a></th>";
             echo "<th>" . ($sort == "`buyname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=buyname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['software'][1] . "</a></th>";
             echo "<th>" . ($sort == "`usename`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=usename&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['software'][2] . "</a></th>";
             echo "<th>" . ($sort == "`expire`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=expire&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . $LANG['software'][32] . "</a></th>";
             echo "</tr>\n";
             $tot_assoc = 0;
             for ($tot = 0; $data = $DB->fetch_assoc($result);) {
                 addToNavigateListItems('SoftwareLicense', $data['id']);
                 echo "<tr class='tab_bg_2'>";
                 if ($license->can($data['id'], "w")) {
                     echo "<td><input type='checkbox' name='item[" . $data["id"] . "]' value='1'></td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 echo "<td><a href='softwarelicense.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? $data['id'] : "") . "</a></td>";
                 if ($software->isRecursive()) {
                     echo "<td>" . $data['entity'] . "</td>";
                 }
                 echo "<td>" . $data['serial'] . "</td>";
                 echo "<td class='right'>" . ($data['number'] > 0 ? $data['number'] . "&nbsp;&nbsp;" : $LANG['software'][4]) . "</td>";
                 $nb_assoc = Computer_SoftwareLicense::countForLicense($data['id']);
                 $tot_assoc += $nb_assoc;
                 echo "<td class='right'>{$nb_assoc}&nbsp;&nbsp;</td>";
                 echo "<td>" . $data['typename'] . "</td>";
                 echo "<td>" . $data['buyname'] . "</td>";
                 echo "<td>" . $data['usename'] . "</td>";
                 echo "<td class='center'>" . convDate($data['expire']) . "</td>";
                 echo "</tr>";
                 if ($data['number'] < 0) {
                     // One illimited license, total is illimited
                     $tot = -1;
                 } else {
                     if ($tot >= 0) {
                         // Not illimited, add the current number
                         $tot += $data['number'];
                     }
                 }
             }
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='" . ($software->isRecursive() ? 4 : 3) . "' class='right b'>" . $LANG['common'][33] . "</td>";
             echo "<td class='right b'>" . ($tot > 0 ? $tot . "&nbsp;&nbsp;" : $LANG['software'][4]) . "</td>";
             echo "<td class='right b'>{$tot_assoc}&nbsp;&nbsp;</td>";
             echo "<td colspan='4' class='center'>";
             if ($canedit) {
                 echo "<a href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . $LANG['software'][8] . "</a>";
             }
             echo "</td></tr>";
             echo "</table>\n";
             if ($canedit) {
                 openArrowMassive("massiveactionlicense_form{$rand}", true);
                 Dropdown::showForMassiveAction('SoftwareLicense', 0, array('softwares_id' => $softwares_id));
                 closeArrowMassive();
                 echo "</form>";
             }
         } else {
             echo $LANG['search'][15];
         }
     }
     echo "</div>";
 }
Пример #18
0
 /**
  * Show ports for an item
  *
  * @param $itemtype integer : item type
  * @param $ID integer : item ID
  * @param $withtemplate integer : withtemplate param
  **/
 static function showForItem($itemtype, $ID, $withtemplate = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     $rand = mt_rand();
     if (!class_exists($itemtype)) {
         return false;
     }
     $item = new $itemtype();
     if (!haveRight('networking', 'r') || !$item->can($ID, 'r')) {
         return false;
     }
     $canedit = $item->can($ID, 'w');
     // Show Add Form
     if ($canedit && (empty($withtemplate) || $withtemplate != 2)) {
         echo "\n<div class='firstbloc'><table class='tab_cadre_fixe'>";
         echo "<tr><td class='tab_bg_2 center'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?items_id={$ID}&amp;itemtype={$itemtype}'><strong>" . $LANG['networking'][19] . "</strong></a></td>\n";
         echo "<td class='tab_bg_2 center' width='50%'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?items_id={$ID}&amp;itemtype={$itemtype}&amp;several=1'>\n               <strong>" . $LANG['networking'][46] . "</strong></a></td>\n";
         echo "</tr></table></div>\n";
     }
     initNavigateListItems('NetworkPort', $item->getTypeName() . " = " . $item->getName());
     $query = "SELECT `id`\n                FROM `glpi_networkports`\n                WHERE `items_id` = '{$ID}'\n                      AND `itemtype` = '{$itemtype}'\n                ORDER BY `name`,\n                         `logical_number`";
     if ($result = $DB->query($query)) {
         echo "<div class='spaced'>";
         if ($DB->numrows($result) != 0) {
             $colspan = 9;
             if ($withtemplate != 2) {
                 if ($canedit) {
                     $colspan++;
                     echo "\n<form id='networking_ports{$rand}' name='networking_ports{$rand}' method='post'\n                        action='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php'>\n";
                 }
             }
             echo "<table class='tab_cadre_fixe'>\n";
             echo "<tr><th colspan='{$colspan}'>\n";
             if ($DB->numrows($result) == 1) {
                 echo $LANG['networking'][12];
             } else {
                 echo $LANG['networking'][11];
             }
             echo "&nbsp;:&nbsp;" . $DB->numrows($result) . "</th></tr>\n";
             echo "<tr>";
             if ($withtemplate != 2 && $canedit) {
                 echo "<th>&nbsp;</th>\n";
             }
             echo "<th>#</th>\n";
             echo "<th>" . $LANG['common'][16] . "</th>\n";
             echo "<th>" . $LANG['networking'][51] . "</th>\n";
             echo "<th>" . $LANG['networking'][14] . "<br>" . $LANG['networking'][15] . "</th>\n";
             echo "<th>" . $LANG['networking'][60] . "&nbsp;/&nbsp;" . $LANG['networking'][61] . "<br>" . $LANG['networking'][59] . "</th>\n";
             echo "<th>" . $LANG['networking'][56] . "</th>\n";
             echo "<th>" . $LANG['common'][65] . "</th>\n";
             echo "<th>" . $LANG['networking'][17] . "&nbsp;:</th>\n";
             echo "<th>" . $LANG['networking'][14] . "<br>" . $LANG['networking'][15] . "</th></tr>\n";
             $i = 0;
             $netport = new NetworkPort();
             while ($devid = $DB->fetch_row($result)) {
                 $netport->getFromDB(current($devid));
                 addToNavigateListItems('NetworkPort', $netport->fields["id"]);
                 echo "<tr class='tab_bg_1'>\n";
                 if ($withtemplate != 2 && $canedit) {
                     echo "<td class='center' width='20'>";
                     echo "<input type='checkbox' name='del_port[" . $netport->fields["id"] . "]' value='1'>";
                     echo "</td>\n";
                 }
                 echo "<td class='center'><strong>";
                 if ($canedit && $withtemplate != 2) {
                     echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?id=" . $netport->fields["id"] . "\">";
                 }
                 echo $netport->fields["logical_number"];
                 if ($canedit && $withtemplate != 2) {
                     echo "</a>";
                 }
                 echo "</strong>";
                 showToolTip($netport->fields['comment']);
                 echo "</td>\n";
                 echo "<td>" . $netport->fields["name"] . "</td>\n";
                 echo "<td>" . Dropdown::getDropdownName("glpi_netpoints", $netport->fields["netpoints_id"]) . "</td>\n";
                 echo "<td>" . $netport->fields["ip"] . "<br>" . $netport->fields["mac"] . "</td>\n";
                 echo "<td>" . $netport->fields["netmask"] . "&nbsp;/&nbsp;" . $netport->fields["subnet"] . "<br>" . $netport->fields["gateway"] . "</td>\n";
                 // VLANs
                 echo "<td>";
                 NetworkPort_Vlan::showForNetworkPort($netport->fields["id"], $canedit, $withtemplate);
                 echo "</td>\n";
                 echo "<td>" . Dropdown::getDropdownName("glpi_networkinterfaces", $netport->fields["networkinterfaces_id"]) . "</td>\n";
                 echo "<td width='300' class='tab_bg_2'>";
                 self::showConnection($item, $netport, $withtemplate);
                 echo "</td>\n";
                 echo "<td class='tab_bg_2'>";
                 if ($netport->getContact($netport->fields["id"])) {
                     echo $netport->fields["ip"] . "<br>";
                     echo $netport->fields["mac"];
                 }
                 echo "</td></tr>\n";
             }
             echo "</table>\n";
             if ($canedit && $withtemplate != 2) {
                 openArrowMassive("networking_ports{$rand}", true);
                 Dropdown::showForMassiveAction('NetworkPort');
                 closeArrowMassive();
             }
             if ($canedit && $withtemplate != 2) {
                 echo "</form>";
             }
         } else {
             echo "<table class='tab_cadre_fixe'><tr><th>" . $LANG['networking'][10] . "</th></tr>";
             echo "</table>";
         }
         echo "</div>";
     }
 }
 /**
  * show defined display preferences for a user
  *
  * @param $users_id integer user ID
  */
 static function showForUser($users_id)
 {
     global $DB, $LANG;
     $url = getItemTypeFormURL(__CLASS__);
     $query = "SELECT `itemtype`, COUNT(*) as nb\n                FROM `glpi_displaypreferences`\n                WHERE `users_id`='{$users_id}'\n                GROUP BY `itemtype`";
     $req = $DB->request($query);
     if ($req->numrows() > 0) {
         echo "<form name='formprefs' id='formprefs' action='{$url}' method='post'>";
         echo "<input type='hidden' name='users_id' value='{$users_id}'>";
         echo "<table class='tab_cadre_fixe'>";
         foreach ($req as $data) {
             echo "<tr class='tab_bg_1'><td width='10'>";
             echo "<input  type='checkbox' name='itemtype[" . $data["itemtype"] . "]' value='1'></td>";
             if (class_exists($data["itemtype"])) {
                 $item = new $data["itemtype"]();
                 $name = $item->getTypeName();
             } else {
                 $name = $data["itemtype"];
             }
             echo "<td>{$name}</td><td class='right'>" . $data['nb'] . "</td>";
             echo "</tr>";
         }
         echo "</table>";
         openArrowMassive('formprefs', true);
         closeArrowMassive('delete_for_user', $LANG['buttons'][6]);
         echo "</form>";
     } else {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><td class='b center'>" . $LANG['search'][15] . "</td></tr>";
         echo "</table>";
     }
 }
 /**
  * Show segments of a calendar
  *
  * @param $calendar Calendar object
  **/
 static function showForCalendar(Calendar $calendar)
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $calendar->getField('id');
     if (!$calendar->can($ID, 'r')) {
         return false;
     }
     $canedit = $calendar->can($ID, 'w');
     $rand = mt_rand();
     echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n             action='";
     echo getItemTypeFormURL(__CLASS__) . "'>";
     if ($canedit) {
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['calendar'][6] . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>" . $LANG['calendar'][7] . "&nbsp;: ";
         echo "<input type='hidden' name='entities_id' value='" . $calendar->fields['entities_id'] . "'>";
         echo "<input type='hidden' name='is_recursive' value='" . $calendar->fields['is_recursive'] . "'>";
         echo "<input type='hidden' name='calendars_id' value='{$ID}'>";
         Dropdown::showFromArray('day', $LANG['calendarDay']);
         echo "</td><td class='center'>" . $LANG['buttons'][33] . "&nbsp;: ";
         Dropdown::showHours("begin", date('H') . ":00");
         echo "</td><td class='center'>" . $LANG['buttons'][32] . "&nbsp;: ";
         Dropdown::showHours("end", date('H') + 1 . ":00");
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
     }
     echo "<div class='center'><table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='2'>" . $LANG['calendar'][7] . "</th>";
     echo "<th>" . $LANG['buttons'][33] . "</th>";
     echo "<th>" . $LANG['buttons'][32] . "</th>";
     echo "</tr>";
     $query = "SELECT *\n                FROM `glpi_calendarsegments`\n                WHERE `calendars_id` = '{$ID}'\n                ORDER BY `day`, `begin`, `end`";
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10'>";
             if ($canedit) {
                 echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             echo "<td>";
             echo $LANG['calendarDay'][$data['day']];
             echo "</td>";
             echo "<td>" . $data["begin"] . "</td>";
             echo "<td>" . $data["end"] . "</td>";
         }
         echo "</tr>";
     }
     echo "</table></div>";
     if ($canedit) {
         openArrowMassive("calendarsegment_form{$rand}", true);
         closeArrowMassive('delete', $LANG['buttons'][6]);
     }
     echo "</form>";
 }
Пример #21
0
 /** Show LDAP users to add or synchronise
  *
  * @return  nothing
  **/
 static function showLdapUsers()
 {
     global $CFG_GLPI, $LANG;
     $values['order'] = 'DESC';
     $values['start'] = 0;
     foreach ($_SESSION['ldap_import'] as $option => $value) {
         $values[$option] = $value;
     }
     $results = array();
     $limitexceeded = false;
     $ldap_users = self::getAllUsers($values, $results, $limitexceeded);
     if (is_array($ldap_users)) {
         $numrows = count($ldap_users);
         $action = "toprocess";
         $form_action = "process_ok";
         if ($numrows > 0) {
             if ($limitexceeded) {
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th class='red'>";
                 echo "<img class='center' src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png'\n                      alt='warning'>&nbsp;" . $LANG['ldap'][8];
                 echo "</th></tr></table><br>";
             }
             printPager($values['start'], $numrows, $_SERVER['PHP_SELF'], '');
             // delete end
             array_splice($ldap_users, $values['start'] + $_SESSION['glpilist_limit']);
             // delete begin
             if ($values['start'] > 0) {
                 array_splice($ldap_users, 0, $values['start']);
             }
             echo "<form method='post' id='ldap_form' name='ldap_form' action='" . $_SERVER['PHP_SELF'] . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . (!$_SESSION['ldap_import']['mode'] ? $LANG['buttons'][37] : $LANG['ldap'][15]) . "</th>";
             $num = 0;
             echo Search::showHeaderItem(HTML_OUTPUT, $LANG['Menu'][14], $num, $_SERVER['PHP_SELF'] . "?order=" . ($values['order'] == "DESC" ? "ASC" : "DESC"));
             echo "<th>" . $LANG['common'][26] . " " . $LANG['ldap'][13] . "</th>";
             if ($_SESSION['ldap_import']['mode']) {
                 echo "<th>" . $LANG['common'][26] . " " . $LANG['ldap'][14] . "</th>";
             }
             echo "</tr>";
             foreach ($ldap_users as $userinfos) {
                 $link = $user = $userinfos["user"];
                 if (isset($userinfos['id']) && haveRight('user', 'r')) {
                     $link = "<a href='" . getItemTypeFormURL('User') . '?id=' . $userinfos['id'] . "'>{$user}</a>";
                 }
                 if (isset($userinfos["timestamp"])) {
                     $stamp = $userinfos["timestamp"];
                 } else {
                     $stamp = '';
                 }
                 if (isset($userinfos["date_sync"])) {
                     $date_sync = $userinfos["date_sync"];
                 } else {
                     $date_sync = '';
                 }
                 echo "<tr class='tab_bg_2 center'>";
                 //Need to use " instead of ' because it doesn't work with names with ' inside !
                 echo "<td><input type='checkbox' name=\"" . $action . "[" . $user . "]\"></td>";
                 echo "<td>" . $link . "</td>";
                 if ($stamp != '') {
                     echo "<td>" . convDateTime(date("Y-m-d H:i:s", $stamp)) . "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($_SESSION['ldap_import']['mode']) {
                     if ($date_sync != '') {
                         echo "<td>" . convDateTime($date_sync) . "</td>";
                     } else {
                         echo "<td>&nbsp;</td>";
                     }
                 }
                 echo "</tr>";
             }
             if ($_SESSION['ldap_import']['mode']) {
                 $colspan = 6;
             } else {
                 $colspan = 5;
             }
             echo "</table>";
             openArrowMassive("ldap_form", true);
             closeArrowMassive($form_action, $_SESSION['ldap_import']['mode'] ? $LANG['ldap'][15] : $LANG['buttons'][37]);
             echo "</form>";
             printPager($values['start'], $numrows, $_SERVER['PHP_SELF'], '');
         } else {
             echo "<div class='center b'>" . ($_SESSION['ldap_import']['mode'] ? $LANG['ldap'][43] : $LANG['ldap'][3]) . "</div>";
         }
     } else {
         echo "<div class='center b'>" . ($_SESSION['ldap_import']['mode'] ? $LANG['ldap'][43] : $LANG['ldap'][3]) . "</div>";
     }
 }
Пример #22
0
 /**
  * Show items links to a document
  *
  * @return nothing (HTML display)
  **/
 function showItems()
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $this->fields['id'];
     if (!$this->can($instID, "r")) {
         return false;
     }
     $canedit = $this->can($instID, 'w');
     // for a document,
     // don't show here others documents associated to this one,
     // it's done for both directions in self::showAssociated
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_documents_items`\n                WHERE `glpi_documents_items`.`documents_id` = '{$instID}'\n                      AND `glpi_documents_items`.`itemtype` != 'Document'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $rand = mt_rand();
     echo "<form method='post' name='document_form{$rand}' id='document_form{$rand}' action='" . $CFG_GLPI["root_doc"] . "/front/document.form.php'>";
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='" . ($canedit ? 6 : 5) . "'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['document'][13];
     } else {
         if ($DB->numrows($result) == 1) {
             echo $LANG['document'][14];
         } else {
             echo $LANG['document'][19];
         }
     }
     echo "</th></tr><tr>";
     if ($canedit) {
         echo "<th>&nbsp;</th>";
     }
     echo "<th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['common'][19] . "</th>";
     echo "<th>" . $LANG['common'][20] . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         if ($item->canView()) {
             $column = "name";
             if ($itemtype == 'Ticket') {
                 $column = "id";
             }
             if ($itemtype == 'KnowbaseItem') {
                 $column = "question";
             }
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                             `glpi_documents_items`.`id` AS IDD, ";
             if ($itemtype == 'Entity') {
                 // Left join because root entity not storeed
                 $query .= "`glpi_documents_items`.`items_id` AS entity\n                          FROM `glpi_documents_items`\n                          LEFT JOIN `glpi_entities`\n                              ON (`glpi_entities`.`id` = `glpi_documents_items`.`items_id`)\n                          WHERE ";
             } else {
                 $query .= "`glpi_entities`.`id` AS entity\n                          FROM `glpi_documents_items`, `{$itemtable}`\n                          LEFT JOIN `glpi_entities`\n                              ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)\n                          WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n                          AND ";
             }
             $query .= "`glpi_documents_items`.`itemtype` = '{$itemtype}'\n                       AND `glpi_documents_items`.`documents_id` = '{$instID}' " . getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`";
             if ($itemtype == 'SoftwareLicense') {
                 $soft = new Software();
             }
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $ID = "";
                         if ($itemtype == 'Entity' && !$data['entity']) {
                             $data['id'] = 0;
                             $data['name'] = $LANG['entity']['2'];
                         }
                         if ($itemtype == 'Ticket') {
                             $data["name"] = $LANG['job'][38] . " " . $data["id"];
                         }
                         if ($itemtype == 'KnowbaseItem') {
                             $data["name"] = $data["question"];
                         }
                         if ($itemtype == 'SoftwareLicense') {
                             $soft->getFromDB($data['softwares_id']);
                             $data["name"] = $data["name"] . ' - ' . $soft->fields['name'];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "{$ID}</a>";
                         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 " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']);
                         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='4' class='center'>";
         echo "<input type='hidden' name='documents_id' value='{$instID}'>";
         Dropdown::showAllItems("items_id", 0, 0, $this->fields['is_recursive'] ? -1 : $this->fields['entities_id'], $CFG_GLPI["document_types"]);
         echo "</td>";
         echo "<td colspan='2' class='center'>";
         echo "<input type='submit' name='adddocumentitem' value='" . $LANG['buttons'][8] . "' class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         openArrowMassive("document_form{$rand}", true);
         closeArrowMassive('deletedocumentitem', $LANG['buttons'][6]);
     } else {
         echo "</table>";
     }
     echo "</div></form>";
 }
 /**
  * Show the list of rules
  *
  * @param $target
  * @param $tab
  * @param $options
  *
  * @return nothing
  **/
 function showListRules($target, $tab = 0, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $p['inherited'] = true;
     $p['childrens'] = false;
     $p['active'] = false;
     foreach (array('inherited', 'childrens') as $param) {
         if (isset($options[$param]) && $this->isRuleRecursive()) {
             $p[$param] = $options[$param];
         }
     }
     $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']);
     // Do not know what it is ?
     $canedit = haveRight($this->right, "w") && !$display_entities;
     $nb = $this->getCollectionSize($p['inherited']);
     $p['start'] = isset($options["start"]) ? $options["start"] : 0;
     if ($p['start'] >= $nb) {
         $p['start'] = 0;
     }
     $p['limit'] = $_SESSION['glpilist_limit'];
     $this->getCollectionPart($p);
     printAjaxPager('', $p['start'], $nb);
     echo "<form name='ruleactions_form' id='ruleactions_form' method='post'action='" . $target . "'>";
     echo "\n<div class='spaced'>";
     echo "<table class='tab_cadre_fixehov'>";
     $colspan = 6;
     if ($display_entities) {
         $colspan++;
     }
     echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n";
     echo "<tr><th colspan='2'>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['joblist'][6] . "</th>";
     echo "<th>" . $LANG['common'][60] . "</th>";
     if ($display_entities) {
         echo "<th>" . $LANG['entity'][0] . "</th>\n";
     }
     if (!$display_entities) {
         echo "<th colspan='2'>&nbsp;</th>";
     }
     echo "</tr>\n";
     if (count($this->RuleList->list)) {
         $ruletype = $this->RuleList->list[0]->getType();
         initNavigateListItems($ruletype);
     }
     for ($i = $p['start'], $j = 0; isset($this->RuleList->list[$j]); $i++, $j++) {
         $this->RuleList->list[$j]->showMinimalForm($target, $i == 0, $i == $nb - 1, $display_entities);
         addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']);
     }
     echo "</table>\n";
     if ($canedit && $nb > 0) {
         openArrowMassive("ruleactions_form", true);
         echo "<select name='massiveaction' id='massiveaction'>";
         echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
         echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
         if ($this->orderby == "ranking") {
             echo "<option value='move_rule'>" . $LANG['buttons'][20] . "</option>";
         }
         echo "<option value='activate_rule'>" . $LANG['buttons'][41] . "</option>";
         echo "</select>\n";
         $params = array('action' => '__VALUE__', 'itemtype' => 'Rule', 'sub_type' => $this->getRuleClassName(), 'entity_restrict' => $this->entity);
         ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveAction.php", $params);
         echo "<span id='show_massiveaction'>&nbsp;</span>\n";
         if ($this->can_replay_rules) {
             echo "</td>";
             // close td of openArrowMassive
             echo "<td><input type='submit' name='replay_rule' value='" . $LANG['rulesengine'][76] . "' class='submit'></td>";
             echo "<td>";
             // open td for closeArrowMassive
         }
         closeArrowMassive();
     }
     echo "</div></form>";
     echo "<div class='spaced center'><span class='icon_consol'>";
     if ($plugin = isPluginItemType($this->getType())) {
         $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']);
     } else {
         $url = $CFG_GLPI["root_doc"];
     }
     echo "<a href='#' onClick=\"var w=window.open('" . $url . "/front/popup.php?popup=test_all_rules&amp;sub_type=" . $this->getRuleClassName() . "&amp' ,'glpipopup', 'height=400, width=1000, top=100, left=100, scrollbars=yes' );" . "w.focus();\">" . $LANG['rulesengine'][84] . "</a></span></div>";
     echo "<div class='spaced'>";
     $this->showAdditionalInformationsInForm($target);
     echo "</div>";
 }
Пример #24
0
 /**
  * Print the HTML array for Items linked to current contract
  *
  *@return Nothing (display)
  *
  **/
 function showItems()
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $this->fields['id'];
     if (!$this->can($instID, 'r')) {
         return false;
     }
     $canedit = $this->can($instID, 'w');
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`contracts_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='center'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='5'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['document'][13];
     } else {
         echo $LANG['document'][19];
     }
     echo "</th></tr>";
     if ($canedit) {
         echo "</table></div>";
         echo "<form method='post' name='contract_form{$rand}' id='contract_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/front/contract.form.php\">";
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'>";
         // massive action checkbox
         echo "<tr><th>&nbsp;</th>";
     } else {
         echo "<tr>";
     }
     echo "<th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['common'][19] . "</th>";
     echo "<th>" . $LANG['common'][20] . "</th></tr>";
     $totalnb = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                             `glpi_contracts_items`.`id` AS IDD,\n                             `glpi_entities`.`id` AS entity\n                      FROM `glpi_contracts_items`,\n                           `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_contracts_items`.`items_id`\n                              AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'\n                              AND `glpi_contracts_items`.`contracts_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             if ($nb > $_SESSION['glpilist_limit']) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>&nbsp;</td>";
                 }
                 echo "<td class='center'>" . $item->getTypeName() . "&nbsp;:&nbsp;{$nb}</td>";
                 echo "<td class='center' colspan='2'>";
                 echo "<a href='" . getItemTypeSearchURL($itemtype) . "?" . rawurlencode("contains[0]") . "=" . rawurlencode('$$$$' . $instID) . "&amp;" . rawurlencode("field[0]") . "=29&amp;sort=80&amp;order=ASC&amp;is_deleted=0" . "&amp;start=0" . "'>" . $LANG['reports'][57] . "</a></td>";
                 echo "<td class='center'>-</td><td class='center'>-</td></tr>";
             } else {
                 if ($nb > 0) {
                     for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                         $ID = "";
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "{$ID}</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             $sel = "";
                             if (isset($_GET["select"]) && $_GET["select"] == "all") {
                                 $sel = "checked";
                             }
                             echo "<td width='10'>";
                             echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}></td>";
                         }
                         if ($prem) {
                             echo "<td class='center top' rowspan='{$nb}'>" . $item->getTypeName() . ($nb > 1 ? "&nbsp;:&nbsp;{$nb}</td>" : "</td>");
                         }
                         echo "<td class='center'>";
                         echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                         echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
                         echo ">" . $name . "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
             $totalnb += $nb;
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' colspan='2'>" . ($totalnb > 0 ? $LANG['common'][33] . "&nbsp;=&nbsp;{$totalnb}</td>" : "&nbsp;</td>");
     echo "<td colspan='4'>&nbsp;</td></tr> ";
     if ($canedit) {
         if ($this->fields['max_links_allowed'] == 0 || $this->fields['max_links_allowed'] > $totalnb) {
             echo "<tr class='tab_bg_1'><td colspan='4' class='right'>";
             Dropdown::showAllItems("items_id", 0, 0, $this->fields['is_recursive'] ? -1 : $this->fields['entities_id'], $CFG_GLPI["contract_types"]);
             echo "</td><td class='center'>";
             echo "<input type='submit' name='additem' value=\"" . $LANG['buttons'][8] . "\"\n                   class='submit'>";
             echo "</td><td>&nbsp;</td></tr>";
         }
         echo "</table>";
         openArrowMassive("contract_form{$rand}", true);
         echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
         closeArrowMassive('deleteitem', $LANG['buttons'][6]);
     } else {
         echo "</table>";
     }
     echo "</div></form>";
 }