function displayValues($services_id, $period, $tooltip = 0)
 {
     $a_times = $this->parseEvents($services_id, $period);
     $displaytime = '';
     if ($a_times[0] > 0) {
         echo "<td style='background-color: rgb(255, 120, 0);-moz-border-radius: 4px;-webkit-border-radius: 4px;-o-border-radius: 4px;padding: 2px;' align='center'>";
         if ($tooltip == '1') {
             $displaytime = '&nbsp;' . showToolTip(timestampToString($a_times[0]), array('display' => false));
         } else {
             $displaytime = '<br/>' . timestampToString($a_times[0]);
         }
     } else {
         echo "<td align='center'>";
     }
     echo round(($a_times[1] - $a_times[0]) / $a_times[1] * 100, 3) . "%" . $displaytime;
     echo "</td>";
 }
 /**
  * Get comments of the Object
  *
  * @return String: comments of the object in the current language (HTML)
  **/
 function getComments()
 {
     global $LANG, $CFG_GLPI;
     $comment = "";
     if ($this->isField('serial')) {
         $comment .= "<strong>" . $LANG['common'][19] . "&nbsp;: </strong>" . $this->getField('serial') . "<br>";
     }
     if ($this->isField('otherserial')) {
         $comment .= "<strong>" . $LANG['common'][20] . "&nbsp;: </strong>" . $this->getField('otherserial') . "<br>";
     }
     if ($this->isField('locations_id')) {
         $tmp = Dropdown::getDropdownName("glpi_locations", $this->getField('locations_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $comment .= "<strong>" . $LANG['common'][15] . "&nbsp;: " . "</strong>" . $tmp . "<br>";
         }
     }
     if ($this->isField('users_id')) {
         $tmp = getUserName($this->getField('users_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $comment .= "<strong>" . $LANG['common'][34] . "&nbsp;: " . "</strong>" . $tmp . "<br>";
         }
     }
     if ($this->isField('groups_id')) {
         $tmp = Dropdown::getDropdownName("glpi_groups", $this->getField('groups_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $comment .= "<strong>" . $LANG['common'][35] . "&nbsp;: " . "</strong>" . $tmp . "<br>";
         }
     }
     if ($this->isField('users_id_tech')) {
         $tmp = getUserName($this->getField('users_id_tech'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $comment .= "<strong>" . $LANG['common'][10] . "&nbsp;: " . "</strong>" . $tmp . "<br>";
         }
     }
     if ($this->isField('contact')) {
         $comment .= "<strong>" . $LANG['common'][18] . "&nbsp;: </strong>" . $this->getField('contact') . "<br>";
     }
     if ($this->isField('contact_num')) {
         $comment .= "<strong>" . $LANG['common'][21] . "&nbsp;: </strong>" . $this->getField('contact_num') . "<br>";
     }
     if (!empty($comment)) {
         return showToolTip($comment, array('display' => false));
     }
     return $comment;
 }
 /**
  * Display a connection of a networking port
  *
  * @param $device1 the device of the port
  * @param $netport to be displayed
  * @param $withtemplate
  **/
 static function showConnection(&$device1, &$netport, $withtemplate = '')
 {
     global $CFG_GLPI, $LANG;
     if (!$device1->can($device1->fields["id"], 'r')) {
         return false;
     }
     $contact = new NetworkPort_NetworkPort();
     $canedit = $device1->can($device1->fields["id"], 'w');
     $ID = $netport->fields["id"];
     if ($contact_id = $contact->getOppositeContact($ID)) {
         $netport->getFromDB($contact_id);
         if (class_exists($netport->fields["itemtype"])) {
             $device2 = new $netport->fields["itemtype"]();
             if ($device2->getFromDB($netport->fields["items_id"])) {
                 echo "\n<table width='100%'>\n";
                 echo "<tr " . ($device2->fields["is_deleted"] ? "class='tab_bg_2_2'" : "") . ">";
                 echo "<td><strong>";
                 if ($device2->can($device2->fields["id"], 'r')) {
                     echo $netport->getLink();
                     echo "</strong>\n";
                     showToolTip($netport->fields['comment']);
                     echo "&nbsp;" . $LANG['networking'][25] . " <strong>";
                     echo $device2->getLink();
                     echo "</strong>";
                     if ($device1->fields["entities_id"] != $device2->fields["entities_id"]) {
                         echo "<br>(" . Dropdown::getDropdownName("glpi_entities", $device2->getEntityID()) . ")";
                     }
                     // 'w' on dev1 + 'r' on dev2 OR 'r' on dev1 + 'w' on dev2
                     if ($canedit || $device2->can($device2->fields["id"], 'w')) {
                         echo "</td>\n<td class='right'><strong>";
                         if ($withtemplate != 2) {
                             echo "<a href=\"" . $netport->getFormURL() . "?disconnect=" . "disconnect&amp;id=" . $contact->fields['id'] . "\">" . $LANG['buttons'][10] . "</a>";
                         } else {
                             "&nbsp;";
                         }
                         echo "</strong>";
                     }
                 } else {
                     if (rtrim($netport->fields["name"]) != "") {
                         echo $netport->fields["name"];
                     } else {
                         echo $LANG['common'][0];
                     }
                     echo "</strong> " . $LANG['networking'][25] . " <strong>";
                     echo $device2->getName();
                     echo "</strong><br>(" . Dropdown::getDropdownName("glpi_entities", $device2->getEntityID()) . ")";
                 }
                 echo "</td></tr></table>\n";
             }
         }
     } else {
         echo "\n<table width='100%'><tr>";
         if ($canedit) {
             echo "<td class='left'>";
             if ($withtemplate != 2 && $withtemplate != 1) {
                 self::dropdownConnect($ID, array('name' => 'dport', 'entity' => $device1->fields["entities_id"], 'entity_sons' => $device1->isRecursive()));
             } else {
                 echo "&nbsp;";
             }
             echo "</td>\n";
         }
         echo "<td><div id='not_connected_display{$ID}'>" . $LANG['connect'][1] . "</div></td>";
         echo "</tr></table>\n";
     }
 }
 static function displayLine($data, $displayhost = 1)
 {
     global $DB, $CFG_GLPI, $LANG;
     $pMonitoringService = new PluginMonitoringService();
     $networkPort = new NetworkPort();
     $pMonitoringComponent = new PluginMonitoringComponent();
     $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
     $pmServicegraph = new PluginMonitoringServicegraph();
     $entity = new Entity();
     $pMonitoringService->getFromDB($data['id']);
     echo "<td width='32' class='center'>";
     $shortstate = self::getState($data['state'], $data['state_type']);
     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $shortstate . "_32.png'/>";
     echo "</td>";
     echo "<td>";
     $entity->getFromDB($data['entities_id']);
     echo $entity->fields['completename'];
     echo "</td>";
     $pMonitoringComponent->getFromDB($data['plugin_monitoring_components_id']);
     echo "<td class='center'>";
     $img = '';
     $timezone = '0';
     if (isset($_SESSION['plugin_monitoring_timezone'])) {
         $timezone = $_SESSION['plugin_monitoring_timezone'];
     }
     $timezone_file = str_replace("+", ".", $timezone);
     $img = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=PluginMonitoringService-" . $data['id'] . "-2h" . $timezone_file . ".png'/>";
     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $data['id'] . "'>";
     if (file_exists(GLPI_ROOT . "/files/_plugins/monitoring/PluginMonitoringService-" . $data['id'] . "-2h" . $timezone_file . ".png") or $pMonitoringComponent->fields['graph_template'] != '') {
         $img = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=PluginMonitoringService-" . $data['id'] . "-2h" . $timezone_file . ".png'/>";
         showToolTip($img, array('img' => $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/stats_32.png"));
     } else {
     }
     echo "</a>";
     echo "</td>";
     if ($displayhost == '1') {
         $pmComponentscatalog_Host->getFromDB($data["plugin_monitoring_componentscatalogs_hosts_id"]);
         if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') {
             $itemtype = $pmComponentscatalog_Host->fields['itemtype'];
             $item = new $itemtype();
             $item->getFromDB($pmComponentscatalog_Host->fields['items_id']);
             echo "<td>";
             echo $item->getTypeName() . " : " . $item->getLink();
             if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
                 $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
                 echo " [" . $networkPort->getLink() . "]";
             }
             echo "</td>";
         } else {
             echo "<td>" . $LANG['plugin_monitoring']['service'][0] . "</td>";
         }
     }
     echo "<td>" . $pMonitoringComponent->getLink();
     if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
         $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
         echo " [" . $networkPort->getLink() . "]";
     }
     echo "</td>";
     //      $nameitem = '';
     //      if (isset($itemmat->fields['name'])) {
     //         $nameitem = "[".$itemmat->getLink(1)."]";
     //      }
     //if ($pMonitoringService->fields['plugin_monitoring_services_id'] == '0') {
     //echo "<td>".$itemmat->getLink(1)."</td>";
     //      } else {
     //         $pMonitoringServiceH->getFromDB($pMonitoringService->fields['plugin_monitoring_services_id']);
     //         $itemtypemat = $pMonitoringServiceH->fields['itemtype'];
     //         $itemmat = new $itemtypemat();
     //         $itemmat->getFromDB($pMonitoringServiceH->fields['items_id']);
     //         echo "<td>".$pMonitoringService->getLink(1).$nameitem." ".$LANG['networking'][25]." ".$itemmat->getLink(1)."</td>";
     //      }
     //      unset($itemmat);
     echo "<td class='center'>";
     echo $data['state'];
     echo "</td>";
     echo "<td>";
     echo convDate($data['last_check']) . ' ' . substr($data['last_check'], 11, 8);
     echo "</td>";
     echo "<td>";
     echo $data['event'];
     echo "</td>";
     echo "<td align='center'>";
     $segments = CalendarSegment::getSegmentsBetween($pMonitoringComponent->fields['calendars_id'], date('w', date('U')), date('H:i:s'), date('w', date('U')), date('H:i:s'));
     if (count($segments) == '0') {
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_pause.png' />";
     } else {
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_run.png' />";
     }
     echo "</td>";
     if ($displayhost == '0') {
         $pmUnavaibility = new PluginMonitoringUnavaibility();
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentmonth', 1);
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'lastmonth', 1);
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentyear', 1);
         echo "<td>";
         $a_arg = importArrayFromDB($pMonitoringService->fields['arguments']);
         $cnt = '';
         if (count($a_arg) > 0) {
             $cnt = " (" . count($a_arg) . ")";
         }
         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/servicearg.form.php?id=" . $data['id'] . "'>" . $LANG['plugin_monitoring']['service'][25] . $cnt . "</a>";
         echo "</td>";
     }
 }
 /**
  * Print out an HTML "<select>" for a dropdown with preselected value
  *
  *
  * @param $myname the name of the HTML select
  * @param $value the preselected value we want
  * @param $locations_id default location ID for search
  * @param $display_comment display the comment near the dropdown
  * @param $entity_restrict Restrict to a defined entity
  * @param $devtype
  * @return nothing (display the select box)
  *
  */
 static function dropdownNetpoint($myname, $value = 0, $locations_id = -1, $display_comment = 1, $entity_restrict = -1, $devtype = -1)
 {
     global $CFG_GLPI, $LANG;
     $rand = mt_rand();
     $name = "------";
     $comment = "";
     $limit_length = $_SESSION["glpidropdown_chars_limit"];
     if (empty($value)) {
         $value = 0;
     }
     if ($value > 0) {
         $tmpname = Dropdown::getDropdownName("glpi_netpoints", $value, 1);
         if ($tmpname["name"] != "&nbsp;") {
             $name = $tmpname["name"];
             $comment = $tmpname["comment"];
             $limit_length = max(utf8_strlen($name), $_SESSION["glpidropdown_chars_limit"]);
         }
     }
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         if ($locations_id < 0 || $devtype == 'NetworkEquipment') {
             $nb = countElementsInTableForEntity("glpi_netpoints", $entity_restrict);
         } else {
             if ($locations_id > 0) {
                 $nb = countElementsInTable("glpi_netpoints", "locations_id={$locations_id} ");
             } else {
                 $nb = countElementsInTable("glpi_netpoints", "locations_id=0 " . getEntitiesRestrictRequest(" AND ", "glpi_netpoints", '', $entity_restrict));
             }
         }
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $params = array('searchText' => '__VALUE__', 'value' => $value, 'locations_id' => $locations_id, 'myname' => $myname, 'limit' => $limit_length, 'comment' => $display_comment, 'rand' => $rand, 'entity_restrict' => $entity_restrict, 'devtype' => $devtype);
     $default = "<select name='{$myname}'><option value='{$value}'>{$name}</option></select>";
     ajaxDropdown($use_ajax, "/ajax/dropdownNetpoint.php", $params, $default, $rand);
     // Display comment
     if ($display_comment) {
         showToolTip($comment);
         $item = new Netpoint();
         if ($item->canCreate()) {
             echo "<img alt='' title=\"" . $LANG['buttons'][8] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;' " . "onClick=\"var w = window.open('" . $item->getFormURL() . "?popup=1&amp;rand={$rand}' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
         }
     }
     return $rand;
 }
 /**
  * Print out an HTML "<select>" for a dropdown with preselected value
  *
  * Parameters which could be used in options array :
  *    - name : string / name of the select (default is depending itemtype)
  *    - value : integer / preselected value (default -1)
  *    - comments : boolean / is the comments displayed near the dropdown (default true)
  *    - entity : integer or array / restrict to a defined entity or array of entities
  *                   (default -1 : no restriction)
  *    - entity_sons : boolean / if entity restrict specified auto select its sons
  *                   only available if entity is a single value not an array (default false)
  *    - toupdate : array / Update a specific item on select change on dropdown
  *                   (need value_fieldname, to_update, url (see ajaxUpdateItemOnSelectEvent for informations)
  *                   and may have moreparams)
  *    - used : array / Already used items ID: not to display in dropdown (default empty)
  *    - auto_submit : boolean / autosubmit on change (default false)
  *    - rand : integer / already computed rand value
  *    - condition : string / aditional SQL condition to limit display
  *    - displaywith : array / array of field to display with request
  *
  * @param $itemtype itemtype used for create dropdown
  * @param $options possible options
  * @return boolean : lse if error and random id if OK
  *
  **/
 static function show($itemtype, $options = array())
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($itemtype && !class_exists($itemtype)) {
         return false;
     }
     $item = new $itemtype();
     $table = $item->getTable();
     $params['name'] = $item->getForeignKeyField();
     $params['value'] = '';
     $params['comments'] = true;
     $params['entity'] = -1;
     $params['entity_sons'] = false;
     $params['toupdate'] = '';
     $params['used'] = array();
     $params['auto_submit'] = 0;
     $params['condition'] = '';
     $params['rand'] = mt_rand();
     $params['displaywith'] = array();
     //Parameters about choice 0
     //Empty choice's label
     $params['emptylabel'] = '';
     //Display emptychoice ?
     $params['display_emptychoice'] = true;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $name = DROPDOWN_EMPTY_VALUE;
     $comment = "";
     $limit_length = $_SESSION["glpidropdown_chars_limit"];
     // Check default value for dropdown : need to be a numeric
     if (strlen($params['value']) == 0 || !is_numeric($params['value'])) {
         $params['value'] = -1;
     }
     if ($params['value'] > 0 || $itemtype == "Entity" && $params['value'] >= 0) {
         $tmpname = self::getDropdownName($table, $params['value'], 1);
         if ($tmpname["name"] != "&nbsp;") {
             $name = $tmpname["name"];
             $comment = $tmpname["comment"];
             if (utf8_strlen($name) > $_SESSION["glpidropdown_chars_limit"]) {
                 if ($item instanceof CommonTreeDropdown) {
                     $pos = strrpos($name, ">");
                     $limit_length = max(utf8_strlen($name) - $pos, $_SESSION["glpidropdown_chars_limit"]);
                     if (utf8_strlen($name) > $limit_length) {
                         $name = "&hellip;" . utf8_substr($name, -$limit_length);
                     }
                 } else {
                     $limit_length = utf8_strlen($name);
                 }
             } else {
                 $limit_length = $_SESSION["glpidropdown_chars_limit"];
             }
         }
     }
     // Manage entity_sons
     if (!($params['entity'] < 0) && $params['entity_sons']) {
         if (is_array($params['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $params['entity'] = getSonsOf('glpi_entities', $params['entity']);
         }
     }
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $nb = 0;
         if ($item->isEntityAssign()) {
             if (!($params['entity'] < 0)) {
                 $nb = countElementsInTableForEntity($table, $params['entity'], $params['condition']);
             } else {
                 $nb = countElementsInTableForMyEntities($table, $params['condition']);
             }
         } else {
             $nb = countElementsInTable($table, $params['condition']);
         }
         $nb -= count($params['used']);
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $param = array('searchText' => '__VALUE__', 'value' => $params['value'], 'itemtype' => $itemtype, 'myname' => $params['name'], 'limit' => $limit_length, 'comment' => $params['comments'], 'rand' => $params['rand'], 'entity_restrict' => $params['entity'], 'update_item' => $params['toupdate'], 'used' => $params['used'], 'auto_submit' => $params['auto_submit'], 'condition' => $params['condition'], 'emptylabel' => $params['emptylabel'], 'display_emptychoice' => $params['display_emptychoice']);
     $default = "<select name='" . $params['name'] . "' id='dropdown_" . $params['name'] . $params['rand'] . "'>";
     $default .= "<option value='" . $params['value'] . "'>{$name}</option></select>";
     ajaxDropdown($use_ajax, "/ajax/dropdownValue.php", $param, $default, $params['rand']);
     // Display comment
     if ($params['comments']) {
         $options_tooltip = array('contentid' => "comment_" . $params['name'] . $params['rand']);
         if ($item->canView() && $params['value'] && $item->getFromDB($params['value']) && $item->canViewItem()) {
             $options_tooltip['link'] = $item->getLinkURL();
             $options_tooltip['linktarget'] = '_blank';
         }
         showToolTip($comment, $options_tooltip);
         if ($item instanceof CommonDropdown && $item->canCreate() && !isset($_GET['popup'])) {
             echo "<img alt='' title=\"" . $LANG['buttons'][8] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n                     onClick=\"var w = window.open('" . $item->getFormURL() . "?popup=1&amp;rand=" . $params['rand'] . "' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
         }
         // Display specific Links
         if ($itemtype == "Supplier") {
             if ($item->getFromDB($params['value'])) {
                 echo $item->getLinks();
             }
         }
         if ($itemtype == 'TicketCategory' && haveRight('knowbase', 'r')) {
             if ($params['value'] && $item->getFromDB($params['value'])) {
                 echo '&nbsp;' . $item->getLinks();
             }
         }
     }
     return $params['rand'];
 }
 /**
  * Display a reservation
  *
  * @param $ID ID a the reservation item
  * @param $date date to display
  **/
 static function displayReservationsForAnItem($ID, $date)
 {
     global $DB, $LANG;
     $users_id = getLoginUserID();
     $resa = new self();
     $user = new User();
     list($year, $month, $day) = explode("-", $date);
     $debut = $date . " 00:00:00";
     $fin = $date . " 23:59:59";
     $query = "SELECT *\n                FROM `glpi_reservations`\n                WHERE '{$debut}' < `end`\n                      AND '{$fin}' > `begin`\n                      AND `reservationitems_id` = '{$ID}'\n                ORDER BY `begin`";
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result) > 0) {
             echo "<table width='100%'>";
             while ($row = $DB->fetch_array($result)) {
                 echo "<tr>";
                 $user->getFromDB($row["users_id"]);
                 $display = "";
                 if ($debut > $row['begin']) {
                     $heure_debut = "00:00";
                 } else {
                     $heure_debut = get_hour_from_sql($row['begin']);
                 }
                 if ($fin < $row['end']) {
                     $heure_fin = "24:00";
                 } else {
                     $heure_fin = get_hour_from_sql($row['end']);
                 }
                 if (strcmp($heure_debut, "00:00") == 0 && strcmp($heure_fin, "24:00") == 0) {
                     $display = $LANG['planning'][5];
                 } else {
                     if (strcmp($heure_debut, "00:00") == 0) {
                         $display = $LANG['reservation'][16] . "&nbsp;" . $heure_fin;
                     } else {
                         if (strcmp($heure_fin, "24:00") == 0) {
                             $display = $LANG['reservation'][17] . "&nbsp;" . $heure_debut;
                         } else {
                             $display = $heure_debut . "-" . $heure_fin;
                         }
                     }
                 }
                 $rand = mt_rand();
                 $modif = $modif_end = "";
                 if ($resa->can($row['id'], "w")) {
                     $modif = "<a id='content_" . $ID . $rand . "'\n                             href='reservation.form.php?id=" . $row['id'] . "'>";
                     $modif_end = "</a>";
                     $modif_end .= showToolTip($row["comment"], array('applyto' => "content_" . $ID . $rand, 'display' => false));
                 }
                 echo "<td class='tab_resa center'>" . $modif . "<span>" . $display . "<br><strong>" . formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]);
                 echo "</strong></span>";
                 echo $modif_end;
                 echo "</td></tr>\n";
             }
             echo "</table>\n";
         }
     }
 }
 /**
  * Display a software for a License (not installed)
  *
  * @param $data data used to display
  * @param $computers_id ID of the computer
  * @param $withtemplate template case of the view process
  * @param $canedit boolean user can edit software ?
  *
  * @return nothing
  */
 private static function displaySoftsByLicense($data, $computers_id, $withtemplate, $canedit)
 {
     global $LANG, $CFG_GLPI;
     if ($data["softwareversions_id_use"] > 0) {
         $ID = $data["softwareversions_id_use"];
     } else {
         $ID = $data["softwareversions_id_buy"];
     }
     $multiple = false;
     $link_item = getItemTypeFormURL('SoftwareLicense');
     $link = $link_item . "?id=" . $data['id'];
     echo "<tr class='tab_bg_1'>";
     if ($canedit) {
         echo "<td>";
         if ((empty($withtemplate) || $withtemplate != 2) && $ID > 0) {
             echo "<input type='checkbox' name='softversion_{$ID}'>";
         }
         echo "</td>";
     }
     echo "<td class='center b'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/software.form.php?id=" . $data['softwares_id'] . "'>";
     echo $data["softname"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data['softwares_id'] . ")" : "");
     echo "</a></td>";
     echo "<td>" . $data["state"] . "</td>";
     echo "<td>" . $data["version"];
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit && $ID > 0) {
         echo " - <a href='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php" . "?install=install&amp;softwareversions_id={$ID}&amp;computers_id={$computers_id}'>";
         echo "<strong>" . $LANG['buttons'][4] . "</strong></a>";
     }
     echo "</td></td><td><strong>" . $data["name"] . "</strong> -&nbsp;" . $data["serial"] . "&nbsp; ";
     if ($data["softwarelicensetypes_id"]) {
         echo " (" . Dropdown::getDropdownName("glpi_softwarelicensetypes", $data["softwarelicensetypes_id"]) . ")&nbsp; ";
     }
     showToolTip($LANG['common'][16] . "&nbsp;: " . $data['name'] . "<br>" . $LANG['common'][19] . "&nbsp;: " . $data['serial'] . "<br>" . $data['comment'], array('link' => $link));
     echo "</td></tr>\n";
 }
 static function showListForCentral($entity = -1, $parent = false)
 {
     global $DB, $CFG_GLPI, $LANG;
     // show reminder that are not planned
     $users_id = getLoginUserID();
     $today = $_SESSION["glpi_currenttime"];
     $is_helpdesk_visible = '';
     if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
         $is_helpdesk_visible = " AND `is_helpdesk_visible` = 1 ";
     }
     if ($entity < 0) {
         $query = "SELECT *\n                   FROM `glpi_reminders`\n                   WHERE `users_id` = '{$users_id}'\n                         AND `is_private` = '1'\n                         AND (`end` >= '{$today}'\n                              OR `is_planned` = '0')\n                   ORDER BY `name`";
         $titre = "<a href='" . $CFG_GLPI["root_doc"] . "/front/reminder.php'>" . $LANG['reminder'][0] . "</a>";
         $is_private = 1;
     } else {
         if ($entity == $_SESSION["glpiactive_entity"]) {
             $query = "SELECT *\n                   FROM `glpi_reminders`\n                   WHERE `is_private` = '0'\n                         {$is_helpdesk_visible} " . getEntitiesRestrictRequest("AND", "glpi_reminders", "", $entity) . "\n                   ORDER BY `name`";
             if ($_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
                 $titre = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/reminder.php\">" . $LANG['reminder'][1] . "</a> (" . Dropdown::getDropdownName("glpi_entities", $entity) . ")";
             } else {
                 $titre = $LANG['reminder'][1] . " (" . Dropdown::getDropdownName("glpi_entities", $entity) . ")";
             }
             if (haveRight("reminder_public", "w")) {
                 $is_private = 0;
             }
         } else {
             if ($parent) {
                 $query = "SELECT *\n                   FROM `glpi_reminders`\n                   WHERE `is_private` = '0'\n                         AND `is_recursive` = '1'\n                         {$is_helpdesk_visible} " . getEntitiesRestrictRequest("AND", "glpi_reminders", "", $entity) . "\n                   ORDER BY `name`";
                 $titre = $LANG['reminder'][1] . " (" . Dropdown::getDropdownName("glpi_entities", $entity) . ")";
             } else {
                 // Filles
                 $query = "SELECT *\n                   FROM `glpi_reminders`\n                   WHERE `is_private` = '0'\n                         {$is_helpdesk_visible} " . getEntitiesRestrictRequest("AND", "glpi_reminders", "", $entity) . "\n                   ORDER BY `name`";
                 $titre = $LANG['reminder'][1] . " (" . Dropdown::getDropdownName("glpi_entities", $entity) . ")";
             }
         }
     }
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     if ($nb || isset($is_private)) {
         echo "<br><table class='tab_cadrehov'>";
         echo "<tr><th><div class='relative'><span>{$titre}</span>";
         if (isset($is_private)) {
             echo "<span class='reminder_right'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?is_private={$is_private}'>";
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/plus.png' alt='+' title=\"" . $LANG['buttons'][8] . "\"></a></span>";
         }
         echo "</div></th></tr>\n";
     }
     if ($nb) {
         $rand = mt_rand();
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_2'><td><div class='relative reminder_list'>";
             echo "<a id='content_reminder_" . $data["id"] . $rand . "'\n                  href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $data["id"] . "'>" . $data["name"] . "</a>&nbsp;";
             showToolTip($data["text"], array('applyto' => "content_reminder_" . $data["id"] . $rand));
             if ($data["is_planned"]) {
                 $tab = explode(" ", $data["begin"]);
                 $date_url = $tab[0];
                 echo "<span class='reminder_right'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/planning.php?date=" . $date_url . "&amp;type=day'>";
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' alt=\"" . $LANG['Menu'][29] . "\" title=\"" . convDateTime($data["begin"]) . "=>" . convDateTime($data["end"]) . "\">";
                 echo "</a></span>";
             }
             echo "</div></td></tr>\n";
         }
     }
     if ($nb || isset($is_private)) {
         echo "</table>\n";
     }
 }
示例#10
0
 function getComments()
 {
     global $LANG;
     $comment = $LANG['plugin_monitoring']['check'][1] . ' : ' . $this->fields['max_check_attempts'] . '<br/>
      ' . $LANG['plugin_monitoring']['check'][2] . ' : ' . $this->fields['check_interval'] . ' minutes<br/>
      ' . $LANG['plugin_monitoring']['check'][3] . ' : ' . $this->fields['retry_interval'] . ' minutes';
     if (!empty($comment)) {
         return showToolTip($comment, array('display' => false));
     }
     return $comment;
 }
示例#11
0
 static function reminderDisplayPlanningItem($val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI, $LANG;
     $rand = mt_rand();
     $users_id = "";
     // show users_id reminder
     $img = "rdv_private.png";
     // default icon for reminder
     if (!$val["is_private"]) {
         $users_id = "<br>" . $LANG['planning'][9] . "&nbsp;: " . getUserName($val["users_id"]);
         $img = "rdv_public.png";
     }
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $img . "' alt='' title='" . $LANG['title'][37] . "'>&nbsp;";
     echo "<a id='reminder_" . $val["reminders_id"] . $rand . "' href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $val["reminders_id"] . "'>";
     switch ($type) {
         case "in":
             echo date("H:i", strtotime($val["begin"])) . " -> " . date("H:i", strtotime($val["end"])) . ": ";
             break;
         case "through":
             break;
         case "begin":
             echo $LANG['buttons'][33] . " " . date("H:i", strtotime($val["begin"])) . ": ";
             break;
         case "end":
             echo $LANG['buttons'][32] . " " . date("H:i", strtotime($val["end"])) . ": ";
             break;
     }
     echo $val["name"];
     echo $users_id;
     echo "</a>";
     if ($complete) {
         echo "<br><strong>" . Planning::getState($val["state"]) . "</strong><br>";
         echo $val["text"];
     } else {
         showToolTip("<strong>" . Planning::getState($val["state"]) . "</strong><br>" . $val["text"], array('applyto' => "reminder_" . $val["reminders_id"] . $rand));
     }
     echo "";
 }
 /**
  * Display a Planning Item
  *
  * @param $val Array of the item to display
  * @param $who ID of the user (0 if all)
  * @param $type position of the item in the time block (in, through, begin or end)
  * @param $complete complete display (more details)
  *
  * @return Nothing (display function)
  **/
 static function displayPlanningItem($val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI, $LANG;
     $rand = mt_rand();
     $styleText = "";
     if (isset($val["state"])) {
         switch ($val["state"]) {
             case 2:
                 // Done
                 $styleText = "color:#747474;";
                 break;
         }
     }
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv_interv.png' alt='' title=\"" . $LANG['planning'][8] . "\">&nbsp;&nbsp;";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $val["status"] . ".png' alt='" . Ticket::getStatus($val["status"]) . "' title=\"" . Ticket::getStatus($val["status"]) . "\">";
     echo "&nbsp;<a id='content_tracking_" . $val["id"] . $rand . "'\n                   href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $val["tickets_id"] . "'\n                   style='{$styleText}'>";
     switch ($type) {
         case "in":
             echo date("H:i", strtotime($val["begin"])) . "/" . date("H:i", strtotime($val["end"])) . ": ";
             break;
         case "through":
             break;
         case "begin":
             echo $LANG['buttons'][33] . " " . date("H:i", strtotime($val["begin"])) . ": ";
             break;
         case "end":
             echo $LANG['buttons'][32] . " " . date("H:i", strtotime($val["end"])) . ": ";
             break;
     }
     echo "<br>- #" . $val["tickets_id"] . " ";
     echo resume_text($val["name"], 80) . " ";
     if (!empty($val["device"])) {
         echo "<br>- " . $val["device"];
     }
     if ($who <= 0) {
         // show tech for "show all and show group"
         echo "<br>- ";
         echo $LANG['common'][95] . " " . getUserName($val["users_id"]);
     }
     echo "</a>";
     if ($complete) {
         echo "<br><strong>" . Planning::getState($val["state"]) . "<br>";
         echo $LANG['joblist'][2] . "&nbsp;:</strong> " . Ticket::getPriorityName($val["priority"]);
         echo "<br><strong>" . $LANG['joblist'][6] . "&nbsp;:</strong><br>" . $val["content"];
     } else {
         $content = "<strong>" . Planning::getState($val["state"]) . "<br>" . $LANG['joblist'][2] . "&nbsp;:</strong> " . Ticket::getPriorityName($val["priority"]) . "<br><strong>" . $LANG['joblist'][6] . "&nbsp;:</strong><br>" . $val["content"] . "</div>";
         showToolTip($content, array('applyto' => "content_tracking_" . $val["id"] . $rand));
     }
 }
示例#13
0
 /**
  * Make a select box with all glpi users where select key = name
  *
  * Parameters which could be used in options array :
  *    - name : string / name of the select (default is users_id)
  *    - right : string / limit user who have specific right :
  *        id -> only current user (default case);
  *        interface -> central ;
  *        all -> all users ;
  *        specific right like show_all_ticket, create_ticket....
  *    - comments : boolean / is the comments displayed near the dropdown (default true)
  *    - entity : integer or array / restrict to a defined entity or array of entities
  *                   (default -1 : no restriction)
  *    - entity_sons : boolean / if entity restrict specified auto select its sons
  *                   only available if entity is a single value not an array(default false)
  *    - all : Nobody or All display for none selected
  *          all=0 (default) -> Nobody
  *          all=1 -> All
  *          all=-1-> nothing
  *    - rand : integer / already computed rand value
  *    - toupdate : array / Update a specific item on select change on dropdown
  *                   (need value_fieldname, to_update, url (see ajaxUpdateItemOnSelectEvent for informations)
  *                   and may have moreparams)
  *    - used : array / Already used items ID: not to display in dropdown (default empty)
  *    - auto_submit : boolean / autosubmit on change (default false)
  *
  * @param $options possible options
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdown($options = array())
 {
     global $DB, $CFG_GLPI, $LANG;
     // Defautl values
     $p['name'] = 'users_id';
     $p['value'] = '';
     $p['right'] = 'id';
     $p['all'] = 0;
     $p['auto_submit'] = false;
     $p['comments'] = 1;
     $p['entity'] = -1;
     $p['entity_sons'] = false;
     $p['used'] = array();
     $p['ldap_import'] = false;
     $p['toupdate'] = '';
     $p['rand'] = mt_rand();
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     // Make a select box with all glpi users
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $res = self::getSqlSearchResult(true, $p['right'], $p['entity'], $p['value'], $p['used']);
         $nb = $res ? $DB->result($res, 0, "cpt") : 0;
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $user = getUserName($p['value'], 2);
     $default_display = "<select id='dropdown_" . $p['name'] . $p['rand'] . "' name='" . $p['name'] . "'>";
     $default_display .= "<option value='" . $p['value'] . "'>";
     $default_display .= utf8_substr($user["name"], 0, $_SESSION["glpidropdown_chars_limit"]);
     $default_display .= "</option></select>";
     $view_users = haveRight("user", "r");
     $params = array('searchText' => '__VALUE__', 'value' => $p['value'], 'myname' => $p['name'], 'all' => $p['all'], 'right' => $p['right'], 'comment' => $p['comments'], 'rand' => $p['rand'], 'auto_submit' => $p['auto_submit'], 'entity_restrict' => $p['entity'], 'used' => $p['used'], 'update_item' => $p['toupdate']);
     if ($view_users) {
         $params['update_link'] = $view_users;
     }
     $default = "";
     if (!empty($p['value']) && $p['value'] > 0) {
         $default = $default_display;
     } else {
         $default = "<select name='" . $p['name'] . "' id='dropdown_" . $p['name'] . $p['rand'] . "'>";
         if ($p['all']) {
             $default .= "<option value='0'>[ " . $LANG['common'][66] . " ]</option></select>";
         } else {
             $default .= "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option></select>\n";
         }
     }
     ajaxDropdown($use_ajax, "/ajax/dropdownUsers.php", $params, $default, $p['rand']);
     // Display comment
     if ($p['comments']) {
         if (!$view_users) {
             $user["link"] = '';
         } else {
             if (empty($user["link"])) {
                 $user["link"] = $CFG_GLPI['root_doc'] . "/front/user.php";
             }
         }
         showToolTip($user["comment"], array('contentid' => "comment_" . $p['name'] . $p['rand'], 'link' => $user["link"], 'linkid' => "comment_link_" . $p["name"] . $p['rand']));
     }
     if (haveRight('import_externalauth_users', 'w') && $p['ldap_import'] && EntityData::isEntityDirectoryConfigured($_SESSION['glpiactive_entity'])) {
         echo "<img alt='' title=\"" . $LANG['ldap'][35] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n                onClick=\"var w = window.open('" . $CFG_GLPI['root_doc'] . "/front/popup.php?popup=add_ldapuser&amp;rand=" . $p['rand'] . "&amp;entity=" . $_SESSION['glpiactive_entity'] . "' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
     }
     return $p['rand'];
 }
示例#14
0
 /**
  * Display services associated with host
  *
  * @param $itemtype value type of item
  * @param $items_id integer id of the object
  *
  **/
 function listByHost($itemtype, $items_id)
 {
     global $LANG, $CFG_GLPI, $DB;
     $pmComponentscatalog = new PluginMonitoringComponentscatalog();
     $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n         WHERE `items_id`='" . $items_id . "'\n            AND `itemtype`='" . $itemtype . "'";
     $result = $DB->query($query);
     //      echo "<form name='form' method='post'
     //         action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.form.php'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='5'>";
     echo $LANG['plugin_monitoring']['service'][0];
     //      echo "&nbsp;<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/service.form.php?services_id=".$a_hosts['id']."'>
     //         <img src='".$CFG_GLPI['root_doc']."/pics/menu_add.png' /></a>";
     //
     //      echo "&nbsp;<a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/servicedef.form.php?add_template=1'>
     //         <img src='".$CFG_GLPI['root_doc']."/pics/menu_addtemplate.png' /></a>";
     echo "</th>";
     echo "</tr>";
     echo "<table>";
     while ($data = $DB->fetch_array($result)) {
         $pmComponentscatalog->getFromDB($data['plugin_monitoring_componentscalalog_id']);
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='12'>" . $pmComponentscatalog->getTypeName() . "&nbsp;:&nbsp;" . $pmComponentscatalog->getLink() . "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<th>";
         echo $LANG['joblist'][0];
         echo "</th>";
         echo "<th>";
         echo $LANG['entity'][0];
         echo "</th>";
         echo "<th>";
         echo $LANG['stats'][7];
         echo "</th>";
         echo "<th>";
         echo $LANG['plugin_monitoring']['component'][0];
         echo "</th>";
         echo "<th>";
         echo $LANG['state'][0];
         echo "</th>";
         echo "<th>";
         echo $LANG['plugin_monitoring']['service'][18];
         echo "</th>";
         echo "<th>";
         echo $LANG['rulesengine'][82];
         echo "</th>";
         echo "<th>";
         echo $LANG['plugin_monitoring']['host'][9];
         echo "</th>";
         echo "<th>" . $LANG['plugin_monitoring']['availability'][1] . " " . showToolTip($LANG['plugin_monitoring']['availability'][0], array('display' => false)) . "</th>";
         echo "<th>" . $LANG['plugin_monitoring']['availability'][2] . " " . showToolTip($LANG['plugin_monitoring']['availability'][0], array('display' => false)) . "</th>";
         echo "<th>" . $LANG['plugin_monitoring']['availability'][3] . " " . showToolTip($LANG['plugin_monitoring']['availability'][0], array('display' => false)) . "</th>";
         echo "<th>";
         echo $LANG['plugin_monitoring']['service'][4];
         echo "</th>";
         echo "</tr>";
         $querys = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services`\n            LEFT JOIN `glpi_plugin_monitoring_components`\n               on `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id`\n            WHERE `plugin_monitoring_componentscatalogs_hosts_id`='" . $data['id'] . "'\n               ORDER BY `name`";
         $results = $DB->query($querys);
         while ($datas = $DB->fetch_array($results)) {
             $this->getFromDB($datas['id']);
             echo "<tr class='tab_bg_1'>";
             PluginMonitoringDisplay::displayLine($datas, 0);
             echo "</tr>";
         }
         echo "</table>";
     }
     //      echo "<tr class='tab_bg_1'>";
     //      echo "<td colspan='8' align='center'>";
     //      echo "<input type='submit' class='submit' name='update' value='".$LANG['buttons'][7]."'>";
     //      echo "</td>";
     //      echo "</tr>";
     echo "</table>";
     echo "</form>";
 }
示例#15
0
 /**
  * Generic Function to display Items
  *
  * @param $itemtype item type
  * @param $ID ID of the SEARCH_OPTION item
  * @param $data array containing data results
  * @param $num item num in the request
  * @param $meta is a meta item ?
  *
  * @return string to print
  **/
 static function giveItem($itemtype, $ID, $data, $num, $meta = 0)
 {
     global $CFG_GLPI, $LANG;
     $searchopt =& self::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         return self::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     if ($meta) {
         $NAME = "META_";
     }
     $table = $searchopt[$ID]["table"];
     $field = $searchopt[$ID]["field"];
     $linkfield = $searchopt[$ID]["linkfield"];
     switch ($table . '.' . $field) {
         case "glpi_users.name":
             // USER search case
             if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if ($split[$k] > 0) {
                         if ($count_display) {
                             $out .= "<br>";
                         }
                         $count_display++;
                         if ($itemtype == 'Ticket') {
                             $userdata = getUserName($split[$k], 2);
                             $out .= $userdata['name'] . "&nbsp;" . showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                         } else {
                             $out .= getUserName($split[$k], 1);
                         }
                     }
                 }
                 // Manage alternative_email for tickets_users
                 if ($itemtype == 'Ticket' && isset($data[$NAME . $num . '_2'])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . '_2']);
                     for ($k = 0; $k < count($split); $k++) {
                         $split2 = explode(" ", $split[$k]);
                         if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>";
                         }
                     }
                 }
                 return $out;
             }
             if ($itemtype != 'User') {
                 $toadd = '';
                 if ($itemtype == 'Ticket' && $data[$NAME . $num . "_3"] > 0) {
                     $userdata = getUserName($data[$NAME . $num . "_3"], 2);
                     $toadd = "&nbsp;" . showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                 }
                 return formatUserName($data[$NAME . $num . "_3"], $data[$NAME . $num], $data[$NAME . $num . "_2"], $data[$NAME . $num . "_4"], 1) . $toadd;
             }
             break;
         case "glpi_profiles.interface":
             return Profile::getInterfaceName($data[$NAME . $num]);
         case "glpi_profiles.name":
             if ($itemtype == 'User' && $ID == 20) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = $split[$k] . " - " . Dropdown::getDropdownName('glpi_entities', $split2[$k]);
                         if ($split3[$k]) {
                             $text .= " (R)";
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_complete_entities.completename":
             if ($itemtype == 'User') {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $added = array();
                 $count_display = 0;
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = $split[$k] . " - " . Dropdown::getDropdownName('glpi_profiles', $split2[$k]);
                         if ($split3[$k]) {
                             $text .= " (R)";
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_entities.completename":
             if ($data[$NAME . $num . "_2"] == 0) {
                 // Set name for Root entity
                 $data[$NAME . $num] = $LANG['entity'][2];
             }
             break;
         case "glpi_documenttypes.icon":
             if (!empty($data[$NAME . $num])) {
                 return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
             }
             return "&nbsp;";
         case "glpi_documents.filename":
             $doc = new Document();
             if ($doc->getFromDB($data['id'])) {
                 return $doc->getDownloadLink();
             }
             return NOT_AVAILABLE;
         case "glpi_deviceharddrives.specificity":
         case "glpi_devicememories.specificity":
         case "glpi_deviceprocessors.specificity":
             return $data[$NAME . $num];
         case "glpi_networkports.mac":
             $out = "";
             if ($itemtype == 'Computer') {
                 $displayed = array();
                 if (!empty($data[$NAME . $num . "_2"])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = utf8_strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                     if (!empty($data[$NAME . $num])) {
                         $out .= "<br>";
                     }
                 }
                 if (!empty($data[$NAME . $num])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = utf8_strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_contracts.duration":
         case "glpi_contracts.notice":
         case "glpi_contracts.periodicity":
         case "glpi_contracts.billing":
             if (!empty($data[$NAME . $num])) {
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $output = "";
                 foreach ($split as $duration) {
                     $output .= (empty($output) ? '' : '<br>') . $duration . " " . $LANG['financial'][57];
                 }
                 return $output;
             }
             return "&nbsp;";
         case "glpi_contracts.renewal":
             return Contract::getContractRenewalName($data[$NAME . $num]);
         case "glpi_infocoms.sink_time":
             if (!empty($data[$NAME . $num])) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= empty($out) ? '' : '<br>';
                     if ($val > 0) {
                         $out .= $val . " " . $LANG['financial'][9];
                     }
                 }
                 return $out;
             }
             return "&nbsp;";
         case "glpi_infocoms.warranty_duration":
             if (!empty($data[$NAME . $num])) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= empty($out) ? '' : '<br>';
                     if ($val > 0) {
                         $out .= $val . " " . $LANG['financial'][57];
                     }
                     if ($val < 0) {
                         $out .= $LANG['financial'][2];
                     }
                 }
                 return $out;
             }
             return "&nbsp;";
         case "glpi_infocoms.sink_type":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $out .= (empty($out) ? '' : '<br>') . Infocom::getAmortTypeName($val);
             }
             return $out;
         case "glpi_infocoms.alert":
             if ($data[$NAME . $num] == pow(2, Alert::END)) {
                 return $LANG['financial'][80];
             }
             return "";
         case "glpi_contracts.alert":
             switch ($data[$NAME . $num]) {
                 case pow(2, Alert::END):
                     return $LANG['buttons'][32];
                 case pow(2, Alert::NOTICE):
                     return $LANG['financial'][10];
                 case pow(2, Alert::END) + pow(2, Alert::NOTICE):
                     return $LANG['buttons'][32] . " + " . $LANG['financial'][10];
             }
             return "";
         case "glpi_tickets_tickets.tickets_id_1":
             $out = "";
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
             $displayed = array();
             for ($k = 0; $k < count($split); $k++) {
                 $linkid = $split[$k] == $data['id'] ? $split2[$k] : $split[$k];
                 if ($linkid > 0 && !isset($displayed[$linkid])) {
                     $text = $linkid . " - " . Dropdown::getDropdownName('glpi_tickets', $linkid);
                     if (count($displayed)) {
                         $out .= "<br>";
                     }
                     $displayed[$linkid] = $linkid;
                     $out .= $text;
                 }
             }
             return $out;
         case "glpi_tickets.count":
             if ($data[$NAME . $num] > 0 && haveRight("show_all_ticket", "1")) {
                 if ($itemtype == 'User') {
                     $options['field'][0] = 4;
                     $options['searchtype'][0] = 'equals';
                     $options['contains'][0] = $data['id'];
                     $options['link'][0] = 'AND';
                     $options['field'][1] = 22;
                     $options['searchtype'][1] = 'equals';
                     $options['contains'][1] = $data['id'];
                     $options['link'][1] = 'OR';
                     $options['field'][2] = 5;
                     $options['searchtype'][2] = 'equals';
                     $options['contains'][2] = $data['id'];
                     $options['link'][2] = 'OR';
                 } else {
                     $options['field'][0] = 12;
                     $options['searchtype'][0] = 'equals';
                     $options['contains'][0] = 'all';
                     $options['link'][0] = 'AND';
                     $options['itemtype2'][0] = $itemtype;
                     $options['field2'][0] = self::getOptionNumber($itemtype, 'name');
                     $options['searchtype2'][0] = 'equals';
                     $options['contains2'][0] = $data['id'];
                     $options['link2'][0] = 'AND';
                 }
                 $options['reset'] = 'reset';
                 $out = "<a id='ticket{$itemtype}" . $data['id'] . "' ";
                 $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&amp;') . "\">";
                 $out .= $data[$NAME . $num] . "</a>";
             } else {
                 $out = $data[$NAME . $num];
             }
             return $out;
         case "glpi_softwarelicenses.number":
             if ($data[$NAME . $num . "_2"] == -1) {
                 return $LANG['software'][4];
             }
             if (empty($data[$NAME . $num])) {
                 return 0;
             }
             return $data[$NAME . $num];
         case "glpi_auth_tables.name":
             return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
         case "glpi_reservationitems.comment":
             if (empty($data[$NAME . $num])) {
                 return "<a title=\"" . $LANG['reservation'][22] . "\"\n                        href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . $LANG['common'][49] . "</a>";
             }
             return "<a title=\"" . $LANG['reservation'][22] . "\"\n                     href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . resume_text($data[$NAME . $num]) . "</a>";
         case 'glpi_notifications.mode':
             return Notification::getMode($data[$NAME . $num]);
         case 'glpi_notifications.event':
             $item = NotificationTarget::getInstanceByType($data['itemtype']);
             if ($item) {
                 $events = $item->getAllEvents();
                 return $events[$data[$NAME . $num]];
             }
             return '';
         case 'glpi_crontasks.description':
             $tmp = new CronTask();
             return $tmp->getDescription($data['id']);
         case 'glpi_crontasks.state':
             return CronTask::getStateName($data[$NAME . $num]);
         case 'glpi_crontasks.mode':
             return CronTask::getModeName($data[$NAME . $num]);
         case 'glpi_crontasks.itemtype':
             if ($plug = isPluginItemType($data[$NAME . $num])) {
                 return $plug['plugin'];
             }
             return '';
         case 'glpi_tickets.status':
             $status = Ticket::getStatus($data[$NAME . $num]);
             return "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . $data[$NAME . $num] . ".png\"\n                     alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
         case 'glpi_tickets.type':
             return Ticket::getTicketTypeName($data[$NAME . $num]);
         case 'glpi_tickets.priority':
             return Ticket::getPriorityName($data[$NAME . $num]);
         case 'glpi_tickets.urgency':
             return Ticket::getUrgencyName($data[$NAME . $num]);
         case 'glpi_tickets.impact':
             return Ticket::getImpactName($data[$NAME . $num]);
         case 'glpi_tickets.items_id':
             if (!empty($data[$NAME . $num . "_2"]) && class_exists($data[$NAME . $num . "_2"])) {
                 $item = new $data[$NAME . $num . "_2"]();
                 if ($item->getFromDB($data[$NAME . $num])) {
                     return $item->getLink(true);
                 }
             }
             return '&nbsp;';
         case 'glpi_tickets.name':
             $link = getItemTypeFormURL('Ticket');
             $out = "<a id='ticket" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
             $out .= strstr($link, '?') ? '&amp;' : '?';
             $out .= 'id=' . $data[$NAME . $num . "_2"];
             // Force solution tab if solved
             if ($data[$NAME . $num . "_4"] == 'solved') {
                 $out .= "&amp;forcetab=4";
             }
             $out .= "\">" . $data[$NAME . $num];
             if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                 $out .= " (" . $data[$NAME . $num . "_2"] . ")";
             }
             $out .= "</a>";
             $out .= showToolTip(nl2br($data[$NAME . $num . "_3"]), array('applyto' => 'ticket' . $data[$NAME . $num . "_2"], 'display' => false));
             return $out;
         case "glpi_tickets.due_date":
             // No due date in waiting status
             if ($data[$NAME . $num . '_2'] == 'waiting') {
                 $data[$NAME . $num] = "";
             }
             break;
         case 'glpi_ticketvalidations.status':
         case "glpi_tickets.global_validation":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $status = TicketValidation::getStatus($val);
                 $bgcolor = TicketValidation::getStatusColor($val);
                 $out .= (empty($out) ? '' : '<br>') . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>';
             }
             return $out;
         case 'glpi_ticketsatisfactions.type':
             return TicketSatisfaction::getTypeInquestName($data[$NAME . $num]);
         case 'glpi_ticketsatisfactions.satisfaction':
             return TicketSatisfaction::displaySatisfaction($data[$NAME . $num]);
         case 'glpi_notimportedemails.reason':
             return NotImportedEmail::getReason($data[$NAME . $num]);
         case 'glpi_notimportedemails.messageid':
             $clean = array('<' => '', '>' => '');
             return strtr($data[$NAME . $num], $clean);
         case 'glpi_fieldunicities.fields':
             $values = explode(',', $data[$NAME . $num]);
             $item = new $data['ITEMTYPE']();
             $message = array();
             foreach ($values as $field) {
                 $table = getTableNameForForeignKeyField($field);
                 if ($table != '') {
                     $searchOption = $item->getSearchOptionByField('field', 'name', $table);
                 } else {
                     $searchOption = $item->getSearchOptionByField('field', $field);
                 }
                 $message[] = $searchOption['name'];
             }
             return implode(',', $message);
     }
     //// Default case
     // Link with plugin tables : need to know left join structure
     if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
         if (count($matches) == 2) {
             $plug = $matches[1];
             $function = 'plugin_' . $plug . '_giveItem';
             if (function_exists($function)) {
                 $out = $function($itemtype, $ID, $data, $num);
                 if (!empty($out)) {
                     return $out;
                 }
             }
         }
     }
     $unit = '';
     if (isset($searchopt[$ID]['unit'])) {
         $unit = $searchopt[$ID]['unit'];
     }
     // Preformat items
     if (isset($searchopt[$ID]["datatype"])) {
         switch ($searchopt[$ID]["datatype"]) {
             case "itemlink":
                 if (!empty($data[$NAME . $num . "_2"])) {
                     if (isset($searchopt[$ID]["itemlink_type"])) {
                         $link = getItemTypeFormURL($searchopt[$ID]["itemlink_type"]);
                     } else {
                         $link = getItemTypeFormURL($itemtype);
                     }
                     $out = "<a id='" . $itemtype . "_" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
                     $out .= strstr($link, '?') ? '&amp;' : '?';
                     $out .= 'id=' . $data[$NAME . $num . "_2"] . "\">" . $data[$NAME . $num] . $unit;
                     if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                         $out .= " (" . $data[$NAME . $num . "_2"] . ")";
                     }
                     $out .= "</a>";
                     return $out;
                 }
                 if (isset($searchopt[$ID]["itemlink_type"])) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     $separate = '<br>';
                     if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                         $separate = '<hr>';
                     }
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             $split2 = explode("\$\$", $split[$k]);
                             if (isset($split2[1]) && $split2[1] > 0) {
                                 if ($count_display) {
                                     $out .= $separate;
                                 }
                                 $count_display++;
                                 $page = getItemTypeFormURL($searchopt[$ID]["itemlink_type"]);
                                 $page .= strpos($page, '?') ? '&id' : '?id';
                                 $out .= "<a id='" . $searchopt[$ID]["itemlink_type"] . "_" . $data['id'] . "_" . $split2[1] . "' href='{$page}=" . $split2[1] . "'>" . $split2[0] . $unit;
                                 if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
                                     $out .= " (" . $split2[1] . ")";
                                 }
                                 $out .= "</a>";
                             }
                         }
                     }
                     return $out;
                 }
                 break;
             case "text":
                 $separate = '<br>';
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = '<hr>';
                 }
                 $text = str_replace('$$$$', $separate, nl2br($data[$NAME . $num]));
                 if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) {
                     $text = html_clean(unclean_cross_side_scripting_deep($text));
                 }
                 return $text;
             case "date":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . convDate($val);
                 }
                 return $out;
             case "datetime":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . convDateTime($val);
                 }
                 return $out;
             case "timestamp":
                 $withseconds = false;
                 if (isset($searchopt[$ID]['withseconds'])) {
                     $withseconds = $searchopt[$ID]['withseconds'];
                 }
                 return timestampToString($data[$NAME . $num], $withseconds);
             case "date_delay":
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     if (strpos($val, ',')) {
                         list($dat, $dur) = explode(',', $val);
                         if (!empty($dat)) {
                             $out .= (empty($out) ? '' : '<br>') . getWarrantyExpir($dat, $dur);
                         }
                     }
                 }
                 return empty($out) ? "&nbsp;" : $out;
             case "email":
                 $email = trim($data[$NAME . $num]);
                 if (!empty($email)) {
                     return "<a href='mailto:{$email}'>{$email}</a>";
                 }
                 return "&nbsp;";
             case "weblink":
                 $orig_link = trim($data[$NAME . $num]);
                 if (!empty($orig_link)) {
                     // strip begin of link
                     $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link);
                     $link = preg_replace('/\\/$/', '', $link);
                     if (utf8_strlen($link) > $CFG_GLPI["url_maxlength"]) {
                         $link = utf8_substr($link, 0, $CFG_GLPI["url_maxlength"]) . "...";
                     }
                     return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>";
                 }
                 return "&nbsp;";
             case "number":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= str_replace(' ', '&nbsp;', formatNumber($split[$k], false, 0)) . $unit;
                         }
                     }
                     return $out;
                 }
                 return str_replace(' ', '&nbsp;', formatNumber($data[$NAME . $num], false, 0)) . $unit;
             case "decimal":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= str_replace(' ', '&nbsp;', formatNumber($split[$k])) . $unit;
                         }
                     }
                     return $out;
                 }
                 return str_replace(' ', '&nbsp;', formatNumber($data[$NAME . $num])) . $unit;
             case "bool":
                 return Dropdown::getYesNo($data[$NAME . $num]) . $unit;
             case "right":
                 return Profile::getRightValue($data[$NAME . $num]);
             case "itemtypename":
                 if (class_exists($data[$NAME . $num])) {
                     $obj = new $data[$NAME . $num]();
                     return $obj->getTypeName();
                 }
                 return "";
             case "language":
                 if (isset($CFG_GLPI['languages'][$data[$NAME . $num]])) {
                     return $CFG_GLPI['languages'][$data[$NAME . $num]][0];
                 }
                 return $LANG['setup'][46];
         }
     }
     // Manage items with need group by / group_concat
     if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
         $out = "";
         $split = explode("\$\$\$\$", $data[$NAME . $num]);
         $count_display = 0;
         $separate = '<br>';
         if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
             $separate = '<hr>';
         }
         for ($k = 0; $k < count($split); $k++) {
             if (strlen(trim($split[$k])) > 0) {
                 if ($count_display) {
                     $out .= $separate;
                 }
                 $count_display++;
                 $out .= $split[$k] . $unit;
             }
         }
         return $out;
     }
     return $data[$NAME . $num] . $unit;
 }
 /**
  * Print the computers disks
  *
  * @param $comp Computer
  *
  * @return Nothing (call to classes members)
  **/
 static function showForComputer(Computer $comp)
 {
     global $DB, $LANG;
     $ID = $comp->fields['id'];
     if (!$comp->getFromDB($ID) || !$comp->can($ID, "r")) {
         return false;
     }
     $canedit = $comp->can($ID, "w");
     echo "<div class='spaced center'>";
     $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}'");
     echo "<table class='tab_cadre_fixe'>";
     if (empty($virtualmachines)) {
         echo "<tr><th>" . $LANG['computers'][59] . "</th></tr>";
     } else {
         echo "<tr><th colspan='9'>" . $LANG['computers'][66] . "</th></tr>";
         echo "<tr><th>" . $LANG['common'][16] . "</th>";
         echo "<th>" . $LANG['computers'][62] . "</th>";
         echo "<th>" . $LANG['computers'][60] . "</th>";
         echo "<th>" . $LANG['computers'][63] . "</th>";
         echo "<th>" . $LANG['computers'][58] . "</th>";
         echo "<th>" . $LANG['computers'][61] . "</th>";
         echo "<th>" . $LANG['computers'][24] . "</th>";
         echo "<th>" . $LANG['computers'][64] . "</th>";
         echo "</tr>";
         initNavigateListItems('ComputerVirtualMachine', $LANG['help'][25] . " = " . (empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name']));
         foreach ($virtualmachines as $virtualmachine) {
             $href = "<a href='computervirtualmachine.form.php?id=" . $virtualmachine['id'] . "'>";
             echo "<tr class='tab_bg_2'>";
             echo "<td>{$href}" . $virtualmachine['name'] . "</a></td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id']);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id']);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id']);
             echo "</td>";
             echo "<td>{$href}" . $virtualmachine['uuid'] . "</a></td>";
             echo "<td>" . $virtualmachine['vcpu'] . "</td>";
             echo "<td>" . $virtualmachine['ram'] . "</td>";
             echo "<td>";
             if ($link_computer = self::findVirtualMachine($virtualmachine)) {
                 $computer = new Computer();
                 if ($computer->can($link_computer, 'r')) {
                     $url = "<a href='computer.form.php?id=" . $link_computer . "'>";
                     $url .= $computer->fields["name"] . "</a>";
                     $tooltip = $LANG['common'][16] . "&nbsp;: " . $computer->fields['name'];
                     $tooltip .= "<br>" . $LANG['common'][19] . "&nbsp;: ";
                     $tooltip .= "<br>" . $computer->fields['serial'];
                     $tooltip .= "<br>" . $computer->fields['comment'];
                     $url .= "&nbsp; " . showToolTip($tooltip, array('display' => false));
                 } else {
                     $url = $computer->fields['name'];
                 }
                 echo $url;
             }
             echo "</td>";
             echo "</tr>";
             addToNavigateListItems('ComputerVirtualMachine', $virtualmachine['id']);
         }
     }
     if ($canedit) {
         echo "<tr class='tab_bg_2'><th colspan='8'>";
         echo "<a href='computervirtualmachine.form.php?computers_id={$ID}'>" . $LANG['computers'][55] . "</a></th></tr>";
     }
     echo "</table>";
     echo "</div>";
 }
示例#17
0
 /**
  * Show the minimal form for the rule
  *
  * @param $target link to the form page
  * @param $first is it the first rule ?
  * @param $last is it the last rule ?
  * @param $display_entities display entities / make it read only display
  **/
 function showMinimalForm($target, $first = false, $last = false, $display_entities = false)
 {
     global $LANG, $CFG_GLPI;
     $canedit = haveRight($this->right, "w") && !$display_entities;
     echo "<tr class='tab_bg_1'>";
     if ($canedit) {
         echo "<td width='10'>";
         $sel = "";
         if (isset($_GET["select"]) && $_GET["select"] == "all") {
             $sel = "checked";
         }
         echo "<input type='checkbox' name='item[" . $this->fields["id"] . "]' value='1' {$sel}>";
         echo "</td>";
     } else {
         echo "<td>&nbsp;</td>";
     }
     echo "<td><a id='rules" . $this->fields["id"] . "' href=\"" . str_replace(".php", ".form.php", $target) . "?id=" . $this->fields["id"] . "&amp;onglet=1\">" . $this->fields["name"] . "</a> ";
     if (!empty($this->fields["comment"])) {
         showToolTip($this->fields["comment"], array('applyto' => "rules" . $this->fields["id"]));
     }
     echo "</td>";
     echo "<td>" . $this->fields["description"] . "</td>";
     echo "<td>" . Dropdown::getYesNo($this->fields["is_active"]) . "</td>";
     if ($display_entities) {
         echo "<td>" . Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']) . "</td>";
     }
     if (!$display_entities) {
         if ($this->can_sort && !$first && $canedit) {
             echo "<td><a href='" . $target . "?type=" . $this->fields["sub_type"] . "&amp;action=up&amp;id=" . $this->fields["id"] . "'>";
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png' alt=''></a></td>";
         } else {
             echo "<td>&nbsp;</td>";
         }
     }
     if (!$display_entities) {
         if ($this->can_sort && !$last && $canedit) {
             echo "<td><a href='" . $target . "?type=" . $this->fields["sub_type"] . "&amp;action=down&amp;id=" . $this->fields["id"] . "'>";
             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png' alt=''></a></td>";
         } else {
             echo "<td>&nbsp;</td>";
         }
     }
     echo "</tr>\n";
 }
示例#18
0
 static function showVeryShort($ID)
 {
     global $CFG_GLPI, $LANG;
     // Prints a job in short form
     // Should be called in a <table>-segment
     // Print links or not in case of user view
     // Make new job object and fill it from database, if success, print it
     $viewusers = haveRight("user", "r");
     $showprivate = haveRight("show_full_ticket", 1);
     $job = new self();
     $rand = mt_rand();
     if ($job->getFromDBwithData($ID, 0)) {
         $bgcolor = $_SESSION["glpipriority_" . $job->fields["priority"]];
         //      $rand    = mt_rand();
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' bgcolor='{$bgcolor}' >ID : " . $job->fields["id"] . "</td>";
         echo "<td class='center'>";
         if (isset($job->users[self::REQUESTER]) && count($job->users[self::REQUESTER])) {
             foreach ($job->users[self::REQUESTER] as $d) {
                 if ($d["users_id"] > 0) {
                     $userdata = getUserName($d["users_id"], 2);
                     echo "<strong>" . $userdata['name'] . "</strong>&nbsp;";
                     if ($viewusers) {
                         showToolTip($userdata["comment"], array('link' => $userdata["link"]));
                     }
                 } else {
                     echo $d['alternative_email'] . "&nbsp;";
                 }
                 echo "<br>";
             }
         }
         if (isset($job->groups[self::REQUESTER]) && count($job->groups[self::REQUESTER])) {
             foreach ($job->groups[self::REQUESTER] as $d) {
                 echo Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
                 echo "<br>";
             }
         }
         echo "</td>";
         if ($job->hardwaredatas && $job->hardwaredatas->canView()) {
             echo "<td class='center";
             if ($job->hardwaredatas->isDeleted()) {
                 echo " tab_bg_1_2";
             }
             echo "'>";
             echo $job->hardwaredatas->getTypeName() . "<br>";
             echo "<strong>" . $job->hardwaredatas->getLink() . "</strong>";
             echo "</td>";
         } else {
             if ($job->hardwaredatas) {
                 echo "<td class='center' >" . $job->hardwaredatas->getTypeName() . "<br><strong>" . $job->hardwaredatas->getNameID() . "</strong></td>";
             } else {
                 echo "<td class='center' >" . $LANG['help'][30] . "</td>";
             }
         }
         echo "<td>";
         echo "<a id='ticket" . $job->fields["id"] . $rand . "' href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $job->fields["id"] . "'>";
         echo "<strong>" . $job->fields["name"] . "</strong></a>&nbsp;";
         echo "(" . $job->numberOfFollowups($showprivate) . "-" . $job->numberOfTasks($showprivate) . ")&nbsp;";
         showToolTip($job->fields['content'], array('applyto' => 'ticket' . $job->fields["id"] . $rand));
         echo "</td>";
         // Finish Line
         echo "</tr>";
     } else {
         echo "<tr class='tab_bg_2'><td colspan='6' ><i>" . $LANG['joblist'][16] . "</i></td></tr>";
     }
 }
 /**
  * Display form for service configuration
  *
  * @param $items_id integer ID 
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($items_id, $options = array(), $copy = array())
 {
     global $DB, $CFG_GLPI, $LANG;
     $pMonitoringCommand = new PluginMonitoringCommand();
     if ($items_id == '0') {
         $this->getEmpty();
         $this->fields['active_checks_enabled'] = 1;
         $this->fields['passive_checks_enabled'] = 1;
     } else {
         $this->getFromDB($items_id);
     }
     if (count($copy) > 0) {
         foreach ($copy as $key => $value) {
             $this->fields[$key] = stripslashes($value);
         }
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if (isset($_SESSION['plugin_monitoring_components'])) {
         $this->fields = $_SESSION['plugin_monitoring_components'];
         if (!isset($this->fields["id"])) {
             $this->fields["id"] = '';
         }
         if (!isset($this->fields["arguments"])) {
             $this->fields["arguments"] = '';
         }
         unset($_SESSION['plugin_monitoring_components']);
     }
     echo "<tr>";
     echo "<td>";
     echo $LANG['common'][16] . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='hidden' name='is_template' value='1' />";
     $objectName = autoName($this->fields["name"], "name", 1, $this->getType());
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     // * checks
     echo "<td>" . $LANG['plugin_monitoring']['check'][0] . "<font class='red'>*</font>&nbsp;:</td>";
     echo "<td>";
     Dropdown::show("PluginMonitoringCheck", array('name' => 'plugin_monitoring_checks_id', 'value' => $this->fields['plugin_monitoring_checks_id']));
     echo "</td>";
     echo "</tr>";
     // * Link
     echo "<tr>";
     echo "<td>";
     //      echo "Type of template&nbsp;:";
     echo "</td>";
     echo "<td>";
     //      $a_types = array();
     //      $a_types[''] = DROPDOWN_EMPTY_VALUE;
     //      $a_types['partition'] = "Partition";
     //      $a_types['processor'] = "Processor";
     //      Dropdown::showFromArray("link", $a_types, array('value'=>$this->fields['link']));
     echo "</td>";
     // * active check
     echo "<td>";
     echo $LANG['plugin_monitoring']['host'][5] . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("active_checks_enabled", $this->fields['active_checks_enabled']);
     echo "</td>";
     echo "</tr>";
     // * command
     echo "<tr>";
     echo "<td>";
     echo $LANG['plugin_monitoring']['service'][5] . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     $pMonitoringCommand->getFromDB($this->fields['plugin_monitoring_commands_id']);
     Dropdown::show("PluginMonitoringCommand", array('name' => 'plugin_monitoring_commands_id', 'value' => $this->fields['plugin_monitoring_commands_id']));
     echo "</td>";
     // * passive check
     echo "<td>";
     echo $LANG['plugin_monitoring']['service'][7] . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("passive_checks_enabled", $this->fields['passive_checks_enabled']);
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     echo $LANG['plugin_monitoring']['service'][12] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $a_templates = array();
     $a_templates[''] = DROPDOWN_EMPTY_VALUE;
     if ($handle = opendir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates/")) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != "..") {
                 if (strstr($entry, "_graph.json")) {
                     $entry = str_replace("_graph.json", "", $entry);
                     $a_templates[$entry] = $entry;
                 }
             }
         }
         closedir($handle);
     }
     Dropdown::showFromArray("graph_template", $a_templates, array('value' => $this->fields['graph_template']));
     echo "</td>";
     // * calendar
     echo "<td>" . $LANG['plugin_monitoring']['host'][9] . "<font class='red'>*</font>&nbsp;:</td>";
     echo "<td>";
     dropdown::show("Calendar", array('name' => 'calendars_id', 'value' => $this->fields['calendars_id']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th colspan='4'>" . $LANG['plugin_monitoring']['service'][8] . "</th>";
     echo "</tr>";
     echo "<tr>";
     // * remotesystem
     echo "<td>";
     echo $LANG['plugin_monitoring']['service'][9] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $input = array();
     $input[''] = '------';
     $input['byssh'] = 'byssh';
     $input['nrpe'] = 'nrpe';
     $input['nsca'] = 'nsca';
     Dropdown::showFromArray("remotesystem", $input, array('value' => $this->fields['remotesystem']));
     echo "</td>";
     // * is_argument
     echo "<td>";
     echo $LANG['plugin_monitoring']['service'][10] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("is_arguments", $this->fields['is_arguments']);
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     // alias command
     echo "<td>";
     echo $LANG['plugin_monitoring']['service'][11] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='alias_command' value='" . $this->fields['alias_command'] . "' />";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     // * Manage arguments
     $array = array();
     $a_displayarg = array();
     if (isset($pMonitoringCommand->fields['command_line'])) {
         preg_match_all("/\\\$(ARG\\d+)\\\$/", $pMonitoringCommand->fields['command_line'], $array);
         $a_arguments = importArrayFromDB($this->fields['arguments']);
         foreach ($array[0] as $arg) {
             if (strstr($arg, "ARG")) {
                 $arg = str_replace('$', '', $arg);
                 if (!isset($a_arguments[$arg])) {
                     $a_arguments[$arg] = '';
                 }
                 $a_displayarg[$arg] = $a_arguments[$arg];
             }
         }
     }
     if (count($a_displayarg) > 0) {
         $a_tags = $this->tagsAvailable();
         $a_argtext = importArrayFromDB($pMonitoringCommand->fields['arguments']);
         echo "<tr>";
         echo "<th colspan='4'>" . $LANG['plugin_monitoring']['service'][4] . "&nbsp;</th>";
         echo "</tr>";
         foreach ($a_displayarg as $key => $value) {
             echo "<tr>";
             echo "<td>";
             if (isset($a_argtext[$key]) and $a_argtext[$key] != '') {
                 echo nl2br($a_argtext[$key]) . "&nbsp;:";
             } else {
                 echo $LANG['plugin_monitoring']['service'][14] . " (" . $key . ")&nbsp;:";
             }
             echo "</td>";
             echo "<td>";
             echo "<input type='text' name='arg[" . $key . "]' value='" . $value . "'/><br/>";
             echo "</td>";
             if (count($a_tags) > 0) {
                 foreach ($a_tags as $key => $value) {
                     echo "<td class='tab_bg_3'>";
                     echo "<strong>" . $key . "</strong>&nbsp;:";
                     echo "</td>";
                     echo "<td class='tab_bg_3'>";
                     echo $value;
                     echo "</td>";
                     unset($a_tags[$key]);
                     break;
                 }
             } else {
                 echo "<td colspan='2'></td>";
             }
             echo "</tr>";
         }
         foreach ($a_tags as $key => $value) {
             echo "<tr>";
             echo "<td colspan='2'></td>";
             echo "<td class='tab_bg_3'>";
             echo "<strong>" . $key . "</strong>&nbsp;:";
             echo "</td>";
             echo "<td class='tab_bg_3'>";
             echo $value;
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "<tr>";
     echo "<th colspan='4'>" . $LANG['plugin_monitoring']['weathermap'][0] . "&nbsp;</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     echo $LANG['plugin_monitoring']['weathermap'][1] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("is_weathermap", $this->fields['is_weathermap']);
     echo "</td>";
     echo "<td>";
     $tooltip = $LANG['plugin_monitoring']['component'][15] . " :<br/><br/>";
     $tooltip .= "perfdata : <i>inUsage=0.00%;85;98 outUsage=0.00%;85;98 inBandwidth=<strong>789944</strong>.00bps outBandwidth=486006.00bps inAbsolut=0 outAbsolut=12665653</i><br/><br/>";
     $tooltip .= $LANG['plugin_monitoring']['weathermap'][18] . " : <i><strong>(?:.*)inBandwidth=(\\d+)(?:.*)</strong></i><br/><br/>";
     $tooltip .= $LANG['rulesengine'][85] . " : <strong>789944</strong>";
     echo $LANG['plugin_monitoring']['weathermap'][18] . "&nbsp;";
     showToolTip($tooltip, array('autoclose' => false));
     echo "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='weathermap_regex_in' value='" . $this->fields['weathermap_regex_in'] . "' size='40' />";
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='2'>";
     echo "</td>";
     echo "<td>";
     $tooltip = $LANG['plugin_monitoring']['component'][15] . " :<br/><br/>";
     $tooltip .= "perfdata : <i>inUsage=0.00%;85;98 outUsage=0.00%;85;98 inBandwidth=789944.00bps outBandwidth=<strong>486006</strong>.00bps inAbsolut=0 outAbsolut=12665653</i><br/><br/>";
     $tooltip .= $LANG['plugin_monitoring']['weathermap'][19] . " : <i><strong>(?:.*)outBandwidth=(\\d+)(?:.*)</strong></i><br/><br/>";
     $tooltip .= $LANG['rulesengine'][85] . " : <strong>789944</strong>";
     echo $LANG['plugin_monitoring']['weathermap'][19] . "&nbsp;";
     showToolTip($tooltip, array('autoclose' => false));
     echo "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='weathermap_regex_out' value='" . $this->fields['weathermap_regex_out'] . "' size='40' />";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     // Add form for copy item
     if ($items_id != '') {
         $this->fields['id'] = 0;
         $this->showFormHeader($options);
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='4' class='center'>";
         foreach ($this->fields as $key => $value) {
             if ($key != 'id') {
                 echo "<input type='hidden' name='" . $key . "' value='" . $value . "'/>";
             }
         }
         echo "<input type='submit' name='copy' value=\"" . $LANG['setup'][283] . "\" class='submit'>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         echo "</form>";
     }
     return true;
 }