{% extends "layouts/mobile_base.twig" %} {% set active_nav = 'profile' %} {% block title %}{{ translations.my_profile ?? 'My profile' }}{% endblock %} {% block page_title %}{{ translations.my_profile ?? 'My profile' }}{% endblock %} {% block page_subtitle %} {{ translations.profile_subtitle ?? 'Your owner details and roles' }} {% endblock %} {% block head %} {% endblock %} {% block content %} {% set displayName = owner.getDisplayName() ?: (owner.getName() ~ ' ' ~ owner.getSurname()) %} {% set initials = (owner.getName()|default('')|slice(0,1) ~ owner.getSurname()|default('')|slice(0,1))|upper %} {% set lang = owner.getLangCode()|default('')|upper %} {% set positions = owner.getPositions()|default([]) %} {% set comps = owner.getCompetencies()|default([]) %} {# HERO #}
{{ initials ?: (translations.me_abbr ?? 'ME') }}

{{ displayName }}

{% if owner.getLogin() %} • {{ translations.login ?? 'Login' }}: {{ owner.getLogin() }}{% endif %}
{{ shop.getRepresentativeName() ?: shop.getName() }} {% if lang %} {{ translations.language ?? 'Language' }}: {{ lang }} {% endif %} {{ translations.positions ?? 'Positions' }}: {{ positions|length }} {{ translations.competencies ?? 'Competencies' }}: {{ comps|length }}
{# CONTACT (tylko dane pracownika bez CTA do dzwonienia) #}
{{ translations.contact ?? 'Contact' }}
{{ translations.phone ?? 'Phone' }}
{{ owner.getPhone() ?: '-' }}
{{ translations.email ?? 'Email' }}
{{ owner.getEmail() ?: '-' }}
{{ translations.language ?? 'Language' }}
{{ lang ?: '-' }}
{# WORKPLACE / SHOP + SHOP CONTACT CTA #}
{{ translations.workplace ?? 'Workplace' }}
{{ translations.shop ?? 'Shop' }}
{{ shop.getRepresentativeName() ?: shop.getName() }}
{{ translations.address ?? 'Address' }}
{{ shop.getStreet() }} {{ shop.getStreetNum() }}, {{ shop.getZip() }} {{ shop.getCity() }} {% if shop.getCountryCode() %} ({{ shop.getCountryCode() }}){% endif %}
{% set open_h = shop.getOpeningHour() %} {% set open_m = shop.getOpeningMinute() %} {% set close_h = shop.getClosingHour() %} {% set close_m = shop.getClosingMinute() %}
{{ translations.opening_hours ?? 'Hours' }}
{{ "%02d"|format(open_h) }}:{{ "%02d"|format(open_m) }} – {{ "%02d"|format(close_h) }}:{{ "%02d"|format(close_m) }}
{% if shop.getTaxNumber() %}
{{ translations.tax_number ?? 'Tax no.' }}
{{ shop.getTaxNumberPrefixe() }} {{ shop.getTaxNumber() }}
{% endif %} {# Shop contact subsection #}
{{ translations.shop_contact ?? 'Shop contact' }}
{{ translations.phone ?? 'Phone' }}
{{ shop.getPhone() ?: '-' }}
{{ translations.email ?? 'Email' }}
{{ shop.getEmail() ?: '-' }}
{% if shop.getPhone() %} {{ translations.call_shop ?? 'Call shop' }} {% else %} {% endif %} {% if shop.getEmail() %} {{ translations.email_shop ?? 'Email shop' }} {% else %} {% endif %}
{# POSITIONS (z levelem, bez level_order i bez id) #}
{{ translations.positions ?? 'Positions' }}
{% if positions is empty %}
{{ translations.no_positions ?? 'No positions assigned yet.' }}
{% else %}
{% for p in positions %}

{{ p.getName() }}

{% if p.getLevelName() %}
{{ p.getLevelName() }}
{% endif %} {% if p.getDescription() %}

{{ p.getDescription() }}

{% endif %}
{% if p.getLevelDescription() %}
{{ p.getLevelDescription()|slice(0,140) }}{% if p.getLevelDescription()|length > 140 %}…{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{# COMPETENCIES (zwinięte domyślnie per KATEGORIA) #}
{{ translations.competencies ?? 'Competencies' }}
{% if comps is empty %}
{{ translations.no_competencies ?? 'No competencies assigned yet.' }}
{% else %} {# 1) Zbuduj strukturę: category -> subcategory -> [competencies] #} {% set catGroups = {} %} {% for c in comps %} {% set cat = c.getCategoryName() ?: (translations.other ?? 'Other') %} {% set sub = c.getSubcategoryName() ?: (translations.other ?? 'Other') %} {% set catNode = catGroups[cat]|default({}) %} {% set subNode = catNode[sub]|default([]) %} {% set catNode = catNode|merge({ (sub): subNode|merge([c]) }) %} {% set catGroups = catGroups|merge({ (cat): catNode }) %} {% endfor %}
{# 2) Kategorie jako
(domyślnie ZWINIĘTE) #} {% for catName, subMap in catGroups %} {# policz ile kompetencji w kategorii #} {% set catCount = 0 %} {% for subName, arr in subMap %} {% set catCount = catCount + (arr|length) %} {% endfor %}
{{ catName }}
{{ catCount }}
{% for subName, items in subMap %}
{{ subName }} {{ items|length }}
{% for c in items %}

{{ c.getName() }}

{% if c.getVerificationMethod() %} {{ c.getVerificationMethod()|upper }} {% endif %}
#{{ c.getId() }} {% if c.getCreatedAt() %} {# jeśli getCreatedAt() zwraca string, usuń |date(...) #} {{ c.getCreatedAt()|date('Y-m-d') }} {% endif %}
{% if c.getDescription() %}
{{ c.getDescription() }}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{# WORKSTATIONS #}
{{ translations.workstations ?? 'Workstations' }}
{# SETTINGS #}
{{ translations.settings ?? 'Settings' }}
{% endblock %}