HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/timetracker.panomity.com/templates/project/charts.html.twig
{# project \App\Entity\Project #}
{# details \App\Reporting\ProjectDetails\ProjectDetailsModel #}
{% macro project_budget(project, details, prefix) %}
    {% set chartPrefix = (prefix is null ? random() : prefix) ~ 'Budget' %}
    {% set chart = is_granted('budget', project) %}
    {% set showMoneyBudget = is_granted('budget', project) and project.hasBudget() %}
    {% set showTimeBudget = is_granted('time', project) and project.hasTimeBudget() %}
    {% if showMoneyBudget or showTimeBudget %}
        {% from "macros/charts.html.twig" import bar_chart %}
        {% set currency = project.customer.currency %}
        {% if project.isMonthlyBudget() %}
            <h4>
                {%- if showMoneyBudget %}{{ 'budget'|trans }}{% else %}{{ 'timeBudget'|trans }}{% endif -%}
                : {{ 'budgetType_month'|trans }}
            </h4>
            {% set chartData = [] %}
            {% set chartLabels = [] %}
            {# year \App\Model\Statistic\Year #}
            {% for year in details.years %}
                {# month \App\Model\Statistic\Month #}
                {% for month in year.months %}
                    {% set monthDate = date(year.year ~ '-' ~ month.month ~ '-01 00:00:00') %}
                    {% if project.end is null or monthDate < project.end %}
                        {% set totalBudget = project.getTimeBudget() - month.billableDuration %}
                        {% set projectBudget = project.getTimeBudget() %}
                        {% if showMoneyBudget %}
                            {% set totalBudget = project.getBudget() - month.billableRate %}
                            {% set projectBudget = project.getBudget() %}
                        {% endif %}
                        {% set chartLabels = chartLabels|merge([monthDate|month_name ~ ' ' ~ year.year]) %}
                        {% set chartValue = {
                            'label': (showMoneyBudget ? totalBudget|money(currency) : totalBudget|duration),
                            'value': '' ~ (showMoneyBudget ? totalBudget|chart_money : totalBudget|chart_duration),
                        } %}
                        {% if totalBudget < 0 %}
                            {% set chartValue = chartValue|merge({'color': 'red'}) %}
                        {% endif %}
                        {% if totalBudget == projectBudget %}
                            {% set chartValue = chartValue|merge({'color': 'green'}) %}
                        {% endif %}
                        {% set chartData = chartData|merge([chartValue]) %}
                    {% endif %}
                {% endfor %}
            {% endfor %}
            {{ bar_chart(chartPrefix, chartLabels, [chartData], {'height': '300px', 'renderEvent': 'render.' ~ chartPrefix}) }}
        {% else %}
            <h4>
                {%- if showMoneyBudget %}{{ 'budget'|trans }}{% else %}{{ 'timeBudget'|trans }}{% endif -%}
            </h4>
            {% set chartData = [] %}
            {% set chartLabels = [] %}
            {% if showMoneyBudget %}
                {% set totalBudget = project.getBudget() %}
            {% else %}
                {% set totalBudget = project.getTimeBudget() %}
            {% endif %}
            {# year \App\Model\Statistic\Year #}
            {% for year in details.years %}
                {# month \App\Model\Statistic\Month #}
                {% for month in year.months %}
                    {% set monthDate = date(year.year ~ '-' ~ month.month ~ '-01') %}
                    {% if project.end is null or monthDate < project.end %}
                        {% if showMoneyBudget %}
                            {% set totalBudget = totalBudget - month.billableRate %}
                        {% else %}
                            {% set totalBudget = totalBudget - month.billableDuration %}
                        {% endif %}
                        {% set chartLabels = chartLabels|merge([monthDate|month_name ~ ' ' ~ year.year]) %}
                        {% set chartValue = {
                            'label': (showMoneyBudget ? totalBudget|money(currency) : totalBudget|duration),
                            'value': (showMoneyBudget ? totalBudget|chart_money : totalBudget|chart_duration),
                        } %}
                        {% if totalBudget < 0 %}
                            {% set chartValue = chartValue|merge({'color': 'red'}) %}
                        {% endif %}
                        {% set chartData = chartData|merge([chartValue]) %}
                    {% endif %}
                {% endfor %}
            {% endfor %}
            {% set last = chartData|last %}
            {% if last is not empty and last.value > 0 %}
                {% set chartValueZero = {
                    'label': (showMoneyBudget ? 0|money(currency) : 0|duration),
                    'value': (showMoneyBudget ? 0|chart_money : 0|chart_duration),
                } %}
                {% set chartData = chartData|merge([chartValueZero]) %}
            {% endif %}
            {{ bar_chart(chartPrefix, chartLabels, [chartData], {'height': '300px', 'renderEvent': 'render.' ~ chartPrefix, 'type': 'line'}) }}
        {% endif %}
    {% endif %}
{% endmacro %}