Print Ajax pager for list in tab panel
static public printAjaxPager ( $title, $start, $numrows, $additional_info = '' ) : nothing | ||
$title | displayed above | |
$start | from witch item we start | |
$numrows | total items | |
$additional_info | Additional information to display (default '') | |
return | nothing | (print a pager) |
/** * Print the wainting ticket form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * * @return Nothing (display) * */ static function showForTicket($item) { global $CFG_GLPI; // validation des droits if (!Session::haveRight('plugin_moreticket', READ)) { return false; } if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } // Total Number of events $number = countElementsInTable("glpi_plugin_moreticket_waitingtickets", "`tickets_id`='" . $item->getField('id') . "'"); if ($number < 1) { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No historical') . "</th></tr>"; echo "</table>"; echo "</div><br>"; return; } else { echo "<div class='center'>"; // Display the pager Html::printAjaxPager(__('Ticket suspension history', 'moreticket'), $start, $number); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __('Suspension date', 'moreticket') . "</th>"; echo "<th>" . __('Reason', 'moreticket') . "</th>"; echo "<th>" . PluginMoreticketWaitingType::getTypeName(1) . "</th>"; echo "<th>" . __('Postponement date', 'moreticket') . "</th>"; echo "<th>" . __('Suspension end date', 'moreticket') . "</th>"; echo "</tr>"; foreach (self::getWaitingTicketFromDB($item->getField('id'), array('start' => $start, 'limit' => $_SESSION['glpilist_limit'])) as $waitingTicket) { echo "<tr class='tab_bg_2'>"; echo "<td>"; echo Html::convDateTime($waitingTicket['date_suspension']); echo "</td>"; echo "<td>"; echo $waitingTicket['reason']; echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_plugin_moreticket_waitingtypes', $waitingTicket['plugin_moreticket_waitingtypes_id']); echo "</td>"; echo "<td>"; if ($waitingTicket['date_report'] == "0000-00-00 00:00:00") { echo _x('periodicity', 'None'); } else { echo Html::convDateTime($waitingTicket['date_report']); } echo "</td>"; echo "<td>"; echo Html::convDateTime($waitingTicket['date_end_suspension']); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; Html::printAjaxPager(__('Ticket suspension history', 'moreticket'), $start, $number); } }
/** * Show computers linked to a License * * @param $license SoftwareLicense object * * @return nothing **/ static function showForLicense(SoftwareLicense $license) { global $DB, $CFG_GLPI; $searchID = $license->getField('id'); if (!Software::canView() || !$searchID) { return false; } $canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE)); $canshowcomputer = Computer::canView(); if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } if (isset($_GET["order"]) && $_GET["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } if (isset($_GET["sort"]) && !empty($_GET["sort"])) { // manage several param like location,compname : order first $tmp = explode(",", $_GET["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`\n = `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'\n AND `glpi_computers_softwarelicenses`.`is_deleted` = '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>"; Computer::dropdown(array('entity' => $license->fields['entities_id'], 'entity_sons' => $license->fields['is_recursive'])); echo "</td>"; echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); } if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table></div>\n"; return; } // Display the pager Html::printAjaxPager(__('Affected computers'), $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_users`.`id` AS userid,\n `glpi_users`.`realname` AS userrealname,\n `glpi_users`.`firstname` AS userfirstname,\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 `glpi_softwarelicenses`.`softwares_id` AS softid\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 AND `glpi_computers_softwarelicenses`.`is_deleted` = '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)) { if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $_SESSION['glpilist_limit'], 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently'))); // show transfer only if multi licenses for this software if (self::countLicenses($data['softid']) > 1) { $massiveactionparams['specific_actions'][__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'move_license'] = _x('button', 'Move'); } // Options to update license $massiveactionparams['extraparams']['options']['move']['used'] = array($searchID); $massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id']; Html::showMassiveActions($massiveactionparams); } $soft = new Software(); $soft->getFromDB($license->fields['softwares_id']); $showEntity = $license->isRecursive(); $linkUser = User::canView(); $text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]); $text = sprintf(__('%1$s - %2$s'), $text, $data["vername"]); Session::initNavigateListItems('Computer', $text); $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'>"; $columns = array('compname' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'otherserial' => __('Inventory number'), 'location,compname' => __('Location'), 'state,compname' => __('Status'), 'groupe,compname' => __('Group'), 'username,compname' => __('User')); if (!$showEntity) { unset($columns['entity']); } $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } foreach ($columns as $key => $val) { // Non order column if ($key[0] == '_') { $header_end .= "<th>{$val}</th>"; } else { $header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>"; } } $header_end .= "</tr>\n"; echo $header_begin . $header_top . $header_end; do { Session::addToNavigateListItems('Computer', $data["cID"]); echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>"; } $compname = $data['compname']; if (empty($compname) || $_SESSION['glpiis_ids_visible']) { $compname = sprintf(__('%1$s (%2$s)'), $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>" . $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>"; echo "</tr>\n"; } while ($data = $DB->fetch_assoc($result)); echo $header_begin . $header_bottom . $header_end; echo "</table>\n"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } else { // Not found _e('No item found'); } } // Query Html::printAjaxPager(__('Affected computers'), $start, $number); echo "</div>\n"; }
static function showMinimalList($params = array()) { global $DB, $CFG_GLPI; $item = new self(); $itemtype = $item->getType(); $itemtable = $item->getTable(); // 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['id'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; $p['withtemplate'] = 0; foreach ($params as $key => $val) { $p[$key] = $val; } $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->getFromDB($p['id']); $canedit = $PluginResourcesResource->can($p['id'], 'w'); if (isset($_POST["start"])) { $p['start'] = $_POST["start"]; } else { $p['start'] = 0; } if (isset($_POST["sort"])) { $p['sort'] = $_POST["sort"]; } else { $p['sort'] = 1; } if (isset($_POST["order"]) && $_POST["order"] == "DESC") { $p['order'] = "DESC"; } else { $p['order'] = "ASC"; } // 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 = Toolbox::getItemTypeSearchURL($itemtype); $limitsearchopt = Search::getCleanedOptions($itemtype); $LIST_LIMIT = $_SESSION['glpilist_limit']; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; // Limit to 10 element if ($_GET['display_type'] == Search::GLOBAL_SEARCH) { $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT; } } $entity_restrict = $item->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView($itemtype); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::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']); } // Clean toview array $toview = array_unique($toview); foreach ($toview as $key => $val) { if (!isset($limitsearchopt[$val])) { unset($toview[$key]); } } $toview_count = count($toview); //// 1 - SELECT $query = "SELECT " . Search::addDefaultSelect($itemtype); // Add select for all toview item foreach ($toview as $key => $val) { $query .= Search::addSelect($itemtype, $val, $key, 0); } $query .= "`" . $itemtable . "`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table $query .= " 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 = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt[$itemtype] =& Search::getOptions($itemtype); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::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)) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]); } } } $query .= " WHERE `" . $itemtable . "`.`plugin_resources_resources_id` = '" . $p['id'] . "'"; $query .= " AND `" . $itemtable . "`.`is_deleted` = '" . $p['is_deleted'] . "' "; //// 7 - Manage GROUP BY $GROUPBY = ""; // Meta Search / Search All / Count tickets if (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`"; } } } $query .= $GROUPBY; //// 4 - ORDER $ORDER = " ORDER BY `id` "; foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key); } } $query .= $ORDER; // Get it from database if ($result = $DB->query($query)) { $numrows = $DB->numrows($result); $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']); $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto; if ($output_type == Search::GLOBAL_SEARCH) { if (class_exists($itemtype)) { echo "<div class='center'><h2>" . $item->getTypeName(); // More items if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) { echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } if ($p['start'] < $numrows) { if ($output_type == Search::HTML_OUTPUT && !$p['withtemplate']) { echo "<div align='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?contains%5B0%5D=" . $p['id'] . "&field%5B0%5D=13&sort=1&is_deleted=0&start=0'>" . _x('button', 'Search') . "</a><br>"; echo "</div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $search_config = ""; if ($item->canCreate() && $canedit) { $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\""; $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config .= $tmp . ">"; } //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']); } // Pager if ($output_type == Search::HTML_OUTPUT) { Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows, $search_config); echo "<br>"; } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; // Export All case if ($p['export_all']) { $begin_display = 0; $end_display = $numrows; } //massive action $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { Html::openMassiveActionsForm('massform' . $itemtype); $massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => true, 'is_deleted' => $p['is_deleted']); Html::showMassiveActions($itemtype, $massiveactionparams); } // Add toview elements $nbcols = $toview_count; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $nbcols++; } // Display List Header echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols, 1); $header_num = 1; // Display column Headers for toview items $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; echo Search::showNewLine($output_type); if ($output_type == Search::HTML_OUTPUT && $item->canCreate() && $canedit) { // HTML display - massive modif $headers_line_top .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); $headers_line_bottom .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $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 = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']); } // End Line for column headers $headers_line .= Search::showEndLine($output_type); $headers_line_top .= $headers_line; $headers_line_bottom .= $headers_line; echo $headers_line_top; $DB->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 == Search::HTML_OUTPUT) { Session::initNavigateListItems($itemtype, PluginResourcesResource::getTypeName(2) . " = " . (empty($PluginResourcesResource->fields['name']) ? "(" . $p['id'] . ")" : $PluginResourcesResource->fields['name'])); } // Num of the row (1=header_line) $row_num = 1; // Display Loop while ($i < $numrows && $i < $end_display) { $item_num = 1; $data = $DB->fetch_array($result); $i++; $row_num++; echo Search::showNewLine($output_type, $i % 2); Session::addToNavigateListItems($itemtype, $data['id']); $tmpcheck = ""; if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $sel = ""; $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>"; } echo Search::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'"); foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, Search::displayConfigItem($itemtype, $val, $data, $key)); } echo Search::showEndLine($output_type); } // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= __('Tasks list', 'resources'); } // Display footer echo Search::showFooter($output_type, $title); //massive action if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($itemtype, $massiveactionparams); Html::closeForm(); } else { echo "</table></div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows); } } else { echo Search::showError($output_type); } } }
/** * Show Licenses of a software * * @param $software Software object * * @return nothing **/ static function showForSoftware(Software $software) { global $DB, $CFG_GLPI; $softwares_id = $software->getField('id'); $license = new self(); $computer = new Computer(); if (!$software->can($softwares_id, READ)) { return false; } $columns = array('name' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'number' => _x('quantity', 'Number'), '_affected' => __('Affected computers'), 'typename' => __('Type'), 'buyname' => __('Purchase version'), 'usename' => __('Version in use'), 'expire' => __('Expiration')); if (!$software->isRecursive()) { unset($columns['entity']); } if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } if (isset($_GET["order"]) && $_GET["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) { $sort = "`" . $_GET["sort"] . "`"; } else { $sort = "`entity` {$order}, `name`"; } // Righ type is enough. Can add a License on a software we have Read access $canedit = Software::canUpdate(); $showmassiveactions = $canedit; // Total Number of events $number = countElementsInTable("glpi_softwarelicenses", "glpi_softwarelicenses.softwares_id = {$softwares_id} " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true)); echo "<div class='spaced'>"; Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $software->getName())); if ($canedit) { echo "<div class='center firstbloc'>"; echo "<a class='vsubmit' href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . _x('button', 'Add a license') . "</a>"; echo "</div>"; } $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']); if ($result = $DB->query($query)) { if ($num_displayed = $DB->numrows($result)) { // Display the pager Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, $number); if ($showmassiveactions) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $num_displayed, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('options' => array('glpi_softwareversions.name' => array('condition' => "`glpi_softwareversions`.`softwares_id`\n = {$softwares_id}"), 'glpi_softwarelicenses.name' => array('itemlink_as_string' => true)))); Html::showMassiveActions($massiveactionparams); } $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>"; $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'>"; $header_begin = "<tr><th>"; $header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end = ''; foreach ($columns as $key => $val) { // Non order column if ($key[0] == '_') { $header_end .= "<th>{$val}</th>"; } else { $header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>"; } } $header_end .= "</tr>\n"; echo $header_begin . $header_top . $header_end; $tot_assoc = 0; for ($tot = 0; $data = $DB->fetch_assoc($result);) { Session::addToNavigateListItems('SoftwareLicense', $data['id']); $expired = true; if (is_null($data['expire']) || $data['expire'] > date('Y-m-d')) { $expired = false; } echo "<tr class='tab_bg_2" . ($expired ? '_2' : '') . "'>"; if ($license->canEdit($data['id'])) { echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</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 (isset($columns['entity'])) { echo "<td>"; echo $data['entity']; echo "</td>"; } echo "<td>" . $data['serial'] . "</td>"; echo "<td class='numeric'>" . ($data['number'] > 0 ? $data['number'] : __('Unlimited')) . "</td>"; $nb_assoc = Computer_SoftwareLicense::countForLicense($data['id']); $tot_assoc += $nb_assoc; $color = $data['is_valid'] ? 'green' : 'red'; echo "<td class='numeric {$color}'>" . $nb_assoc . "</td>"; echo "<td>" . $data['typename'] . "</td>"; echo "<td>" . $data['buyname'] . "</td>"; echo "<td>" . $data['usename'] . "</td>"; echo "<td class='center'>" . Html::convDate($data['expire']) . "</td>"; echo "</tr>"; if ($data['number'] < 0) { // One illimited license, total is illimited $tot = -1; } else { if ($tot >= 0) { // Expire license not count if (!$expired) { // Not illimited, add the current number $tot += $data['number']; } } } } echo "<tr class='tab_bg_1 noHover'>"; echo "<td colspan='" . ($software->isRecursive() ? 4 : 3) . "' class='right b'>" . __('Total') . "</td>"; echo "<td class='numeric'>" . ($tot > 0 ? $tot . "" : __('Unlimited')) . "</td>"; $color = $software->fields['is_valid'] ? 'green' : 'red'; echo "<td class='numeric {$color}'>" . $tot_assoc . "</td><td></td><td></td><td></td><td></td>"; echo "</tr>"; echo "</table>\n"; if ($showmassiveactions) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, $number); } else { echo "<table class='tab_cadre_fixe'><tr><th>" . __('No item found') . "</th></tr></table>"; } } echo "</div>"; }
public static function showForBudget($budgets_id) { global $DB, $CFG_GLPI; $table = getTableForItemType(__CLASS__); $query = "SELECT *\n FROM `{$table}`\n WHERE `budgets_id` = '{$budgets_id}'\n AND `is_template`='0'\n ORDER BY `entities_id`, `name` "; $result = $DB->query($query); $nb = $DB->numrows($result); echo "<div class='center'>"; if ($nb) { $start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0; $query_limit = $query . " LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); Html::printAjaxPager(__("Linked orders", "order"), $start, $nb); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th style='width:15%;'>" . _n("Action", "Actions", 2) . "</th>"; echo "<th>" . __("Name") . "</th>"; echo "<th>" . __("Order status", "order") . "</th>"; echo "<th>" . __("Entity") . "</th>"; echo "<th>" . __("Price tax free", "order") . "</th>"; echo "<th>" . __("Price ATI", "order") . "</th>"; echo "</tr>"; $total = 0; foreach ($DB->request($query_limit) as $data) { $PluginOrderOrder_Item = new PluginOrderOrder_Item(); $prices = $PluginOrderOrder_Item->getAllPrices($data["id"]); $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($data["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $data["plugin_order_ordertaxes_id"])); $total += $prices["priceTTC"] + $postagewithTVA; $link = Toolbox::getItemTypeFormURL(__CLASS__); echo "<tr class='tab_bg_1' align='center'>"; echo "<td>"; echo "<a href=\"" . $link . "?unlink_order=unlink_order&id=" . $data["id"] . "\">" . __("Unlink", "order") . "</a>"; echo "</td>"; echo "<td>"; if (self::canView()) { echo "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "</a>"; } else { echo $data["name"]; } echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName(getTableForItemType('PluginOrderOrderState'), $data["plugin_order_orderstates_id"]); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo "</td>"; echo "<td>"; echo Html::formatNumber($prices["priceHT"]); echo "</td>"; echo "<td>"; echo Html::formatNumber($prices["priceTTC"] + $postagewithTVA); echo "</td>"; echo "</tr>"; } echo "</table></div>"; echo "<br><div class='center'>"; echo "<table class='tab_cadre' width='15%'>"; echo "<tr class='tab_bg_2'><td>" . __("Budget already used") . ": </td>"; echo "<td>"; echo Html::formatNumber($total) . "</td>"; echo "</tr>"; echo "</table></div>"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><td class='center'>" . __("No item to display") . "</td></tr>"; echo "</table>"; } }
/** * Show items for the group * * @param $tech boolean false search groups_id, true, search groups_id_tech **/ function showItems($tech) { global $DB, $CFG_GLPI; $rand = mt_rand(); $ID = $this->fields['id']; if ($tech) { $types = $CFG_GLPI['linkgroup_tech_types']; $field = 'groups_id_tech'; $title = __('Managed items'); } else { $types = $CFG_GLPI['linkgroup_types']; $field = 'groups_id'; $title = __('Used items'); } $tree = Session::getSavedOption(__CLASS__, 'tree', 0); $user = Session::getSavedOption(__CLASS__, 'user', 0); $type = Session::getSavedOption(__CLASS__, 'onlytype', ''); if (!in_array($type, $types)) { $type = ''; } echo "<div class='spaced'>"; // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='3'>{$title}</tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo __('Type') . " "; Dropdown::showItemType($types, array('value' => $type, 'name' => 'onlytype', 'plural' => true, 'on_change' => 'reloadTab("start=0&onlytype="+this.value)', 'checkright' => true)); if ($this->haveChildren()) { echo "</td><td class='center'>" . __('Child groups') . " "; Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)')); } else { $tree = 0; } if ($this->getField('is_usergroup')) { echo "</td><td class='center'>" . User::getTypeName(Session::getPluralNumber()) . " "; Dropdown::showYesNo('user', $user, -1, array('on_change' => 'reloadTab("start=0&user="******"</td></tr></table>"; $datas = array(); if ($type) { $types = array($type); } $start = isset($_GET['start']) ? intval($_GET['start']) : 0; $nb = $this->getDataItems($types, $field, $tree, $user, $start, $datas); $nbcan = 0; if ($nb) { Html::printAjaxPager('', $start, $nb); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); echo Html::hidden('field', array('value' => $field, 'data-glpicore-ma-tags' => 'common')); $massiveactionparams = array('num_displayed' => $nb, 'check_itemtype' => 'Group', 'check_items_id' => $ID, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('is_tech' => $tech, 'massive_action_fields' => array('field')), 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'changegroup' => __('Move'))); Html::showMassiveActions($massiveactionparams); echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr><th width='10'>"; $header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end = '</th>'; $header_end .= "<th>" . __('Type') . "</th><th>" . __('Name') . "</th><th>" . __('Entity') . "</th>"; if ($tree || $user) { $header_end .= "<th>" . sprintf(__('%1$s / %2$s'), self::getTypeName(1), User::getTypeName(1)) . "</th>"; } $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; $tuser = new User(); $group = new Group(); foreach ($datas as $data) { if (!($item = getItemForItemtype($data['itemtype']))) { continue; } echo "<tr class='tab_bg_1'><td>"; if ($item->canEdit($data['items_id'])) { Html::showMassiveActionCheckBox($data['itemtype'], $data['items_id']); } echo "</td><td>" . $item->getTypeName(1); echo "</td><td>" . $item->getLink(array('comments' => true)); echo "</td><td>" . Dropdown::getDropdownName("glpi_entities", $item->getEntityID()); if ($tree || $user) { echo "</td><td>"; if ($grp = $item->getField($field)) { if ($group->getFromDB($grp)) { echo $group->getLink(array('comments' => true)); } } else { if ($usr = $item->getField(str_replace('groups', 'users', $field))) { if ($tuser->getFromDB($usr)) { echo $tuser->getLink(array('comments' => true)); } } } } echo "</td></tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } if ($nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); } Html::closeForm(); if ($nb) { Html::printAjaxPager('', $start, $nb); } echo "</div>"; }
function showReport($params) { global $CFG_GLPI; $PluginAddressingReport = new PluginAddressingReport(); // Default values of parameters $default_values["start"] = $start = 0; $default_values["id"] = $id = 0; $default_values["export"] = $export = false; foreach ($default_values as $key => $val) { if (isset($params[$key])) { ${$key} = $params[$key]; } } if ($this->getFromDB($id)) { $result = $this->compute($start); $nbipf = 0; // ip libres $nbipr = 0; // ip reservees $nbipt = 0; // ip trouvees $nbipd = 0; // doublons foreach ($result as $ip => $lines) { if (count($lines)) { if (count($lines) > 1) { $nbipd++; } if (isset($lines[0]['pname']) && strstr($lines[0]['pname'], "reserv")) { $nbipr++; } $nbipt++; } else { $nbipf++; } } ////title echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 left'>"; echo "<td>"; if ($this->fields['free_ip']) { echo __('Number of free ip', 'addressing') . " " . $nbipf . "<br>"; } if ($this->fields['reserved_ip']) { echo __('Number of reserved ip', 'addressing') . " " . $nbipr . "<br>"; } if ($this->fields['alloted_ip']) { echo __('Number of assigned ip (no doubles)', 'addressing') . " " . $nbipt . "<br>"; } if ($this->fields['double_ip']) { echo __('Doubles', 'addressing') . " " . $nbipd . "<br>"; } echo "</td>"; echo "<td>"; if ($this->fields['double_ip']) { echo "<span class='plugin_addressing_ip_double'>" . __('Red row', 'addressing') . "</span> - " . __('Same Ip', 'addressing') . "<br>"; } if (isset($this->fields['use_ping']) && $this->fields['use_ping']) { echo __('Ping free Ip', 'addressing') . "<br>"; echo "<span class='plugin_addressing_ping_off'>" . __('Ping: got a response - used Ip', 'addressing') . "</span><br>"; echo "<span class='plugin_addressing_ping_on'>" . __('Ping: no response - free Ip', 'addressing') . "</span>"; } else { echo "<span class='plugin_addressing_ip_free'>" . __('Blue row', 'addressing') . "</span> - " . __('Free Ip', 'addressing') . "<br>"; } echo "</td></tr>"; echo "<tr><td colspan='2' align='center'>"; echo "<a href='./report.form.php?id=" . $this->getID() . "&export=true'>" . __('Export') . "</a>"; echo "</td></tr>"; echo "</table>"; echo "</div>"; $numrows = 1 + ip2long($this->fields['end_ip']) - ip2long($this->fields['begin_ip']); if (strpos($_SERVER['PHP_SELF'], "report.form.php")) { Html::printPager($start, $numrows, $_SERVER['PHP_SELF'], "start={$start}&id=" . $id, 'PluginAddressingReport'); } else { Html::printAjaxPager("", $start, $numrows); } //////////////////////////liste ips//////////////////////////////////////////////////////////// $ping_response = $PluginAddressingReport->displayReport($result, $this); if ($this->fields['use_ping']) { $total_realfreeip = $nbipf - $ping_response; echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 center'>"; echo "<td>"; echo __('Real free Ip (Ping=KO)', 'addressing') . " " . $total_realfreeip; echo "</td></tr>"; echo "</table>"; } echo "</div>"; } else { echo "<div class='center'>" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='warning'><br><br><b>" . __('Problem detected with the IP Range', 'addressing') . "</b></div>"; } }
function showErrorLog() { $fic = GLPI_LOG_DIR . "/ocsng_fullsync.log"; if (!is_file($fic)) { return false; } $size = filesize($fic); if ($size > 20000) { $logfile = file_get_contents($fic, 0, NULL, $size - 20000, 20000); $events = explode("\n", $logfile); // Remove fist partial event array_shift($events); } else { $logfile = file_get_contents($fic); $events = explode("\n\n", $logfile); } // Remove last empty event array_pop($events); $number = count($events); $SEARCH_OPTION = getSearchOptions(); if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } if ($number < 1) { return $this->lognothing(); } if ($start > $number) { $start = $number; } // Display the pager Html::printAjaxPager("Logfile: ocsng_fullsync.log", $start, $number); // Output events echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>Message</th></tr>"; for ($i = $start; $i < $start + $_SESSION['glpilist_limit'] && $i < count($events); $i++) { $lines = explode("\n", $events[$i]); echo "<tr class='tab_bg_2 top'><td>" . $lines[0] . "</td>"; echo "</tr>"; } echo "</table></div>"; }
public static function showReferencesFromSupplier($ID) { global $DB, $CFG_GLPI; if (isset($_POST["start"])) { $start = $_POST["start"]; } else { $start = 0; } $query = "SELECT `gr`.`id`, `gr`.`manufacturers_id`, `gr`.`entities_id`, `gr`.`itemtype`, `gr`.`name`,\n `grm`.`price_taxfree`, `grm`.`reference_code`\n FROM `glpi_plugin_order_references_suppliers` AS grm, `glpi_plugin_order_references` AS gr\n WHERE `grm`.`suppliers_id` = '{$ID}'\n AND `grm`.`plugin_order_references_id` = `gr`.`id`" . getEntitiesRestrictRequest(" AND ", "gr", '', '', true); $query_limit = $query . " LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); $result = $DB->query($query); $nb = $DB->numrows($result); echo "<div class='center'>"; if ($nb) { $result = $DB->query($query_limit); Html::printAjaxPager(__("List references", "order"), $start, $nb); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __("Entity") . "</th>"; echo "<th>" . __("Manufacturer") . "</th>"; echo "<th>" . __("Product reference", "order") . "</th>"; echo "<th>" . __("Reference") . "</th>"; echo "<th>" . __("Product reference", "order") . "</th>"; echo "<th>" . __("Unit price tax free", "order") . "</th></tr>"; while ($data = $DB->fetch_array($result)) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td>"; echo Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]); echo "</td>"; echo "<td>"; $PluginOrderReference = new PluginOrderReference(); echo $PluginOrderReference->getReceptionReferenceLink($data); echo "</td>"; echo "<td>"; $item = new $data["itemtype"](); echo $item->getTypeName(); echo "</td>"; echo "<td>"; echo $data['reference_code']; echo "</td>"; echo "<td>"; echo number_format($data["price_taxfree"], 2); echo "</td>"; echo "</tr>"; } } echo "</table>"; echo "</div>"; }
/** * Print the HTML array of items for a location * * @since version 0.85 * * @return Nothing (display) **/ function showItems() { global $DB, $CFG_GLPI; $locations_id = $this->fields['id']; $crit = Session::getSavedOption(__CLASS__, 'criterion', ''); if (!$this->can($locations_id, READ)) { return false; } $first = 1; $query = ''; if ($crit) { $table = getTableForItemType($crit); $query = "SELECT `{$table}`.`id`, '{$crit}' AS type\n FROM `{$table}`\n WHERE `{$table}`.`locations_id` = '{$locations_id}' " . getEntitiesRestrictRequest(" AND", $table, "entities_id"); } else { foreach ($CFG_GLPI['location_types'] as $type) { $table = getTableForItemType($type); $query .= ($first ? "SELECT " : " UNION SELECT ") . "`id`, '{$type}' AS type\n FROM `{$table}`\n WHERE `{$table}`.`locations_id` = '{$locations_id}' " . getEntitiesRestrictRequest(" AND", $table, "entities_id"); $first = 0; } } $result = $DB->query($query); $number = $DB->numrows($result); $start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0; if ($start >= $number) { $start = 0; } // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Type') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo __('Type') . " "; Dropdown::showItemType($CFG_GLPI['location_types'], array('value' => $crit, 'on_change' => 'reloadTab("start=0&criterion="+this.value)')); echo "</td></tr></table>"; if ($number) { echo "<div class='spaced'>"; Html::printAjaxPager('', $start, $number); echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Type') . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Serial number') . "</th>"; echo "<th>" . __('Inventory number') . "</th>"; echo "</tr>"; $DB->data_seek($result, $start); for ($row = 0; ($data = $DB->fetch_assoc($result)) && $row < $_SESSION['glpilist_limit']; $row++) { $item = getItemForItemtype($data['type']); $item->getFromDB($data['id']); echo "<tr class='tab_bg_1'><td class='center top'>" . $item->getTypeName() . "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $item->getEntityID()); echo "</td><td class='center'>" . $item->getLink() . "</td>"; echo "<td class='center'>" . (isset($item->fields["serial"]) ? "" . $item->fields["serial"] . "" : "-"); echo "</td>"; echo "<td class='center'>" . (isset($item->fields["otherserial"]) ? "" . $item->fields["otherserial"] . "" : "-"); echo "</td></tr>"; } } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } echo "</table></div>"; }
/** * Show users linked to a License * * @param $license SoftwareLicense object * * @return nothing **/ static function showForLicense(SoftwareLicense $license) { global $DB, $CFG_GLPI; $searchID = $license->getField('id'); if (!Software::canView() || !$searchID) { return false; } $canedit = PluginFpsoftwareVersionhelper::checkRights("software", array(CREATE, UPDATE, DELETE, PURGE), "Or"); $canshowuser = User::canView(); if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } if (isset($_GET["order"]) && $_GET["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } //SoftwareLicense ID $query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_users_softwarelicenses`\n INNER JOIN `glpi_users`\n ON (`glpi_users_softwarelicenses`.`users_id`\n = `glpi_users`.`id`)\n WHERE `glpi_users_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'"; $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"] . self::$front_url . "/front/user_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>"; //FOR NOW ALL USERS ARE SHOWN, DON'T KNOW IF THERE SHOULD BE ANY RESTRICTION. //ALSO IT CAUSES A POSSIBILITY TO ONE USER MANY TIMES. User::dropdown(array('right' => 'all')); echo "</td>"; echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); } if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table></div>\n"; return; } // Display the pager Html::printAjaxPager(__('Affected users'), $start, $number); $query = "SELECT `glpi_users_softwarelicenses`.*,\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_softwarelicenses`.`name` AS license,\n `glpi_softwarelicenses`.`id` AS lID\n FROM `glpi_users_softwarelicenses`\n INNER JOIN `glpi_softwarelicenses`\n ON (`glpi_users_softwarelicenses`.`softwarelicenses_id`\n = `glpi_softwarelicenses`.`id`)\n INNER JOIN `glpi_users`\n ON (`glpi_users_softwarelicenses`.`users_id` = `glpi_users`.`id`)\n WHERE `glpi_softwarelicenses`.`id` = '{$searchID}'\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); $rand = mt_rand(); if ($result = $DB->query($query)) { if ($data = $DB->fetch_assoc($result)) { if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); list($higher_version, $massiveactionparams) = PluginFpsoftwareVersionhelper::massiveActionParams($rand, __CLASS__); // Options to update license $massiveactionparams['extraparams']['options']['move']['used'] = array($searchID); $massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id']; Html::showMassiveActions($higher_version ? $massiveactionparams : __CLASS__, $massiveactionparams); } $soft = new Software(); $soft->getFromDB($license->fields['softwares_id']); $text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]); $text = sprintf(__('%1$s - ID %2$s'), $text, $license->fields['softwares_id']); Session::initNavigateListItems('User', $text); echo "<table class='tab_cadre_fixehov'>"; $columns = array('username' => __('Username'), 'userrealname' => __('Surname'), 'userfirstname' => __('First name'), 'added' => __('Added')); $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } foreach ($columns as $key => $val) { // Non order column $header_end .= "<th>{$val}</th>"; } $header_end .= "</tr>\n"; echo $header_begin . $header_top . $header_end; do { Session::addToNavigateListItems('User', $data["userid"]); echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>"; } if ($canshowuser) { echo "<td><a href='user.form.php?id=" . $data['userid'] . "'>" . $data['username'] . "</a></td>"; } else { echo "<td>" . $data['username'] . "</td>"; } echo "<td>" . $data['userrealname'] . "</td>"; echo "<td>" . $data['userfirstname'] . "</td>"; echo "<td style=\"text-align:center;\">" . $data['added'] . "</td>"; echo "</tr>\n"; } while ($data = $DB->fetch_assoc($result)); echo $header_begin . $header_bottom . $header_end; echo "</table>\n"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } else { // Not found _e('No item found'); } } // Query Html::printAjaxPager(__('Affected users'), $start, $number); echo "</div>\n"; }
/** * Show table with linked licenses to user * @param Software $software * @return bool */ private static function showUsersLicenses(Software $software) { global $DB; $softwareId = $software->getField("id"); $totalRecordsCount = self::countLicenses($software); $currentPage = isset($_GET["start"]) ? $_GET["start"] : 0; $sortingOrder = SortingOrder::getFromString($_GET["order"]); $columnKeys = array_keys(self::getColumns()); $sortingColumn = array_key_exists($_GET["sort"], self::getColumns()) ? $_GET["sort"] : reset($columnKeys); $queryResult = $DB->query(self::getDataQuery($softwareId, $currentPage, $sortingColumn, $sortingOrder)); $options = PluginFpsoftwareConfig::getConfigValues(array('group_by_users')); Html::printAjaxPager(self::getTypeName(2), $currentPage, $totalRecordsCount); echo self::printTableBegin(); echo self::printGridColumnsHeaders($sortingOrder, $sortingColumn); if ($totalRecordsCount > 0) { while ($data = $DB->fetch_assoc($queryResult)) { echo "<tr class='tab_bg_1'>"; echo "<td class='left'><a href='softwarelicense.form.php?id=" . $data['license_id'] . "'>" . $data["license_name"] . "</a> - " . $data["license_serial"] . " (" . $data["license_type"] . ") " . "</td>"; echo "<td class='left'><a href='user.form.php?id=" . $data['user_id'] . "'>" . $data["user_name"] . "</a></td>"; if ($options['group_by_users']) { $computers = array(); if ($data['computer_ids']) { $computer_ids = explode(';|;', $data['computer_ids']); $computer_names = explode(';|;', $data['computer_names']); foreach ($computer_ids as $index => $computer_id) { $computers[] = " <a href='computer.form.php?id=" . $computer_id . "'>" . $computer_names[$index] . "</a>"; } } echo "<td class='left'>"; echo implode("<br /><br />", $computers) . "</td>"; } else { echo "<td class='left'><a href='computer.form.php?id=" . $data['computer_id'] . "'>" . $data["computer_name"] . "</a></td>"; } echo "<td class='left'><a href='location.form.php?id=" . $data['location_id'] . "'>" . $data["location_name"] . "</a></td>"; echo "</tr>"; } } else { echo "<tr class='tab_bg_1'><td class='center' colspan='3'>No results.</td></tr>"; } Html::printAjaxPager(self::getTypeName(2), $currentPage, $totalRecordsCount); echo self::printTableEnd(); return true; }
/** * Show installations of a software * * @param $searchID value of 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; if (!Session::haveRight("software", "r") || !$searchID) { return false; } $canedit = Session::haveRight("software", "w"); $canshowcomputer = Session::haveRight("computer", "r"); if (isset($_POST["start"])) { $start = $_POST["start"]; } else { $start = 0; } if (isset($_POST["order"]) && $_POST["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } if (isset($_POST["sort"]) && !empty($_POST["sort"])) { // manage several param like location,compname : order first $tmp = explode(",", $_POST["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'\n AND `glpi_computers_softwareversions`.`is_deleted` = '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`\n = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'\n AND `glpi_computers_softwareversions`.`is_deleted` = '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>" . __('No item found') . "</th></tr>"; echo "</table></div>\n"; return; } // Display the pager Html::printAjaxPager(self::getTypeName(2), $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 AND `glpi_computers_softwareversions`.`is_deleted` = '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 = Session::haveRight('user', 'r'); $title = $soft->fields["name"]; if ($crit == "id") { $title = sprintf(__('%1$s - %2$s'), $title, $data["vername"]); } Session::initNavigateListItems('Computer', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $title)); $sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt=''\n title=''>"; if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $_SESSION['glpilist_limit'], 'specific_actions' => array('move_version' => _x('button', 'Move'), 'purge' => _x('button', 'Delete permanently'))); // Options to update version $paramsma['extraparams']['options']['move']['softwares_id'] = $softwares_id; if ($crit == 'softwares_id') { $paramsma['extraparams']['options']['move']['used'] = array(); } else { $paramsma['extraparams']['options']['move']['used'] = array($searchID); } Html::showMassiveActions(__CLASS__, $paramsma); } echo "<table class='tab_cadre_fixehov'><tr>"; if ($canedit) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } if ($crit == "softwares_id") { echo "<th>" . ($sort == "`vername`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=vername&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . _n('Version', 'Versions', 2) . "</a></th>"; } echo "<th>" . ($sort == "`compname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('Name') . "</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\");'>" . __('Entity') . "</a></th>"; } echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('Serial number') . "</a></th>"; echo "<th>" . ($sort == "`otherserial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=otherserial&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('Inventory number') . "</a></th>"; echo "<th>" . (strstr($sort, "`location`") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=location,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('Location') . "</a></th>"; echo "<th>" . (strstr($sort, "state") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=state,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('Status') . "</a></th>"; echo "<th>" . (strstr($sort, "groupe") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=groupe,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('Group') . "</a></th>"; echo "<th>" . (strstr($sort, "username") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=username,compname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . __('User') . "</a></th>"; echo "<th>" . ($sort == "`lname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=lname&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>" . _n('License', 'Licenses', 2) . "</a></th>"; echo "</tr>\n"; do { Session::addToNavigateListItems('Computer', $data["cID"]); echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } if ($crit == "softwares_id") { echo "<td><a href='softwareversion.form.php?id=" . $data['vID'] . "'>" . $data['version'] . "</a></td>"; } $compname = $data['compname']; if (empty($compname) || $_SESSION['glpiis_ids_visible']) { $compname = sprintf(__('%1$s (%2$s)'), $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>" . $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) { $serial = $data['serial']; if (!empty($data['type'])) { $serial = sprintf(__('%1$s (%2$s)'), $serial, $data['type']); } echo "<a href='softwarelicense.form.php?id=" . $data['id'] . "'>" . $data['name']; echo "</a> - " . $serial; echo "<br>"; } } echo "</td>"; echo "</tr>\n"; } while ($data = $DB->fetch_assoc($result)); echo "</table>\n"; if ($canedit) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } } else { // Not found _e('No item found'); } } // Query Html::printAjaxPager(self::getTypeName(2), $start, $number); echo "</div>\n"; }
/** * Show History of an item * * @param $item CommonDBTM object * @param $withtemplate integer withtemplate param (default '') **/ static function showForItem(CommonDBTM $item, $withtemplate = '') { global $DB; $itemtype = $item->getType(); $items_id = $item->getField('id'); $SEARCHOPTION = Search::getOptions($itemtype); if (isset($_POST["start"])) { $start = $_POST["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>" . __('No historical') . "</th></tr>"; echo "</table>"; echo "</div><br>"; return; } // Display the pager Html::printAjaxPager(self::getTypeName(1), $start, $number); // Output events echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('ID') . "</th><th>" . __('Date') . "</th>"; echo "<th>" . __('User') . "</th><th>" . __('Field') . "</th>"; //TRANS: a noun, modification, change echo "<th>" . _x('name', 'Update') . "</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>"; Html::printAjaxPager(self::getTypeName(1), $start, $number); }
/** * Print out the consumables of a defined type * * @param $consitem ConsumableItem object * @param $show_old boolean show old consumables or not. (default 0) * * @return Nothing (displays) **/ static function showForConsumableItem(ConsumableItem $consitem, $show_old = 0) { global $DB, $CFG_GLPI; $tID = $consitem->getField('id'); if (!$consitem->can($tID, READ)) { return false; } if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } $canedit = $consitem->can($tID, UPDATE); $rand = mt_rand(); $where = ""; if (!$show_old) { // NEW $where = " AND `date_out` IS NULL\n ORDER BY `date_in`, `id`"; } else { //OLD $where = " AND `date_out` IS NOT NULL\n ORDER BY `date_out` DESC,\n `date_in`,\n `id`"; } $number = countElementsInTable("glpi_consumables", "`consumableitems_id` = '{$tID}' {$where}"); $query = "SELECT `glpi_consumables`.*\n FROM `glpi_consumables`\n WHERE `consumableitems_id` = '{$tID}'\n {$where}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); $result = $DB->query($query); echo "<div class='spaced'>"; // Display the pager Html::printAjaxPager(Consumable::getTypeName(Session::getPluralNumber()), $start, $number); if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $actions = array('delete' => _x('button', 'Delete permanently'), 'Infocom' . MassiveAction::CLASS_ACTION_SEPARATOR . 'activate' => __('Enable the financial and administrative information')); if ($show_old) { $actions['Consumable' . MassiveAction::CLASS_ACTION_SEPARATOR . 'backtostock'] = __('Back to stock'); } else { $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'give'] = _x('button', 'Give'); } $entparam = array('entities_id' => $consitem->getEntityID()); if ($consitem->isRecursive()) { $entparam = array('entities_id' => getSonsOf('glpi_entities', $consitem->getEntityID())); } $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => $actions, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => $entparam); Html::showMassiveActions($massiveactionparams); echo "<input type='hidden' name='consumableitems_id' value='{$tID}'>\n"; } echo "<table class='tab_cadre_fixehov'>"; if (!$show_old) { echo "<tr><th colspan=" . ($canedit ? '5' : '4') . ">"; echo self::getCount($tID, -1); echo "</th></tr>"; } else { // Old echo "<tr><th colspan='" . ($canedit ? '7' : '6') . "'>" . __('Used consumables') . "</th></tr>"; } if ($number) { $i = 0; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . __('ID') . "</th>"; $header_end .= "<th>" . _x('item', 'State') . "</th>"; $header_end .= "<th>" . __('Add date') . "</th>"; if ($show_old) { $header_end .= "<th>" . __('Use date') . "</th>"; $header_end .= "<th>" . __('Given to') . "</th>"; } $header_end .= "<th width='200px'>" . __('Financial and administrative information') . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; while ($data = $DB->fetch_assoc($result)) { $date_in = Html::convDate($data["date_in"]); $date_out = Html::convDate($data["date_out"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>" . $data["id"] . "</td>"; echo "<td class='center'>" . self::getStatus($data["id"]) . "</td>"; echo "<td class='center'>" . $date_in . "</td>"; if ($show_old) { echo "<td class='center'>" . $date_out . "</td>"; echo "<td class='center'>"; if ($item = getItemForItemtype($data['itemtype'])) { if ($item->getFromDB($data['items_id'])) { echo $item->getLink(); } } echo "</td>"; } echo "<td class='center'>"; Infocom::showDisplayLink('Consumable', $data["id"]); echo "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show users of a group * * @since version 0.83 * * @param $group Group object: the group **/ static function showForGroup(Group $group) { global $DB, $CFG_GLPI; $ID = $group->getID(); if (!User::canView() || !$group->can($ID, READ)) { return false; } // Have right to manage members $canedit = self::canUpdate(); $rand = mt_rand(); $user = new User(); $crit = Session::getSavedOption(__CLASS__, 'criterion', ''); $tree = Session::getSavedOption(__CLASS__, 'tree', 0); $used = array(); $ids = array(); // Retrieve member list $entityrestrict = self::getDataForGroup($group, $used, $ids, $crit, $tree); if ($canedit) { self::showAddUserForm($group, $ids, $entityrestrict, $crit); } // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . User::getTypeName(Session::getPluralNumber()) . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo _n('Criterion', 'Criteria', 1) . " "; $crits = array('' => Dropdown::EMPTY_VALUE, 'is_manager' => __('Manager'), 'is_userdelegate' => __('Delegatee')); Dropdown::showFromArray('crit', $crits, array('value' => $crit, 'on_change' => 'reloadTab("start=0&criterion="+this.value)')); if ($group->haveChildren()) { echo "</td><td class='center'>" . __('Child groups'); Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)')); } else { $tree = 0; } echo "</td></tr></table>"; $number = count($used); $start = isset($_GET['start']) ? intval($_GET['start']) : 0; if ($start >= $number) { $start = 0; } // Display results if ($number) { echo "<div class='spaced'>"; Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number); Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName())); if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => min($number - $start, $_SESSION['glpilist_limit']), 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov table-striped table-hover'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . User::getTypeName(1) . "</th>"; if ($tree) { $header_end .= "<th>" . Group::getTypeName(1) . "</th>"; } $header_end .= "<th>" . __('Dynamic') . "</th>"; $header_end .= "<th>" . __('Manager') . "</th>"; $header_end .= "<th>" . __('Delegatee') . "</th></tr>"; echo $header_begin . $header_top . $header_end; $tmpgrp = new Group(); for ($i = $start, $j = 0; $i < $number && $j < $_SESSION['glpilist_limit']; $i++, $j++) { $data = $used[$i]; $user->getFromDB($data["id"]); Session::addToNavigateListItems('User', $data["id"]); echo "\n<tr class='tab_bg_" . ($user->isDeleted() ? '1_2' : '1') . "'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } echo "<td>" . $user->getLink(); if ($tree) { echo "</td><td>"; if ($tmpgrp->getFromDB($data['groups_id'])) { echo $tmpgrp->getLink(array('comments' => true)); } } echo "</td><td class='center'>"; if ($data['is_dynamic']) { echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Dynamic') . "\">"; } echo "</td><td class='center'>"; if ($data['is_manager']) { echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Manager') . "\">"; } echo "</td><td class='center'>"; if ($data['is_userdelegate']) { echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Delegatee') . "\">"; } echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number); echo "</div>"; } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } }
/** * Show the list of rules * * @param $target * @param $options array * * @return nothing **/ function showListRules($target, $options = array()) { global $CFG_GLPI; $p['inherited'] = 1; $p['childrens'] = 0; $p['active'] = false; $p['condition'] = 0; $rand = mt_rand(); foreach (array('inherited', 'childrens', 'condition') as $param) { if (isset($options[$param]) && $this->isRuleRecursive()) { $p[$param] = $options[$param]; } } $rule = $this->getRuleClass(); $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']); // Do not know what it is ? $canedit = self::canUpdate() && !$display_entities; $use_conditions = false; if ($rule->useConditions()) { // First get saved option $p['condition'] = Session::getSavedOption($this->getType(), 'condition', 0); if ($p['condition'] == 0) { $p['condition'] = $this->getDefaultRuleConditionForList(); } $use_conditions = true; // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center' width='50%'>"; echo __('Rules used for') . "</td><td>"; $rule->dropdownConditions(array('value' => $p['condition'], 'on_change' => 'reloadTab("start=0&inherited=' . $p['inherited'] . '&childrens=' . $p['childrens'] . '&condition="+this.value)')); echo "</td></tr></table>"; } $nb = $this->getCollectionSize($p['inherited'], $p['condition']); $p['start'] = isset($options["start"]) ? $options["start"] : 0; if ($p['start'] >= $nb) { $p['start'] = 0; } $p['limit'] = $_SESSION['glpilist_limit']; $this->getCollectionPart($p); Html::printAjaxPager('', $p['start'], $nb); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); echo "\n<div class='spaced'>"; if ($canedit && $nb) { $massiveactionparams = array('num_displayed' => min($p['limit'], $nb), 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('entity' => $this->entity, 'condition' => $p['condition'], 'rule_class_name' => $this->getRuleClassName())); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov table-striped table-hover'>"; $colspan = 6; if ($display_entities) { $colspan++; } if ($use_conditions) { $colspan++; } echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n"; echo "<tr>"; echo "<th>"; if ($canedit) { Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Description') . "</th>"; if ($use_conditions) { echo "<th>" . __('Use rule for') . "</th>"; } echo "<th>" . __('Active') . "</th>"; if ($display_entities) { echo "<th>" . __('Entity') . "</th>\n"; } if (!$display_entities) { echo "<th colspan='2'> </th>"; } echo "</tr>\n"; if (count($this->RuleList->list)) { $ruletype = $this->RuleList->list[0]->getType(); Session::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, $p['condition']); Session::addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']); } if ($nb) { echo "<tr>"; echo "<th>"; if ($canedit) { Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Description') . "</th>"; if ($use_conditions) { echo "<th>" . __('Use rule for') . "</th>"; } echo "<th>" . __('Active') . "</th>"; if ($display_entities) { echo "<th>" . __('Entity') . "</th>\n"; } if (!$display_entities) { echo "<th colspan='2'> </th>"; } echo "</tr>\n"; } echo "</table>\n"; if ($canedit && $nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); } echo "</div>"; Html::closeForm(); Html::printAjaxPager('', $p['start'], $nb); echo "<div class='spaced center'>"; if ($plugin = isPluginItemType($this->getType())) { $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']); } else { $url = $CFG_GLPI["root_doc"]; } echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID('allruletest' . $rand) . ".dialog('open');\">" . __('Test rules engine') . "</a>"; Ajax::createIframeModalWindow('allruletest' . $rand, $url . "/front/rulesengine.test.php?" . "sub_type=" . $this->getRuleClassName() . "&condition=" . $p['condition'], array('title' => __('Test rules engine'))); echo "</div>"; if ($this->can_replay_rules) { echo "<div class='spaced center'>"; echo "<a class='vsubmit' href='" . $rule->getSearchURL() . "?replay_rule=replay_rule'>" . __s('Replay the dictionary rules') . "</a>"; echo "</div>"; } echo "<div class='spaced'>"; $this->showAdditionalInformationsInForm($target); echo "</div>"; }
/** * Print the HTML array of the Netpoint associated to a Location * * @param $item Location * * @return Nothing (display) **/ static function showForLocation($item) { global $DB, $CFG_GLPI; $ID = $item->getField('id'); $netpoint = new self(); $item->check($ID, READ); $canedit = $item->canEdit($ID); if (isset($_GET["start"])) { $start = intval($_GET["start"]); } else { $start = 0; } $number = countElementsInTable('glpi_netpoints', "`locations_id`='{$ID}'"); if ($canedit) { echo "<div class='first-bloc'>"; // 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'>"; echo "<td class='b'>" . _n('Network outlet', 'Network outlets', 1) . "</td>"; echo "<td>" . __('Name') . "</td><td>"; Html::autocompletionTextField($item, "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=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>\n"; echo "</table>\n"; Html::closeForm(); // 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'>"; echo "<td class='b'>" . _n('Network outlet', 'Network outlets', Session::getPluralNumber()) . "</td>"; echo "<td>" . __('Name') . "</td><td>"; echo "<input type='text' maxlength='100' size='10' name='_before'> "; Dropdown::showNumber('_from', array('value' => 0, 'min' => 0, 'max' => 400)); echo " --> "; Dropdown::showNumber('_to', array('value' => 0, 'min' => 0, 'max' => 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}'>"; echo "<input type='hidden' name='_method' value='AddMulti'></td>"; echo "<td><input type='submit' name='execute' value=\"" . _sx('button', 'Add') . "\"\n class='submit'>"; echo "</td></tr>\n"; echo "</table>\n"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . self::getTypeName(1) . "</th>"; echo "<th>" . __('No item found') . "</th></tr>"; echo "</table>\n"; } else { Html::printAjaxPager(sprintf(__('Network outlets for %s'), $item->getTreeLink()), $start, $number); if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $_SESSION['glpilist_limit'], 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently'))); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixe'><tr>"; if ($canedit) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Name') . "</th>"; // Name echo "<th>" . __('Comments') . "</th>"; // Comment echo "</tr>\n"; $crit = array('locations_id' => $ID, 'ORDER' => 'name', 'START' => $start, 'LIMIT' => $_SESSION['glpilist_limit']); Session::initNavigateListItems('Netpoint', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); foreach ($DB->request('glpi_netpoints', $crit) as $data) { Session::addToNavigateListItems('Netpoint', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</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) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } Html::printAjaxPager(sprintf(__('Network outlets for %s'), $item->getTreeLink()), $start, $number); } echo "</div>\n"; }
/** * Print the wainting ticket form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * * @return Nothing (display) * */ static function showList($item, $canedit) { global $CFG_GLPI; // validation des droits if (!self::canView()) { return false; } if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } $rand = mt_rand(); // Get close informations $data = self::getCloseTicketFromDB($item->getField('id'), array('start' => $start, 'limit' => $_SESSION['glpilist_limit'])); if (!count($data)) { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No historical') . "</th></tr>"; echo "</table>"; echo "</div><br>"; } else { $doc = new Document(); echo "<div class='center'>"; // Display the pager Html::printAjaxPager(__('Close ticket informations', 'moreticket'), $start, count($data)); if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('item' => __CLASS__, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'>"; if ($canedit) { echo Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Date') . "</th>"; echo "<th>" . __('Comments') . "</th>"; echo "<th>" . __('Writer') . "</th>"; echo "<th>" . __('Document') . "</th>"; echo "</tr>"; foreach ($data as $closeTicket) { echo "<tr class='tab_bg_2'>"; echo "<td width='10'>"; if ($canedit) { Html::showMassiveActionCheckBox(__CLASS__, $closeTicket['id']); } echo "</td>"; echo "<td>"; echo Html::convDateTime($closeTicket['date']); echo "</td>"; echo "<td>"; echo $closeTicket['comment']; echo "</td>"; echo "<td>"; echo getUserName($closeTicket['requesters_id']); echo "</td>"; echo "<td>"; if ($doc->getFromDB($closeTicket['documents_id'])) { echo $doc->getLink(); } echo "</td>"; echo "</tr>"; } if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</table>"; echo "</div>"; Html::printAjaxPager(__('Close ticket informations', 'moreticket'), $start, count($data)); } }
static function showForItem(CommonGLPI $item, $withtemplate = 0) { global $DB, $CFG_GLPI; if ($item->getType() == 'IPNetwork') { if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } if (!empty($_GET["order"])) { $table_options['order'] = $_GET["order"]; } else { $table_options['order'] = 'ip'; } $order_by_itemtype = $table_options['order'] == 'itemtype'; $table_options['SQL_options'] = "LIMIT " . $_SESSION['glpilist_limit'] . "\n OFFSET {$start}"; $table = new HTMLTableMain(); $content = "<a href='javascript:reloadTab(\"order=ip\");'>" . self::getTypeName(Session::getPluralNumber()) . "</a>"; $internet_column = $table->addHeader('IP Address', $content); $content = sprintf(__('%1$s - %2$s'), _n('Item', 'Items', Session::getPluralNumber()), "<a href='javascript:reloadTab(\"order=itemtype\");'>" . __('Order by item type') . "</a>"); $item_column = $table->addHeader('Item', $content); if ($order_by_itemtype) { foreach ($CFG_GLPI["networkport_types"] as $itemtype) { $table_options['group_' . $itemtype] = $table->createGroup($itemtype, $itemtype::getTypeName(Session::getPluralNumber())); self::getHTMLTableHeader($item->getType(), $table_options['group_' . $itemtype], $item_column, NULL, $table_options); } } $table_options['group_None'] = $table->createGroup('Main', __('Other kind of items')); self::getHTMLTableHeader($item->getType(), $table_options['group_None'], $item_column, NULL, $table_options); self::getHTMLTableCellsForItem(NULL, $item, NULL, $table_options); if ($table->getNumberOfRows() > 0) { Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, self::countForItem($item)); Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); $table->display(array('display_title_for_each_group' => $order_by_itemtype, 'display_super_for_each_group' => false, 'display_tfoot' => false)); Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, self::countForItem($item)); } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No IP address found') . "</th></tr>"; echo "</table>"; } } }
/** * Show software installed on a computer * * @param $comp Computer object * @param $withtemplate template case of the view process (default '') * * @return nothing **/ static function showForComputer(Computer $comp, $withtemplate = '') { global $DB, $CFG_GLPI; if (!Software::canView()) { return false; } $computers_id = $comp->getField('id'); $rand = mt_rand(); $canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE)); $entities_id = $comp->fields["entities_id"]; $crit = Session::getSavedOption(__CLASS__, 'criterion', -1); $where = ''; if ($crit > -1) { $where = " AND `glpi_softwares`.`softwarecategories_id` = {$crit}"; } $add_dynamic = ''; if (Plugin::haveImport()) { $add_dynamic = "`glpi_computers_softwareversions`.`is_dynamic`,"; } $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`name` AS softname,\n `glpi_computers_softwareversions`.`id`,\n {$add_dynamic}\n `glpi_states`.`name` AS state,\n `glpi_softwareversions`.`id` AS verid,\n `glpi_softwareversions`.`softwares_id`,\n `glpi_softwareversions`.`name` AS version,\n `glpi_softwares`.`is_valid` AS softvalid\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_states`\n ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$computers_id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n {$where}\n ORDER BY `softname`, `version`"; $result = $DB->query($query); $i = 0; if ((empty($withtemplate) || $withtemplate != 2) && $canedit) { echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php'>"; echo "<div class='spaced'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo _n('Software', 'Software', Session::getPluralNumber()) . " "; echo "<input type='hidden' name='computers_id' value='{$computers_id}'>"; Software::dropdownSoftwareToInstall("softwareversions_id", $entities_id); echo "</td><td width='20%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Install') . "\"\n class='submit'>"; echo "</td>"; echo "</tr>\n"; echo "</table></div>\n"; Html::closeForm(); } echo "<div class='spaced'>"; $cat = -1; Session::initNavigateListItems('Software', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName())); Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName())); // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . Software::getTypeName(Session::getPluralNumber()) . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo __('Category') . "</td><td>"; SoftwareCategory::dropdown(array('value' => $crit, 'toadd' => array('-1' => __('All categories')), 'emptylabel' => __('Uncategorized software'), 'on_change' => 'reloadTab("start=0&criterion="+this.value)')); echo "</td></tr></table></div>"; $number = $DB->numrows($result); $start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0; if ($start >= $number) { $start = 0; } $installed = array(); if ($number) { echo "<div class='spaced'>"; Html::printAjaxPager('', $start, $number); if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently'))); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . __('Name') . "</th><th>" . __('Status') . "</th>"; $header_end .= "<th>" . __('Version') . "</th><th>" . __('License') . "</th>"; if (Plugin::haveImport()) { $header_end .= "<th>" . __('Automatic inventory') . "</th>"; } $header_end .= "<th>" . SoftwareCategory::getTypeName(1) . "</th>"; $header_end .= "<th>" . __('Valid license') . "</th>"; $header_end .= "</tr>\n"; echo $header_begin . $header_top . $header_end; for ($row = 0; $data = $DB->fetch_assoc($result); $row++) { if ($row >= $start && $row < $start + $_SESSION['glpilist_limit']) { $licids = self::softsByCategory($data, $computers_id, $withtemplate, $canedit, true); } else { $licids = self::softsByCategory($data, $computers_id, $withtemplate, $canedit, false); } Session::addToNavigateListItems('Software', $data["softwares_id"]); foreach ($licids as $licid) { Session::addToNavigateListItems('SoftwareLicense', $licid); $installed[] = $licid; } } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } echo "</div>\n"; if ((empty($withtemplate) || $withtemplate != 2) && $canedit) { echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>"; echo "<div class='spaced'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>"; echo _n('License', 'Licenses', Session::getPluralNumber()) . " "; echo "<input type='hidden' name='computers_id' value='{$computers_id}'>"; Software::dropdownLicenseToInstall("softwarelicenses_id", $entities_id); echo "</td><td width='20%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>\n"; echo "</table></div>\n"; Html::closeForm(); } echo "<div class='spaced'>"; // Affected licenses NOT installed $query = "SELECT `glpi_softwarelicenses`.*,\n `glpi_computers_softwarelicenses`.`id` AS linkID,\n `glpi_softwares`.`name` AS softname,\n `glpi_softwareversions`.`name` AS version,\n `glpi_states`.`name` AS state\n FROM `glpi_softwarelicenses`\n LEFT JOIN `glpi_computers_softwarelicenses`\n ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n = `glpi_softwarelicenses`.`id`)\n INNER JOIN `glpi_softwares`\n ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n = `glpi_softwareversions`.`id`\n OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n = `glpi_softwareversions`.`id`))\n LEFT JOIN `glpi_states`\n ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$computers_id}'\n AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'\n {$where}"; if (count($installed)) { $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")"; } $query .= " ORDER BY `softname`, `version`;"; $req = $DB->request($query); if ($number = $req->numrows()) { if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('massSoftwareLicense' . $rand); $actions = array('Computer_SoftwareLicense' . MassiveAction::CLASS_ACTION_SEPARATOR . 'install' => _x('button', 'Install')); if (SoftwareLicense::canUpdate()) { $actions['purge'] = _x('button', 'Delete permanently'); } $massiveactionparams = array('num_displayed' => $number, 'container' => 'massSoftwareLicense' . $rand, 'specific_actions' => $actions); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('massSoftwareLicense' . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('massSoftwareLicense' . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . __('Name') . "</th><th>" . __('Status') . "</th>"; $header_end .= "<th>" . __('Version') . "</th><th>" . __('License') . "</th>"; $header_end .= "</tr>\n"; echo $header_begin . $header_top . $header_end; $cat = true; foreach ($req as $data) { self::displaySoftsByLicense($data, $computers_id, $withtemplate, $canedit); Session::addToNavigateListItems('SoftwareLicense', $data["id"]); } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } echo "</div>\n"; }
/** * Display list of a runned tasks * * @return nothing **/ function showHistory() { global $DB, $CFG_GLPI; if (isset($_GET["crontasklogs_id"]) && $_GET["crontasklogs_id"]) { return $this->showHistoryDetail($_GET["crontasklogs_id"]); } if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } // Total Number of events $number = countElementsInTable('glpi_crontasklogs', ['crontasks_id' => $this->fields['id'], 'state' => CronTaskLog::STATE_STOP]); echo "<br><div class='center'>"; if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table>"; echo "</div>"; return; } // Display the pager Html::printAjaxPager(__('Last run list'), $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'>"; $header = "<tr>"; $header .= "<th>" . __('Date') . "</th>"; $header .= "<th>" . __('Total duration') . "</th>"; $header .= "<th>" . _x('quantity', 'Number') . "</th>"; $header .= "<th>" . __('Description') . "</th>"; $header .= "</tr>\n"; echo $header; do { echo "<tr class='tab_bg_2'>"; echo "<td><a href='javascript:reloadTab(\"crontasklogs_id=" . $data['crontasklogs_id'] . "\");'>" . Html::convDateTime($data['date']) . "</a></td>"; echo "<td class='right'>" . sprintf(_n('%s second', '%s seconds', intval($data['elapsed'])), number_format($data['elapsed'], 3)) . " </td>"; echo "<td class='numeric'>" . $data['volume'] . "</td>"; // Use gettext to display echo "<td>" . __($data['content']) . "</td>"; echo "</tr>\n"; } while ($data = $DB->fetch_assoc($result)); echo $header; echo "</table>"; } else { // Not found _e('No item found'); } } // Query Html::printAjaxPager(__('Last run list'), $start, $number); echo "</div>"; }
/** * Display history of taskjob * * @param $taskjobs_id integer id of the taskjob * @param $width integer how large in pixel display array * @param $options array to display with specific options * - items_id integer id of item to display history * - itemtype value type of item to display * * @return bool TRUE if form is ok * **/ function showHistory($taskjobs_id, $width = "950", $options = array()) { global $DB, $CFG_GLPI; $this->javascriptHistory(); $a_uniqid = array(); $start = 0; if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } $where = ''; if (isset($options['items_id']) and isset($options['itemtype'])) { $where = " AND `items_id`='" . $options['items_id'] . "'\n AND `itemtype`='" . $options['itemtype'] . "' "; } if (isset($options['uniqid'])) { $where .= " AND `uniqid`='" . $options['uniqid'] . "' "; } echo "<center>"; $query = 'SELECT * FROM `glpi_plugin_fusioninventory_taskjobstates` WHERE `plugin_fusioninventory_taskjobs_id`="' . $taskjobs_id . '" AND `state`!="3" ' . $where . ' GROUP BY uniqid, plugin_fusioninventory_agents_id ORDER BY `id` DESC'; $result = $DB->query($query); // ***** Display for all status running / prepared if (isset($options['uniqid']) and $DB->numrows($result) == '0') { } else { // Display echo "<table class='tab_cadre' style='width: " . $width . "px'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='32'>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/task_running.png'/>"; echo "</th>"; echo "<td>"; if ($DB->numrows($result) > 0) { echo "<table class='tab_cadre'>"; echo "<tr>"; echo "<th></th>"; echo "<th>" . __('Unique id', 'fusioninventory') . "</th>"; echo "<th>" . __('Process number', 'fusioninventory') . "</th>"; echo "<th>" . __('Agent', 'fusioninventory') . "</th>"; echo "<th>"; echo __('Date'); echo "</th>"; echo "<th>"; echo __('Status'); echo "</th>"; echo "<th>"; echo __('Comments'); echo "</th>"; echo "</tr>"; while ($data = $DB->fetch_array($result)) { $this->showHistoryLines($data['id'], 1, 0, 7); $a_uniqid[] = $data['uniqid']; } echo "</table>"; } echo "</td>"; echo "</tr>"; echo "</table><br/>"; } // ***** Display for statejob OK if (count($a_uniqid) > 0) { $where .= " AND `uniqid` NOT IN ('" . implode("', '", $a_uniqid) . "')"; $query = 'SELECT * FROM `glpi_plugin_fusioninventory_taskjobstates` WHERE `plugin_fusioninventory_taskjobs_id`="' . $taskjobs_id . '" AND `state`!="3" ' . $where . ' GROUP BY uniqid, plugin_fusioninventory_agents_id ORDER BY `id` DESC'; } $querycount = 'SELECT count(*) AS cpt FROM `glpi_plugin_fusioninventory_taskjobstates` WHERE `plugin_fusioninventory_taskjobs_id`="' . $taskjobs_id . '" AND `state`="3" ' . $where . ' GROUP BY uniqid, plugin_fusioninventory_agents_id'; $resultcount = $DB->query($querycount); $a_datacount = $DB->fetch_assoc($resultcount); $number = $a_datacount['cpt']; if (isset($options['uniqid']) and $number == '0') { } else { // display echo "<table class='tab_cadre' width='" . $width . "'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='32'>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/task_finished.png'/>"; echo "</td>"; echo "<td>"; echo "<table class='tab_cadre' >"; echo "<tr>"; echo "<td colspan='5'>"; Html::printAjaxPager('', $start, $number); echo "</td>"; echo "</tr>"; $query = str_replace('`state`!="3"', '`state`="3"', $query); $query .= ' LIMIT ' . intval($start) . ', ' . intval($_SESSION['glpilist_limit']); $result = $DB->query($query); echo "<tr>"; echo "<th></th>"; echo "<th>" . __('Unique id', 'fusioninventory') . "</th>"; echo "<th>" . __('Agent', 'fusioninventory') . "</th>"; echo "<th>"; echo __('Date'); echo "</th>"; echo "<th>"; echo __('Status'); echo "</th>"; echo "</tr>"; while ($data = $DB->fetch_array($result)) { $this->showHistoryLines($data['id'], 0, 0, 5); } echo "<tr>"; echo "<td colspan='5'>"; Html::printAjaxPager('', $start, $number); echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table>"; } echo "</center>"; return TRUE; }
/** * \brief Show names for an item from its form * Beware that the rendering can be different if readden from direct item form (ie : add new * NetworkName, remove, ...) or if readden from item of the item (for instance from the computer * form through NetworkPort::ShowForItem). * * @param $item CommonGLPI object * @param $withtemplate integer withtemplate param (default 0) **/ static function showForItem(CommonDBTM $item, $withtemplate = 0) { global $DB, $CFG_GLPI; $ID = $item->getID(); if (!$item->can($ID, READ)) { return false; } $rand = mt_rand(); if ($item->getType() == 'NetworkPort' && Session::haveRight('internet', UPDATE) && $item->canUpdateItem()) { $items_id = $item->getID(); $itemtype = $item->getType(); echo "<div class='firstbloc'>\n"; echo "<form method='post' action='" . static::getFormURL() . "'>\n"; echo "<table class='tab_cadre_fixe'>\n"; echo "<tr><th colspan='4'>" . __('Add a network name') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='right'>"; echo "<input type='hidden' name='items_id' value='{$items_id}'>\n"; echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n"; _e('Not associated'); echo "</td><td class='left'>"; self::dropdown(array('name' => 'addressID', 'condition' => '`items_id`=0')); echo "</td><td class='left'>"; echo "<input type='submit' name='assign_address' value='" . _sx('button', 'Associate') . "' class='submit'>"; echo "</td>"; if (static::canCreate()) { echo "<td class='right' width='30%'>"; echo "<a href=\"" . static::getFormURL() . "?items_id={$items_id}&itemtype={$itemtype}\">"; echo __('Create a new network name') . "</a>"; echo "</td>"; } echo "</tr>\n"; echo "</table>\n"; Html::closeForm(); echo "</div>\n"; } $table_options = array('createRow' => true); if ($item->getType() == 'FQDN' || $item->getType() == 'NetworkEquipment') { if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } if (!empty($_GET["order"])) { $table_options['order'] = $_GET["order"]; } else { $table_options['order'] = 'name'; } if ($item->getType() == 'FQDN') { $table_options['column_links'] = array('NetworkName' => 'javascript:reloadTab("order=name");', 'NetworkAlias' => 'javascript:reloadTab("order=alias");', 'IPAddress' => 'javascript:reloadTab("order=ip");'); } $table_options['SQL_options'] = "LIMIT " . $_SESSION['glpilist_limit'] . "\n OFFSET {$start}"; $canedit = false; } else { $canedit = Session::haveRight('internet', UPDATE) && $item->canUpdateItem(); } $table_options['canedit'] = false; $table_options['rand'] = $rand; $table_options['massiveactionnetworkname'] = $canedit; $table = new HTMLTableMain(); $column = $table->addHeader('Internet', self::getTypeName(Session::getPluralNumber())); $t_group = $table->createGroup('Main', ''); self::getHTMLTableHeader(__CLASS__, $t_group, $column, NULL, $table_options); $t_row = $t_group->createRow(); self::getHTMLTableCellsForItem($t_row, $item, NULL, $table_options); if ($table->getNumberOfRows() > 0) { $number = $table->getNumberOfRows(); if ($item->getType() == 'FQDN') { $number = min($_SESSION['glpilist_limit'], $table->getNumberOfRows()); Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, self::countForItem($item)); } Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } $table->display(array('display_title_for_each_group' => false, 'display_thead' => false, 'display_tfoot' => false, 'display_header_on_foot_for_each_group' => true)); if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } if ($item->getType() == 'FQDN') { Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, self::countForItem($item)); } } else { echo "<table class='tab_cadre_fixe'><tr><th>" . __('No network name found') . "</th></tr>"; echo "</table>"; } }
public function showOrders($ref) { global $DB; $order = new PluginOrderOrder(); $query = "SELECT `glpi_plugin_order_orders_items`.*\n FROM `glpi_plugin_order_orders_items`\n LEFT JOIN `glpi_plugin_order_references`\n ON (`glpi_plugin_order_references`.`id` = `glpi_plugin_order_orders_items`.`plugin_order_references_id`)\n WHERE `plugin_order_references_id` = '" . $ref->getID() . "'"; $query .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_order_references", "entities_id", $ref->fields["entities_id"], true); $query .= " GROUP BY `glpi_plugin_order_orders_items`.`plugin_order_orders_id`\n ORDER BY `entities_id`, `name` "; $result = $DB->query($query); $nb = $DB->numrows($result); echo "<div class='center'>"; if ($nb) { if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } $query_limit = $query . " LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); Html::printAjaxPager(__("Linked orders", "order"), $start, $nb); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __("Name") . "</a></th>"; echo "<th>" . __("Entity") . "</th>"; echo "</tr>"; foreach ($DB->request($query_limit) as $data) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td>"; $order->getFromDB($data['plugin_order_orders_id']); echo $order->getLink(PluginOrderOrder::canView()); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName("glpi_entities", $order->fields["entities_id"]); echo "</td>"; echo "</tr>"; } echo "</table>"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center'>" . __("No item to display") . "</td></tr>"; echo "</table>"; } echo "</div>"; }
/** * Show the aliases contained by the alias * * @param $item the FQDN owning the aliases * @param $withtemplate integer withtemplate param **/ static function showForFQDN(CommonGLPI $item, $withtemplate) { global $DB; $alias = new self(); $address = new NetworkName(); $item->check($item->getID(), 'r'); $canedit = $item->can($item->getID(), 'w'); if (isset($_POST["start"])) { $start = $_POST["start"]; } else { $start = 0; } if (!empty($_POST["order"])) { $order = $_POST["order"]; } else { $order = "alias"; } $number = countElementsInTable($alias->getTable(), "`fqdns_id`='" . $item->getID() . "'"); echo "<br><div class='center'>"; if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . self::getTypeName(1) . "</th><th>" . __('No item found') . "</th></tr>"; echo "</table>\n"; } else { Html::printAjaxPager(self::getTypeName($number), $start, $number); echo "<table class='tab_cadre_fixe'><tr>"; echo "<th><a href='javascript:reloadTab(\"order=alias\");'>" . self::getTypeName(1) . "</a></th>"; // Alias echo "<th><a href='javascript:reloadTab(\"order=realname\");'>" . __("Computer's name") . "</a></th>"; echo "<th>" . __('Comments') . "</th>"; echo "</tr>\n"; Session::initNavigateListItems($item->getType(), sprintf(__('%1$s = %2$s'), self::getTypeName(1), $item->fields['name'])); $query = "SELECT `glpi_networkaliases`.`id` AS alias_id,\n `glpi_networkaliases`.`name` AS alias,\n `glpi_networknames`.`id` AS address_id,\n `glpi_networkaliases`.`comment` AS comment\n FROM `glpi_networkaliases`, `glpi_networknames`\n WHERE `glpi_networkaliases`.`fqdns_id` = '" . $item->getID() . "'\n AND `glpi_networknames`.`id` = `glpi_networkaliases`.`networknames_id`\n ORDER BY `{$order}`\n LIMIT " . $_SESSION['glpilist_limit'] . "\n OFFSET {$start}"; foreach ($DB->request($query) as $data) { Session::addToNavigateListItems($alias->getType(), $data["alias_id"]); if ($address->getFromDB($data["address_id"])) { echo "<tr class='tab_bg_1'>"; echo "<td><a href='" . $alias->getFormURL() . '?id=' . $data['alias_id'] . "'>" . $data['alias'] . "</a></td>"; echo "<td><a href='" . $address->getLinkURL() . "'>" . $address->getInternetName() . "</a></td>"; echo "<td>" . $data['comment'] . "</td>"; echo "</tr>\n"; } } echo "</table>\n"; Html::printAjaxPager(self::getTypeName($number), $start, $number); } echo "</div>\n"; }
/** * Show the list of rules * * @param $target * @param $options array * * @return nothing **/ function showListRules($target, $options = array()) { global $CFG_GLPI; $p['inherited'] = true; $p['childrens'] = false; $p['active'] = false; $rand = mt_rand(); foreach (array('inherited', 'childrens') as $param) { if (isset($options[$param]) && $this->isRuleRecursive()) { $p[$param] = $options[$param]; } } $rule = $this->getRuleClass(); $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']); // Do not know what it is ? $canedit = Session::haveRight(static::$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); Html::printAjaxPager('', $p['start'], $nb); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); echo "\n<div class='spaced'>"; if ($canedit && $nb) { $massiveactionparams = array('num_displayed' => min($p['limit'], $nb), 'extraparams' => array('entity_restrict' => $this->entity)); Html::showMassiveActions($this->getRuleClassName(), $massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $colspan = 6; if ($display_entities) { $colspan++; } echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n"; echo "<tr>"; echo "<th>"; if ($canedit) { Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Description') . "</th>"; echo "<th>" . __('Active') . "</th>"; if ($display_entities) { echo "<th>" . __('Entity') . "</th>\n"; } if (!$display_entities) { echo "<th colspan='2'> </th>"; } echo "</tr>\n"; if (count($this->RuleList->list)) { $ruletype = $this->RuleList->list[0]->getType(); Session::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); Session::addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']); } if ($nb) { echo "<tr>"; echo "<th>"; if ($canedit) { Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Description') . "</th>"; echo "<th>" . __('Active') . "</th>"; if ($display_entities) { echo "<th>" . __('Entity') . "</th>\n"; } if (!$display_entities) { echo "<th colspan='2'> </th>"; } echo "</tr>\n"; } echo "</table>\n"; if ($canedit && $nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($this->getRuleClassName(), $massiveactionparams); } echo "</div>"; Html::closeForm(); Html::printAjaxPager('', $p['start'], $nb); echo "<div class='spaced center'>"; if ($plugin = isPluginItemType($this->getType())) { $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']); } else { $url = $CFG_GLPI["root_doc"]; } echo "<a class='vsubmit' 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();\">" . __('Test rules engine') . "</a></div>"; if ($this->can_replay_rules) { echo "<div class='spaced center'>"; echo "<a class='vsubmit' href='" . $rule->getSearchURL() . "?replay_rule=replay_rule'>" . __s('Replay the dictionary rules') . "</a>"; echo "</div>"; } echo "<div class='spaced'>"; $this->showAdditionalInformationsInForm($target); echo "</div>"; }