Skip to content

Commit

Permalink
Fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr committed Nov 22, 2022
1 parent 4f59374 commit 8d7f3bd
Show file tree
Hide file tree
Showing 16 changed files with 8,541 additions and 8,006 deletions.
435 changes: 226 additions & 209 deletions ajax/loadcomputerstoimport.php

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions front/ocsng.import.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
}

if (isset($_SESSION["ocs_import"]['computers'])) {

if ((isset($_SESSION["ocs_import"]["connection"])
&& $_SESSION["ocs_import"]["connection"] == false)
|| !isset($_SESSION["ocs_import"]["connection"])) {
Expand All @@ -58,17 +57,19 @@
$_SESSION["ocs_import"]["id"] = [];

Html::redirect($_SERVER['PHP_SELF']);

} else {
$_SESSION["ocs_import"]["connection"] = true;
}
}

if ($count = count($_SESSION["ocs_import"]['computers'])) {

$percent = min(100,
round(100 * ($_SESSION["ocs_import_count"] - $count) / $_SESSION["ocs_import_count"],
0));
$percent = min(
100,
round(
100 * ($_SESSION["ocs_import_count"] - $count) / $_SESSION["ocs_import_count"],
0
)
);

$key = array_pop($_SESSION["ocs_import"]['computers']);

Expand Down Expand Up @@ -106,20 +107,19 @@

$action = PluginOcsinventoryngOcsProcess::processComputer($process_params);

PluginOcsinventoryngOcsProcess::manageImportStatistics($_SESSION["ocs_import"]['statistics'],
$action['status']);
PluginOcsinventoryngOcsProcess::manageImportStatistics(
$_SESSION["ocs_import"]['statistics'],
$action['status']
);
Html::displayProgressBar(400, $percent);

Html::redirect($_SERVER['PHP_SELF']);

}
}

if (isset($_SESSION["plugin_ocsinventoryng_ocsservers_id"])
&& $_SESSION["plugin_ocsinventoryng_ocsservers_id"] > -1) {

if (!isset($_POST["import_ok"])) {

$ocsClient = PluginOcsinventoryngOcsServer::getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"]);
$deleted_pcs = $ocsClient->getTotalDeletedComputers();
if ($deleted_pcs > 0) {
Expand All @@ -134,7 +134,6 @@
'import_mode' => $_SESSION["change_import_mode"],
'entities_id' => $_SESSION['glpiactiveentities']];
PluginOcsinventoryngOcsServer::showComputersToAdd($show_params);

} else {
if (isset($_POST['toadd']) && count($_POST['toadd']) > 0) {
$_SESSION["ocs_import_count"] = 0;
Expand Down Expand Up @@ -166,7 +165,6 @@
}
Html::redirect($_SERVER['PHP_SELF']);
}

} else {
echo "<div align='center'>";
echo "<i class='fas fa-exclamation-triangle fa-4x' style='color:orange'></i>";
Expand Down
21 changes: 12 additions & 9 deletions front/ocsng.sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@

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));
$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"]);
$sync_params = ['ID' => $key,
'plugin_ocsinventoryng_ocsservers_id' => $_SESSION["plugin_ocsinventoryng_ocsservers_id"],
'cfg_ocs' => $cfg_ocs,
'force' => 0];
'force' => 1];
$action = PluginOcsinventoryngOcsProcess::synchronizeComputer($sync_params);

PluginOcsinventoryngOcsProcess::manageImportStatistics($_SESSION["ocs_update"]['statistics'],
$action['status']);
PluginOcsinventoryngOcsProcess::manageImportStatistics(
$_SESSION["ocs_update"]['statistics'],
$action['status']
);
Html::displayProgressBar(400, $percent);

Html::redirect($_SERVER['PHP_SELF']);
Expand All @@ -61,7 +67,6 @@
if (isset($_SESSION["plugin_ocsinventoryng_ocsservers_id"])
&& $_SESSION["plugin_ocsinventoryng_ocsservers_id"] > -1) {
if (!isset($_POST["update_ok"])) {

$ocsClient = PluginOcsinventoryngOcsServer::getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"]);
$deleted_pcs = $ocsClient->getTotalDeletedComputers();
if ($deleted_pcs > 0) {
Expand All @@ -77,7 +82,6 @@
$show_params = ['plugin_ocsinventoryng_ocsservers_id' => $_SESSION["plugin_ocsinventoryng_ocsservers_id"]];
PluginOcsinventoryngOcsServer::showComputersToSynchronize($show_params);
}

} else {
if (isset($_POST['toupdate']) && count($_POST['toupdate']) > 0) {
$_SESSION["ocs_update_count"] = 0;
Expand All @@ -89,7 +93,6 @@
}
Html::redirect($_SERVER['PHP_SELF']);
}

} else {
echo "<div align='center'>";
echo "<i class='fas fa-exclamation-triangle fa-4x' style='color:orange'></i>";
Expand Down
Loading

0 comments on commit 8d7f3bd

Please sign in to comment.