-------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkCentralAccess(); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); try { $ma = new MassiveAction($_POST, $_GET, 'process'); } catch (Exception $e) { Html::popHeader(__('Bulk modification error'), $_SERVER['PHP_SELF']); 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>"; Html::displayBackLink(); echo "</div>"; Html::popFooter(); exit; } Html::popHeader(__('Bulk modification'), $_SERVER['PHP_SELF']); $results = $ma->process(); $nbok = $results['ok']; $nbko = $results['ko']; $nbnoright = $results['noright']; if ($nbok == 0) { $message = __('Failed operation'); } else { if ($nbnoright || $nbko) { $message = __('Operation performed partially successful'); } else {
/** * Show reservation calendar * * @param $ID ID of the reservation item (if empty display all) (default '') **/ static function showCalendar($ID = "") { global $CFG_GLPI; if (!Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) { return false; } if (!isset($_GET["mois_courant"])) { $mois_courant = intval(strftime("%m")); } else { $mois_courant = $_GET["mois_courant"]; } if (!isset($_GET["annee_courante"])) { $annee_courante = strftime("%Y"); } else { $annee_courante = $_GET["annee_courante"]; } $mois_courant = intval($mois_courant); $mois_suivant = $mois_courant + 1; $mois_precedent = $mois_courant - 1; $annee_suivante = $annee_courante; $annee_precedente = $annee_courante; if ($mois_precedent == 0) { $mois_precedent = 12; $annee_precedente--; } if ($mois_suivant == 13) { $mois_suivant = 1; $annee_suivante++; } $monthsarray = Toolbox::getMonthsOfYearArray(); $str_suivant = "?reservationitems_id={$ID}&mois_courant={$mois_suivant}&" . "annee_courante={$annee_suivante}"; $str_precedent = "?reservationitems_id={$ID}&mois_courant={$mois_precedent}&" . "annee_courante={$annee_precedente}"; if (!empty($ID)) { $m = new ReservationItem(); $m->getFromDB($ID); if (!isset($m->fields['is_active']) || !$m->fields['is_active']) { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'>"; echo "<td class='center b'>" . __('Device temporarily unavailable') . "</td></tr>"; echo "<tr class='tab_bg_1'><td class='center b'>"; Html::displayBackLink(); echo "</td></tr>"; echo "</table>"; echo "</div>"; return false; } $type = $m->fields["itemtype"]; $name = NOT_AVAILABLE; if ($item = getItemForItemtype($m->fields["itemtype"])) { $type = $item->getTypeName(); if ($item->getFromDB($m->fields["items_id"])) { $name = $item->getName(); } $name = sprintf(__('%1$s - %2$s'), $type, $name); } $all = "<a class='vsubmit' href='reservation.php?reservationitems_id=&mois_courant=" . "{$mois_courant}&annee_courante={$annee_courante}'>" . __('Show all') . "</a>"; } else { $type = ""; $name = __('All reservable devices'); $all = " "; } echo "<div class='center'><table class='tab_glpi'><tr><td>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation.png' alt='' title=''></td>"; echo "<td class ='b'>" . $name . "</td></tr>"; echo "<tr><td colspan='2' class ='center'>{$all}</td></tr></table></div><br>\n"; // Check bisextile years if ($annee_courante % 4 == 0) { $fev = 29; } else { $fev = 28; } $nb_jour = array(31, $fev, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // Datas used to put right information in columns $jour_debut_mois = strftime("%w", mktime(0, 0, 0, $mois_courant, 1, $annee_courante)); if ($jour_debut_mois == 0) { $jour_debut_mois = 7; } $jour_fin_mois = strftime("%w", mktime(0, 0, 0, $mois_courant, $nb_jour[$mois_courant - 1], $annee_courante)); echo "<div class='center'>"; echo "<table class='tab_glpi'><tr><td><a href='reservation.php" . $str_precedent . "'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\"></a></td>"; echo "<td class='b'>" . sprintf(__('%1$s %2$s'), $monthsarray[$mois_courant], $annee_courante) . "</td>"; echo "<td><a href='reservation.php" . $str_suivant . "'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\"></a></td></tr></table>\n"; // test echo "<table width='90%' class='tab_glpi'><tr><td class='top' width='100px'>"; echo "<table><tr><td width='100px' class='top'>"; // today date $today = getdate(time()); $mois = $today["mon"]; $annee = $today["year"]; $annee_avant = $annee_courante - 1; $annee_apres = $annee_courante + 1; echo "<div class='calendrier_mois'>"; echo "<div class='center b'>{$annee_avant}</div>"; for ($i = $mois_courant; $i < 13; $i++) { echo "<div class='calendrier_case2'>"; echo "<a href='reservation.php?reservationitems_id={$ID}&mois_courant={$i}&" . "annee_courante={$annee_avant}'>" . $monthsarray[$i] . "</a></div>"; } echo "<div class='center b'>{$annee_courante}</div>"; for ($i = 1; $i < 13; $i++) { if ($i == $mois_courant) { echo "<div class='calendrier_case1 b'>" . $monthsarray[$i] . "</div>\n"; } else { echo "<div class='calendrier_case2'>"; echo "<a href='reservation.php?reservationitems_id={$ID}&mois_courant={$i}&" . "annee_courante={$annee_courante}'>" . $monthsarray[$i] . "</a></div>\n"; } } echo "<div class='center b'>{$annee_apres}</div>\n"; for ($i = 1; $i < $mois_courant + 1; $i++) { echo "<div class='calendrier_case2'>"; echo "<a href='reservation.php?reservationitems_id={$ID}&mois_courant={$i}&" . "annee_courante={$annee_apres}'>" . $monthsarray[$i] . "</a></div>\n"; } echo "</div>"; echo "</td></tr></table>"; echo "</td><td class='top' width='100%'>"; // test echo "<table width='100%' class='tab_cadre'><tr>"; echo "<th width='14%'>" . __('Monday') . "</th>"; echo "<th width='14%'>" . __('Tuesday') . "</th>"; echo "<th width='14%'>" . __('Wednesday') . "</th>"; echo "<th width='14%'>" . __('Thursday') . "</th>"; echo "<th width='14%'>" . __('Friday') . "</th>"; echo "<th width='14%'>" . __('Saturday') . "</th>"; echo "<th width='14%'>" . __('Sunday') . "</th>"; echo "</tr>\n"; echo "<tr class='tab_bg_3' >"; // Insert blank cell before the first day of the month for ($i = 1; $i < $jour_debut_mois; $i++) { echo "<td class='calendrier_case_white'> </td>"; } // voici le remplissage proprement dit if ($mois_courant < 10 && strlen($mois_courant) == 1) { $mois_courant = "0" . $mois_courant; } for ($i = 1; $i < $nb_jour[$mois_courant - 1] + 1; $i++) { if ($i < 10) { $ii = "0" . $i; } else { $ii = $i; } echo "<td class='top' height='100px'>"; echo "<table class='center' width='100%'><tr><td class='center'>"; echo "<span class='calendrier_jour'>" . $i . "</span></td></tr>\n"; if (!empty($ID)) { echo "<tr><td class='center'>"; echo "<a href='reservation.form.php?id=&item[{$ID}]={$ID}&" . "begin=" . $annee_courante . "-" . $mois_courant . "-" . $ii . " 12:00:00'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/addresa.png' alt=\"" . __s('Reserve') . "\" title=\"" . __s('Reserve') . "\"></a></td></tr>\n"; } echo "<tr><td>"; self::displayReservationDay($ID, $annee_courante . "-" . $mois_courant . "-" . $ii); echo "</td></tr></table>\n"; echo "</td>"; // il ne faut pas oublie d'aller a la ligne suivante en fin de semaine if (($i + $jour_debut_mois) % 7 == 1) { echo "</tr>\n"; if ($i != $nb_jour[$mois_courant - 1]) { echo "<tr class='tab_bg_3'>"; } } } // on recommence pour finir le tableau proprement pour les m�es raisons if ($jour_fin_mois != 0) { for ($i = 0; $i < 7 - $jour_fin_mois; $i++) { echo "<td class='calendrier_case_white'> </td>"; } } echo "</tr></table>\n"; echo "</td></tr></table></div>\n"; }
/** * Displays a list of computers that can be cleaned. * * @param $plugin_ocsinventoryng_ocsservers_id int : id of ocs server in GLPI * @param $check string : parameter for HTML input checkbox * @param $start int : parameter for Html::printPager method * * @return nothing **/ static function showComputersToClean($plugin_ocsinventoryng_ocsservers_id, $check, $start) { global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI; self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id); if (!plugin_ocsinventoryng_haveRight("clean_ocsng", "r")) { return false; } $canedit = plugin_ocsinventoryng_haveRight("clean_ocsng", "w"); // Select unexisting OCS hardware $query_ocs = "SELECT*\n FROM `hardware`"; $result_ocs = $PluginOcsinventoryngDBocs->query($query_ocs); $hardware = array(); if ($PluginOcsinventoryngDBocs->numrows($result_ocs) > 0) { while ($data = $PluginOcsinventoryngDBocs->fetch_array($result_ocs)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); $hardware[$data["ID"]] = $data["DEVICEID"]; } } $query = "SELECT `ocsid`\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `plugin_ocsinventoryng_ocsservers_id`\n = '{$plugin_ocsinventoryng_ocsservers_id}'"; $result = $DB->query($query); $ocs_missing = array(); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_array($result)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); if (!isset($hardware[$data["ocsid"]])) { $ocs_missing[$data["ocsid"]] = $data["ocsid"]; } } } $sql_ocs_missing = ""; if (count($ocs_missing)) { $sql_ocs_missing = " OR `ocsid` IN ('" . implode("','", $ocs_missing) . "')"; } //Select unexisting computers $query_glpi = "SELECT `glpi_plugin_ocsinventoryng_ocslinks`.`entities_id` AS entities_id,\n `glpi_plugin_ocsinventoryng_ocslinks`.`ocs_deviceid` AS ocs_deviceid,\n `glpi_plugin_ocsinventoryng_ocslinks`.`last_update` AS last_update,\n `glpi_plugin_ocsinventoryng_ocslinks`.`ocsid` AS ocsid,\n `glpi_plugin_ocsinventoryng_ocslinks`.`id`,\n `glpi_computers`.`name` AS name\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n LEFT JOIN `glpi_computers`\n ON `glpi_computers`.`id` = `glpi_plugin_ocsinventoryng_ocslinks`.`computers_id`\n WHERE ((`glpi_computers`.`id` IS NULL\n AND `glpi_plugin_ocsinventoryng_ocslinks`.`plugin_ocsinventoryng_ocsservers_id`\n = '{$plugin_ocsinventoryng_ocsservers_id}')" . $sql_ocs_missing . ")" . getEntitiesRestrictRequest(" AND", "glpi_plugin_ocsinventoryng_ocslinks"); $result_glpi = $DB->query($query_glpi); // fetch all links missing between glpi and OCS $already_linked = array(); if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_assoc($result_glpi)) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); $already_linked[$data["ocsid"]]["entities_id"] = $data["entities_id"]; if (Toolbox::strlen($data["ocs_deviceid"]) > 20) { // Strip datetime tag $already_linked[$data["ocsid"]]["ocs_deviceid"] = substr($data["ocs_deviceid"], 0, -20); } else { $already_linked[$data["ocsid"]]["ocs_deviceid"] = $data["ocs_deviceid"]; } $already_linked[$data["ocsid"]]["date"] = $data["last_update"]; $already_linked[$data["ocsid"]]["id"] = $data["id"]; $already_linked[$data["ocsid"]]["in_ocs"] = isset($hardware[$data["ocsid"]]); if ($data["name"] == null) { $already_linked[$data["ocsid"]]["in_glpi"] = 0; } else { $already_linked[$data["ocsid"]]["in_glpi"] = 1; } } } echo "<div class='center'>"; echo "<h2>" . __('Clean links between GLPI and OCSNG', 'ocsinventoryng') . "</h2>"; $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.clean.php'; if (($numrows = count($already_linked)) > 0) { $parameters = "check={$check}"; Html::printPager($start, $numrows, $target, $parameters); // delete end array_splice($already_linked, $start + $_SESSION['glpilist_limit']); // delete begin if ($start > 0) { array_splice($already_linked, 0, $start); } echo "<form method='post' id='ocsng_form' name='ocsng_form' action='" . $target . "'>"; if ($canedit) { self::checkBox($target); } echo "<table class='tab_cadre'>"; echo "<tr><th>" . __('Item') . "</th><th>" . __('Import date in GLPI', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Existing in GLPI', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Existing in OCSNG', 'ocsinventoryng') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } if ($canedit) { echo "<th> </th>"; } echo "</tr>\n"; echo "<tr class='tab_bg_1'><td colspan='6' class='center'>"; if ($canedit) { echo "<input class='submit' type='submit' name='clean_ok' value=\"" . _sx('button', 'Clean') . "\">"; } echo "</td></tr>\n"; foreach ($already_linked as $ID => $tab) { echo "<tr class='tab_bg_2 center'>"; echo "<td>" . $tab["ocs_deviceid"] . "</td>\n"; echo "<td>" . Html::convDateTime($tab["date"]) . "</td>\n"; echo "<td>" . Dropdown::getYesNo($tab["in_glpi"]) . "</td>\n"; echo "<td>" . Dropdown::getYesNo($tab["in_ocs"]) . "</td>\n"; if (Session::isMultiEntitiesMode()) { echo "<td>" . Dropdown::getDropdownName('glpi_entities', $tab['entities_id']) . "</td>\n"; } if ($canedit) { echo "<td><input type='checkbox' name='toclean[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . "></td>"; } echo "</tr>\n"; } echo "<tr class='tab_bg_1'><td colspan='6' class='center'>"; if ($canedit) { echo "<input class='submit' type='submit' name='clean_ok' value=\"" . _sx('button', 'Clean') . "\">"; } echo "</td></tr>"; echo "</table>\n"; Html::closeForm(); Html::printPager($start, $numrows, $target, $parameters); } else { echo "<div class='center b '>" . __('No item to clean', 'ocsinventoryng') . "</div>"; Html::displayBackLink(); } echo "</div>"; }
/** * @static function showMap : affiche tous les éléments de la carte (menus, onglets...) * @param $options */ static function showMap($options) { global $CFG_GLPI; if (!$options['locations_id']) { $self = new self(); $self->getFromDB($options["id"]); if (isset($self->fields["itemtype"])) { $options['locations_id'] = $self->fields['locations_id']; } } if ($options['locations_id']) { $documents_id = self::getDocument($options['locations_id']); $Doc = new Document(); if (isset($documents_id) && $Doc->getFromDB($documents_id)) { $params = array("locations_id" => $options['locations_id'], "id" => $options['id'], "itemtype" => $options['itemtype'], "target" => $options['target']); $params['docid'] = $documents_id; $path = GLPI_DOC_DIR . "/" . $Doc->fields["filepath"]; if ($handle = fopen($path, "r")) { $infos_image = @getImageSize($path); $params["largeur"] = $infos_image[0]; $params["hauteur"] = $infos_image[1]; $params["download"] = 1; if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { $params["download"] = 0; } echo "<div class='center'><table class='plugin_positions_tab_cadre_fixe'>"; echo "<tr class='tab_bg_2' valign='top'>"; $items = self::getMapItems($params['locations_id']); if (!isset($options['menuoff'])) { echo "<td>"; self::showLocationForm($params["locations_id"], "100%"); echo "</td>"; } if (Session::haveRight('plugin_positions', UPDATE) && !isset($options['menuoff'])) { echo "<td>"; self::showAddFromPlugin($params['locations_id']); echo "</td>"; echo "<td>"; self::selectDisplay($params, $items); echo "</td>"; } echo "</tr>"; echo "</table></div>"; if (isset($options['menuoff'])) { $params["menuoff"] = $options['menuoff']; } if (Session::haveRight('plugin_positions', UPDATE) && !isset($options['menuoff'])) { echo "<form method='post' name='pointform' id='pointform' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/positions/front/position.form.php\">"; echo "<div class='center'>"; echo "<table class='plugin_positions_tab_cadre_fixe' width='30%'>"; if ($options['id']) { echo "<tr class='tab_bg_2'>"; $form = Toolbox::getItemTypeFormURL($self->getType()); echo "<td colspan='4' class='center'>" . $self->getLink(); echo "</td></tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td colspan='2' class='center'>"; echo "<input type='submit' name='update' value=\"" . __s('Change the coordinates', 'positions') . "\" class='submit'>"; echo "</td>"; //création d'un nouveau bouton pour la création de nouvelles pièces echo "<td colspan='2' class='center'>"; echo "<input type='submit' name='addLocation' value=\"" . __s('Add a sub-area', 'positions') . "\" class='submit'>"; echo "</td>"; echo "<input type='hidden' name='locations_id' value='" . $options['locations_id'] . "'>"; echo "<input type='hidden' name='id' value='" . $options['id'] . "'>"; echo "<input type='hidden' name ='x_coordinates'>"; echo "<input type='hidden' name ='y_coordinates'>"; echo "<input type='hidden' name ='multi'>"; echo "<input type='hidden' name ='referrer' value='" . $options['id'] . "'>"; echo "</tr>"; echo "</table></div>"; } echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>"; echo $Doc->fields["name"]; echo "</th></tr>"; echo "<tr class='tab_bg_1'><td>"; self::displayMap($items, $params); echo "</td></tr>"; echo "</table>"; if (Session::haveRight('plugin_positions', UPDATE) && !isset($options['menuoff'])) { Html::closeForm(); } } else { echo "<div class='center'>"; _e('No location has a configured map', 'positions'); echo "</div>"; } } else { echo "<div class='center'>"; echo __('The object location does not match a map', 'positions') . "<br><br>"; Html::displayBackLink(); echo "</div>"; } } else { echo "<div class='center'>"; _e('No location selected', 'positions'); echo "</div>"; } }
/** * Launch export of datas * * @param $opt */ function export($opt) { global $LANG; switch ($opt['switchto']) { default: case 'png': $graph = new PluginMreportingGraphpng(); //check the format display charts configured in glpi $opt = $this->initParams($opt, true); $opt['export'] = 'png'; $opt['withdata'] = 1; break; case 'csv': $graph = new PluginMreportingGraphcsv(); $opt['export'] = 'csv'; $opt['withdata'] = 1; break; case 'odt': $graph = new PluginMreportingGraphpng(); $opt = $this->initParams($opt, true); $opt['export'] = 'odt'; break; case 'odtall': $graph = new PluginMreportingGraphpng(); $opt = $this->initParams($opt, true); $opt['export'] = 'odtall'; break; } //export all with odt if (isset($opt['classname'])) { if (isset($opt['check'])) { unset($_SESSION['glpi_plugin_mreporting_odtarray']); $reports = $this->getAllReports(false, $opt); foreach ($reports as $classname => $report) { foreach ($report['functions'] as $func) { foreach ($opt['check'] as $do => $to) { if ($do == $func['function'] . $classname) { //dynamic instanciation of class passed by 'short_classname' GET parameter $class = 'PluginMreporting' . $func['short_classname']; $obj = new $class(); $randname = $classname . $func['function']; if (isset($opt['date1']) && isset($opt['date2'])) { $s = strtotime($opt['date2']) - strtotime($opt['date1']); // If customExportDates exists in class : we configure the dates if (method_exists($obj, 'customExportDates')) { $opt = $obj->customExportDates($opt, $func['function']); } $_REQUEST['date1' . $randname] = $opt['date1']; $_REQUEST['date2' . $randname] = $opt['date2']; } //dynamic call of method passed by 'f_name' //GET parameter with previously instancied class $datas = $obj->{$func}['function'](); //show graph (pgrah type determined by //first entry of explode of camelcase of function name $title_func = $LANG['plugin_mreporting'][$func['short_classname']][$func['function']]['title']; $des_func = ""; if (isset($LANG['plugin_mreporting'][$func['short_classname']][$func['function']]['desc'])) { $des_func = $LANG['plugin_mreporting'][$func['short_classname']][$func['function']]['desc']; } if (isset($LANG['plugin_mreporting'][$func['short_classname']][$func['function']]['desc']) && isset($opt['date1']) && isset($opt['date2'])) { $des_func .= " - "; } if (isset($opt['date1']) && isset($opt['date2'])) { $des_func .= Html::convdate($opt['date1']) . " / " . Html::convdate($opt['date2']); } $options = array("short_classname" => $func['short_classname'], "f_name" => $func['function'], "class" => $opt['classname'], "gtype" => $func['gtype'], "randname" => $randname, "withdata" => $opt['withdata']); $show_label = 'always'; $params = array("raw_datas" => $datas, "title" => $title_func, "desc" => $des_func, "export" => $opt['export'], "opt" => $options); $graph->{'show' . $func['gtype']}($params); } } } } if (isset($_SESSION['glpi_plugin_mreporting_odtarray']) && !empty($_SESSION['glpi_plugin_mreporting_odtarray'])) { if (PluginMreportingPreference::atLeastOneTemplateExists()) { $template = PluginMreportingPreference::checkPreferenceTemplateValue(Session::getLoginUserID()); if ($template) { self::generateOdt($_SESSION['glpi_plugin_mreporting_odtarray']); } else { Html::popHeader($LANG['plugin_mreporting']["export"][0], $_SERVER['PHP_SELF']); echo "<div class='center'><br>" . $LANG['plugin_mreporting']["parser"][2] . "<br><br>"; Html::displayBackLink(); echo "</div>"; Html::popFooter(); } } else { Html::popHeader($LANG['plugin_mreporting']["export"][0], $_SERVER['PHP_SELF']); echo "<div class='center'><br>" . $LANG['plugin_mreporting']["parser"][3] . "<br><br>"; Html::displayBackLink(); echo "</div>"; Html::popFooter(); } } } else { //no selected data Html::popHeader($LANG['plugin_mreporting']["export"][0], $_SERVER['PHP_SELF']); echo "<div class='center'><br>" . $LANG['plugin_mreporting']["error"][3] . "<br><br>"; Html::displayBackLink(); echo "</div>"; Html::popFooter(); } } else { //dynamic instanciation of class passed by 'short_classname' GET parameter $classname = 'PluginMreporting' . $opt['short_classname']; $obj = new $classname(); //dynamic call of method passed by 'f_name' GET parameter with previously instancied class $datas = $obj->{$opt}['f_name'](); //show graph (pgrah type determined by first entry of explode of camelcase of function name $title_func = $LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['title']; $des_func = ""; if (isset($LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['desc'])) { $des_func = $LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['desc']; } if (isset($LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['desc']) && isset($_REQUEST['date1' . $opt['randname']]) && isset($_REQUEST['date2' . $opt['randname']])) { $des_func .= " - "; } if (isset($_REQUEST['date1' . $opt['randname']]) && isset($_REQUEST['date2' . $opt['randname']])) { $des_func .= Html::convdate($_REQUEST['date1' . $opt['randname']]) . " / " . Html::convdate($_REQUEST['date2' . $opt['randname']]); } $show_label = 'always'; $opt['class'] = $classname; $params = array("raw_datas" => $datas, "title" => $title_func, "desc" => $des_func, "export" => $opt['export'], "opt" => $opt); $graph->{'show' . $opt['gtype']}($params); } }
/** * show hardware to be identified, or identified and imported, or just the hardware with agents installed on them * @param type $hardware array * @param type $lim integer * @param int|type $start integer * @param type $ipAdress string * @param type $status string * @param $subnet * @param $action * @global type $CFG_GLPI */ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $subnet, $action) { global $CFG_GLPI, $DB; $output_type = Search::HTML_OUTPUT; //0 $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php"; $return = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $returnargs = "subnetsChoice={$subnet}&action={$action}"; $reload = "ip={$ipAdress}&status={$status}&action={$action}"; $backValues = "?b[]={$ipAdress}&b[]={$status}"; if ($status == "inventoried") { $status_name = __('Inventoried', 'ocsinventoryng'); } elseif ($status == "imported") { $status_name = __('Imported / Linked', 'ocsinventoryng'); } elseif ($status == "noninventoried") { $status_name = __('Non Inventoried', 'ocsinventoryng'); } else { $status_name = __('Identified', 'ocsinventoryng'); } $subnet_name = self::getSubnetNamebyIP($ipAdress); echo "<div class='center'>"; echo "<h2>" . __('Subnet', 'ocsinventoryng') . " " . $subnet_name . " (" . $ipAdress . ") - " . $status_name; echo " "; $refresh = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php?" . $reload; Html::showSimpleForm($refresh, 'refresh', _sx('button', 'Refresh'), array(), $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/pics/synchro.png"); echo "</h2>"; echo "</div>"; if ($subnet >= 0) { $back = __('Back'); echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>"; } echo Html::printPager($start, count($hardware), $link, $reload); echo Search::showNewLine($output_type, true); if (empty($hardware)) { echo "<div class='center b'><br>" . __('No new IPDiscover device to import', 'ocsinventoryng') . "</div>"; Html::displayBackLink(); } else { $header_num = 1; switch ($status) { case "inventoried": echo "<table width='100%'class='tab_cadrehov'>\n"; echo Search::showHeaderItem($output_type, __('User'), $header_num); echo Search::showHeaderItem($output_type, __('Name'), $header_num); echo Search::showHeaderItem($output_type, __('System'), $header_num); echo Search::showHeaderItem($output_type, __('Version of the operating system'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Last OCSNG inventory date', 'ocsinventoryng'), $header_num); echo Search::showEndLine($output_type); $row_num = 1; for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type, $row_num % 2); echo Search::showItem($output_type, $hardware[$i]["userid"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["name"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["osname"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["osversion"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["ipaddr"], $item_num, $row_num); echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["lastdate"]), $item_num, $row_num); echo Search::showEndLine($output_type); } } echo "</table>\n"; break; case "imported": $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; self::checkBox($target); echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>"; echo "<div class='center' style=\"width=100%\">"; echo "<input type='submit' class='submit' name='deletelink' value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>"; echo "<table width='100%'class='tab_cadrehov'>\n"; echo Search::showHeaderItem($output_type, __('Item'), $header_num); echo Search::showHeaderItem($output_type, __('Item type'), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Location'), $header_num); echo Search::showHeaderItem($output_type, __('Import date in GLPI', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('Subnet'), $header_num); echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type, $row_num % 2); $class = getItemForItemtype($hardware[$i]["itemtype"]); $class->getFromDB($hardware[$i]["items_id"]); $iplist = ""; $ip = new IPAddress(); // Update IPAddress foreach ($DB->request('glpi_networkports', array('itemtype' => $hardware[$i]["itemtype"], 'items_id' => $hardware[$i]["items_id"])) as $netname) { foreach ($DB->request('glpi_networknames', array('itemtype' => 'NetworkPort', 'items_id' => $netname['id'])) as $dataname) { foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', 'items_id' => $dataname['id'])) as $data) { $ip->getFromDB($data['id']); $iplist .= $ip->getName() . "<br>"; } } } echo Search::showItem($output_type, $class->getLink(), $item_num, $row_num); echo Search::showItem($output_type, $class->getTypeName(), $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["macaddress"], $item_num, $row_num); echo Search::showItem($output_type, $iplist, $item_num, $row_num); echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $class->fields["locations_id"]), $item_num, $row_num); echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["last_update"]), $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["subnet"], $item_num, $row_num); echo self::showItem($hardware[$i]["id"], "", "", "", true, "", $i); echo Search::showEndLine($output_type); } } echo "<tbody style=\"display:none\">"; echo "<tr><td><input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>"; echo "</tbody>"; echo "</table>\n"; echo "<div class='center' style=\"width=100%\">"; echo "<input type='submit' class='submit' name='deletelink' value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>"; Html::closeForm(); self::checkBox($target); break; case "noninventoried": $ocsTypes = array("id" => array(Dropdown::EMPTY_VALUE), "name" => array(Dropdown::EMPTY_VALUE)); $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; $macConstructor = ""; self::getOCSTypes($ocsTypes); self::checkBox($target); echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='IdentifyAndImport' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='IdentifyAndLink' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; echo "<table width='100%'class='tab_cadrehov'>\n"; echo Search::showHeaderItem($output_type, __('Date'), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Subnet mask'), $header_num); echo Search::showHeaderItem($output_type, __('DNS', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('Description') . "<span class='red'>*</span>", $header_num); echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num); if ($action == "import") { echo Search::showHeaderItem($output_type, __('Name'), $header_num); if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num); } else { echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%'); } echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; $ocstypes = array(); foreach ($ocsTypes["name"] as $items) { $ocstypes[$items] = $items; } $itemstypes = array(Dropdown::EMPTY_VALUE); foreach (self::$hardwareItemTypes as $items) { $class = getItemForItemtype($items); $itemstypes[$items] = $class->getTypeName(); } for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; echo Search::showNewLine($output_type, $row_num % 2); echo self::showItem(Html::convDateTime($hardware[$i]["date"])); if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) { $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]); if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) { $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))]; } else { $macConstructor = __("unknow"); } } $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>"; echo self::showItem($mac); echo self::showItem($ip = $hardware[$i]["ip"]); echo self::showItem($hardware[$i]["mask"]); echo self::showItem($hardware[$i]["DNS"]); echo "<td><input type=\"text\" name='itemsdescription[" . $i . "]' value=\"\" ></td>"; echo "<td>"; Dropdown::showFromArray("ocsitemstype[{$i}]", $ocstypes); echo "</td>"; if ($action == "import") { echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>"; if (Session::isMultiEntitiesMode()) { echo "<td>"; Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"])); echo "</td>"; } echo "<td>"; Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes); echo "</td>"; } else { echo "<td width='10'>"; $mtrand = mt_rand(); $mynamei = "itemtype"; $myname = "tolink_items[" . $i . "]"; $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand)); $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname); //print_r($p); Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "<span id='results_{$mynamei}{$rand}'>\n"; echo "</span>\n"; //} echo "</td>"; } echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i); echo "<tbody style=\"display:none\">"; echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >\n <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>"; echo "</tbody>"; } } echo "</table>\n"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='IdentifyAndImport' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='IdentifyAndLink' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; Html::closeForm(); self::checkBox($target); break; default: $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; $macConstructor = ""; self::checkBox($target); echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='Import' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='Link' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; echo "<table width='100%'class='tab_cadrehov'>"; echo Search::showHeaderItem($output_type, __('Date'), $header_num); echo Search::showHeaderItem($output_type, __('Description'), $header_num); echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); if ($action == "import") { if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('Name'), $header_num); echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num); } else { echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%'); } echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; $itemstypes = array(Dropdown::EMPTY_VALUE); foreach (self::$hardwareItemTypes as $items) { $class = getItemForItemtype($items); $itemstypes[$items] = $class->getTypeName(); } for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; echo Search::showNewLine($output_type, $row_num % 2); echo self::showItem(Html::convDateTime($hardware[$i]["date"])); echo self::showItem($description = $hardware[$i]["description"]); echo self::showItem($hardware[$i]["type"]); echo self::showItem($ip = $hardware[$i]["ip"]); if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) { $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]); if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) { $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))]; } else { $macConstructor = __("unknow"); } } $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>"; echo self::showItem($mac); if ($action == "import") { if (Session::isMultiEntitiesMode()) { echo "<td>"; Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"])); echo "</td>"; } echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>"; echo "<td>"; Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes); echo "</td>"; } else { echo "<td width='10'>"; $mtrand = mt_rand(); $mynamei = "itemtype"; $myname = "tolink_items[" . $i . "]"; $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand)); $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname); Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "<span id='results_{$mynamei}{$rand}'>\n"; echo "</span>\n"; echo "</td>"; } echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i); echo "<tbody style=\"display:none\">"; echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >"; echo "<input type=\"hidden\" name='itemsdescription[" . $i . "]' value=\"{$description}\" >\n <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></tr>"; echo "</td></tr></tbody>"; } } echo "</table>"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='Import' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='Link' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; Html::closeForm(); self::checkBox($target); break; } } if ($subnet >= 0) { $back = __('Back'); echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>"; } }