--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("plugin_ocsinventoryng", UPDATE);
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>";
}
}