{% from "_eroare.html" import card_erori %} {% import '_macros.html' as ui %} {# Detaliu editabil in-place. Fragmentul se swap-uieste in corpul modalului global (#detaliu-modal-body). Heading-ul poarta id-ul folosit de aria-labelledby al dialogului. Operatie + cod RAR rezolvat apar IMPREUNA, read-only, folosind `prez.cod_rar` (fallback „nemapat"), fara eticheta separata „Cod RAR". #} {% set cod_afis = prez.cod_rar if (prez.cod_rar and prez.cod_rar != '—') else 'nemapat' %}
{# === Header — #id + pill + motiv uman === #}

Detaliu trimitere #{{ id }}

{{ stare_text }}
{% if motiv %}

{{ motiv }}

{% elif stare_subtext %}

{{ stare_subtext }}

{% endif %} {# === Bloc eroare blocanta — DOAR in read-only. In editare, cardul 3-niveluri e inlocuit cu: erori per-camp in macro `camp` (text simplu .s-error) + rezumat top-of-form pentru erori fara camp (mai jos). === #} {% if not editabil and erori_3n %}
{{ card_erori(erori_3n) }}
{% endif %} {# === Mapare inline — alege cod RAR pentru operatiile nemapate. Cand nemapate_inline, linia „Operatie: X · nemapat" apare in formularul de mai jos (cod_afis = nemapat), iar aici e picker-ul; dupa mapare, re-render arata codul rezolvat. === #} {% if nemapate_inline %}

Mapeaza codul operatiei

Alege codul RAR pentru fiecare operatie. La salvare, randul se re-rezolva pe loc (si celelalte randuri cu aceeasi operatie).

{% for op in nemapate_inline %} {% set top = op.suggestions[0] if op.suggestions else None %} {% set preselect = top.cod_prestatie if (top and top.score >= 60) else '' %}
{{ op.cod_op_service }} {% if op.denumire and op.denumire != op.cod_op_service %} — {{ op.denumire }} {% endif %}
{% if op.suggestions %}
Sugestii: {% for s in op.suggestions[:3] %} {{ s.cod_prestatie }} ({{ s.score|round|int }}%){% if not loop.last %}, {% endif %} {% endfor %}
{% endif %}
{{ ui.autosend_toggle(checked=True) }}
{% endfor %}
{% endif %} {# === Formular editabil (needs_data/needs_mapping) SAU context read-only. Zero dublare: campurile vehiculului apar O SINGURA DATA — editabile cand randul e corectabil, altfel read-only. Operatie + cod RAR read-only deasupra campurilor. === #} {% if editabil %} {% set err_map = {} %} {% for e in corectie_errors %}{% if e.field %}{% set _ = err_map.update({e.field: e.message}) %}{% endif %}{% endfor %} {% if corectie_msg %}
{{ corectie_msg }}
{% endif %} {# Erori fara camp (field None) nu dispar silentios in editare — cardul 3n e ascuns, deci adaugam un rezumat simplu top-of-form. Erori cu camp raman afisate per-camp de macro-ul `camp` de mai jos. #} {% for e in erori_3n if not e.field %} {% endfor %} {% macro camp(nume, eticheta, valoare, tip='text') %}
{% if err_map.get(nume) %}
{{ err_map.get(nume) }}
{% endif %}
{% endmacro %}
{# Select cod RAR pe stari editabile (needs_data/needs_mapping), cu nomenclator. Read-only pe sent/sending/queued/error (nomenclator_rar gol → ramura else). #} {% if nomenclator_rar %}
{% if prez.operatie and prez.operatie != '—' %}
{{ prez.operatie }}
{% endif %}
{% else %} {# Operatie + cod RAR read-only deasupra campurilor (fara eticheta „Cod RAR"). #}
Operatie
{{ prez.operatie }} · {{ cod_afis }}
{% endif %} {# Operatie service (cod intern + denumire venita prin API/import), distinct de operatia RAR mapata. op_service_cod="" cand lipseste → randul absent. #} {% if prez.op_service_cod %}
Operatie service
{{ prez.op_service_cod }}{% if prez.op_service_denumire %} — {{ prez.op_service_denumire }}{% endif %}
{% endif %} {# Nr. inmatriculare pe rand propriu, VIN dedesubt — ambele latime plina. #} {{ camp('nr_inmatriculare', 'Numar inmatriculare', form_nr) }} {{ camp('vin', 'VIN (serie sasiu)', form_vin) }} {# Restul campurilor in grila. #}
{{ camp('data_prestatie', 'Data prestatie (YYYY-MM-DD)', form_data) }} {{ camp('odometru_final', 'Odometru final', form_odo_final) }} {{ camp('odometru_initial', 'Odometru initial (daca e cerut)', form_odo_initial) }}
{# === Actiune primara conditionata de stare. needs_data/needs_mapping -> „Salveaza si retrimite" pe /corecteaza. UN SINGUR buton primar per stare. === #}
{% else %} {# Context read-only pentru randuri ne-editabile (sent/sending/queued/error). #}
Numar inmatriculare
{{ prez.vehicul_nr }}
VIN (serie sasiu)
{{ prez.vin }}
Operatie
{{ prez.operatie }} · {{ cod_afis }}
{# Operatie service (cod intern + denumire), distinct de operatia RAR. op_service_cod="" cand lipseste → randul absent (fara "—"). #} {% if prez.op_service_cod %}
Operatie service
{{ prez.op_service_cod }}{% if prez.op_service_denumire %} — {{ prez.op_service_denumire }}{% endif %}
{% endif %}
Data prestatie
{{ prez.data_prestatie }}
Odometru final
{{ prez.odometru }}
{% endif %} {# === Actiuni de jos — primar Re-pune (doar error) + Sterge pe RAND SEPARAT === #} {% if status == 'error' or gestionabil %}
{# Error -> buton primar „Re-pune in coada" pe /repune (error nu e editabil pentru #} {# campuri vehicul, dar se poate schimba cod_prestatie prin acelasi formular). #} {% if status == 'error' %}
{# Select cod_prestatie optional in formularul /repune (doar pentru error). #} {% if nomenclator_rar %} {% endif %}
{% endif %} {# UN SINGUR Sterge, outline distructiv (var(--err)), pe rand separat, full-width pe mobil. #} {% if gestionabil %}
{% endif %}
{% endif %} {# === Detalii tehnice — colapsat implicit === #}
Detalii tehnice
Nr. prezentare RAR
{{ id_prezentare or '—' }}
Cod HTTP RAR
{{ rar_status_code or '—' }}
Reincercari
{{ retry_count }}
Creat
{{ created_at }}
Actualizat
{{ updated_at }}
Urmatoarea incercare
{{ next_attempt_at }}
{% if erori_3n and erori_3n[0].cod %}
Cod eroare (brut)
{{ erori_3n[0].cod }}
{% endif %}
{% if rar_error %}
Mesaj RAR (integral)
{{ rar_error }}
{% endif %}
{# Focus-ul post-swap (incl. re-render corectie/mapare) e gestionat de htmx:afterSettle pe #detaliu-modal-body din base.html. Inchiderea modalului pe succes (queued/sterge) vine din HX-Trigger `inchideModal` emis de rute. #}