{% macro progressbar(max, current, title, subTitle) %} {% set percentReached = 0 %} {% if max > 0 %} {% set percentReached = (current / (max / 100)) %} {% endif %} {% set class = "progress-bar-info" %} {% set width = percentReached|number_format(1, '.', '') %} {% if percentReached > 90 %} {% set class = "progress-bar-danger" %} {% elseif percentReached > 70 %} {% set class = "progress-bar-warning" %} {% elseif percentReached > 50 %} {% set class = "progress-bar-success" %} {% elseif percentReached > 30 %} {% set class = "progress-bar-primary" %} {% endif %} {% if width > 100 %} {% set width = 100 %} {% endif %}
{{ title }}{% if percentReached >= 0 and subTitle is not empty %} – {{ percentReached|number_format(2) }}%{% endif %} {% if percentReached >= 0 and subTitle is empty %} {{ percentReached|number_format(2) }}% {% elseif subTitle is not empty %} {{ subTitle }} {% endif %}
{% endmacro %} {% macro progressbar_small(max, current, leftValue, leftFormatted) %} {% set percentReached = 0 %} {% if max > 0 %} {% set percentReached = (current / (max / 100)) %} {% endif %} {% set class = "progress-bar-info" %} {% set width = percentReached|number_format(1, '.', '') %} {% if percentReached > 90 %} {% set class = "progress-bar-danger" %} {% elseif percentReached > 70 %} {% set class = "progress-bar-warning" %} {% elseif percentReached > 50 %} {% set class = "progress-bar-success" %} {% elseif percentReached > 30 %} {% set class = "progress-bar-primary" %} {% endif %} {% if width > 100 %} {% set width = 100 %} {% endif %}
{% if leftValue is not null and leftValue > 0 %} {{ 'stats.percentUsedLeft'|trans({'%percent%': percentReached|number_format(0), '%left%': leftFormatted}) }} {% else %} {{ 'stats.percentUsed'|trans({'%percent%': percentReached|number_format(0)}) }} {% endif %}
{% endmacro %}