Html::displayProgressBar PHP Method

displayProgressBar() static public method

Display a simple progress bar
static public displayProgressBar ( $width, $percent, $options = [] ) : nothing
$width Width of the progress bar
$percent Percent of the progress bar
$options array of possible options: - title : string title to display (default Progesssion) - simple : display a simple progress bar (no title / only percent) - forcepadding : boolean force str_pad to force refresh (default true)
return nothing
    static function displayProgressBar($width, $percent, $options = array())
    {
        global $CFG_GLPI;
        $param['title'] = __('Progress');
        $param['simple'] = false;
        $param['forcepadding'] = true;
        if (is_array($options) && count($options)) {
            foreach ($options as $key => $val) {
                $param[$key] = $val;
            }
        }
        $percentwidth = floor($percent * $width / 100);
        $output = "<div class='center'><table class='tab_cadre' width='" . ($width + 20) . "px'>";
        if (!$param['simple']) {
            $output .= "<tr><th class='center'>" . $param['title'] . "&nbsp;" . $percent . "%</th></tr>";
        }
        $output .= "<tr><td>\n                  <table class='tabcompact'><tr><td class='center' style='background:url(" . $CFG_GLPI["root_doc"] . "/pics/loader.png) repeat-x; padding: 0px;font-size: 10px;' width='" . $percentwidth . " px' height='12'>";
        if ($param['simple']) {
            $output .= $percent . "%";
        } else {
            $output .= '&nbsp;';
        }
        $output .= "</td></tr></table></td>";
        $output .= "</tr></table>";
        $output .= "</div>";
        if (!$param['forcepadding']) {
            echo $output;
        } else {
            echo Toolbox::str_pad($output, 4096);
            self::glpi_flush();
        }
    }

Usage Example

コード例 #1
0
--------------------------------------------------------------------------
*/
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>";
    }
}
All Usage Examples Of Html::displayProgressBar
Html