/** * @param $target **/ function showProcesses($target) { global $DB, $CFG_GLPI; $canedit = Session::haveRight("plugin_ocsinventoryng", UPDATE); $config = new PluginOcsinventoryngConfig(); $config->getFromDB(1); $minfreq = 9999; //$task = new CronTask(); //if ($task->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) { //First of all, deleted old processes // $this->deleteOldProcesses($task->fields['param']); // if ($task->fields['param'] > 0) { // $minfreq=$task->fields['param']; // } //} $imported_number = new PluginOcsinventoryngMiniStat(); $synchronized_number = new PluginOcsinventoryngMiniStat(); $linked_number = new PluginOcsinventoryngMiniStat(); $failed_number = new PluginOcsinventoryngMiniStat(); $notupdated_number = new PluginOcsinventoryngMiniStat(); $notunique_number = new PluginOcsinventoryngMiniStat(); $linkedrefused_number = new PluginOcsinventoryngMiniStat(); $process_time = new PluginOcsinventoryngMiniStat(); $sql = "SELECT `id`, `processid`, SUM(`total_number_machines`) AS total_machines,\n `plugin_ocsinventoryng_ocsservers_id`, `status`, COUNT(*) AS threads_number,\n MIN(`start_time`) AS starting_date, MAX(`end_time`) AS ending_date,\n TIME_TO_SEC(MAX(`end_time`)) - TIME_TO_SEC(MIN(`start_time`)) AS duree,\n SUM(`imported_machines_number`) AS imported_machines,\n SUM(`synchronized_machines_number`) AS synchronized_machines,\n SUM(`linked_machines_number`) AS linked_machines,\n SUM(`failed_rules_machines_number`) AS failed_rules_machines,\n SUM(`notupdated_machines_number`) AS notupdated_machines,\n SUM(`not_unique_machines_number`) AS not_unique_machines_number,\n SUM(`link_refused_machines_number`) AS link_refused_machines_number,\n `end_time` >= DATE_ADD(NOW(), INTERVAL - " . $minfreq . " HOUR) AS DoStat\n FROM `" . $this->getTable() . "`\n GROUP BY `processid`\n ORDER BY `id` DESC\n LIMIT 50"; $result = $DB->query($sql); echo "<div class='center'>"; echo "<form name='processes' id='processes' action='{$target}' method='post'>"; echo "<table class='tab_cadrehov'>"; echo "<tr><th colspan='16'>" . __('Processes execution of automatic actions', 'ocsinventoryng') . "</th></tr>"; echo "<tr>"; echo "<th> </th>"; echo "<th> </th>"; echo "<th>" . __('Status') . "</th>"; echo "<th>" . __('Number of threads', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Beginning date of execution', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Ending date of execution', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers imported by automatic actions', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers synchronized', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers linked', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers not imported by automatic actions', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers not updated', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers not unique', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers refused', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Process time execution', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Server') . "</th>"; echo "<th> </th>"; echo "</th></tr>\n"; if ($DB->numrows($result)) { while ($thread = $DB->fetch_array($result)) { if ($config->fields["is_displayempty"] || $thread["status"] != PLUGIN_OCSINVENTORYNG_STATE_FINISHED || !$config->fields["is_displayempty"] && $thread["total_machines"] > 0 && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) { if ($thread["DoStat"] && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) { $imported_number->AddValue($thread["imported_machines"]); $synchronized_number->AddValue($thread["synchronized_machines"]); $linked_number->AddValue($thread["linked_machines"]); $failed_number->AddValue($thread["failed_rules_machines"]); $notupdated_number->AddValue($thread["notupdated_machines"]); $notunique_number->AddValue($thread["not_unique_machines_number"]); $linkedrefused_number->AddValue($thread["link_refused_machines_number"]); $process_time->AddValue($thread["duree"]); } else { if ($imported_number->GetCount() > 0) { $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time); $imported_number->Reset(); } } echo "<tr class='tab_bg_1'>"; echo "<td width='10'>"; if ($canedit) { echo "<input type='checkbox' name='item[" . $thread["processid"] . "]' value='1'>"; } else { echo " "; } echo "</td>"; echo "<td class='center'>"; echo "<a href=\"./thread.form.php?pid=" . $thread["processid"] . "\">" . $thread["processid"] . "</a></td>"; echo "<td class='center'>"; $this->displayProcessStatusIcon($this->getProcessStatus($thread["processid"])); echo "</td>"; echo "<td class='center'>" . $thread["threads_number"] . "</td>"; echo "<td class='center'>" . Html::convDateTime($thread["starting_date"]) . "</td>"; echo "<td class='center'>" . Html::convDateTime($thread["ending_date"]) . "</td>"; echo "<td class='center'>" . $thread["imported_machines"] . "</td>"; echo "<td class='center'>" . $thread["synchronized_machines"] . "</td>"; echo "<td class='center'>" . $thread["linked_machines"] . "</td>"; echo "<td class='center'>" . $thread["failed_rules_machines"] . "</td>"; echo "<td class='center'>" . $thread["notupdated_machines"] . "</td>"; echo "<td class='center'>" . $thread["not_unique_machines_number"] . "</td>"; echo "<td class='center'>" . $thread["link_refused_machines_number"] . "</td>"; echo "<td class='center'>"; if ($thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) { echo Html::timestampToString($thread["duree"]); } else { echo Dropdown::EMPTY_VALUE; } echo "</td>"; echo "<td class='center'>"; if ($thread["plugin_ocsinventoryng_ocsservers_id"] != -1) { $ocsConfig = PluginOcsinventoryngOcsServer::getConfig($thread["plugin_ocsinventoryng_ocsservers_id"]); echo "<a href=\"ocsserver.form.php?id=" . $ocsConfig["id"] . "\">" . $ocsConfig["name"] . "</a>"; } else { _e('All servers', 'ocsinventoryng'); } echo "</td>"; echo "<td class='center'>"; echo "<a href=\"detail.php?reset=reset_before&field[0]=" . "5&contains[0]=^" . $thread["processid"] . '$">' . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png'</a></td>"; echo "</tr>\n"; } } } if ($imported_number->GetCount() > 0) { $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time); } echo "</table>"; if ($canedit) { Html::openArrowMassives("processes"); Html::closeArrowMassives(array("delete_processes" => _x('button', 'Delete permanently'))); } Html::closeForm(); }
if (!$plugin->isInstalled("ocsinventoryng")) { echo "Disabled plugin\n"; exit(1); } if (!$plugin->isActivated("ocsinventoryng")) { echo "Disabled plugin\n"; exit(1); } $thread_nbr = ''; $threadid = ''; $ocsservers_id = -1; $fields = array(); //Get script configuration $config = new PluginOcsinventoryngConfig(); $notimport = new PluginOcsinventoryngNotimportedcomputer(); $config->getFromDB(1); if (!isset($_GET["ocs_server_id"]) || $_GET["ocs_server_id"] == '') { $ocsservers_id = -1; } else { $ocsservers_id = $_GET["ocs_server_id"]; } if (isset($_GET["managedeleted"]) && $_GET["managedeleted"] == 1) { //echo "=====================================================\n"; //echo "\tClean old Not Imported machine list (" . $notimport->cleanNotImported($ocsservers_id) . ")\n"; if ($ocsservers_id != -1) { FirstPass($ocsservers_id); } else { echo "\tManage delete items in all OCS server\n"; echo "=====================================================\n"; //Import from all the OCS servers $query = "SELECT `id`, `name`\n FROM `glpi_plugin_ocsinventoryng_ocsservers`\n WHERE `is_active`\n AND `use_massimport`";
static function canUpdateOCS() { $config = new PluginOcsinventoryngConfig(); $config->getFromDB(1); return $config->fields['allow_ocs_update']; }