Display open form for massive action
static public openMassiveActionsForm ( $name = '' ) : nothing | ||
$name | given name/id to the form (default '') | |
return | nothing | / display item |
/** * Display datas extracted from DB * * @param $data array of search datas prepared to get datas * * @return nothing **/ static function displayDatas(array &$data) { global $CFG_GLPI; $item = null; if (class_exists($data['itemtype'])) { $item = new $data['itemtype'](); } $rand = mt_rand(); if (!isset($data['data']) || !isset($data['data']['totalcount'])) { return false; } // Contruct Pager parameters $globallinkto = Toolbox::append_params(array('criteria' => Toolbox::stripslashes_deep($data['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($data['search']['metacriteria'])), '&'); $parameters = "sort=" . $data['search']['sort'] . "&order=" . $data['search']['order'] . '&' . $globallinkto; if (isset($_GET['_in_modal'])) { $parameters .= "&_in_modal=1"; } // Global search header if ($data['display_type'] == self::GLOBAL_SEARCH) { if ($data['item']) { echo "<div class='center'><h2>" . $data['item']->getTypeName(); // More items if ($data['data']['totalcount'] > $data['search']['start'] + self::GLOBAL_DISPLAY_COUNT) { echo " <a href='" . $data['search']['target'] . "?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } // If the begin of the view is before the number of items if ($data['data']['count'] > 0) { // Display pager only for HTML if ($data['display_type'] == self::HTML_OUTPUT) { // For plugin add new parameter if available if ($plug = isPluginItemType($data['itemtype'])) { $function = 'plugin_' . $plug['plugin'] . '_addParamFordynamicReport'; if (function_exists($function)) { $out = $function($data['itemtype']); if (is_array($out) && count($out)) { $parameters .= Toolbox::append_params($out, '&'); } } } $search_config_top = ""; $search_config_bottom = ""; if (!isset($_GET['_in_modal']) && Session::haveRightsOr('search_config', array(DisplayPreference::PERSONAL, DisplayPreference::GENERAL))) { $search_config_top = $search_config_bottom = "<div class='pager_controls'><img alt=\"" . __s('Select default items to show') . "\" title=\"" . __s('Select default items to show') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config_top .= " class='pointer' onClick=\""; $search_config_top .= Html::jsGetElementbyID('search_config_top') . ".dialog('open');\">"; $search_config_bottom .= " class='pointer' onClick=\""; $search_config_bottom .= Html::jsGetElementbyID('search_config_bottom') . ".dialog('open');\">"; $search_config_top .= Ajax::createIframeModalWindow('search_config_top', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false)); $search_config_bottom .= Ajax::createIframeModalWindow('search_config_bottom', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false)); } if ($item !== null && $item->maybeDeleted()) { $delete_ctrl = self::isDeletedSwitch($data['search']['is_deleted']); $search_config_top .= $delete_ctrl; } Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, $data['itemtype'], 0, $search_config_top); $search_config_top .= "</div>"; $search_config_bottom .= "</div>"; } // Define begin and end var for loop // Search case $begin_display = $data['data']['begin']; $end_display = $data['data']['end']; // Form to massive actions $isadmin = $data['item'] && $data['item']->canUpdate(); if (!$isadmin && InfoCom::canApplyOn($data['itemtype'])) { $isadmin = Infocom::canUpdate() || Infocom::canCreate(); } if ($data['itemtype'] != 'AllAssets') { $showmassiveactions = count(MassiveAction::getAllMassiveActions($data['item'], $data['search']['is_deleted'])); } else { $showmassiveactions = true; } $massformid = 'massform' . $data['itemtype']; if ($showmassiveactions && $data['display_type'] == self::HTML_OUTPUT) { Html::openMassiveActionsForm($massformid); $massiveactionparams = $data['search']['massiveactionparams']; $massiveactionparams['num_displayed'] = $end_display - $begin_display; $massiveactionparams['fixed'] = false; $massiveactionparams['is_deleted'] = $data['search']['is_deleted']; $massiveactionparams['container'] = $massformid; Html::showMassiveActions($massiveactionparams); } // Compute number of columns to display // Add toview elements $nbcols = count($data['data']['cols']); if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $nbcols++; } // Display List Header echo self::showHeader($data['display_type'], $end_display - $begin_display + 1, $nbcols); // New Line for Header Items Line $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; $headers_line_top .= self::showBeginHeader($data['display_type']); $headers_line_top .= self::showNewLine($data['display_type']); if ($data['display_type'] == self::HTML_OUTPUT) { // $headers_line_bottom .= self::showBeginHeader($data['display_type']); $headers_line_bottom .= self::showNewLine($data['display_type']); } $header_num = 1; if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $headers_line_top .= self::showHeaderItem($data['display_type'], Html::getCheckAllAsCheckbox($massformid), $header_num, "", 0, $data['search']['order']); if ($data['display_type'] == self::HTML_OUTPUT) { $headers_line_bottom .= self::showHeaderItem($data['display_type'], Html::getCheckAllAsCheckbox($massformid), $header_num, "", 0, $data['search']['order']); } } // Display column Headers for toview items $metanames = array(); foreach ($data['data']['cols'] as $key => $val) { $linkto = ''; if (!$val['meta'] && (!isset($val['searchopt']['nosort']) || !$val['searchopt']['nosort'])) { $linkto = $data['search']['target'] . (strpos($data['search']['target'], '?') ? '&' : '?') . "itemtype=" . $data['itemtype'] . "&sort=" . $val['id'] . "&order=" . ($data['search']['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $data['search']['start'] . "&" . $globallinkto; } $name = $val["name"]; // prefix by group name (corresponding to optgroup in dropdown) if exists if (isset($val['groupname'])) { $name = $val['groupname'] . " - " . $name; } // Not main itemtype add itemtype to display if ($data['itemtype'] != $val['itemtype']) { if (!isset($metanames[$val['itemtype']])) { if ($metaitem = getItemForItemtype($val['itemtype'])) { $metanames[$val['itemtype']] = $metaitem->getTypeName(); } } $name = sprintf(__('%1$s - %2$s'), $metanames[$val['itemtype']], $val["name"]); } $headers_line .= self::showHeaderItem($data['display_type'], $name, $header_num, $linkto, !$val['meta'] && $data['search']['sort'] == $val['id'], $data['search']['order']); } // Add specific column Header if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $headers_line .= self::showHeaderItem($data['display_type'], __('Item type'), $header_num); } // End Line for column headers $headers_line .= self::showEndLine($data['display_type']); $headers_line_top .= $headers_line; if ($data['display_type'] == self::HTML_OUTPUT) { $headers_line_bottom .= $headers_line; } $headers_line_top .= self::showEndHeader($data['display_type']); // $headers_line_bottom .= self::showEndHeader($data['display_type']); echo $headers_line_top; // Init list of items displayed if ($data['display_type'] == self::HTML_OUTPUT) { Session::initNavigateListItems($data['itemtype']); } // Num of the row (1=header_line) $row_num = 1; $massiveaction_field = 'id'; if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $massiveaction_field = 'refID'; } $typenames = array(); // Display Loop foreach ($data['data']['rows'] as $rowkey => $row) { // Column num $item_num = 1; $row_num++; // New line echo self::showNewLine($data['display_type'], $row_num % 2, $data['search']['is_deleted']); $current_type = isset($row['TYPE']) ? $row['TYPE'] : $data['itemtype']; $massiveaction_type = $current_type; if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $massiveaction_type = $data['itemtype']; } // Add item in item list Session::addToNavigateListItems($current_type, $row["id"]); if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $tmpcheck = ""; if ($data['itemtype'] == 'Entity' && !in_array($row["id"], $_SESSION["glpiactiveentities"])) { $tmpcheck = " "; } else { if ($data['item'] instanceof CommonDBTM && $data['item']->maybeRecursive() && !in_array($row["entities_id"], $_SESSION["glpiactiveentities"])) { $tmpcheck = " "; } else { $tmpcheck = Html::getMassiveActionCheckBox($massiveaction_type, $row[$massiveaction_field]); } } echo self::showItem($data['display_type'], $tmpcheck, $item_num, $row_num, "width='10'"); } // Print other toview items foreach ($data['data']['cols'] as $colkey => $col) { if (!$col['meta']) { echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num, self::displayConfigItem($data['itemtype'], $col['id'], $row, $colkey)); } else { // META case echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num); } } if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { if (!isset($typenames[$row["TYPE"]])) { if ($itemtmp = getItemForItemtype($row["TYPE"])) { $typenames[$row["TYPE"]] = $itemtmp->getTypeName(); } } echo self::showItem($data['display_type'], $typenames[$row["TYPE"]], $item_num, $row_num); } // End Line echo self::showEndLine($data['display_type']); } // Create title $title = ''; if ($data['display_type'] == self::PDF_OUTPUT_LANDSCAPE || $data['display_type'] == self::PDF_OUTPUT_PORTRAIT) { $title = self::computeTitle($data); } if ($data['display_type'] == self::HTML_OUTPUT) { echo $headers_line_bottom; } // Display footer echo self::showFooter($data['display_type'], $title); // Delete selected item if ($data['display_type'] == self::HTML_OUTPUT) { if ($showmassiveactions) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); // End form for delete item Html::closeForm(); } else { echo "<br>"; } } if ($data['display_type'] == self::HTML_OUTPUT) { // In case of HTML display Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, '', 0, $search_config_bottom); } } else { if ($item !== null && $item->maybeDeleted()) { echo "<div class='center'>" . self::isDeletedSwitch($data['search']['is_deleted']) . "</div><br/>"; } echo self::showError($data['display_type']); } }
* @since version 0.84 */ include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); try { $ma = new MassiveAction($_POST, $_GET, 'initial'); } catch (Exception $e) { echo "<div class='center'><img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='" . __s('Warning') . "'><br><br>"; echo "<span class='b'>" . $e->getMessage() . "</span><br>"; echo "</div>"; exit; } echo "<div width='90%' class='center'><br>"; Html::openMassiveActionsForm(); $params = array('action' => '__VALUE__'); $input = $ma->getInput(); foreach ($input as $key => $val) { $params[$key] = $val; } $actions = $params['actions']; if (count($actions)) { if (isset($params['hidden']) && is_array($params['hidden'])) { foreach ($params['hidden'] as $key => $val) { echo Html::hidden($key, array('value' => $val)); } } _e('Action'); echo " "; $actions = array('-1' => Dropdown::EMPTY_VALUE) + $actions;
/** * Print the HTML array for Items linked to a problem * * @param $problem Problem object * * @return Nothing (display) **/ static function showForProblem(Problem $problem) { global $DB, $CFG_GLPI; $instID = $problem->fields['id']; if (!$problem->can($instID, READ)) { return false; } $canedit = $problem->canEdit($instID); $rand = mt_rand(); $query = "SELECT DISTINCT `itemtype`\n FROM `glpi_items_problems`\n WHERE `glpi_items_problems`.`problems_id` = '{$instID}'\n ORDER BY `itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='problemitem_form{$rand}' id='problemitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>"; $types = array(); foreach ($problem->getAllTypesForHelpdesk() as $key => $val) { $types[] = $key; } Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $types, 'entity_restrict' => $problem->fields['is_recursive'] ? getSonsOf('glpi_entities', $problem->fields['entities_id']) : $problem->fields['entities_id'])); echo "</td><td class='center' width='30%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "<input type='hidden' name='problems_id' value='{$instID}'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $number) { $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_top .= "</th>"; $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= "</th>"; } $header_end .= "<th>" . __('Type') . "</th>"; $header_end .= "<th>" . __('Entity') . "</th>"; $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __('Serial number') . "</th>"; $header_end .= "<th>" . __('Inventory number') . "</th></tr>"; echo $header_begin . $header_top . $header_end; $totalnb = 0; for ($i = 0; $i < $number; $i++) { $itemtype = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { $itemtable = getTableForItemType($itemtype); $query = "SELECT `{$itemtable}`.*,\n `glpi_items_problems`.`id` AS IDD,\n `glpi_entities`.`id` AS entity\n FROM `glpi_items_problems`,\n `{$itemtable}`"; if ($itemtype != 'Entity') { $query .= " LEFT JOIN `glpi_entities`\n ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) "; } $query .= " WHERE `{$itemtable}`.`id` = `glpi_items_problems`.`items_id`\n AND `glpi_items_problems`.`itemtype` = '{$itemtype}'\n AND `glpi_items_problems`.`problems_id` = '{$instID}'"; if ($item->maybeTemplate()) { $query .= " AND `{$itemtable}`.`is_template` = '0'"; } $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`"; $result_linked = $DB->query($query); $nb = $DB->numrows($result_linked); for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) { $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } $link = $itemtype::getFormURLWithID($data['id']); $namelink = "<a href=\"" . $link . "\">" . $name . "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); echo "</td>"; } if ($prem) { $typename = $item->getTypeName($nb); echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>"; } echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>"; echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'"); echo ">" . $namelink . "</td>"; echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>"; echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>"; echo "</tr>"; } $totalnb += $nb; } } if ($number) { echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show tickets for a projecttask * * @param $projecttask ProjectTask object **/ static function showForProjectTask(ProjectTask $projecttask) { global $DB, $CFG_GLPI; $ID = $projecttask->getField('id'); if (!$projecttask->can($ID, READ)) { return false; } $canedit = $projecttask->canEdit($ID); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_projecttasks_tickets`.`id` AS linkID,\n `glpi_tickets`.*\n FROM `glpi_projecttasks_tickets`\n LEFT JOIN `glpi_tickets`\n ON (`glpi_projecttasks_tickets`.`tickets_id` = `glpi_tickets`.`id`)\n WHERE `glpi_projecttasks_tickets`.`projecttasks_id` = '{$ID}'\n ORDER BY `glpi_tickets`.`name`"; $result = $DB->query($query); $tickets = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $tickets[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='projecttaskticket_form{$rand}' id='projecttaskticket_form{$rand}'\n method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a ticket') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='right'>"; echo "<input type='hidden' name='projecttasks_id' value='{$ID}'>"; $condition = "`glpi_tickets`.`status`\n NOT IN ('" . implode("', '", array_merge(Ticket::getSolvedStatusArray(), Ticket::getClosedStatusArray())) . "')"; Ticket::dropdown(array('used' => $used, 'entity' => $projecttask->getEntityID(), 'entity_sons' => $projecttask->isRecursive(), 'condition' => $condition, 'displaywith' => array('id'))); echo "</td><td width='20%'>"; echo "<a href='" . Toolbox::getItemTypeFormURL('Ticket') . "?_projecttasks_id={$ID}'>"; _e('Create a ticket from this task'); echo "</a>"; echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='12'>" . Ticket::getTypeName($numrows) . "</th>"; echo "</tr>"; if ($numrows) { Ticket::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); Session::initNavigateListItems('Ticket', sprintf(__('%1$s = %2$s'), ProjectTask::getTypeName(1), $projecttask->fields["name"])); $i = 0; foreach ($tickets as $data) { Session::addToNavigateListItems('Ticket', $data["id"]); Ticket::showShort($data['id'], array('followups' => false, 'row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID'])); $i++; } } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show ports for an item * * @param $item CommonDBTM object * @param $withtemplate integer withtemplate param (default '') **/ static function showForItem(CommonDBTM $item, $withtemplate = '') { global $DB, $CFG_GLPI; $rand = mt_rand(); $itemtype = $item->getType(); $items_id = $item->getField('id'); if (!Session::haveRight('networking', 'r') || !$item->can($items_id, 'r')) { return false; } $netport = new self(); $netport->item = $item; if ($itemtype == 'NetworkPort') { $canedit = false; } else { $canedit = $item->can($items_id, 'w'); } $showmassiveactions = false; if ($withtemplate != 2) { $showmassiveactions = $canedit; } // Show Add Form if ($canedit && (empty($withtemplate) || $withtemplate != 2)) { echo "\n<form method='get' action='" . $netport->getFormURL() . "'>\n"; echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>\n"; echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n"; echo "<div class='firstbloc'><table class='tab_cadre_fixe'>\n"; echo "<tr class='tab_bg_2'><td class='center'>\n"; _e('Network port type to be added'); echo " "; $instantiations = array(); foreach (self::getNetworkPortInstantiations() as $inst_type) { if (call_user_func(array($inst_type, 'canCreate'))) { $instantiations[$inst_type] = call_user_func(array($inst_type, 'getTypeName')); } } Dropdown::showFromArray('instantiation_type', $instantiations, array('value' => 'NetworkPortEthernet')); echo "</td>\n"; echo "<td class='tab_bg_2 center' width='50%'>"; _e('Add several ports'); echo " <input type='checkbox' name='several' value='1'></td>\n"; echo "<td>\n"; echo "<input type='submit' name='create' value=\"" . _sx('button', 'Add') . "\" class='submit'>\n"; echo "</td></tr></table></div>\n"; Html::closeForm(); } if ($showmassiveactions) { $checkbox_column = true; Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); } else { $checkbox_column = false; } $is_active_network_port = false; Session::initNavigateListItems('NetworkPort', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); if ($itemtype == 'NetworkPort') { $porttypes = array('NetworkPortAlias', 'NetworkPortAggregate'); } else { $porttypes = self::getNetworkPortInstantiations(); // Manage NetworkportMigration $porttypes[] = ''; } $display_options = self::getDisplayOptions($itemtype); $table = new HTMLTableMain(); $number_port = self::countForItem($item); $table_options = array('canedit' => $canedit, 'display_options' => &$display_options); // Make table name and add the correct show/hide parameters $table_name = sprintf(__('%1$s: %2$d'), self::getTypeName($number_port), $number_port); // Add the link to the popup to display the options ... $table_namelink = self::getDisplayOptionsLink($itemtype); $table_name = sprintf(__('%1$s - %2$s'), $table_name, $table_namelink); $table->setTitle($table_name); $c_main = $table->addHeader('main', self::getTypeName(2)); if ($display_options['dynamic_import'] && $item->isDynamic()) { $table_options['display_isDynamic'] = true; } else { $table_options['display_isDynamic'] = false; } if ($display_options['characteristics']) { $c_instant = $table->addHeader('Instantiation', __('Characteristics')); $c_instant->setHTMLClass('center'); } if ($display_options['internet']) { $options = array('names' => 'NetworkName', 'aliases' => 'NetworkAlias', 'ipaddresses' => 'IPAddress', 'ipnetworks' => 'IPNetwork'); $table_options['dont_display'] = array(); foreach ($options as $option => $itemtype_for_option) { if (!$display_options[$option]) { $table_options['dont_display'][$itemtype_for_option] = true; } } $c_network = $table->addHeader('Internet', _n(__('Internet information'), __('Internet information'), 2)); $c_network->setHTMLClass('center'); } else { $c_network = NULL; } foreach ($porttypes as $portType) { if (empty($portType)) { $group_name = 'Migration'; $group_title = __('Network ports waiting for manual migration'); } else { $group_name = $portType; $group_title = $portType::getTypeName(2); } $t_group = $table->createGroup($group_name, $group_title); if ($withtemplate != 2 && $canedit) { $c_checkbox = $t_group->addHeader('checkbox', Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand, '__RAND__'), $c_main); } else { $c_checkbox = NULL; } $c_number = $t_group->addHeader('NetworkPort', "#", $c_main); $c_name = $t_group->addHeader("Name", __('Name'), $c_main); $c_name->setItemType('NetworkPort'); $c_name->setHTMLClass('center'); if ($table_options['display_isDynamic']) { $c_dynamic = $t_group->addHeader("Dynamic", __('Automatic inventory'), $c_main); $c_dynamic->setHTMLClass('center'); } if ($display_options['characteristics']) { if (empty($portType)) { NetworkPortMigration::getMigrationInstantiationHTMLTableHeaders($t_group, $c_instant, $c_network, NULL, $table_options); } else { $instantiation = new $portType(); $instantiation->getInstantiationHTMLTableHeaders($t_group, $c_instant, $c_network, NULL, $table_options); unset($instantiation); } } if ($display_options['internet'] && !$display_options['characteristics']) { NetworkName::getHTMLTableHeader(__CLASS__, $t_group, $c_network, NULL, $table_options); } if ($itemtype == 'NetworkPort') { switch ($portType) { case 'NetworkPortAlias': $search_table = 'glpi_networkportaliases'; $search_request = "`networkports_id_alias`='{$items_id}'"; break; case 'NetworkPortAggregate': $search_table = 'glpi_networkportaggregates'; $search_request = "`networkports_id_list` like '%\"{$items_id}\"%'"; break; } $query = "SELECT `networkports_id` AS id\n FROM `{$search_table}`\n WHERE {$search_request}"; } else { $query = "SELECT `id`\n FROM `glpi_networkports`\n WHERE `items_id` = '{$items_id}'\n AND `itemtype` = '{$itemtype}'\n AND `instantiation_type` = '{$portType}'\n AND `is_deleted` = '0'\n ORDER BY `name`,\n `logical_number`"; } if ($result = $DB->query($query)) { echo "<div class='spaced'>"; $number_port = $DB->numrows($result); if ($number_port != 0) { $is_active_network_port = true; $save_canedit = $canedit; if (!empty($portType)) { $name = sprintf(__('%1$s (%2$s)'), self::getTypeName($number_port), call_user_func(array($portType, 'getTypeName'))); $name = sprintf(__('%1$s: %2$s'), $name, $number_port); } else { $name = __('Network ports waiting for manual migration'); $canedit = false; } while ($devid = $DB->fetch_row($result)) { $t_row = $t_group->createRow(); $netport->getFromDB(current($devid)); // No massive action for migration ports if ($withtemplate != 2 && $canedit && !empty($portType)) { $ce_checkbox = $t_row->addCell($c_checkbox, "<input type='checkbox' name='item[" . $netport->fields["id"] . "]' value='1'>"); } else { $ce_checkbox = NULL; } $content = "<span class='b'>"; // Display link based on default rights if ($save_canedit && $withtemplate != 2) { if (!empty($portType)) { $content .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?id=" . $netport->fields["id"] . "\">"; } else { $content .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkportmigration.form.php?id=" . $netport->fields["id"] . "\">"; } } $content .= $netport->fields["logical_number"]; if ($canedit && $withtemplate != 2) { $content .= "</a>"; } $content .= "</span>"; $content .= Html::showToolTip($netport->fields['comment'], array('display' => false)); $t_row->addCell($c_number, $content); $value = $netport->fields["name"]; $t_row->addCell($c_name, $value, NULL, $netport); if ($table_options['display_isDynamic']) { $t_row->addCell($c_dynamic, Dropdown::getYesNo($netport->fields['is_dynamic'])); } $instant_cell = NULL; if ($display_options['characteristics']) { $instantiation = $netport->getInstantiation(); if ($instantiation !== false) { $instantiation->getInstantiationHTMLTable($netport, $t_row, NULL, $table_options); unset($instantiation); } } else { if ($display_options['internet']) { NetworkName::getHTMLTableCellsForItem($t_row, $netport, NULL, $table_options); } } } $canedit = $save_canedit; } echo "</div>"; } } if ($is_active_network_port && $showmassiveactions) { $massiveactionparams = array('num_displayed' => $number_port, 'check_itemtype' => $itemtype, 'check_items_id' => $items_id); Html::showMassiveActions('NetworkPort', $massiveactionparams); } $table->display(array('display_thead' => false, 'display_tfoot' => false)); unset($table); if (!$is_active_network_port) { echo "<table class='tab_cadre_fixe'><tr><th>" . __('No network port found') . "</th></tr>"; echo "</table>"; } if ($showmassiveactions) { $massiveactionparams['ontop'] = false; Html::showMassiveActions('NetworkPort', $massiveactionparams); Html::closeForm(); } }
/** * 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>"; }
/** * Print the mandatory fields * * @since version 0.83 * * @param $tt Ticket Template * @param $withtemplate boolean Template or basic item (default '') * * @return Nothing (call to classes members) **/ static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '') { global $DB; $ID = $tt->fields['id']; if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) { return false; } $canedit = $tt->canEdit($ID); $ttm = new self(); $used = $ttm->getMandatoryFields($ID); $fields = $tt->getAllowedFieldsNames(true); $simplified_fields = $tt->getSimplifiedInterfaceFields(); $both_interfaces = sprintf(__('%1$s + %2$s'), __('Simplified interface'), __('Standard interface')); $rand = mt_rand(); $query = "SELECT `glpi_tickettemplatemandatoryfields`.*\n FROM `glpi_tickettemplatemandatoryfields`\n WHERE (`tickettemplates_id` = '{$ID}')"; if ($result = $DB->query($query)) { $mandatoryfields = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $mandatoryfields[$data['id']] = $data; $used[$data['num']] = $data['num']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a mandatory field') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='right'>"; echo "<input type='hidden' name='tickettemplates_id' value='{$ID}'>"; $select_fields = $fields; foreach ($select_fields as $key => $val) { if (in_array($key, $simplified_fields)) { $select_fields[$key] = sprintf(__('%1$s (%2$s)'), $val, $both_interfaces); } else { $select_fields[$key] = sprintf(__('%1$s (%2$s)'), $val, __('Standard interface')); } } Dropdown::showFromArray('num', $select_fields, array('used' => $used)); echo "</td><td class='center'>"; echo " <input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr class='noHover'><th colspan='3'>"; echo self::getTypeName($DB->numrows($result)); echo "</th></tr>"; if ($numrows) { $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_top .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; $header_bottom .= "<th width='10'>"; $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __("Profile's interface") . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; foreach ($mandatoryfields as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>"; } echo "<td>" . $fields[$data['num']] . "</td>"; echo "<td>"; if (in_array($data['num'], $simplified_fields)) { echo $both_interfaces; } else { _e('Standard interface'); } echo "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; } else { echo "<tr><th colspan='2'>" . __('No item found') . "</th></tr>"; } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; } }
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); } } }
/** * @param $template NotificationTemplate object * @param $options array **/ function showSummary(NotificationTemplate $template, $options = array()) { global $DB, $CFG_GLPI; $nID = $template->getField('id'); $canedit = Config::canUpdate(); if ($canedit) { echo "<div class='center'>" . "<a class='vsubmit' href='" . Toolbox::getItemTypeFormURL('NotificationTemplateTranslation') . "?notificationtemplates_id=" . $nID . "'>" . __('Add a new translation') . "</a></div><br>"; } echo "<div class='center' id='tabsbody'>"; Session::initNavigateListItems('NotificationTemplateTranslation', sprintf(__('%1$s = %2$s'), NotificationTemplate::getTypeName(1), $template->getName())); if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Language') . "</th></tr>"; foreach ($DB->request('glpi_notificationtemplatetranslations', array('notificationtemplates_id' => $nID)) as $data) { if ($this->getFromDB($data['id'])) { Session::addToNavigateListItems('NotificationTemplateTranslation', $data['id']); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td class='center'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>"; echo "<a href='" . Toolbox::getItemTypeFormURL('NotificationTemplateTranslation') . "?id=" . $data['id'] . "&notificationtemplates_id=" . $nID . "'>"; if ($data['language'] != '') { echo $CFG_GLPI['languages'][$data['language']][0]; } else { _e('Default translation'); } echo "</a></td></tr>"; } } echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
function showMinimalList($params) { global $DB, $CFG_GLPI; $itemtype = "PluginResourcesDirectory"; $itemtable = $this->table; if (class_exists($itemtype)) { $item = new $itemtype(); } // Default values of parameters $p['link'] = array(); // $p['field'] = array(); // $p['contains'] = array(); // $p['searchtype'] = array(); // $p['sort'] = '1'; // $p['order'] = 'ASC'; // $p['start'] = 0; // $p['is_deleted'] = 0; $p['id'] = 0; $p['withtemplate'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; foreach ($params as $key => $val) { $p[$key] = $val; } if ($p['export_all']) { $p['start'] = 0; } $PluginResourcesResource = new PluginResourcesResource(); $canedit = $PluginResourcesResource->can($p['id'], 'w'); // Manage defautlt 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 = $CFG_GLPI["root_doc"] . "/plugins/resources/front/directory.php"; $limitsearchopt = Search::getCleanedOptions("PluginResourcesDirectory"); $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 = $PluginResourcesResource->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView("User"); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser("PluginResourcesDirectory", 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("User"); // Add select for all toview item foreach ($toview as $key => $val) { $query .= self::addSelect("PluginResourcesDirectory", $val, $key, 0); } $query .= "`glpi_plugin_resources_resources`.`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("PluginResourcesDirectory", $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt["PluginResourcesDirectory"] =& Search::getOptions("PluginResourcesDirectory"); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt["PluginResourcesDirectory"][$val]["table"], $searchopt["PluginResourcesDirectory"][$val]["linkfield"], 0, 0, $searchopt["PluginResourcesDirectory"][$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["PluginResourcesDirectory"][$key]["table"], $searchopt["PluginResourcesDirectory"][$key]["linkfield"], 0, 0, $searchopt["PluginResourcesDirectory"][$key]["joinparams"]); } } } $ASSIGN = " `glpi_plugin_resources_resources`.`is_leaving` = 0 AND `glpi_users`.`is_active` = 1 AND "; //// 3 - WHERE // default string $COMMONWHERE = Search::addDefaultWhere($itemtype); $first = empty($COMMONWHERE); // Add deleted if item have it if ($PluginResourcesResource && $PluginResourcesResource->maybeDeleted()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "`glpi_plugin_resources_resources`.`is_deleted` = '" . $p['is_deleted'] . "' "; } // Remove template items if ($PluginResourcesResource && $PluginResourcesResource->maybeTemplate()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "`glpi_plugin_resources_resources`.`is_template` = '0' "; } // Add Restrict to current entities if ($entity_restrict) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } if (isset($CFG_GLPI["union_search_type"][$itemtype])) { // Will be replace below in Union/Recursivity Hack $COMMONWHERE .= $LINK . " ENTITYRESTRICT "; } else { $COMMONWHERE .= getEntitiesRestrictRequest($LINK, "glpi_plugin_resources_resources", '', '', $PluginResourcesResource->maybeRecursive()); } } $WHERE = ""; $HAVING = ""; // Add search conditions // If there is search items if ($_SESSION["glpisearchcount"]["PluginResourcesDirectory"] > 0 && count($p['contains']) > 0) { for ($key = 0; $key < $_SESSION["glpisearchcount"]["PluginResourcesDirectory"]; $key++) { // if real search (strlen >0) and not all and view search if (isset($p['contains'][$key]) && strlen($p['contains'][$key]) > 0) { // common search if ($p['field'][$key] != "all" && $p['field'][$key] != "view") { $LINK = " "; $NOT = 0; $tmplink = ""; if (is_array($p['link']) && isset($p['link'][$key])) { if (strstr($p['link'][$key], "NOT")) { $tmplink = " " . str_replace(" NOT", "", $p['link'][$key]); $NOT = 1; } else { $tmplink = " " . $p['link'][$key]; } } else { $tmplink = " AND "; } if (isset($searchopt["PluginResourcesDirectory"][$p['field'][$key]]["usehaving"])) { // Manage Link if not first item if (!empty($HAVING)) { $LINK = $tmplink; } // Find key $item_num = array_search($p['field'][$key], $toview); $HAVING .= Search::addHaving($LINK, $NOT, "PluginResourcesDirectory", $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key], 0, $item_num); } else { // Manage Link if not first item if (!empty($WHERE)) { $LINK = $tmplink; } $WHERE .= self::addWhere($LINK, $NOT, "PluginResourcesDirectory", $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key]); } // view and all search } else { $LINK = " OR "; $NOT = 0; $globallink = " AND "; if (is_array($p['link']) && isset($p['link'][$key])) { switch ($p['link'][$key]) { case "AND": $LINK = " OR "; $globallink = " AND "; break; case "AND NOT": $LINK = " AND "; $NOT = 1; $globallink = " AND "; break; case "OR": $LINK = " OR "; $globallink = " OR "; break; case "OR NOT": $LINK = " AND "; $NOT = 1; $globallink = " OR "; break; } } else { $tmplink = " AND "; } // Manage Link if not first item if (!empty($WHERE)) { $WHERE .= $globallink; } $WHERE .= " ( "; $first2 = true; $items = array(); if ($p['field'][$key] == "all") { $items = $searchopt["PluginResourcesDirectory"]; } else { // toview case : populate toview foreach ($toview as $key2 => $val2) { $items[$val2] = $searchopt["PluginResourcesDirectory"][$val2]; } } foreach ($items as $key2 => $val2) { if (is_array($val2)) { // Add Where clause if not to be done in HAVING CLAUSE if (!isset($val2["usehaving"])) { $tmplink = $LINK; if ($first2) { $tmplink = " "; $first2 = false; } $WHERE .= self::addWhere($tmplink, $NOT, "PluginResourcesDirectory", $key2, $p['searchtype'][$key], $p['contains'][$key]); } } } $WHERE .= " ) "; } } } } if (!empty($WHERE) || !empty($COMMONWHERE)) { if (!empty($COMMONWHERE)) { $WHERE = ' WHERE ' . $ASSIGN . ' ' . $COMMONWHERE . (!empty($WHERE) ? ' AND ( ' . $WHERE . ' )' : ''); } else { $WHERE = ' WHERE ' . $ASSIGN . ' ' . $WHERE . ' '; } $first = false; } $query .= $WHERE; //// 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["PluginResourcesDirectory"][$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("searchtype", $p['searchtype']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("searchtype2", $p['searchtype2']) . 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>" . $this->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) { // 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::printPager($p['start'], $numrows, $target, $parameters, $itemtype, 0, $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' => false, 'is_deleted' => $p['is_deleted']); Html::showMassiveActions("PluginResourcesDirectory", $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); $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["PluginResourcesDirectory"][$val]['nosort']) || !$searchopt["PluginResourcesDirectory"][$val]['nosort']) { $linkto = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt["PluginResourcesDirectory"][$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); } // 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("PluginResourcesDirectory", $val, $data, $key), $item_num, $row_num, Search::displayConfigItem("PluginResourcesDirectory", $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 .= self::getTypeName(1); } // 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; $massiveactionparams['fixed'] = false; Html::showMassiveActions("PluginResourcesDirectory", $massiveactionparams); Html::closeForm(); } else { echo "</table></div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printPager($p['start'], $numrows, $target, $parameters, "PluginResourcesDirectory", 0, $search_config); } } else { echo Search::showError($output_type); } } }
/** * @param $port NetworkPort object **/ static function showForNetworkPort(NetworkPort $port) { global $DB, $CFG_GLPI; $ID = $port->getID(); if (!$port->can($ID, READ)) { return false; } $canedit = $port->canEdit($ID); $rand = mt_rand(); $query = "SELECT `glpi_networkports_vlans`.id as assocID,\n `glpi_networkports_vlans`.tagged ,\n `glpi_vlans`.*\n FROM `glpi_networkports_vlans`\n LEFT JOIN `glpi_vlans`\n ON (`glpi_networkports_vlans`.`vlans_id` = `glpi_vlans`.`id`)\n WHERE `networkports_id` = '{$ID}'"; $result = $DB->query($query); $vlans = array(); $used = array(); if ($number = $DB->numrows($result)) { while ($line = $DB->fetch_assoc($result)) { $used[$line["id"]] = $line["id"]; $vlans[$line["assocID"]] = $line; } } if ($canedit) { 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'>" . __('Associate a VLAN') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='right'>"; echo "<input type='hidden' name='networkports_id' value='{$ID}'>"; Vlan::dropdown(array('used' => $used)); echo "</td>"; echo "<td class='right'>" . __('Tagged') . "</td>"; echo "<td class='left'><input type='checkbox' name='tagged' value='1'></td>"; echo "<td><input type='submit' name='add' value='" . _sx('button', 'Associate') . "' class='submit'>"; echo "</td></tr>\n"; echo "</table>\n"; Html::closeForm(); echo "</div>\n"; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $number) { $header_top .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; $header_bottom .= "<th width='10'>"; $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __('Entity') . "</th>"; $header_end .= "<th>" . __('Tagged') . "</th>"; $header_end .= "<th>" . __('ID TAG') . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; $used = array(); foreach ($vlans as $data) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]); echo "</td>"; } $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } echo "<td class='center b'>\n <a href='" . $CFG_GLPI["root_doc"] . "/front/vlan.form.php?id=" . $data["id"] . "'>" . $name . "</a>"; echo "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo "</td><td class='center'>" . Dropdown::getYesNo($data["tagged"]) . "</td>"; echo "<td class='numeric'>" . $data["tag"] . "</td>"; echo "</tr>"; } if ($number) { echo $header_begin . $header_top . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show holidays for a calendar * * @param $calendar Calendar object **/ static function showForCalendar(Calendar $calendar) { global $DB, $CFG_GLPI; $ID = $calendar->getField('id'); if (!$calendar->can($ID, 'r')) { return false; } $canedit = $calendar->can($ID, 'w'); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_calendars_holidays`.`id` AS linkID,\n `glpi_holidays`.*\n FROM `glpi_calendars_holidays`\n LEFT JOIN `glpi_holidays`\n ON (`glpi_calendars_holidays`.`holidays_id` = `glpi_holidays`.`id`)\n WHERE `glpi_calendars_holidays`.`calendars_id` = '{$ID}'\n ORDER BY `glpi_holidays`.`name`"; $result = $DB->query($query); $holidays = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $holidays[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n action='"; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a close time') . "</tr>"; echo "<tr class='tab_bg_2'><td class='right' colspan='4'>"; echo "<input type='hidden' name='calendars_id' value='{$ID}'>"; Holiday::dropdown(array('used' => $used, 'entity' => $calendar->fields["entities_id"])); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $numrows); Html::showMassiveActions(__CLASS__, $paramsma); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $numrows) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Start') . "</th>"; echo "<th>" . __('End') . "</th>"; echo "<th>" . __('Recurrent') . "</th>"; echo "</tr>"; $used = array(); if ($numrows) { Session::initNavigateListItems('Holiday', sprintf(__('%1$s = %2$s'), Calendar::getTypeName(1), $calendar->fields["name"])); foreach ($holidays as $data) { Session::addToNavigateListItems('Holiday', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } echo "<td><a href='" . Toolbox::getItemTypeFormURL('Holiday') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>"; echo "<td>" . Html::convDate($data["begin_date"]) . "</td>"; echo "<td>" . Html::convDate($data["end_date"]) . "</td>"; echo "<td>" . Dropdown::getYesNo($data["is_perpetual"]) . "</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit && $numrows) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }
/** * Show visibility config for a knowbaseitem * * @since version 0.83 **/ function showVisibility() { global $DB, $CFG_GLPI; $ID = $this->fields['id']; $canedit = $this->can($ID, UPDATE); echo "<div class='center'>"; $rand = mt_rand(); $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='knowbaseitemvisibility_form{$rand}' id='knowbaseitemvisibility_form{$rand}' "; echo " method='post' action='" . Toolbox::getItemTypeFormURL('KnowbaseItem') . "'>"; echo "<input type='hidden' name='knowbaseitems_id' value='{$ID}'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</th></tr>"; echo "<tr class='tab_bg_2'><td width='100px'>"; $types = array('Entity', 'Group', 'Profile', 'User'); $addrand = Dropdown::showItemTypes('_type', $types); $params = array('type' => '__VALUE__', 'right' => $this->getField('is_faq') ? 'faq' : 'knowbase'); Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params); echo "</td>"; echo "<td><span id='visibility{$rand}'></span>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $nb) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('delete' => _x('button', 'Delete permanently'))); if ($this->fields['users_id'] != Session::getLoginUserID()) { $massiveactionparams['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.'); } Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $nb) { $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>" . __('Type') . "</th>"; $header_end .= "<th>" . _n('Recipient', 'Recipients', Session::getPluralNumber()) . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; // Users if (count($this->users)) { foreach ($this->users as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox('KnowbaseItem_User', $data["id"]); echo "</td>"; } echo "<td>" . __('User') . "</td>"; echo "<td>" . getUserName($data['users_id']) . "</td>"; echo "</tr>"; } } } // Groups if (count($this->groups)) { foreach ($this->groups as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox('Group_KnowbaseItem', $data["id"]); echo "</td>"; } echo "<td>" . __('Group') . "</td>"; echo "<td>"; $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1); $groupname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false))); if ($data['entities_id'] >= 0) { $groupname = sprintf(__('%1$s / %2$s'), $groupname, Dropdown::getDropdownName('glpi_entities', $data['entities_id'])); if ($data['is_recursive']) { $groupname = sprintf(__('%1$s %2$s'), $groupname, "<span class='b'>(" . __('R') . ")</span>"); } } echo $groupname; echo "</td>"; echo "</tr>"; } } } // Entity if (count($this->entities)) { foreach ($this->entities as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox('Entity_KnowbaseItem', $data["id"]); echo "</td>"; } echo "<td>" . __('Entity') . "</td>"; echo "<td>"; $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1); $entityname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false))); if ($data['is_recursive']) { $entityname = sprintf(__('%1$s %2$s'), $entityname, "<span class='b'>(" . __('R') . ")</span>"); } echo $entityname; echo "</td>"; echo "</tr>"; } } } // Profiles if (count($this->profiles)) { foreach ($this->profiles as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox('KnowbaseItem_Profile', $data["id"]); echo "</td>"; } echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>"; echo "<td>"; $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1); $profilename = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false))); if ($data['entities_id'] >= 0) { $profilename = sprintf(__('%1$s / %2$s'), $profilename, Dropdown::getDropdownName('glpi_entities', $data['entities_id'])); if ($data['is_recursive']) { $profilename = sprintf(__('%1$s %2$s'), $profilename, "<span class='b'>(" . __('R') . ")</span>"); } } echo $profilename; echo "</td>"; echo "</tr>"; } } } if ($nb) { echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; // Add items return true; }
/** * 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 changes for a ticket * * @param $ticket Ticket object **/ static function showForTicket(Ticket $ticket) { global $DB, $CFG_GLPI; $ID = $ticket->getField('id'); if (!$ticket->can($ID, READ)) { return false; } $canedit = $ticket->canEdit($ID); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n `glpi_changes`.*\n FROM `glpi_changes_tickets`\n LEFT JOIN `glpi_changes`\n ON (`glpi_changes_tickets`.`changes_id` = `glpi_changes`.`id`)\n WHERE `glpi_changes_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_changes`.`name`"; $result = $DB->query($query); $changes = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $changes[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>"; echo "<input type='hidden' name='tickets_id' value='{$ID}'>"; Change::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID())); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td><td>"; if (Session::haveRight('change', CREATE)) { echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?tickets_id={$ID}'>"; _e('Create a change from this ticket'); echo "</a>"; } echo "</td></tr></table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th>"; echo "</tr>"; if ($numrows) { Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"])); $i = 0; foreach ($changes as $data) { Session::addToNavigateListItems('Change', $data["id"]); Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID'])); $i++; } Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Display list of packages to import */ function listPackagesToImport() { $rand = mt_rand(); echo "<div class='spaced'>"; Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='5'>"; echo __('Packages to import', 'fusioninventory'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; echo "<th>"; echo __('Name'); echo "</th>"; echo "<th>"; echo __('uuid'); echo "</th>"; echo "<th>"; echo __('Package to update'); echo "</th>"; echo "</tr>"; foreach (glob(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/import/*.zip") as $file) { echo "<tr class='tab_bg_1'>"; $file = str_replace(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/import/", "", $file); $split = explode('.', $file); echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $file); echo "</td>"; echo "<td>"; echo $split[2]; echo "</td>"; echo "<td>"; echo $split[0] . "." . $split[1]; echo "</td>"; echo "<td>"; $a_packages = current($this->find("`uuid`='" . $split[0] . "." . $split[1] . "'", '', 1)); if (count($a_packages) > 1) { $this->getFromDB($a_packages['id']); echo $this->getLink(); } echo "</td>"; echo "</tr>"; } echo "</table>"; $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); echo "</div>"; }
/** * Print the HTML array for device on link * * @param $link : Link * * @return Nothing (display) **/ static function showForLink($link) { global $DB, $CFG_GLPI; $links_id = $link->getField('id'); $canedit = $link->can($links_id, 'w'); $rand = mt_rand(); if (!Session::haveRight("link", "r") || !$link->can($links_id, 'r')) { return false; } $query = "SELECT *\n FROM `glpi_links_itemtypes`\n WHERE `links_id` = '{$links_id}'\n ORDER BY `itemtype`"; $result = $DB->query($query); $types = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $types[$data['id']] = $data; $used[$data['itemtype']] = $data['itemtype']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item type') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='right'>"; echo "<input type='hidden' name='links_id' value='{$links_id}'>"; Dropdown::showItemTypes('itemtype', $CFG_GLPI["link_types"], array('used' => $used)); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit && $numrows) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Type') . "</th>"; echo "</tr>"; foreach ($types as $data) { $typename = NOT_AVAILABLE; if ($item = getItemForItemtype($data['itemtype'])) { $typename = $item->getTypeName(1); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>{$typename}</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions(__CLASS__, $massiveactionparams); Html::closeForm(); } 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"; }
/** * \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>"; } }
/** * 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>"; }
/** * Show segments of a calendar * * @param $calendar Calendar object **/ static function showForCalendar(Calendar $calendar) { global $DB, $CFG_GLPI; $ID = $calendar->getField('id'); if (!$calendar->can($ID, READ)) { return false; } $canedit = $calendar->can($ID, UPDATE); $rand = mt_rand(); $query = "SELECT *\n FROM `glpi_calendarsegments`\n WHERE `calendars_id` = '{$ID}'\n ORDER BY `day`, `begin`, `end`"; $result = $DB->query($query); $numrows = $DB->numrows($result); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n action='"; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a schedule') . "</tr>"; echo "<tr class='tab_bg_2'><td class='center'>" . __('Day') . "</td><td>"; echo "<input type='hidden' name='calendars_id' value='{$ID}'>"; Dropdown::showFromArray('day', Toolbox::getDaysOfWeekArray()); echo "</td><td class='center'>" . __('Start') . '</td><td>'; Dropdown::showHours("begin", array('value' => date('H') . ":00")); echo "</td><td class='center'>" . __('End') . '</td><td>'; Dropdown::showHours("end", array('value' => date('H') + 1 . ":00")); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $numrows) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Day') . "</th>"; echo "<th>" . __('Start') . "</th>"; echo "<th>" . __('End') . "</th>"; echo "</tr>"; $daysofweek = Toolbox::getDaysOfWeekArray(); if ($numrows) { while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td>"; echo $daysofweek[$data['day']]; echo "</td>"; echo "<td>" . $data["begin"] . "</td>"; echo "<td>" . $data["end"] . "</td>"; } echo "</tr>"; } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show the User having a profile, in allowed Entity * * @param $prof Profile object **/ static function showForProfile(Profile $prof) { global $DB, $CFG_GLPI; $ID = $prof->fields['id']; $canedit = Session::haveRightsOr("user", array(CREATE, UPDATE, DELETE, PURGE)); $rand = mt_rand(); if (!$prof->can($ID, READ)) { return false; } $query = "SELECT `glpi_users`.*,\n `glpi_profiles_users`.`entities_id` AS entity,\n `glpi_profiles_users`.`id` AS linkID,\n `glpi_profiles_users`.`is_dynamic`,\n `glpi_profiles_users`.`is_recursive`\n FROM `glpi_profiles_users`\n LEFT JOIN `glpi_entities`\n ON (`glpi_entities`.`id`=`glpi_profiles_users`.`entities_id`)\n LEFT JOIN `glpi_users`\n ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n WHERE `glpi_profiles_users`.`profiles_id` = '{$ID}'\n AND `glpi_users`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_profiles_users", 'entities_id', $_SESSION['glpiactiveentities'], true) . "\n ORDER BY `glpi_entities`.`completename`"; $result = $DB->query($query); $nb = $DB->numrows($result); echo "<div class='spaced'>"; if ($canedit && $nb) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixe'><tr>"; echo "<th>" . sprintf(__('%1$s: %2$s'), __('Profile'), $prof->fields["name"]) . "</th></tr>\n"; echo "<tr><th colspan='2'>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive')) . "</th></tr>"; echo "</table>\n"; echo "<table class='tab_cadre_fixe'>"; $i = 0; $nb_per_line = 3; $rand = mt_rand(); // Just to avoid IDE warning $canedit_entity = false; if ($nb) { $temp = -1; while ($data = $DB->fetch_assoc($result)) { if ($data["entity"] != $temp) { while ($i % $nb_per_line != 0) { if ($canedit_entity) { echo "<td width='10'> </td>"; } echo "<td class='tab_bg_1'> </td>\n"; $i++; } if ($i != 0) { echo "</table>"; echo "</div>"; echo "</td></tr>\n"; } // New entity $i = 0; $temp = $data["entity"]; $canedit_entity = $canedit && in_array($temp, $_SESSION['glpiactiveentities']); $rand = mt_rand(); echo "<tr class='tab_bg_2'>"; echo "<td>"; echo "<a href=\"javascript:showHideDiv('entity{$temp}{$rand}','imgcat{$temp}', '" . $CFG_GLPI['root_doc'] . "/pics/folder.png','" . $CFG_GLPI['root_doc'] . "/pics/folder-open.png');\">"; echo "<img alt='' name='imgcat{$temp}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/folder.png\"> "; echo "<span class='b'>" . Dropdown::getDropdownName('glpi_entities', $data["entity"]) . "</span>"; echo "</a>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_2'><td>"; echo "<div class='center' id='entity{$temp}{$rand}' style='display:none;'>\n"; echo Html::checkAllAsCheckbox("entity{$temp}{$rand}") . __('All'); echo "<table class='tab_cadre_fixe'>\n"; } if ($i % $nb_per_line == 0) { if ($i != 0) { echo "</tr>\n"; } echo "<tr class='tab_bg_1'>\n"; $i = 0; } if ($canedit_entity) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } $username = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1); if ($data["is_dynamic"] || $data["is_recursive"]) { $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>("); if ($data["is_dynamic"]) { $username = sprintf(__('%1$s%2$s'), $username, __('D')); } if ($data["is_dynamic"] && $data["is_recursive"]) { $username = sprintf(__('%1$s%2$s'), $username, ", "); } if ($data["is_recursive"]) { $username = sprintf(__('%1$s%2$s'), $username, __('R')); } $username = sprintf(__('%1$s%2$s'), $username, ")</span>"); } echo "<td class='tab_bg_1'>" . $username . "</td>\n"; $i++; } if ($i % $nb_per_line != 0) { while ($i % $nb_per_line != 0) { if ($canedit_entity) { echo "<td width='10'> </td>"; } echo "<td class='tab_bg_1'> </td>"; $i++; } } if ($i != 0) { echo "</table>"; echo "</div>"; echo "</td></tr>\n"; } } else { echo "<tr class='tab_bg_2'><td class='tab_bg_1 center'>" . __('No user found') . "</td></tr>\n"; } echo "</table>"; if ($canedit && $nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>\n"; }
/** * \brief Show aliases for an item from its form * Beware that the rendering can be different if readden from direct item form (ie : add new * NetworkAlias, remove, ...) or if readden from item of the item (for instance from the computer * form through NetworkPort::ShowForItem and NetworkName::ShowForItem). * * @param $item NetworkName object * @param $withtemplate integer withtemplate param (default 0) **/ static function showForNetworkName(NetworkName $item, $withtemplate = 0) { global $DB, $CFG_GLPI; $ID = $item->getID(); if (!$item->can($ID, 'r')) { return false; } $canedit = $item->can($ID, 'w'); $rand = mt_rand(); $query = "SELECT *\n FROM `glpi_networkaliases`\n WHERE `networknames_id` = '{$ID}'"; $result = $DB->query($query); $aliases = array(); if ($number = $DB->numrows($result)) { while ($line = $DB->fetch_assoc($result)) { $aliases[$line["id"]] = $line; } } if ($canedit) { echo "\n<div class='firstbloc'>"; echo "<script type='text/javascript' >\n"; echo "function viewAddAlias{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'NetworkName', 'networknames_id' => $ID, 'id' => -1); Ajax::updateItemJsCode("viewnetworkalias{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>"; echo "<a class='vsubmit' href='javascript:viewAddAlias{$rand}();'>"; echo __('Add a network alias') . "</a>\n"; echo "</div>\n"; } echo "<div id='viewnetworkalias{$rand}'></div>"; echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $number) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . _n('Internet domain', 'Internet domains', 1) . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "</tr>"; $used = array(); foreach ($aliases as $data) { $showviewjs = $canedit ? "style='cursor:pointer' onClick=\"viewEditAlias" . $data['id'] . "{$rand}();\"" : ''; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } echo "<td class='center b' {$showviewjs}>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditAlias" . $data["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'NetworkName', 'networknames_id' => $ID, 'id' => $data["id"]); Ajax::updateItemJsCode("viewnetworkalias{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo "<a href='" . static::getFormURL() . "?id=" . $data["id"] . "'>" . $name . "</a>"; echo "</td>"; echo "<td class='center' {$showviewjs}>" . Dropdown::getDropdownName("glpi_fqdns", $data["fqdns_id"]); echo "<td class='center' {$showviewjs}>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo "</tr>"; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions(__CLASS__, $massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** Show LDAP groups to add or synchronise in an entity * * @param $target target page for the form * @param $start where to start the list * @param $sync synchronise or add ? (default 0) * @param $filter ldap filter to use (default '') * @param $filter2 second ldap filter to use (which case ?) (default '') * @param $entity working entity * @param $order display order (default DESC) * * @return nothing **/ static function showLdapGroups($target, $start, $sync = 0, $filter = '', $filter2 = '', $entity, $order = 'DESC') { echo "<br>"; $limitexceeded = false; $ldap_groups = self::getAllGroups($_SESSION["ldap_server"], $filter, $filter2, $entity, $limitexceeded, $order); if (is_array($ldap_groups)) { $numrows = count($ldap_groups); $rand = mt_rand(); $colspan = Session::isMultiEntitiesMode() ? 5 : 4; if ($numrows > 0) { self::displaySizeLimitWarning($limitexceeded); $parameters = ''; Html::printPager($start, $numrows, $target, $parameters); // delete end array_splice($ldap_groups, $start + $_SESSION['glpilist_limit']); // delete begin if ($start > 0) { array_splice($ldap_groups, 0, $start); } echo "<div class='center'>"; Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => min($_SESSION['glpilist_limit'], count($ldap_groups)), 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'import_group' => _sx('button', 'Import')), 'extraparams' => array('massive_action_fields' => array('dn', 'ldap_import_type', 'ldap_import_entities', 'ldap_import_recursive'))); Html::showMassiveActions($massiveactionparams); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'>"; Html::showCheckbox(array('criterion' => array('tag_for_massive' => 'select_item'))); echo "</th>"; $header_num = 0; echo Search::showHeaderItem(Search::HTML_OUTPUT, __('Group'), $header_num, $target . "?order=" . ($order == "DESC" ? "ASC" : "DESC"), 1, $order); echo "<th>" . __('Group DN') . "</th>"; echo "<th>" . __('Destination entity') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Child entities') . "</th>"; } echo "</tr>"; $dn_index = 0; foreach ($ldap_groups as $groupinfos) { $group = $groupinfos["cn"]; $group_dn = $groupinfos["dn"]; $search_type = $groupinfos["search_type"]; echo "<tr class='tab_bg_2 center'>"; echo "<td>"; echo Html::hidden("dn[{$dn_index}]", array('value' => $group_dn, 'data-glpicore-ma-tags' => 'common')); echo Html::hidden("ldap_import_type[{$dn_index}]", array('value' => $search_type, 'data-glpicore-ma-tags' => 'common')); Html::showMassiveActionCheckBox(__CLASS__, $dn_index, array('massive_tags' => 'select_item')); echo "</td>"; echo "<td>" . $group . "</td>"; echo "<td>" . $group_dn . "</td>"; echo "<td>"; Entity::dropdown(array('value' => $entity, 'name' => "ldap_import_entities[{$dn_index}]", 'specific_tags' => array('data-glpicore-ma-tags' => 'common'))); echo "</td>"; if (Session::isMultiEntitiesMode()) { echo "<td>"; Html::showCheckbox(array('name' => "ldap_import_recursive[{$dn_index}]", 'specific_tags' => array('data-glpicore-ma-tags' => 'common'))); echo "</td>"; } else { echo Html::hidden("ldap_import_recursive[{$dn_index}]", array('value' => 0, 'data-glpicore-ma-tags' => 'common')); } echo "</tr>\n"; $dn_index++; } $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); echo "</div>"; Html::printPager($start, $numrows, $target, $parameters); } else { echo "<div class='center b'>" . __('No group to be imported') . "</div>"; } } else { echo "<div class='center b'>" . __('No group to be imported') . "</div>"; } }
/** * Print the HTML array of suppliers for this contract * * @since version 0.84 * * @param $contract Contract object * * @return Nothing (HTML display) **/ static function showForContract(Contract $contract) { global $DB, $CFG_GLPI; $instID = $contract->fields['id']; if (!$contract->can($instID, 'r') || !Session::haveRight("contact_enterprise", "r")) { return false; } $canedit = $contract->can($instID, 'w'); $rand = mt_rand(); $query = "SELECT `glpi_contracts_suppliers`.`id`,\n `glpi_suppliers`.`id` AS entID,\n `glpi_suppliers`.`name` AS name,\n `glpi_suppliers`.`website` AS website,\n `glpi_suppliers`.`phonenumber` AS phone,\n `glpi_suppliers`.`suppliertypes_id` AS type,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_suppliers`,\n `glpi_suppliers`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_suppliers`.`entities_id`)\n WHERE `glpi_contracts_suppliers`.`contracts_id` = '{$instID}'\n AND `glpi_contracts_suppliers`.`suppliers_id`=`glpi_suppliers`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_suppliers", '', '', true) . "\n ORDER BY `glpi_entities`.`completename`, `name`"; $result = $DB->query($query); $suppliers = array(); $used = array(); if ($number = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $suppliers[$data['id']] = $data; $used[$data['entID']] = $data['entID']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<input type='hidden' name='contracts_id' value='{$instID}'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a supplier') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='right'>"; Supplier::dropdown(array('used' => $used, 'entity' => $contract->fields["entities_id"], 'entity_sons' => $contract->fields["is_recursive"])); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit && $number) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Supplier') . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "<th>" . __('Third party type') . "</th>"; echo "<th>" . __('Phone') . "</th>"; echo "<th>" . __('Website') . "</th>"; echo "</tr>"; $used = array(); foreach ($suppliers as $data) { $ID = $data['id']; $website = $data['website']; if (!empty($website)) { if (!preg_match("?https*://?", $website)) { $website = "http://" . $website; } $website = "<a target=_blank href='{$website}'>" . $data['website'] . "</a>"; } $entID = $data['entID']; $entity = $data['entity']; $used[$entID] = $entID; $entname = Dropdown::getDropdownName("glpi_suppliers", $entID); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>"; if ($_SESSION["glpiis_ids_visible"] || empty($entname)) { $entname = sprintf(__('%1$s (%2$s)'), $entname, $entID); } echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id={$entID}'>" . $entname; echo "</a></td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $entity) . "</td>"; echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_suppliertypes", $data['type']) . "</td>"; echo "<td class='center'>" . $data['phone'] . "</td>"; echo "<td class='center'>" . $website . "</td>"; echo "</tr>"; } echo "</table>"; if ($canedit && $number) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }
/** * Show visibility config for a reminder **/ function showVisibility() { global $DB, $CFG_GLPI; $ID = $this->fields['id']; $canedit = Session::haveRight('reminder_public', 'w'); echo "<div class='center'>"; $rand = mt_rand(); $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='remindervisibility_form{$rand}' id='remindervisibility_form{$rand}' "; echo " method='post' action='" . Toolbox::getItemTypeFormURL('Reminder') . "'>"; echo "<input type='hidden' name='reminders_id' value='{$ID}'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</tr>"; echo "<tr class='tab_bg_2'><td width='100px'>"; $types = array('Entity', 'Group', 'Profile', 'User'); $addrand = Dropdown::showItemTypes('_type', $types); $params = array('type' => '__VALUE__', 'right' => 'reminder_public'); Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params); echo "</td>"; echo "<td><span id='visibility{$rand}'></span>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $nb) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('deletevisibility' => _x('button', 'Delete permanently'))); if ($this->fields['users_id'] != Session::getLoginUserID()) { $paramsma['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.'); } Html::showMassiveActions(__CLASS__, $paramsma); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $nb) { echo "<th width='10'>"; echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Type') . "</th>"; echo "<th>" . _n('Recipient', 'Recipients', 2) . "</th>"; echo "</tr>"; // Users if (count($this->users)) { foreach ($this->users as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Reminder_User][" . $data["id"] . "]'\n value='1' >"; echo "</td>"; } echo "<td>" . __('User') . "</td>"; echo "<td>" . getUserName($data['users_id']) . "</td>"; echo "</tr>"; } } } // Groups if (count($this->groups)) { foreach ($this->groups as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Group_Reminder][" . $data["id"] . "]'\n value='1'>"; echo "</td>"; } echo "<td>" . __('Group') . "</td>"; $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1); $entname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false))); if ($data['entities_id'] >= 0) { $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id'])); if ($data['is_recursive']) { //TRANS: R for Recursive sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>"); } } echo "<td>" . $entname . "</td>"; echo "</tr>"; } } } // Entity if (count($this->entities)) { foreach ($this->entities as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Entity_Reminder][" . $data["id"] . "]'\n value='1'>"; echo "</td>"; } echo "<td>" . __('Entity') . "</td>"; $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1); $tooltip = Html::showToolTip($names["comment"], array('display' => false)); $entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip); if ($data['is_recursive']) { $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>"); } echo "<td>" . $entname . "</td>"; echo "</tr>"; } } } // Profiles if (count($this->profiles)) { foreach ($this->profiles as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Profile_Reminder][" . $data["id"] . "]'\n value='1'>"; echo "</td>"; } echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>"; $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1); $tooltip = Html::showToolTip($names["comment"], array('display' => false)); $entname = sprintf(__('%1$s %2$s'), $names["name"], $entname); if ($data['entities_id'] >= 0) { $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id'])); if ($data['is_recursive']) { $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>"); } } echo "<td>" . $entname . "</td>"; echo "</tr>"; } } } echo "</table>"; if ($canedit && $nb) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; // Add items return true; }
/** * show defined display preferences for a user * * @param $users_id integer user ID **/ static function showForUser($users_id) { global $DB; $url = Toolbox::getItemTypeFormURL(__CLASS__); $query = "SELECT `itemtype`,\n COUNT(*) AS nb\n FROM `glpi_displaypreferences`\n WHERE `users_id` = '{$users_id}'\n GROUP BY `itemtype`"; $req = $DB->request($query); if ($req->numrows() > 0) { $rand = mt_rand(); echo "<div class='spaced'>"; Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('width' => 400, 'height' => 200, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'delete_for_user' => _x('button', 'Delete permanently')), 'extraparams' => array('massive_action_fields' => array('users_id'))); Html::showMassiveActions($massiveactionparams); echo Html::hidden('users_id', array('value' => $users_id, 'data-glpicore-ma-tags' => 'common')); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; echo "<th colspan='2'>" . __('Type') . "</th></tr>"; foreach ($req as $data) { echo "<tr class='tab_bg_1'><td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["itemtype"]); echo "</td>"; if ($item = getItemForItemtype($data["itemtype"])) { $name = $item->getTypeName(1); } else { $name = $data["itemtype"]; } echo "<td>{$name}</td><td class='numeric'>" . $data['nb'] . "</td>"; echo "</tr>"; } echo "</table>"; $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); echo "</div>"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>"; echo "</table>"; } }
/** * Show softwares candidates to be merged with the current * * @return nothing **/ function showMergeCandidates() { global $DB, $CFG_GLPI; $ID = $this->getField('id'); $this->check($ID, "w"); $rand = mt_rand(); echo "<div class='center'>"; $sql = "SELECT `glpi_softwares`.`id`,\n `glpi_softwares`.`name`,\n `glpi_entities`.`completename` AS entity\n FROM `glpi_softwares`\n LEFT JOIN `glpi_entities` ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)\n WHERE (`glpi_softwares`.`id` != '{$ID}'\n AND `glpi_softwares`.`name` = '" . addslashes($this->fields["name"]) . "'\n AND `glpi_softwares`.`is_deleted` = '0'\n AND `glpi_softwares`.`is_template` = '0' " . getEntitiesRestrictRequest('AND', 'glpi_softwares', 'entities_id', getSonsOf("glpi_entities", $this->fields["entities_id"]), false) . ")\n ORDER BY `entity`"; $req = $DB->request($sql); if ($nb = $req->numrows()) { $link = Toolbox::getItemTypeFormURL('Software'); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('mergesoftware' => __('Merge'))); Html::showMassiveActions(__CLASS__, $paramsma); echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th width='10'>"; echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "<th>" . _n('Installation', 'Installations', 2) . "</th>"; echo "<th>" . _n('License', 'Licenses', 2) . "</th></tr>"; foreach ($req as $data) { echo "<tr class='tab_bg_2'>"; echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>"; echo "<td><a href='" . $link . "?id=" . $data["id"] . "'>" . $data["name"] . "</a></td>"; echo "<td>" . $data["entity"] . "</td>"; echo "<td class='right'>" . Computer_SoftwareVersion::countForSoftware($data["id"]) . "</td>"; echo "<td class='right'>" . SoftwareLicense::countForSoftware($data["id"]) . "</td></tr>\n"; } echo "</table>\n"; echo "<input type='hidden' name='id' value='{$ID}'>"; $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } else { _e('No item found'); } echo "</div>"; }
/** * Show the printer types that are compatible with a cartridge type * * @param $item CartridgeItem object * * @return nothing (display) **/ static function showForCartridgeItem(CartridgeItem $item) { global $DB, $CFG_GLPI; $instID = $item->getField('id'); if (!$item->can($instID, READ)) { return false; } $canedit = $item->canEdit($instID); $rand = mt_rand(); $query = "SELECT `" . static::getTable() . "`.`id`,\n `glpi_printermodels`.`name` AS `type`,\n `glpi_printermodels`.`id` AS `pmid`\n FROM `" . static::getTable() . "`,\n `glpi_printermodels`\n WHERE `" . static::getTable() . "`.`printermodels_id` = `glpi_printermodels`.`id`\n AND `" . static::getTable() . "`.`cartridgeitems_id` = '{$instID}'\n ORDER BY `glpi_printermodels`.`name`"; $result = $DB->query($query); $i = 0; $used = array(); $datas = array(); if ($number = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $used[$data["pmid"]] = $data["pmid"]; $datas[$data["id"]] = $data; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='printermodel_form{$rand}' id='printermodel_form{$rand}' method='post'"; echo " action='" . static::getFormURL() . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='6'>" . __('Add a compatible printer model') . "</th></tr>"; echo "<tr><td class='tab_bg_2 center'>"; echo "<input type='hidden' name='cartridgeitems_id' value='{$instID}'>"; PrinterModel::dropdown(array('used' => $used)); echo "</td><td class='tab_bg_2 center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } if ($number) { echo "<div class='spaced'>"; if ($canedit) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => count($used), 'container' => 'mass' . __CLASS__ . $rand); 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>" . __('Model') . "</th></tr>"; echo $header_begin . $header_top . $header_end; foreach ($datas as $data) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>" . $data['type'] . "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } }
function showScripts(PluginDatabasesDatabase $database) { global $DB, $CFG_GLPI; $instID = $database->fields['id']; if (!$database->can($instID, "r")) { return false; } $rand = mt_rand(); $canedit = $database->can($instID, 'w'); $query = "SELECT `glpi_plugin_databases_scripts`.`name` AS name,\n `glpi_plugin_databases_scripts`.`id`,\n `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`,\n `glpi_plugin_databases_scripts`.`path`,\n `glpi_plugin_databases_scripts`.`comment`,\n `glpi_plugin_databases_scripttypes`.`name` AS type\n FROM `glpi_plugin_databases_scripts` "; $query .= " LEFT JOIN `glpi_plugin_databases_scripttypes`\n ON (`glpi_plugin_databases_scripttypes`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_scripttypes_id`)"; $query .= " LEFT JOIN `glpi_plugin_databases_databases`\n ON (`glpi_plugin_databases_databases`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`)"; $query .= " WHERE `glpi_plugin_databases_scripts`.`plugin_databases_databases_id` = '{$instID}'\n ORDER BY `glpi_plugin_databases_scripts`.`name`"; $result = $DB->query($query); $number = $DB->numrows($result); echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array(); Html::showMassiveActions(__CLASS__, $massiveactionparams); } if ($number != 0) { echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit && $number) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Type') . "</th>"; echo "<th>" . __('Path', 'databases') . "</th>"; echo "<th>" . __('Comments') . "</th>"; echo "</tr>"; Session::initNavigateListItems($this->getType(), PluginDatabasesDatabase::getTypeName(2) . " = " . $database->fields["name"]); $i = 0; $row_num = 1; while ($data = $DB->fetch_array($result)) { Session::addToNavigateListItems($this->getType(), $data['id']); $i++; $row_num++; echo "<tr class='tab_bg_1 center'>"; echo "<td width='10'>"; if ($canedit) { Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); } echo "</td>"; echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/script.form.php?id=" . $data["id"] . "&plugin_databases_databases_id=" . $data["plugin_databases_databases_id"] . "'>"; echo $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { echo " (" . $data["id"] . ")"; } echo "</a></td>"; echo "<td class='center'>" . $data["type"] . "</td>"; echo "<td class='left'>" . $data["path"] . "</td>"; echo "<td class='center'>" . nl2br($data["comment"]) . "</td>"; echo "</tr>"; } echo "</table>"; } if ($canedit && $number) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }