/**
  * @param $plugin_ocsinventoryng_ocsservers_id
  * @param $check
  * @param $start
  * @return bool|void
  */
 static function showSnmpDeviceToUpdate($plugin_ocsinventoryng_ocsservers_id, $check, $start)
 {
     global $DB, $CFG_GLPI;
     PluginOcsinventoryngOcsServer::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
     if (!Session::haveRight("plugin_ocsinventoryng", UPDATE)) {
         return false;
     }
     // Get linked computer ids in GLPI
     $already_linked_query = "SELECT `glpi_plugin_ocsinventoryng_snmpocslinks`.`ocs_id` AS ocsid\n                               FROM `glpi_plugin_ocsinventoryng_snmpocslinks`\n                               WHERE `glpi_plugin_ocsinventoryng_snmpocslinks`.`plugin_ocsinventoryng_ocsservers_id`\n                                            = '{$plugin_ocsinventoryng_ocsservers_id}'";
     $already_linked_result = $DB->query($already_linked_query);
     if ($DB->numrows($already_linked_result) == 0) {
         echo "<div class='center b'>" . __('No new SNMP device to be updated', 'ocsinventoryng') . "</div>";
         return;
     }
     $already_linked_ids = array();
     while ($data = $DB->fetch_assoc($already_linked_result)) {
         $already_linked_ids[] = $data['ocsid'];
     }
     // Fetch linked items from ocs
     $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($plugin_ocsinventoryng_ocsservers_id);
     $ocsResult = $ocsClient->getSnmp(array('ORDER' => 'LASTDATE', 'FILTER' => array('IDS' => $already_linked_ids)));
     if (isset($ocsResult['SNMP'])) {
         if (count($ocsResult['SNMP']) > 0) {
             // Get all ids of the returned items
             $ocs_snmp_ids = array();
             $hardware = array();
             $snmps = array_slice($ocsResult['SNMP'], $start, $_SESSION['glpilist_limit']);
             foreach ($snmps as $snmp) {
                 $LASTDATE = $snmp['META']['LASTDATE'];
                 $ocs_snmp_inv[$snmp['META']['ID']] = $LASTDATE;
                 $NAME = $snmp['META']['NAME'];
                 $ocs_snmp_name[$snmp['META']['ID']] = $NAME;
                 $ID = $snmp['META']['ID'];
                 $ocs_snmp_ids[] = $ID;
                 if (isset($snmp['PRINTER'])) {
                     $TYPE = "printer";
                 } else {
                     $TYPE = "";
                 }
                 $ocs_snmp_type[$snmp['META']['ID']] = $TYPE;
             }
             // query snmp links
             $query = "SELECT * FROM `glpi_plugin_ocsinventoryng_snmpocslinks`\n                WHERE `glpi_plugin_ocsinventoryng_snmpocslinks`.`ocs_id` IN (" . implode(',', $ocs_snmp_ids) . ")";
             $result = $DB->query($query);
             // Get all links between glpi and OCS
             $already_linked = array();
             if ($DB->numrows($result) > 0) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
                     $format = 'Y-m-d H:i:s';
                     //                  $last_glpi_update = DateTime::createFromFormat($format, $data['last_update']);
                     //                  $last_ocs_inventory = DateTime::createFromFormat($format, $ocs_snmp_inv[$data['ocs_id']]);
                     //TODOSNMP comment for test
                     //if ($last_ocs_inventory > $last_glpi_update) {
                     $already_linked[$data['id']] = $data;
                     //}
                 }
             }
             echo "<div class='center'>";
             echo "<h2>" . __('Snmp device updated in OCSNG', 'ocsinventoryng') . "</h2>";
             $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsngsnmp.sync.php';
             if (($numrows = $ocsResult['TOTAL_COUNT']) > 0) {
                 $parameters = "check={$check}";
                 Html::printPager($start, $numrows, $target, $parameters);
                 echo "<form method='post' id='ocsng_form' name='ocsng_form' action='" . $target . "'>";
                 PluginOcsinventoryngOcsServer::checkBox($target);
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'><td colspan='6' class='center'>";
                 echo "<input class='submit' type='submit' name='update_ok' value=\"" . _sx('button', 'Synchronize', 'ocsinventoryng') . "\">";
                 echo "&nbsp;<input class='submit' type='submit' name='delete' value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\">";
                 echo "</td></tr>\n";
                 echo "<tr>";
                 echo "<th>" . __('GLPI Object', 'ocsinventoryng') . "</th>";
                 echo "<th>" . __('Item type') . "</th>";
                 echo "<th>" . __('OCS SNMP device', 'ocsinventoryng') . "</th>";
                 echo "<th>" . __('Import date in GLPI', 'ocsinventoryng') . "</th>";
                 echo "<th>" . __('Last OCSNG SNMP inventory date', 'ocsinventoryng') . "</th>";
                 echo "<th>&nbsp;</th></tr>\n";
                 foreach ($already_linked as $ID => $tab) {
                     echo "<tr class='tab_bg_2 center'>";
                     $item = new $tab["itemtype"]();
                     $item->getFromDB($tab["items_id"]);
                     echo "<td>" . $item->getLink() . "</td>\n";
                     echo "<td>" . $item->getTypeName() . "</td>\n";
                     echo "<td>" . $ocs_snmp_name[$tab["ocs_id"]] . "</td>\n";
                     echo "<td>" . Html::convDateTime($tab["last_update"]) . "</td>\n";
                     echo "<td>" . Html::convDateTime($ocs_snmp_inv[$tab["ocs_id"]]) . "</td>\n";
                     echo "<td><input type='checkbox' name='toupdate[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . ">";
                     echo "</td></tr>\n";
                 }
                 echo "<tr class='tab_bg_1'><td colspan='6' class='center'>";
                 echo "<input class='submit' type='submit' name='update_ok' value=\"" . _sx('button', 'Synchronize', 'ocsinventoryng') . "\">";
                 echo "&nbsp;<input class='submit' type='submit' name='delete' value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\">";
                 echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='{$plugin_ocsinventoryng_ocsservers_id}'>";
                 echo "</td></tr>";
                 echo "<tr class='tab_bg_1'><td colspan='6' class='center'>";
                 PluginOcsinventoryngOcsServer::checkBox($target);
                 echo "</table>\n";
                 Html::closeForm();
                 Html::printPager($start, $numrows, $target, $parameters);
             } else {
                 echo "<br><span class='b'>" . __('Update SNMP device', 'ocsinventoryng') . "</span>";
             }
             echo "</div>";
         } else {
             echo "<div class='center b'>" . __('No new SNMP device to be updated', 'ocsinventoryng') . "</div>";
         }
     } else {
         echo "<div class='center b'>" . __('No new SNMP device to be updated', 'ocsinventoryng') . "</div>";
     }
 }