function show_panel($id, $config)
 {
     global $DB, $CFG_GLPI;
     $pmDisplayview = new PluginMonitoringDisplayview();
     $pmDisplayview->getFromDB($id);
     $queryitems = "SELECT * FROM `glpi_plugin_monitoring_displayviews_items`\n         WHERE `plugin_monitoring_displayviews_id`='" . $id . "'";
     $resultitems = $DB->query($queryitems);
     $a_items = array();
     while ($dataitems = $DB->fetch_array($resultitems)) {
         //         if ($this->displayItem($dataitems, $config)) {
         $a_items[] = $dataitems;
         //         }
         //         }
     }
     echo "\n      <script type=\"text/javascript\">\n      \$(function() {\n      ";
     foreach ($a_items as $item) {
         if ($config == '1') {
             $event = ", stop: function() {\n                 pos = \$('#draggable" . $item['id'] . "').position();\n                 \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/displayview_itemcoordinates.php" . "?id=" . $item['id'] . "&x=' + pos.left + '&y=' + pos.top);\n               }";
         } else {
             $event = '';
         }
         $size = $this->getSizeOfWidget($item['itemtype']);
         echo "\$( \"#draggable" . $item['id'] . "\" ).draggable({ cursor: 'move', cursorAt: { " . "top: " . $size['height'] / 2 . ", left: " . $size['width'] / 2 . ", " . " }, grid: [ 10, 10 ]" . $event . " } );";
     }
     echo "\n      });\n      </script>";
     echo "<div id='viewform' style='width: " . $pmDisplayview->fields['width'] . "px;height:1200px;position: relative;'>";
     foreach ($a_items as $item) {
         $itemtype2 = '';
         $size = $this->getSizeOfWidget($item['itemtype']);
         echo '<div id="draggable' . $item['id'] . '" ';
         if ($item['itemtype'] != 'PluginMonitoringServicescatalog' && $item['itemtype'] != 'PluginMonitoringComponentscatalog' && $item['itemtype'] != 'PluginMonitoringDisplayview' && $item['itemtype'] != 'host' && !($item['itemtype'] == 'PluginMonitoringWeathermap' && $item['items_id'] == -1)) {
             echo 'class="ui-widget-content" ';
         }
         if ($item['itemtype'] == 'host' || $item['itemtype'] == 'service') {
             $itemtype2 = $item['itemtype'];
             $item['itemtype'] = 'PluginMonitoringDisplayview';
         }
         if ($item['itemtype'] == 'PluginMonitoringService') {
             echo 'style="width: ' . $size['width'] . 'px; height: ' . $size['height'] . 'px; ' . 'position: absolute; left: ' . $item['x'] . 'px; top: ' . $item['y'] . 'px;">';
             $pmComponent = new PluginMonitoringComponent();
             $pmService = new PluginMonitoringService();
             if ($pmService->getFromDB($item['items_id'])) {
                 $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']);
                 $pmServicegraph = new PluginMonitoringServicegraph();
                 $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $item['items_id'], "0", $item['extra_infos'], "", $size['width'] - 15);
             } else {
                 $this->delete($item);
             }
         } else {
             if ($item['itemtype'] == 'PluginMonitoringWeathermap') {
                 if ($item['items_id'] == -1) {
                     $title = " : " . __('Legend', 'monitoring');
                     echo 'style="width: 400px; height: 51px; ' . 'position: absolute; left: ' . $item['x'] . 'px; top: ' . $item['y'] . 'px;">';
                 } else {
                     $weathermap = new PluginMonitoringWeathermap();
                     $weathermap->getFromDB($item['items_id']);
                     //            $title .= " : ".Dropdown::getDropdownName(
                     //                     getTableForItemType('PluginMonitoringWeathermap'), $item['items_id']);
                     $width = $weathermap->fields['width'] * $item['extra_infos'] / 100;
                     $height = $weathermap->fields['height'] * $item['extra_infos'] / 100;
                     echo 'style="width: ' . $width . 'px; height: ' . $height . 'px; ' . 'position: absolute; left: ' . $item['x'] . 'px; top: ' . $item['y'] . 'px;">';
                 }
                 echo '<div id="weathermap-' . $item['items_id'] . '"></div>';
                 echo "<script type=\"text/javascript\">\n                  (function worker() {\n                    \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/widgetWeathermap.php?" . "id=" . $item['items_id'] . "&extra_infos=" . $item['extra_infos'] . "&glpiID=" . $_SESSION['glpiID'] . "', function(data) {\n                      \$('#weathermap-" . $item['items_id'] . "').html(data);\n                      setTimeout(worker, 50000);\n                    });\n                  })();\n               </script>";
             } else {
                 if ($item['itemtype'] == "PluginMonitoringDisplayview") {
                     echo 'style="width: ' . $size['width'] . 'px; height: ' . $size['height'] . 'px; ' . 'position: absolute; left: ' . $item['x'] . 'px; top: ' . $item['y'] . 'px;">';
                     $pmDisplayview = new PluginMonitoringDisplayview();
                     if (!empty($itemtype2)) {
                         echo "<div id=\"updatedisplayview" . $item['id'] . "\"></div>";
                         $pmDisplayview->ajaxLoad2($item['id'], $item['is_minemap']);
                     } else {
                         echo "<div id=\"updatedisplayview" . $item['items_id'] . "\"></div>";
                         $pmDisplayview->ajaxLoad($item['items_id']);
                     }
                 } else {
                     echo 'style="width: ' . $size['width'] . 'px; height: ' . $size['height'] . 'px; ' . 'position: absolute; left: ' . $item['x'] . 'px; top: ' . $item['y'] . 'px;">';
                     echo "<div id=\"update" . $item['itemtype'] . $item['items_id'] . "\"></div>";
                     echo "<script type=\"text/javascript\">";
                     echo "\n                     (function worker() {\n                       \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/updateWidgetComponentscatalog.php" . "?id=" . $item['items_id'] . "&is_minemap=" . $item['is_minemap'] . "', function(data) {\n                         \$('#update" . $item['itemtype'] . $item['items_id'] . "').html(data);\n                         setTimeout(worker, 30000);\n                       });\n                     })();";
                     echo "</script>";
                 }
             }
         }
         echo '</div>';
     }
     //      echo "<script type='text/javascript'>
     //
     //        //Simple 'border layout' panel to house both grids
     //        var displayPanel = new Ext.Panel({
     //          id       : 'viewpanel',
     //          width    : ".$pmDisplayview->fields['width'].",
     //          height   : 1200,
     //          layout: 'absolute',
     //          renderTo : 'panel',
     //          items    : []
     //        });
     //
     //      </script>";
     echo "</div>";
     echo "<script type=\"text/javascript\">\n         function reloadview() {\n              \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/loadView.php?id=' + \$('#updateviewid').val() + '&config=" . $config . "', function(data) {\n                \$('#viewform').html(data);\n               });\n         }\n      </script>";
 }
  ------------------------------------------------------------------------
*/
if (strpos($_SERVER['PHP_SELF'], "widgetWeathermap.php")) {
    include "../../../inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
session_write_close();
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
if (!isset($_GET["id"]) or !isset($_GET['extra_infos'])) {
    exit;
}
$pmWeathermap = new PluginMonitoringWeathermap();
$pmWeathermap->getFromDB($_GET['id']);
echo "<center>";
if ($_GET["id"] == -1) {
    echo "<table width='100%' class='tab_cadre'>";
} else {
    echo "<table width='100%'>";
}
echo "<tr>";
echo "<th>";
if ($_GET["id"] == -1) {
    echo __('Weathermap legend', 'monitoring');
} else {
    echo $pmWeathermap->getName();
    if ($_GET['extra_infos'] < 100) {
        echo " <a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/weathermap_full.php?id=" . $_GET["id"] . "' target='_blank'>(" . __('full 100%', 'monitoring') . ")</a>";
    }
include ("../../../inc/includes.php");

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

$pmSecurity = new PluginMonitoringSecurity();
$pmSecurity->isSecure();
PluginMonitoringSecurity::deleteCheckSessionTime();

if (!isset($_POST["id"])
        OR !isset($_POST['extra_infos'])) {
   exit();
}

$pmWeathermap = new PluginMonitoringWeathermap();
$pmWeathermap->getFromDB($_POST['id']);

echo "<center>";
if ($_POST["id"] == -1) {
   echo "<table width='100%' class='tab_cadre'>";
} else {
   echo "<table width='100%'>";
}
echo "<tr>";
echo "<th>";
if ($_POST["id"] == -1) {
   echo __('Weathermap legend', 'monitoring');
} else {
   echo $pmWeathermap->getName();
   if ($_POST['extra_infos'] < 100) {
      echo " <a href='".$CFG_GLPI['root_doc'].