Html::header('OCS Inventory NG', '', "tools", "pluginocsinventoryngmenu", "sync");
$display_list = true;
if (isset($_SESSION["ocs_update"]['computers'])) {
    if ($count = count($_SESSION["ocs_update"]['computers'])) {
        $percent = min(100, round(100 * ($_SESSION["ocs_update_count"] - $count) / $_SESSION["ocs_update_count"], 0));
        $key = array_pop($_SESSION["ocs_update"]['computers']);
        $cfg_ocs = PluginOcsinventoryngOcsServer::getConfig($_SESSION["plugin_ocsinventoryng_ocsservers_id"]);
        $dohistory = isset($cfg_ocs['dohistory']) ? $cfg_ocs['dohistory'] : false;
        $action = PluginOcsinventoryngOcsServer::updateComputer($key, $_SESSION["plugin_ocsinventoryng_ocsservers_id"], $dohistory);
        PluginOcsinventoryngOcsServer::manageImportStatistics($_SESSION["ocs_update"]['statistics'], $action['status']);
        PluginOcsinventoryngOcsServer::showStatistics($_SESSION["ocs_update"]['statistics']);
        Html::displayProgressBar(400, $percent);
        Html::redirect($_SERVER['PHP_SELF']);
    } else {
        if (isset($_SESSION["ocs_update"]['statistics'])) {
            PluginOcsinventoryngOcsServer::showStatistics($_SESSION["ocs_update"]['statistics'], true);
        } else {
            echo "<div class='center b red'>";
            _e('No synchronization: the plugin will not synchronize these elements', 'ocsinventoryng');
            echo "</div>";
        }
        unset($_SESSION["ocs_update"]);
        $display_list = false;
        echo "<div class='center b'><br>";
        echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . __('Back') . "</a></div>";
    }
}
if (!isset($_POST["update_ok"])) {
    if (!isset($_GET['check'])) {
        $_GET['check'] = 'all';
    }
         $_SESSION["ocs_importipdiscover"]["datas"]["b"] = $_GET["b"];
         $_SESSION["ocs_importipdiscover"]["datas"]["macAdresses"] = $macAdresses;
         Html::redirect($_SERVER['PHP_SELF']);
     }
 } else {
     if (isset($_SESSION["ocs_importipdiscover"]["datas"])) {
         $action = null;
         while ($ipObject = array_pop($_SESSION["ocs_importipdiscover"]["datas"]["ipObjects"])) {
             $percent = min(100, round(100 * (sizeof($_SESSION["ocs_importipdiscover"]["datas"]["macAdresses"]) - sizeof($_SESSION["ocs_importipdiscover"]["datas"]["ipObjects"])) / sizeof($_SESSION["ocs_importipdiscover"]["datas"]["macAdresses"]), 0));
             $action = $ip->processIpDiscover($ipObject, $_SESSION["plugin_ocsinventoryng_ocsservers_id"], $_POST["subnet"]);
             PluginOcsinventoryngOcsServer::manageImportStatistics($_SESSION["ocs_importipdiscover"]['statistics'], $action['status'], false, true);
             PluginOcsinventoryngOcsServer::showStatistics($_SESSION["ocs_importipdiscover"]['statistics'], false, false, true);
             Html::displayProgressBar(400, $percent);
             Html::redirect($_SERVER['PHP_SELF']);
         }
         PluginOcsinventoryngOcsServer::showStatistics($_SESSION["ocs_importipdiscover"]['statistics'], false, false, true);
         if (isset($_GET["b"])) {
             $b = $_GET["b"];
             $ipAdress = $b[0];
             $status = $b[1];
             echo "<div class='center b'><br>";
             echo "<a href='" . $_SERVER['PHP_SELF'] . "?ip={$ipAdress}&status={$status}'>" . __('Back') . "</a></div>";
         }
         if (isset($_SESSION["ocs_importipdiscover"]["datas"]["b"])) {
             $b = $_SESSION["ocs_importipdiscover"]["datas"]["b"];
             $ipAdress = $b[0];
             $status = $b[1];
             echo "<div class='center b'><br>";
             echo "<a href='" . $_SERVER['PHP_SELF'] . "?ip={$ipAdress}&status={$status}'>" . __('Back') . "</a></div>";
         }
         if (isset($_SESSION["ocs_importipdiscover"]["datas"])) {