static function displayHostLine($data)
 {
     global $DB, $CFG_GLPI;
     $pm_Host = new PluginMonitoringHost();
     $pm_Host->getFromDB($data['id']);
     if ($data[3]['displayname'] == '') {
         $data[3]['displayname'] = 'UNKNOWN';
         $data[4]['displayname'] = 'SOFT';
     }
     $shortstate = $pm_Host->getState($data[3]['displayname'], $data[4]['displayname'], $data[6]['displayname'], $pm_Host->isCurrentlyAcknowledged());
     echo "<td>";
     echo $data[0]['displayname'];
     echo "</td>";
     echo "<td>";
     $item = new $data[1]['displayname']();
     echo $item->getTypeName();
     echo "</td>";
     echo "<td>";
     echo "<span>" . $pm_Host->getLink() . "</span>";
     echo "</td>";
     echo "<td class='center'>";
     echo "<div class='page foldtl resource" . $data[3]['displayname'] . " resource" . $data[4]['displayname'] . "'>";
     echo "<div style='vertical-align:middle;'>";
     echo "<span>";
     echo $data[3]['displayname'];
     echo "</span>";
     echo "</div>";
     echo "</div>";
     echo "</td>";
     if (isset($data['host_command_name'])) {
         $scriptName = $CFG_GLPI['root_doc'] . "/plugins/monitoring/scripts/" . $data['host_command_command'];
         $scriptArgs = $data[2]['displayname'] . " " . $data['ip'];
         echo "<td class='center'>";
         echo "<form name='form' method='post'\n            action='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/" . $data['host_command_command'] . ".php'>";
         echo "<input type='hidden' name='host_id' value='" . $data[9]['displayname'] . "' />";
         echo "<input type='hidden' name='host_name' value='" . $data[2]['displayname'] . "' />";
         echo "<input type='hidden' name='host_ip' value='" . $data['ip'] . "' />";
         echo "<input type='hidden' name='host_state' value='" . $data[3]['displayname'] . "' />";
         echo "<input type='hidden' name='host_statetype' value='" . $data[4]['displayname'] . "' />";
         echo "<input type='hidden' name='host_event' value='" . $data[6]['displayname'] . "' />";
         echo "<input type='hidden' name='host_perfdata' value='" . $data[7]['displayname'] . "' />";
         echo "<input type='hidden' name='host_last_check' value='" . $data[5]['displayname'] . "' />";
         echo "<input type='hidden' name='glpi_users_id' value='" . $_SESSION['glpiID'] . "' />";
         echo "<input type='submit' name='host_command' value=\"" . $data['host_command_name'] . "\" class='submit'>";
         Html::closeForm();
         echo "</td>";
     }
     echo "<td class='center'>";
     echo "<div class='page foldtl resource" . $data['host_services_state'] . "'>";
     echo "<div style='vertical-align:middle;'>";
     echo "<span>";
     if (Session::haveRight("plugin_monitoring_service", READ)) {
         $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=1" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $data[9]['displayname'] . "&itemtype=PluginMonitoringService" . "&start=0'";
         echo '<a href="' . $link . '">' . $data['host_services_state'] . "</a>";
     } else {
         echo '<span>' . $data['host_services_state'] . "</span>";
     }
     if (!empty($data['host_services_state_list'])) {
         echo "&nbsp;" . Html::showToolTip($data['host_services_state_list'], array('display' => false));
     }
     echo "</span>";
     echo "</div>";
     echo "</div>";
     echo "</td>";
     echo "<td>";
     echo $data['ip'];
     echo "</td>";
     echo "<td>";
     echo Html::convDate($data[5]['displayname']) . ' ' . substr($data[5]['displayname'], 11, 8);
     echo "</td>";
     echo "<td>";
     echo $data[6]['displayname'];
     echo "</td>";
     echo "<td>";
     echo $data[7]['displayname'];
     echo "</td>";
     if (Session::haveRight("plugin_monitoring_acknowledge", READ) || Session::haveRight("plugin_monitoring_downtime", READ)) {
         echo "<td>";
         // Manage downtimes for an host
         if (Session::haveRight("plugin_monitoring_downtime", READ)) {
             if ($pm_Host->isInScheduledDowntime()) {
                 $pmDowntime = new PluginMonitoringDowntime();
                 $pmDowntime->getFromDBByQuery("WHERE `" . $pmDowntime->getTable() . "`.`plugin_monitoring_hosts_id` = '" . $pm_Host->getID() . "' ORDER BY end_time DESC LIMIT 1");
                 $downtime_id = $pmDowntime->getID();
                 // Toolbox::logInFile("pm", "Host ".$pm_Host->getName()." is in downtime period \n");
                 if (Session::haveRight("plugin_monitoring_downtime", CREATE)) {
                     echo "<div style='float: left; margin-right: 10px;'>";
                     echo "<span>";
                     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/downtime.form.php?host_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/downtime_scheduled.png'" . " alt='" . htmlspecialchars(__('Edit the downtime scheduled for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Edit the downtime scheduled for the host', 'monitoring'), ENT_QUOTES) . "'/>" . "</a>";
                     echo "&nbsp;&nbsp;</span>";
                     echo "</div>";
                 } else {
                     echo "<div style='float: left; margin-right: 10px;'>";
                     echo "<span>";
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/downtime_scheduled.png'" . " alt='" . htmlspecialchars(__('A downtime is scheduled for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('A downtime is scheduled for the host', 'monitoring'), ENT_QUOTES) . "'/>";
                     echo "&nbsp;&nbsp;</span>";
                     echo "</div>";
                 }
             } else {
                 if (Session::haveRight("plugin_monitoring_downtime", CREATE)) {
                     echo "<div style='float: left; margin-right: 10px;'>";
                     echo "<span>";
                     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/downtime.form.php?id=-1&host_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/downtime_to_schedule.png'" . " alt='" . htmlspecialchars(__('Schedule a downtime for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Schedule a downtime for the host', 'monitoring'), ENT_QUOTES) . "'/>" . "</a>";
                     echo "&nbsp;&nbsp;</span>";
                     echo "</div>";
                 }
             }
         }
         echo "<div style='float: left;'>";
         // Manage acknowledgement for an host
         if ($pm_Host->isCurrentlyAcknowledged()) {
             if (Session::haveRight("plugin_monitoring_acknowledge", CREATE)) {
                 echo "<span>";
                 echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?itemtype=Host&items_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_ok.png'" . " alt='" . htmlspecialchars(__('Modify acknowledge comment for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Modify acknowledge comment for the host', 'monitoring'), ENT_QUOTES) . "'" . " width='25' height='20'/>" . "</a>";
                 echo "&nbsp;&nbsp;</span>";
             } else {
                 echo "<span>";
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_ok.png'" . " alt='" . htmlspecialchars(__('Host problem has been acknowledged', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Host problem has been acknowledged', 'monitoring'), ENT_QUOTES) . "'" . " width='25' height='20'/>";
                 echo "&nbsp;&nbsp;</span>";
             }
             // Display acknowledge data ...
             $pm_Host->getAcknowledge();
         } else {
             if ($shortstate == 'red' || $shortstate == 'yellow' || $shortstate == 'orange' || !empty($data['host_services_state_list'])) {
                 if (Session::haveRight("plugin_monitoring_acknowledge", CREATE)) {
                     echo "<span>";
                     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?itemtype=Host&items_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_ko.png'" . " alt='" . htmlspecialchars(__('Add an acknowledge for the host and all faulty services of the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Add an acknowledge for the host and all faulty services of the host', 'monitoring'), ENT_QUOTES) . "'" . " width='25' height='20'/>" . "</a>";
                     echo "&nbsp;&nbsp;</span>";
                 }
             }
         }
         echo "</div>";
         echo "</td>";
     }
 }
    /**
     * Display info of device
     *
     * @global type $DB      Toolbox::logDebug($this->fields);
     * @param type $id
     */
    function showWidget2Frame($id, $is_minemap = FALSE)
    {
        global $DB, $CFG_GLPI;
        $pmDisplayview_item = new PluginMonitoringDisplayview_item();
        $pmDisplayview_item->getFromDB($id);
        $itemtype = $pmDisplayview_item->fields['extra_infos'];
        $item = new $itemtype();
        $item->getFromDB($pmDisplayview_item->fields['items_id']);
        $critical = 0;
        $warning = 0;
        $ok = 0;
        $acknowledge = 0;
        $query = "SELECT * FROM `glpi_plugin_monitoring_services`" . " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`" . "    ON `plugin_monitoring_componentscatalogs_hosts_id`=" . " `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`" . " WHERE `items_id`='" . $item->fields['id'] . "'" . " AND `itemtype`='" . $itemtype . "'" . " AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL" . " ORDER BY `glpi_plugin_monitoring_services`.`name`";
        $result = $DB->query($query);
        $services = array();
        $resources = array();
        $i = 0;
        while ($data = $DB->fetch_array($result)) {
            $ret = PluginMonitoringHost::getState($data['state'], $data['state_type'], '', $data['is_acknowledged']);
            if (strstr($ret, '_soft')) {
                $ok++;
                $resources[$data['id']]['state'] = 'OK';
            } else {
                if ($ret == 'red') {
                    $critical++;
                    $resources[$data['id']]['state'] = 'CRITICAL';
                } else {
                    if ($ret == 'redblue') {
                        $acknowledge++;
                        $resources[$data['id']]['state'] = 'ACKNOWLEDGE';
                    } else {
                        if ($ret == 'orange' || $ret == 'yellow') {
                            $warning++;
                            $resources[$data['id']]['state'] = 'WARNING';
                        } else {
                            $ok++;
                            $resources[$data['id']]['state'] = 'OK';
                        }
                    }
                }
            }
            $services[$i++] = $data['id'];
            $resources[$data['id']]['last_check'] = $data['last_check'];
            $resources[$data['id']]['event'] = $data['event'];
            $resources[$data['id']]['name'] = $data['name'];
            $resources[$data['id']]['plugin_monitoring_components_id'] = $data['plugin_monitoring_components_id'];
        }
        $class = 'ok';
        if ($critical > 0) {
            $nb_ressources = $critical;
            $class = 'crit';
        } else {
            if ($warning > 0) {
                $nb_ressources = $warning;
                $class = 'warn';
            } else {
                $nb_ressources = $ok;
            }
        }
        echo '<div class="ch-item">
         <div class="ch-info-' . $class . '">
			<h1><a href="';
        if ($item->can($item->getID(), READ)) {
            echo $item->getFormURL() . '?id=' . $item->getID() . '&forcetab=PluginMonitoringHost$0';
        } else {
            echo $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayhost.php?itemtype=" . $itemtype . "&items_id=" . $item->getID();
        }
        echo '">' . '<span id="devicea-' . $id . '">' . $item->getName() . '</span></a></h1>
			<p><a>' . $nb_ressources . '</a><font style="font-size: 14px;"> / ' . ($ok + $warning + $critical + $acknowledge) . '</font></p>
         </div>
		</div>';
        echo "<script>\n         fittext('devicea-" . $id . "');\n      </script>";
        echo "<div class='minemapdiv' align='center'>" . "<a onclick='\$(\"#minemapdisplayview2-" . $id . "\").toggle()'>" . "Minemap</a></div>";
        if (!$is_minemap) {
            echo '<div class="minemapdiv" id="minemapdisplayview2-' . $id . '" style="display: none; z-index: 1500">';
        } else {
            echo '<div class="minemapdiv" id="minemapdisplayview2-' . $id . '">';
        }
        echo '<table class="tab_cadrehov" >';
        // Get services list ...
        echo '<div class="minemapdiv">';
        echo '<table class="tab_cadrehov">';
        // Header with services name and link to services list ...
        echo '<tr class="tab_bg_2">';
        echo '<th colspan="2">';
        echo __('Services', 'monitoring');
        echo '</th>';
        echo '</tr>';
        // Content with host/service status and link to services list ...
        foreach ($services as $services_id) {
            $field_id = 20;
            if ($itemtype == 'Printer') {
                $field_id = 21;
            } else {
                if ($itemtype == 'NetworkEquipment') {
                    $field_id = 22;
                }
            }
            $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=" . $field_id . "" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $item->getID() . "&criteria[1][link]=AND" . "&criteria[1][field]=2" . "&criteria[1][searchtype]=equals" . "&criteria[1][value]=" . $resources[$services_id]['plugin_monitoring_components_id'] . "&itemtype=PluginMonitoringService" . "&start=0'";
            echo "<tr class='tab_bg_2'>";
            echo "<td class='left'><a href='" . $link . "'>" . $resources[$services_id]['name'] . "</a></td>";
            echo '<td>';
            echo '<a href="' . $link . '" title="' . $resources[$services_id]['state'] . " - " . $resources[$services_id]['last_check'] . " - " . $resources[$services_id]['event'] . '">' . '<div class="service service' . $resources[$services_id]['state'] . '"></div></a>';
            echo '</td>';
            echo '</tr>';
        }
        echo '</table>';
        echo '</div>';
    }