/**
* Update the progress bar
*
* Display and update the progress bar. If the delay is more than 1 second, then activate it
*
* @return nothing (display only)
**/
function updateProgressBars()
{
if ($this->timer->getTime() > 1) {
// If the action's delay is more than one second, the display progress bars
$this->display_progress_bars = true;
}
if ($this->display_progress_bars) {
if (!isset($this->progress_bar_displayed)) {
Html::progressBar('main_' . $this->identifier, array('create' => true, 'message' => $this->action_name));
$this->progress_bar_displayed = true;
$this->fields_to_remove_when_reload[] = 'progress_bar_displayed';
if (count($this->items) > 1) {
Html::progressBar('itemtype_' . $this->identifier, array('create' => true));
}
}
$percent = 100 * $this->nb_done / $this->nb_items;
Html::progressBar('main_' . $this->identifier, array('percent' => $percent));
if (count($this->items) > 1 && isset($this->current_itemtype)) {
$itemtype = $this->current_itemtype;
if (isset($this->items[$itemtype])) {
if (isset($this->done[$itemtype])) {
$nb_done = count($this->done[$itemtype]);
} else {
$nb_done = 0;
}
$percent = 100 * $nb_done / count($this->items[$itemtype]);
Html::progressBar('itemtype_' . $this->identifier, array('message' => $itemtype::getTypeName(Session::getPluralNumber()), 'percent' => $percent));
}
}
}
}