/** * 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'> </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'> </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&sub_type=" . $this->getRuleClassName() . "&' ,'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>"; }
/** * Show installations of a software * * @param $searchID valeur to the ID to search * @param $crit to search : softwares_id (software) or id (version) * * @return nothing **/ private static function showInstallations($searchID, $crit) { global $DB, $CFG_GLPI, $LANG; 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 { if ($crit == "softwares_id") { $sort = "`entity` {$order}, `version`, `compname`"; } else { $sort = "`entity` {$order}, `compname`"; } } // Total Number of events if ($crit == "softwares_id") { // Software ID $query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_computers_softwareversions`\n INNER JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwareversions`.`computers_id`\n = `glpi_computers`.`id`)\n WHERE `glpi_softwareversions`.`softwares_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'"; } else { //SoftwareVersion ID $query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_computers_softwareversions`\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwareversions`.`computers_id`\n = `glpi_computers`.`id`)\n WHERE `glpi_computers_softwareversions`.`softwareversions_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 ($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'][19], $start, $number); $query = "SELECT DISTINCT `glpi_computers_softwareversions`.*,\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_users`.`id` AS userid,\n `glpi_users`.`realname` AS userrealname,\n `glpi_users`.`firstname` AS userfirstname,\n `glpi_softwareversions`.`name` AS version,\n `glpi_softwareversions`.`id` AS vID,\n `glpi_softwareversions`.`softwares_id` AS sID,\n `glpi_softwareversions`.`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 FROM `glpi_computers_softwareversions`\n INNER JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwareversions`.`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_softwareversions`.`{$crit}` = '{$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)) { $softwares_id = $data['sID']; $soft = new Software(); $showEntity = $soft->getFromDB($softwares_id) && $soft->isRecursive(); $linkUser = haveRight('user', 'r'); $title = $LANG['help'][31] . " = " . $soft->fields["name"]; if ($crit == "id") { $title .= " - " . $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_softwareversion.form.php'>"; echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>"; echo "<table class='tab_cadre_fixehov'><tr>"; echo "<th> </th>"; } else { echo "<table class='tab_cadre_fixehov'><tr>"; } if ($crit == "softwares_id") { echo "<th>" . ($sort == "`vername`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=vername&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['software'][5] . "</a></th>"; } echo "<th>" . ($sort == "`compname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][16] . "</a></th>"; if ($showEntity) { echo "<th>" . (strstr($sort, "entity") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=entity,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['entity'][0] . "</a></th>"; } echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][19] . "</a></th>"; echo "<th>" . ($sort == "`otherserial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=otherserial&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][20] . "</a></th>"; echo "<th>" . (strstr($sort, "`location`") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=location,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][15] . "</a></th>"; echo "<th>" . (strstr($sort, "state") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=state,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['state'][0] . "</a></th>"; echo "<th>" . (strstr($sort, "groupe") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=groupe,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][35] . "</a></th>"; echo "<th>" . (strstr($sort, "username") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=username,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][34] . "</a></th>"; echo "<th>" . ($sort == "`lname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=lname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['software'][11] . "</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>"; } if ($crit == "softwares_id") { echo "<td><a href='softwareversion.form.php?id=" . $data['vID'] . "'>" . $data['version']; echo "</a></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>" . formatUserName($data['userid'], $data['username'], $data['userrealname'], $data['userfirstname'], $linkUser) . "</td>"; $lics = Computer_SoftwareLicense::GetLicenseForInstallation($data['cID'], $data['vID']); echo "<td>"; if (count($lics)) { foreach ($lics as $data) { echo "<a href='softwarelicense.form.php?id=" . $data['id'] . "'>" . $data['name']; echo "</a> - " . $data['serial']; if (!empty($data['type'])) { echo " (" . $data['type'] . ")"; } echo "<br>"; } } echo "</td>"; echo "</tr>\n"; } while ($data = $DB->fetch_assoc($result)); echo "</table>\n"; if ($canedit) { openArrowMassive("softinstall" . $rand . "", true); SoftwareVersion::dropdown(array('name' => 'versionID', 'softwares_id' => $softwares_id)); echo " <input type='submit' name='moveinstalls' value='" . $LANG['buttons'][20] . "' class='submit'> "; closeArrowMassive('deleteinstalls', $LANG['buttons'][6]); echo "</form>"; } } else { // Not found echo $LANG['search'][15]; } } // Query echo "</div>\n"; }
/** * 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> </th>"; echo "<th>" . ($sort == "`name`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=name&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&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&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['entity'][0] . "</a></th>"; } echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][19] . "</a></th>"; echo "<th>" . ($sort == "`number`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=number&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&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&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['common'][17] . "</a></th>"; echo "<th>" . ($sort == "`buyname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=buyname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['software'][1] . "</a></th>"; echo "<th>" . ($sort == "`usename`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=usename&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . $LANG['software'][2] . "</a></th>"; echo "<th>" . ($sort == "`expire`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=expire&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&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> </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'] . " " : $LANG['software'][4]) . "</td>"; $nb_assoc = Computer_SoftwareLicense::countForLicense($data['id']); $tot_assoc += $nb_assoc; echo "<td class='right'>{$nb_assoc} </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 . " " : $LANG['software'][4]) . "</td>"; echo "<td class='right b'>{$tot_assoc} </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>"; }
/** * Show History of an item * * @param $item CommonDBTM object **/ static function showForItem(CommonDBTM $item) { global $DB, $LANG; $itemtype = $item->getType(); $items_id = $item->getField('id'); $SEARCHOPTION = Search::getOptions($itemtype); if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } // Total Number of events $number = countElementsInTable("glpi_logs", "`items_id`='{$items_id}' AND `itemtype`='{$itemtype}'"); // No Events in database if ($number < 1) { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . $LANG['event'][20] . "</th></tr>"; echo "</table>"; echo "</div><br>"; return; } // Display the pager printAjaxPager($LANG['title'][38], $start, $number); // Output events echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . $LANG['common'][2] . "</th><th>" . $LANG['common'][27] . "</th>"; echo "<th>" . $LANG['common'][34] . "</th><th>" . $LANG['event'][18] . "</th>"; echo "<th>" . $LANG['event'][19] . "</th></tr>"; foreach (self::getHistoryData($item, $start, $_SESSION['glpilist_limit']) as $data) { if ($data['display_history']) { // show line echo "<tr class='tab_bg_2'>"; echo "<td>" . $data['id'] . "</td><td>" . $data['date_mod'] . "</td><td>" . $data['user_name'] . "</td><td>" . $data['field'] . "</td>"; echo "<td width='60%'>" . $data['change'] . "</td></tr>"; } } echo "</table></div>"; }
/** * 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'> </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] . " : "; 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] . " : "; echo "<input type='text' maxlength='100' size='10' name='_before'> "; Dropdown::showInteger('_from', 0, 0, 400); echo " --> "; Dropdown::showInteger('_to', 0, 0, 400); echo " <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"; }
/** * Display list of a runned tasks * * @return nothing **/ function showHistory() { global $DB, $CFG_GLPI, $LANG; if (isset($_REQUEST["crontasklogs_id"]) && $_REQUEST["crontasklogs_id"]) { return $this->showHistoryDetail($_REQUEST["crontasklogs_id"]); } if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } // Total Number of events $number = countElementsInTable('glpi_crontasklogs', "`crontasks_id` = '" . $this->fields['id'] . "'\n AND `state` = '" . CronTaskLog::STATE_STOP . "'"); echo "<br><div class='center'>"; if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . $LANG['search'][15] . "</th></tr>"; echo "</table>"; echo "</div>"; return; } // Display the pager printAjaxPager($LANG['crontask'][47], $start, $number); $query = "SELECT *\n FROM `glpi_crontasklogs`\n WHERE `crontasks_id` = '" . $this->fields['id'] . "'\n AND `state` = '" . CronTaskLog::STATE_STOP . "'\n ORDER BY `id` DESC\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); if ($result = $DB->query($query)) { if ($data = $DB->fetch_assoc($result)) { echo "<table class='tab_cadrehov'><tr>"; echo "<th>" . $LANG['common'][27] . "</th>"; // Date echo "<th>" . $LANG['job'][20] . "</th>"; // Duration echo "<th>" . $LANG['tracking'][29] . "</th>"; // Number echo "<th>" . $LANG['joblist'][6] . "</th>"; // Description echo "</tr>\n"; do { echo "<tr class='tab_bg_2'>"; echo "<td><a href='javascript:reloadTab(\"crontasklogs_id=" . $data['crontasklogs_id'] . "\");'>" . convDateTime($data['date']) . "</a></td>"; echo "<td class='right'>" . number_format($data['elapsed'], 3) . "s</td>"; echo "<td class='right'>" . $data['volume'] . "</td>"; echo "<td>" . $data['content'] . "</td>"; echo "</tr>\n"; } while ($data = $DB->fetch_assoc($result)); echo "</table>"; } else { // Not found echo $LANG['search'][15]; } } // Query echo "</div>"; }