. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Report class * * @ since version 0.84 **/ class Report extends CommonGLPI{ static protected $notable = false; static $rightname = 'reports'; static function getTypeName($nb = 0) { return _n('Report', 'Reports', $nb); } /** * @see CommonGLPI::getMenuShorcut() * * @since 0.85 **/ static function getMenuShorcut() { return 'e'; } /** * Show report title **/ static function title() { global $PLUGIN_HOOKS, $CFG_GLPI; // Report generation // Default Report included $report_list = []; $report_list["default"]["name"] = __('Default report'); $report_list["default"]["file"] = "report.default.php"; if (Contract::canView()) { // Rapport ajoute par GLPI V0.2 $report_list["Contrats"]["name"] = __('By contract'); $report_list["Contrats"]["file"] = "report.contract.php"; } if (Infocom::canView()) { $report_list["Par_annee"]["name"] = __('By year'); $report_list["Par_annee"]["file"] = "report.year.php"; $report_list["Infocoms"]["name"] = __('Hardware financial and administrative information'); $report_list["Infocoms"]["file"] = "report.infocom.php"; $report_list["Infocoms2"]["name"] = __('Other financial and administrative information (licenses, cartridges, consumables)'); $report_list["Infocoms2"]["file"] = "report.infocom.conso.php"; } if (Session::haveRight("networking", READ)) { $report_list["Rapport prises reseau"]["name"] = __('Network report'); $report_list["Rapport prises reseau"]["file"] = "report.networking.php"; } if (Session::haveRight("reservation", READ)) { $report_list["reservation"]["name"] = __('Loan'); $report_list["reservation"]["file"] = "report.reservation.php"; } if (Computer::canView() || Monitor::canView() || Session::haveRight("networking", READ) || Peripheral::canView() || Printer::canView() || Phone::canView()) { $report_list["state"]["name"] = __('Status'); $report_list["state"]["file"] = "report.state.php"; } //Affichage du tableau de presentation des stats echo "
| ".__('Select the report you want to generate')." | |
|---|---|
| "; $selected = -1; $values = [$CFG_GLPI["root_doc"].'/front/report.php' => Dropdown::EMPTY_VALUE]; foreach ($report_list as $val => $data) { $name = $data['name']; $file = $data['file']; $key = $CFG_GLPI["root_doc"]."/front/".$file; $values[$key] = $name; if (stripos($_SERVER['REQUEST_URI'], $key) !== false) { $selected = $key; } } $names = []; $optgroup = []; if (isset($PLUGIN_HOOKS["reports"]) && is_array($PLUGIN_HOOKS["reports"])) { foreach ($PLUGIN_HOOKS["reports"] as $plug => $pages) { if (!Plugin::isPluginActive($plug)) { continue; } if (is_array($pages) && count($pages)) { foreach ($pages as $page => $name) { $names[$plug.'/'.$page] = ["name" => $name, "plug" => $plug]; $optgroup[$plug] = Plugin::getInfo($plug, 'name'); } } } asort($names); } foreach ($optgroup as $opt => $title) { $group = $title; foreach ($names as $key => $val) { if ($opt == $val["plug"]) { $file = $CFG_GLPI["root_doc"]."/plugins/".$key; $values[$group][$file] = $val["name"]; if (stripos($_SERVER['REQUEST_URI'], $file) !== false) { $selected = $file; } } } } Dropdown::showFromArray('statmenu', $values, ['on_change' => "window.location.href=this.options[this.selectedIndex].value", 'value' => $selected]); echo " | "; echo "|
| ".$itemtype::getTypeName(Session::getPluralNumber())." | "; echo "$number |
| ".OperatingSystem::getTypeName(1)." | |
| ".$data['name']." | "; echo "".$data['count']." |
| ".$itemtype::getTypeName(Session::getPluralNumber()). " | |
| ".$data['name']." | "; echo "".$data['count']." |
| "; } echo " | ".__('Device 1')." | "; echo "".__('Device 2')." | "; echo "|||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| $extra | "; } echo ""._n('Device type', 'Device types', 1)." | "; echo "".__('Device name')." | "; echo "".__('Port Number')." | "; echo "".NetworkPort::getTypeName(1)." | "; echo "".__('MAC address')." | "; echo "".IPAddress::getTypeName(0)." | "; echo "".NetworkPort::getTypeName(1)." | "; echo "".__('MAC address')." | "; echo "".IPAddress::getTypeName(0)." | "; echo ""._n('Device type', 'Device types', 1)." | "; echo "".__('Device name')." | "; echo "||||
| ".(empty($line['extra']) ? NOT_AVAILABLE : $line['extra'])." | "; } $itemtype = $line["itemtype_$idx"]; if (!empty($itemtype)) { echo "".$itemtype::getTypeName(1)." | "; $item_name = ''; if ($item = getItemForItemtype($itemtype)) { if ($item->getFromDB($line["items_id_$idx"])) { $item_name = $item->getName(); } } echo "".(empty($item_name) ? NOT_AVAILABLE : $item_name)." | "; } else { echo "".NOT_AVAILABLE." | "; echo "".NOT_AVAILABLE." | "; } echo "".(empty($line["logical_$idx"]) ? NOT_AVAILABLE : $line["logical_$idx"])." | "; echo "".(empty($line["port_$idx"]) ? NOT_AVAILABLE : $line["port_$idx"])." | "; echo "".(empty($line["mac_$idx"]) ? NOT_AVAILABLE : $line["mac_$idx"])." | "; echo "".(empty($line["ip_$idx"]) ? NOT_AVAILABLE : $line["ip_$idx"])." | "; if ($idx == 1) { $idx = 2; } else { $idx = 1; } echo "".(empty($line["port_$idx"]) ? NOT_AVAILABLE : $line["port_$idx"])." | "; echo "".(empty($line["mac_$idx"]) ? NOT_AVAILABLE : $line["mac_$idx"])." | "; echo "".(empty($line["ip_$idx"]) ? NOT_AVAILABLE : $line["ip_$idx"])." | "; $itemtype = $line["itemtype_$idx"]; if (!empty($itemtype)) { echo "".$itemtype::getTypeName(1)." | "; $item_name = ''; if ($item = getItemForItemtype($itemtype)) { if ($item->getFromDB($line["items_id_$idx"])) { $item_name = $item->getName(); } } echo "".(empty($item_name) ? NOT_AVAILABLE : $item_name)." | "; } else { echo "".NOT_AVAILABLE." | "; echo "".NOT_AVAILABLE." | "; } echo "