public function showResult($output_type, $limit = 0) { global $DB; $arrayRet = $this->execQuery($_POST); $result = $arrayRet['query_result']; $query = $arrayRet['query']; $nbtot = $result ? $DB->numrows($result) : 0; if ($limit) { $start = isset($_GET["start"]) ? $_GET["start"] : 0; if ($start >= $nbtot) { $start = 0; } if ($start > 0 || $start + $limit < $nbtot) { $result = $DB->query($query . " LIMIT {$start},{$limit}"); } } else { $start = 0; } $nbCols = $DB->num_fields($result); $nbrows = $DB->numrows($result); $groupByRackName = true; if (isset($_POST['groupByRackName']) && $_POST['groupByRackName'] == "on") { $groupByRackName = false; } $title = date("d/m/Y H:i"); if ($nbtot == 0) { echo "<div class='center'><font class='red b'>" . __("No item found") . "</font></div>"; Html::footer(); } else { if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php"; } else { if ($output_type == Search::HTML_OUTPUT) { echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>{$title}</th></tr>\n"; echo "<tr class='tab_bg_2 center'><td class='center'>"; echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}' target='_blank'>\n"; $param = ""; foreach ($_POST as $key => $val) { if (is_array($val)) { foreach ($val as $k => $v) { echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >"; if (!empty($param)) { $param .= "&"; } $param .= $key . "[" . $k . "]=" . urlencode($v); } } else { echo "<input type='hidden' name='{$key}' value='{$val}' >"; if (!empty($param)) { $param .= "&"; } $param .= "{$key}=" . urlencode($val); } } echo "<input type='hidden' name='result_search_reports' value='searchdone' >"; $param .= "&result_search_reports=searchdone&target=_blank"; Dropdown::showOutputFormat(); Html::closeForm(); echo "</td></tr>"; echo "</table></div>"; Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param); } } } if ($nbtot > 0) { if ($output_type == Search::HTML_OUTPUT) { echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n"; } echo Search::showHeader($output_type, $nbrows, $nbCols, true); $showAllFieds = true; $listFields = array(); $cptField = 0; $showAllFieds = (!isset($_POST['cb_object_name']) || $_POST['cb_object_name'] != "on") && (!isset($_POST['cb_object_location']) || $_POST['cb_object_location'] != "on") && (!isset($_POST['cb_group']) || $_POST['cb_group'] != "on") && (!isset($_POST['cb_manufacturer']) || $_POST['cb_manufacturer'] != "on") && (!isset($_POST['cb_model']) || $_POST['cb_model'] != "on") && (!isset($_POST['cb_serial_number']) || $_POST['cb_serial_number'] != "on"); $num = 1; $cptRow = 1; if (!$showAllFieds) { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'name', false); $cptField++; $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'location', false); $cptField++; $this->showTitle($output_type, $num, _n("Location", "Locations", 1, "racks"), 'roomlocation', false); $cptField++; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false); $cptField++; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . __("Back", "racks"), 'front_rear', false); $cptField++; if (isset($_POST['cb_object_name']) && $_POST['cb_object_name'] == "on") { $listFields['object_name'] = $_POST['cb_object_name']; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false); $cptField++; } // Lieu if (isset($_POST['cb_object_location']) && $_POST['cb_object_location'] == "on") { $listFields['object_location'] = $_POST['cb_object_location']; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false); $cptField++; } // Groupe if (isset($_POST['cb_group']) && $_POST['cb_group'] == "on") { $listFields['group'] = $_POST['cb_group']; $this->showTitle($output_type, $num, __("Group"), 'roomlocation', false); $cptField++; } // Fabricant if (isset($_POST['cb_manufacturer']) && $_POST['cb_manufacturer'] == "on") { $listFields['manufacturer'] = $_POST['cb_manufacturer']; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false); $cptField++; } // Modèle if (isset($_POST['cb_model']) && $_POST['cb_model'] == "on") { $listFields['model'] = $_POST['cb_model']; $this->showTitle($output_type, $num, __("Model"), 'model', false); $cptField++; } // Numéro de série if (isset($_POST['cb_serial_number']) && $_POST['cb_serial_number'] == "on") { $listFields['serial_number'] = $_POST['cb_serial_number']; $this->showTitle($output_type, $num, __("Serial number", "racks"), 'group', false); $cptField++; } } else { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'rack_name', false); $listFields['rack_name'] = true; $this->showTitle($output_type, $num, __("Place", "racks"), 'location', false); $listFields['location'] = true; $this->showTitle($output_type, $num, __("Location", "racks"), 'roomlocation', false); $listFields['roomlocation'] = true; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false); $listFields['u'] = true; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . __("Back", "racks"), 'front_rear', false); $listFields['front_rear'] = true; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false); $listFields['object_name'] = true; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false); $listFields['object_location'] = true; $this->showTitle($output_type, $num, __("Group"), false); $listFields['group'] = true; $this->showTitle($output_type, $num, __("Type"), 'type', false); $listFields['type'] = true; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false); $listFields['manufacturer'] = true; $this->showTitle($output_type, $num, __("Model"), 'model', false); $listFields['model'] = true; $this->showTitle($output_type, $num, __("Serial number", "racks"), 'serial_number', false); $listFields['serial_number'] = true; $this->showTitle($output_type, $num, __("Inventory number"), 'other_serial', false); $listFields['other_serial'] = true; $cptField = 13; } echo Search::showEndLine($output_type); $num = 1; $currentRack = -1; while ($row = $DB->fetch_array($result)) { // itemtype $itemtype = $row['itemtype']; $num = 1; $cptRow++; echo Search::showNewLine($output_type); if (isset($row['itemtype']) && $row['itemtype'] != "") { $class = substr($itemtype, 0, -5); $item = new $class(); $table = getTableForItemType($class); $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' "); $device = $DB->fetch_array($r); } // nom $link = Toolbox::getItemTypeFormURL("PluginRacksRack"); if ($groupByRackName || $currentRack != $row['id']) { if ($output_type == Search::HTML_OUTPUT) { echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow); } else { echo Search::showItem($output_type, $row["name"], $num, $cptRow); } } else { echo Search::showItem($output_type, " ", $num, $cptRow); } // lieu if ($groupByRackName || $currentRack != $row['id']) { $tmpId = $row['locations_id']; $tmpObj = new Location(); $tmpObj->getFromDB($tmpId); if (isset($tmpObj->fields['name'])) { echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow); } else { echo Search::showItem($output_type, " ", $num, $cptRow); } } else { echo Search::showItem($output_type, " ", $num, $cptRow); } // Emplacement if ($groupByRackName || $currentRack != $row['id']) { $tmpId = $row['plugin_racks_roomlocations_id']; $tmpObj = new PluginRacksRoomLocation(); $tmpObj->getFromDB($tmpId); if (isset($tmpObj->fields['name'])) { echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow); } else { echo Search::showItem($output_type, ' ', $num, $cptRow); } } else { echo Search::showItem($output_type, " ", $num, $cptRow); } if (isset($row['itemtype']) && $row['itemtype'] != "") { // U if (isset($row['position']) && $row['position'] != "") { echo Search::showItem($output_type, $row['position'], $num, $cptRow); } else { echo Search::showItem($output_type, " ", $num, $cptRow); } // avant / arrière if ($row['faces_id'] == 1) { echo Search::showItem($output_type, __("Front", "racks"), $num, $cptRow); } else { echo Search::showItem($output_type, __("Back", "racks"), $num, $cptRow); } // Nom de l'objet if (array_key_exists("object_name", $listFields)) { $link = Toolbox::getItemTypeFormURL(substr($itemtype, 0, -5)); if ($itemtype != 'PluginRacksOtherModel') { if ($output_type == Search::HTML_OUTPUT) { echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["items_id"] . "\">" . $device["name"] . "</a>", $num, $cptRow); } else { echo Search::showItem($output_type, $device["name"], $num, $cptRow); } } else { echo Search::showItem($output_type, $device["name"], $num, $cptRow); } } // Lieu de l'objet if (array_key_exists("object_location", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $device["locations_id"]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // Groupe if (array_key_exists("group", $listFields)) { // Groupe if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $device["groups_id_tech"]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // type if (array_key_exists("type", $listFields)) { echo Search::showItem($output_type, $item->getTypeName(), $num, $cptRow); } // fabricant if (array_key_exists("manufacturer", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_manufacturers", $device["manufacturers_id"]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // modèle //TODO = model du rack => model des objets if (array_key_exists("model", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { $model_table = getTableForItemType($itemtype); $modelfield = getForeignKeyFieldForTable(getTableForItemType($itemtype)); echo Search::showItem($output_type, Dropdown::getDropdownName($model_table, $device[$modelfield]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // numéro de série if (array_key_exists("serial_number", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, $device['serial'], $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // numéro d'inventaire if (array_key_exists("other_serial", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, $device['otherserial'], $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } $currentRack = $row['id']; } else { for ($k = 0; $k < $cptField - 3; $k++) { echo Search::showItem($output_type, " ", $num, $cptRow, ""); } } echo Search::showEndLine($output_type); } if ($output_type == Search::HTML_OUTPUT) { Html::closeForm(); } echo Search::showFooter($output_type, $title); } }
/** * Print pager for search option (first/previous/next/last) * * @param $start from witch item we start * @param $numrows total items * @param $target page would be open when click on the option (last,previous etc) * @param $parameters parameters would be passed on the URL. * @param $item_type_output item type display - if >0 display export PDF et Sylk form * (default 0) * @param $item_type_output_param item type parameter for export (default 0) * @param $additional_info Additional information to display (default '') * * @return nothing (print a pager) * **/ static function printPager($start, $numrows, $target, $parameters, $item_type_output = 0, $item_type_output_param = 0, $additional_info = '') { global $CFG_GLPI; $list_limit = $_SESSION['glpilist_limit']; // Forward is the next step forward $forward = $start + $list_limit; // This is the end, my friend $end = $numrows - $list_limit; // Human readable count starts here $current_start = $start + 1; // And the human is viewing from start to end $current_end = $current_start + $list_limit - 1; if ($current_end > $numrows) { $current_end = $numrows; } // Empty case if ($current_end == 0) { $current_start = 0; } // Backward browsing if ($current_start - $list_limit <= 0) { $back = 0; } else { $back = $start - $list_limit; } // Print it echo "<div><table class='tab_cadre_pager'>"; echo "<tr>"; if (strpos($target, '?') == false) { $fulltarget = $target . "?" . $parameters; } else { $fulltarget = $target . "&" . $parameters; } // Back and fast backward button if (!$start == 0) { echo "<th class='left'>"; echo "<a href='{$fulltarget}&start=0'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('Start') . "\" title=\"" . __s('Start') . "\" class='pointer'>"; echo "</a></th>"; echo "<th class='left'>"; echo "<a href='{$fulltarget}&start={$back}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\" class='pointer'>"; echo "</a></th>"; } // Print the "where am I?" echo "<td width='31%' class='tab_bg_2'>"; self::printPagerForm("{$fulltarget}&start={$start}"); echo "</td>"; if (!empty($additional_info)) { echo "<td class='tab_bg_2'>"; echo $additional_info; echo "</td>"; } if (!empty($item_type_output) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") { echo "<td class='tab_bg_2 responsive_hidden' width='30%'>"; echo "<form method='GET' action='" . $CFG_GLPI["root_doc"] . "/front/report.dynamic.php'\n target='_blank'>"; echo Html::hidden('item_type', array('value' => $item_type_output)); if ($item_type_output_param != 0) { echo Html::hidden('item_type_param', array('value' => Toolbox::prepareArrayForInput($item_type_output_param))); } $split = explode("&", $parameters); for ($i = 0; $i < count($split); $i++) { $pos = Toolbox::strpos($split[$i], '='); $length = Toolbox::strlen($split[$i]); echo Html::hidden(Toolbox::substr($split[$i], 0, $pos), array('value' => urldecode(Toolbox::substr($split[$i], $pos + 1)))); } Dropdown::showOutputFormat(); Html::closeForm(); echo "</td>"; } echo "<td width='20%' class='tab_bg_2 b'>"; //TRANS: %1$d, %2$d, %3$d are page numbers printf(__('From %1$d to %2$d on %3$d'), $current_start, $current_end, $numrows); echo "</td>\n"; // Forward and fast forward button if ($forward < $numrows) { echo "<th class='right'>"; echo "<a href='{$fulltarget}&start={$forward}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\" class='pointer'>"; echo "</a></th>\n"; echo "<th class='right'>"; echo "<a href='{$fulltarget}&start={$end}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/last.png' alt=\"" . __s('End') . "\" title=\"" . __s('End') . "\" class='pointer'>"; echo "</a></th>\n"; } // End pager echo "</tr></table></div>"; }
foreach ($val as $k => $v) { echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >"; if (!empty($param)) { $param .= "&"; } $param .= $key . "[" . $k . "]=" . urlencode($v); } } else { echo "<input type='hidden' name='{$key}' value='{$val}' >"; if (!empty($param)) { $param .= "&"; } $param .= "{$key}=" . urlencode($val); } } Dropdown::showOutputFormat(); Html::closeForm(); echo "</td></tr>"; echo "</table></div>"; Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param); } } } if ($nbtot > 0) { $nbcols = $DB->num_fields($result); $nbrows = $DB->numrows($result); $num = 1; $link = $_SERVER['PHP_SELF']; $order = 'ASC'; $issort = false; echo Search::showHeader($output_type, $nbrows, $nbcols, true);
/** * Print pager for search option (first/previous/next/last) * * @param $start from witch item we start * @param $numrows total items * @param $target page would be open when click on the option (last,previous etc) * @param $parameters parameters would be passed on the URL. * @param $item_type_output item type display - if >0 display export PDF et Sylk form * (default 0) * @param $item_type_output_param item type parameter for export (default 0) * @param $additional_info Additional information to display (default '') * * @return nothing (print a pager) * * */ function printPager($start, $numrows, $target, $parameters, $item_type_output = 0, $item_type_output_param = 0, $additional_info = '') { global $CFG_GLPI; $list_limit = $_SESSION['glpilist_limit']; // Forward is the next step forward $forward = $start + $list_limit; // This is the end, my friend $end = $numrows - $list_limit; // Human readable count starts here $current_start = $start + 1; // And the human is viewing from start to end $current_end = $current_start + $list_limit - 1; if ($current_end > $numrows) { $current_end = $numrows; } // Empty case if ($current_end == 0) { $current_start = 0; } // Backward browsing if ($current_start - $list_limit <= 0) { $back = 0; } else { $back = $start - $list_limit; } // Print it echo "<div><table class='tab_cadre_pager'>"; echo "<tr>"; // Back and fast backward button if (!$start == 0) { echo "<th class='left'>"; echo "<a href='{$target}?{$parameters}&start=0'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('Start') . "\" title=\"" . __s('Start') . "\">"; echo "</a></th>"; echo "<th class='left'>"; echo "<a href='{$target}?{$parameters}&start={$back}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\">"; echo "</a></th>"; } // Print the "where am I?" echo "<td width='50%' class='tab_bg_2'>"; Html::printPagerForm("{$target}?{$parameters}&start={$start}"); echo "</td>"; if (!empty($additional_info)) { echo "<td class='tab_bg_2'>"; echo $additional_info; echo "</td>"; } if (!empty($item_type_output) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") { echo "<td class='tab_bg_2' width='30%'>"; echo "<form method='GET' action='" . $target . "' target='_blank'>"; echo Html::hidden('item_type', array('value' => $item_type_output)); if ($item_type_output_param != 0) { echo Html::hidden('item_type_param', array('value' => Toolbox::prepareArrayForInput($item_type_output_param))); } $split = explode("&", $parameters); for ($i = 0; $i < count($split); $i++) { $pos = Toolbox::strpos($split[$i], '='); $length = Toolbox::strlen($split[$i]); echo Html::hidden(Toolbox::substr($split[$i], 0, $pos), array('value' => urldecode(Toolbox::substr($split[$i], $pos + 1)))); } Dropdown::showOutputFormat(); $this->showCSVOptions(); echo "<script type='text/javascript'>"; echo "\$('select[name=display_type]').change(function() {\r\n switch(\$(this).val()){\r\n case '3' :case '-3' :\r\n \$('#display_csv_preferences').css('display', 'block');\r\n break;\r\n default : \r\n \$('#display_csv_preferences').css('display', 'none');\r\n break;\r\n }\r\n });"; echo "</script>"; Html::closeForm(); echo "</td>"; } echo "<td width='50%' class='tab_bg_2 b'>"; //TRANS: %1$d, %2$d, %3$d are page numbers printf(__('From %1$d to %2$d on %3$d'), $current_start, $current_end, $numrows); echo "</td>\n"; // Forward and fast forward button if ($forward < $numrows) { echo "<th class='right'>"; echo "<a href='{$target}?{$parameters}&start={$forward}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\">"; echo "</a></th>\n"; echo "<th class='right'>"; echo "<a href='{$target}?{$parameters}&start={$end}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/last.png' alt=\"" . __s('End') . "\" title=\"" . __s('End') . "\">"; echo "</a></th>\n"; } // End pager echo "</tr></table></div>"; }
/** * Execute the report * * @param $options array **/ function execute($options = array()) { global $DB, $CFG_GLPI, $HEADER_LOADED; // Require (for pager) when not called by displayCriteriasForm $this->manageCriteriasValues(); if (isset($_POST['list_limit'])) { $_SESSION['glpilist_limit'] = $_POST['list_limit']; unset($_POST['list_limit']); } $limit = $_SESSION['glpilist_limit']; if (isset($_POST["display_type"])) { $output_type = $_POST["display_type"]; if ($output_type < 0) { $output_type = -$output_type; $limit = 0; } } else { $output_type = Search::HTML_OUTPUT; } $title = $this->title; if ($this->subname) { $title = sprintf(__('%1$s - %2$s'), $title, $this->subname); } $res = $DB->query($this->sql); $nbtot = $res ? $DB->numrows($res) : 0; if ($limit) { $start = isset($_GET["start"]) ? $_GET["start"] : 0; if ($start >= $nbtot) { $start = 0; } if ($start > 0 || $start + $limit < $nbtot) { $res = $DB->query($this->sql . " LIMIT {$start},{$limit}"); } } else { $start = 0; } if ($nbtot == 0) { if (!$HEADER_LOADED) { Html::header($title, $_SERVER['PHP_SELF'], "utils", "report"); Report::title(); } echo "<div class='center'><font class='red b'>" . __('No item found') . "</font></div>"; Html::footer(); } else { if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php"; } else { if ($output_type == Search::HTML_OUTPUT) { if (!$HEADER_LOADED) { Html::header($title, $_SERVER['PHP_SELF'], "utils", "report"); Report::title(); } echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . $title . "</th></tr>\n"; echo "<tr class='tab_bg_2 center'><td class='center'>"; echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n"; $param = ""; foreach ($_POST as $key => $val) { if (is_array($val)) { foreach ($val as $k => $v) { echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >"; if (!empty($param)) { $param .= "&"; } $param .= $key . "[" . $k . "]=" . urlencode($v); } } else { echo "<input type='hidden' name='" . $key . "' value='{$val}' >"; if (!empty($param)) { $param .= "&"; } $param .= "{$key}=" . urlencode($val); } } Dropdown::showOutputFormat(); Html::closeForm(); echo "</td></tr>"; echo "</table></div>"; Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param); } } } if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) { if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) { echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php\">"; } } plugin_reports_checkRight($this->plug, $this->name, "r"); if ($res && $nbtot > 0) { $nbcols = $DB->num_fields($res); $nbrows = $DB->numrows($res); echo Search::showHeader($output_type, $nbrows, $nbcols, true); echo Search::showNewLine($output_type); $num = 1; // fill $sqlcols with default sql query fields so we can validate $columns $sqlcols = array(); for ($i = 0; $i < $nbcols; $i++) { $colname = $DB->field_name($res, $i); $sqlcols[] = $colname; } $colsname = array(); // if $columns is not empty, display $columns if (count($this->columns) > 0) { foreach ($this->columns as $colname => $column) { // display only $columns that are valid if (in_array($colname, $sqlcols)) { $column->showTitle($output_type, $num); $colsname[$colname] = $column; } } } else { // else display default columns from SQL query foreach ($sqlcols as $colname) { $column = new PluginReportsColumn($colname, $colname); $column->showTitle($output_type, $num); $colsname[$colname] = $column; } } echo Search::showEndLine($output_type); $prev = ""; for ($row_num = 2; $row = $DB->fetch_assoc($res); $row_num++) { $crt = ""; foreach ($this->group_by as $colname) { if (isset($row[$colname])) { $crt .= $row[$colname] . "####"; } } echo Search::showNewLine($output_type); $num = 1; foreach ($colsname as $colname => $column) { //If value needs to be modified on the fly if (isset($this->columns_mapping[$colname]) && isset($this->columns_mapping[$colname][$row[$colname]])) { $new_value = $this->columns_mapping[$colname][$row[$colname]]; $row[$colname] = $new_value; } if (!in_array($colname, $this->group_by)) { $column->showValue($output_type, $row, $num, $row_num); } else { if ($crt == $prev) { $column->showValue($output_type, $output_type == Search::CSV_OUTPUT ? $row : array(), $num, $row_num); } else { $column->showValue($output_type, $row, $num, $row_num, true); } } } // Each column echo Search::showEndLine($output_type); $prev = $crt; } // Each row if (isset($options['withtotal']) && $options['withtotal']) { echo Search::showNewLine($output_type); $num = 1; foreach ($colsname as $colname => $column) { $column->showTotal($output_type, $num, $row_num); } echo Search::showEndLine($output_type); } } echo Search::showFooter($output_type, $title); if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) { if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) { Html::openArrowMassives("massiveaction_form", true); Dropdown::showForMassiveAction($options['withmassiveaction']); $options = array(); Html::closeArrowMassives($options); Html::closeForm(); } Html::footer(); } }