{% from "_eroare.html" import card_erori %} {% import '_macros.html' as ui %} {# PRD 5.9 US-004: detaliu editabil in-place, butoane consolidate, ordine verticala R10. Fragmentul se swap-uieste in corpul modalului global (#detaliu-modal-body). Heading-ul poarta id-ul folosit de aria-labelledby al dialogului. R9: 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' %}
{# === R10 (1): header — #id + pill + motiv uman === #}

Detaliu trimitere #{{ id }}

{{ stare_text }}
{% if motiv %}

{{ motiv }}

{% elif stare_subtext %}

{{ stare_subtext }}

{% endif %} {# === R10 (2): bloc eroare blocanta cand exista === #} {% if erori_3n %}
{{ card_erori(erori_3n) }}
{% endif %} {# === R10 (3) + R9: mapare inline (PRD 5.7) — 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 %} {# === R10 (4): 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 %} {% macro camp(nume, eticheta, valoare, tip='text') %}
{% if err_map.get(nume) %}
{{ err_map.get(nume) }}
{% endif %}
{% endmacro %}
{# Operatie + cod RAR read-only deasupra campurilor (R9, fara eticheta „Cod RAR"). #}
Operatie
{{ prez.operatie }} · {{ cod_afis }}
{# 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) }}
{# === R10 (5): actiune primara conditionata de stare (R2). 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 }}
Data prestatie
{{ prez.data_prestatie }}
Odometru final
{{ prez.odometru }}
{% endif %} {# === R10 (5): actiuni de jos — primar Re-pune (doar error) + Sterge pe RAND SEPARAT (R2/R11) === #} {% if status == 'error' or gestionabil %}
{# R2: error -> buton primar „Re-pune in coada" pe /repune (error nu e editabil). #} {% if status == 'error' %}
{% endif %} {# R11: UN SINGUR Sterge, outline distructiv (var(--err)), pe rand separat, full-width pe mobil. #} {% if gestionabil %}
{% endif %}
{% endif %} {# === R10 (6): 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 %}
{# PRD 5.9 US-004 (R4): scriptul inline vechi (marcheazaDetaliuDeschis / scrollIntoView pe randul-sibling) a fost eliminat de US-003. Focus-ul post-swap (incl. re-render corectie/ mapare) e gestionat de htmx:afterSettle pe #detaliu-modal-body din base.html. R5: inchiderea modalului pe succes (queued/sterge) vine din HX-Trigger `inchideModal` emis de rute. #}