{# Sidebar Start #}
<div class="sidebar pe-4 pb-3">
<nav class="navbar bg-secondary navbar-dark">
<a href="{{ path('index') }}" class="navbar-brand mx-4 mb-3">
<h3 class="text-primary"><i class="fa fa-user-edit me-2"></i>MyHajs</h3>
</a>
<div class="d-flex align-items-center ms-4 mb-4">
<div class="position-relative">
{% set avatar = app.user and app.user.avatar ? '/uploads/avatars/' ~ app.user.avatar : '/darkpan/img/user.jpg' %}
<img class="rounded-circle" src="{{ avatar }}" alt="avatar" style="width: 40px; height: 40px; object-fit: cover;">
<div class="bg-success rounded-circle border border-2 border-white position-absolute end-0 bottom-0 p-1"></div>
</div>
<div class="ms-3">
<h6 class="mb-0">{{ app.user ? app.user.userIdentifier : 'Gość' }}</h6>
<span>{{ app.user ? 'Zalogowany' : 'Niezalogowany' }}</span>
</div>
</div>
{# Aktywne zakładki #}
{% set current = app.request.attributes.get('_route') %}
{% set isIndexActive = current == 'index' %}
{# Zbiory tras dla sekcji #}
{% set kategorieRoutes = ['kategorie_list', 'kategoria_new', 'kategoria_edit'] %}
{% set przychodyRoutes = ['przychody_list', 'przychod_new', 'przychod_edit', 'przychody_edit'] %}
{% set rozchodyRoutes = ['rozchody_list', 'rozchod_new', 'rozchod_edit', 'rozchody_edit'] %}
{% set planyRozchodowRoutes = ['plany_rozchodow'] %}
{% set statystykiRoutes = ['app_statistics'] %}
{# Flagi aktywności #}
{% set isKategorieActive = current in kategorieRoutes %}
{% set isPrzychodyActive = current in przychodyRoutes %}
{% set isRozchodyActive = current in rozchodyRoutes %}
{% set isPlanyRozchodowActive = current in planyRozchodowRoutes %}
{% set isStatystykiActive = current in statystykiRoutes %}
{% set isKontaActive = current == 'app_konta_index' or current == 'app_konta_new' or current == 'app_konta_edit' %}
{% set isKonfiguracjaActive = isKategorieActive or isPrzychodyActive or isRozchodyActive or isKontaActive %}
<div class="navbar-nav w-100">
<a href="{{ path('index') }}" class="nav-item nav-link {{ isIndexActive ? 'active' : '' }}">
<i class="fa fa-tachometer-alt me-2"></i>Budżet
</a>
{% if is_granted('ROLE_ADMIN') %}
<div class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle {{ isKonfiguracjaActive ? 'active' : '' }}" data-bs-toggle="dropdown">
<i class="fa fa-laptop me-2"></i>Konfiguracja
</a>
<div class="dropdown-menu bg-transparent border-0 {{ isKonfiguracjaActive ? 'show' : '' }}">
<a href="{{ path('kategorie_list') }}" class="dropdown-item {{ isKategorieActive ? 'active' : '' }}"><i class="fa fa-tags me-2"></i>Kategorie</a>
<a href="{{ path('przychody_list') }}" class="dropdown-item {{ isPrzychodyActive ? 'active' : '' }}"><i class="fa fa-arrow-down me-2"></i>Przychody</a>
<a href="{{ path('rozchody_list') }}" class="dropdown-item {{ isRozchodyActive ? 'active' : '' }}"><i class="fa fa-arrow-up me-2"></i>Rozchody</a>
<a href="{{ path('app_konta_index') }}" class="dropdown-item {{ isKontaActive ? 'active' : '' }}"><i class="fa fa-wallet me-2"></i>Konta</a>
</div>
</div>
{% endif %}
{% set isPlanyActive = current in ['plany_list', 'plany_przychodow', 'plany_rozchody', 'plany_rozchodow'] %}
<div class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle {{ isPlanyActive ? 'active' : '' }}" data-bs-toggle="dropdown" data-bs-auto-close="outside">
<i class="fa fa-th me-2"></i>Plany
</a>
<div class="dropdown-menu bg-transparent border-0 {{ isPlanyActive ? 'show' : '' }}">
<a href="{{ path('plany_list') }}" class="dropdown-item {{ current == 'plany_list' ? 'active' : '' }}"><i class="fa fa-list-ul me-2"></i>Zbiorczo</a>
<a href="{{ path('plany_przychodow') }}" class="dropdown-item {{ current == 'plany_przychodow' ? 'active' : '' }}"><i class="fa fa-arrow-down me-2"></i>Plany przychodów</a>
<a href="{{ path('plany_rozchodow') }}" class="dropdown-item {{ current == 'plany_rozchodow' ? 'active' : '' }}"><i class="fa fa-arrow-up me-2"></i>Plany rozchodów</a>
</div>
</div>
{% set isOperacjeActive = current in ['operacje_przychody', 'operacje_wydatki'] %}
<div class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle {{ isOperacjeActive ? 'active' : '' }}" data-bs-toggle="dropdown" data-bs-auto-close="outside">
<i class="fa fa-keyboard me-2"></i>Operacje
</a>
<div class="dropdown-menu bg-transparent border-0 {{ isOperacjeActive ? 'show' : '' }}">
<a href="{{ path('operacje_przychody') }}" class="dropdown-item {{ current == 'operacje_przychody' ? 'active' : '' }}">
<i class="fa fa-arrow-down text-success me-2"></i>Przychody
</a>
<a href="{{ path('operacje_wydatki') }}" class="dropdown-item {{ current == 'operacje_wydatki' ? 'active' : '' }}">
<i class="fa fa-arrow-up text-danger me-2"></i>Wydatki
</a>
</div>
</div>
{% set isStatystykiActive = current in ['app_statistics', 'app_budget_realization'] %}
<div class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle {{ isStatystykiActive ? 'active' : '' }}" data-bs-toggle="dropdown" data-bs-auto-close="outside">
<i class="fa fa-chart-bar me-2"></i>Statystyki
</a>
<div class="dropdown-menu bg-transparent border-0 {{ isStatystykiActive ? 'show' : '' }}">
<a href="{{ path('app_statistics') }}" class="dropdown-item {{ current == 'app_statistics' ? 'active' : '' }}">
<i class="fa fa-chart-pie me-2"></i>Wykresy
</a>
<a href="{{ path('app_budget_realization') }}" class="dropdown-item {{ current == 'app_budget_realization' ? 'active' : '' }}">
<i class="fa fa-chart-line me-2"></i>Realizacja budżetu
</a>
</div>
</div>
</div>
</nav>
</div>
{# Sidebar End #}