{% extends "base.html" %} {% load static %} {% load tz %} {% load i18n %} {% load documents_tags %} {% load asset_tags %} {% load document_viewer_tags %} {% block content %}

{{ intersection.code}} - {{ intersection.get_name }}

{% if can_edit_location %}
{% endif %}

{{ intersection.get_status_display }}
{{ intersection.get_voltage_type_display }}
{% if intersection.is_connected_to_control_center %} {% elif intersection.is_connected_to_control_center == False %} {% else %} {% endif %}
{{ intersection.current_index|default:""}}
{{ intersection.controller_model_name|default:""}} {% if intersection.master %}
{{ intersection.master.code|default:"/" }} {% endif %}
{% if can_edit_location %}
{% if trafficlight_contracts %} {% for tlc in trafficlight_contracts %} {{ tlc.contract.contract_number }} ({{ tlc.get_maintenance_type_display }}) {% endfor %} {% else %} {% translate "Aucun" %} {% endif %}
{% endif %}
{{ intersection.municipality }}
{% if intersection.lon %} {% translate 'Street View' %} {% translate "View in Google Street View" %} {% endif %}
{% if staged_assets_count > 0 %}
{% translate "Assets importés par DXF en attente de validation" %}

{% blocktranslate count count=staged_assets_count %} Il y a {{ count }} poteau importé depuis un plan DXF qui est en attente de validation pour ce carrefour. {% plural %} Il y a {{ count }} poteaux importés depuis un plan DXF qui sont en attente de validation pour ce carrefour. {% endblocktranslate %}

{% csrf_token %}
{% csrf_token %}
{% translate "Réimporter / Corriger" %}
{% endif %}

{% translate "Documents" %}

{% if can_browse_folder and document_folder %}
{{ intersection.code }}
{% endif %} {# ── Document grid ── #} {% if use_managed_documents %} {# Nouveau système : le composant gère sa propre grille + modale visionneuse #} {% render_document_viewer main_documents modal_id="tliDocViewerModal" show_tags=True show_versions=True location_id=intersection.id %} {% else %} {# Ancien système - TrafficLightIntersectionDocument #}
{% for document in main_documents %} {% if document %}
{{ document.get_document_type_display }}
{% if document.thumbnail %} {{ document.filename }} {% else %} {% endif %}
{{ document.upload_date|timezone:"Europe/Paris"|date:"d/m/Y" }}
{{ document.uploaded_by.username }}
{% endif %} {% endfor %}
{% endif %}
{{ dxf_files|json_script:"dxfFilesData" }}

{% translate "Assets" %}

{% if allowed_location_actions %}
{% if 'create' in allowed_location_actions %} {% endif %} {% if can_edit_location %} {% translate "Importer plan DXF" %} {% translate "Importer plan de croix" %} {% endif %} {% if 'bulk_archive' in allowed_location_actions %} {% endif %}
{% endif %}
{# ── Onglet Installation extérieure ── #}
{# ── Colonne Poteaux ── #}
{% translate "Poteaux" %} {{ assets.poles|length }}
{% if assets.poles %}
    {% for pole in assets.poles %}
  • {# ── En-tête du poteau ── #}
    {% if pole.sorted_radars and not pole.sorted_lanterns and not pole.sorted_accessories %} {% else %} {% endif %} {{ pole.code }} {% if pole.name %}{{ pole.name }}{% endif %} {% if pole.status != 'active' %}{{ pole.get_status_display }}{% endif %} {% if pole.sorted_lanterns or pole.sorted_accessories or pole.sorted_radars or pole.sorted_detectors or pole.sorted_signpanels %}
    {% if pole.sorted_accessories %} {{ pole.sorted_accessories|length }} {% endif %} {% if pole.sorted_lanterns %} {{ pole.sorted_lanterns|length }} {% endif %} {% if pole.sorted_radars %} {{ pole.sorted_radars|length }} {% endif %} {% if pole.sorted_detectors %} {{ pole.sorted_detectors|length }} {% endif %} {% if pole.sorted_signpanels %} {{ pole.sorted_signpanels|length }} {% endif %}
    {% endif %}
    {# ── Lanternes + Accessoires + Radars + Détecteurs + Panneaux ── #} {% if pole.sorted_lanterns or pole.sorted_accessories or pole.sorted_radars or pole.sorted_detectors or pole.sorted_signpanels %}
      {% for lantern in pole.sorted_lanterns %}
    • {{ lantern.code }} {% if lantern.get_name %}{{ lantern.get_name }}{% endif %} {% if lantern.status != 'active' %}{{ lantern.get_status_display }}{% endif %}
    • {% endfor %} {% for accessory in pole.sorted_accessories %}
    • {{ accessory.code }} {% if accessory.get_name %}{{ accessory.get_name }}{% endif %} {% if accessory.status != 'active' %}{{ accessory.get_status_display }}{% endif %}
    • {% endfor %} {% for radar in pole.sorted_radars %}
    • {{ radar.code }} {% if radar.get_name %}{{ radar.get_name }}{% endif %} {% if radar.status != 'active' %}{{ radar.get_status_display }}{% endif %}
    • {% endfor %} {% for detector in pole.sorted_detectors %}
    • {{ detector.code }} {% if detector.get_name %}{{ detector.get_name }}{% endif %} {% if detector.status != 'active' %}{{ detector.get_status_display }}{% endif %}
    • {% endfor %} {% for panel in pole.sorted_signpanels %}
    • {{ panel.code }} {% if panel.signpanel_type %}{{ panel.signpanel_type }}{% endif %} {% if panel.signpanel_text %}"{{ panel.signpanel_text }}"{% endif %} {% if panel.status != 'active' %}{{ panel.get_status_display }}{% endif %}
    • {% endfor %}
    {% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun poteau" %}

{% endif %}
{# ── Colonne Armoires + Câbles ── #}
{# Armoires électriques #}
{% translate "Armoires électriques" %} {{ assets.electrical_cabinets|length }}
{% if assets.electrical_cabinets %}
    {% for cabinet in assets.electrical_cabinets %}
  • {{ cabinet.code }} {{ cabinet.get_name }} {% if cabinet.status != 'active' %}{{ cabinet.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucune armoire électrique" %}

{% endif %}
{# Câbles #}
{% translate "Câbles" %} {{ assets.cables|length }}
{% if assets.cables %}
    {% for cable in assets.cables %}
  • {{ cable.code }} {% if cable.name %}{{ cable.name }}{% endif %} {% if cable.status != 'active' %}{{ cable.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun câble" %}

{% endif %}
{# Radars #}
{% translate "Radars préventifs" %} {{ assets.radars|length }}
{% if assets.radars %}
    {% for radar in assets.radars %}
  • {{ radar.code }} {% if radar.get_name %}{{ radar.get_name }}{% endif %} {% if radar.status != 'active' %}{{ radar.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun radar préventif" %}

{% endif %}
{# /col armoires+câbles #}
{# /row #}
{% if not intersection.is_radar %} {# ── Onglet Contrôleur ── #}
{% if assets.controllers.first %} {% with ctrl=assets.controllers.first %} {# ── Carte contrôleur ── #}
{% translate "Contrôleur de trafic" %}
{{ ctrl.code }} {% if ctrl.name %}
{{ ctrl.name }}
{% endif %}
{% translate "Modèle" %} : {% if ctrl.model %}{{ ctrl.model.get_name }}{% else %}—{% endif %}
{% translate "Type" %} : {{ ctrl.cabinet_type|default:"—" }}
{% translate "Plan" %} : {{ ctrl.plan|default:"—" }}
{% translate "Puissance" %} : {{ ctrl.power|default:"—" }}
{% translate "Date de mise en service" %} : {% if ctrl.installation_date %}{{ ctrl.installation_date|date:"d/m/Y" }}{% else %}—{% endif %}
{# ── Accordéons liés au contrôleur ── #}
{# ── Block 1 : Hardwares du contrôleur ── #}

{% with hw_list=ctrl.sorted_hardwares %} {% if hw_list %}
    {% for hw in hw_list %}
  • {{ hw.code }} {% if hw.name %}{{ hw.name }}{% endif %} {% if hw.hardware %}{{ hw.hardware }}{% endif %} {% if hw.status != 'active' %}{{ hw.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun hardware" %}

{% endif %} {% endwith %}
{# ── Block 2 : Détecteurs ── #}

{% with det_list=ctrl.sorted_detectors %} {% if det_list %}
    {% for det in det_list %}
  • {{ det.code }} {% if det.name %}{{ det.name }}{% endif %} {% if det.pole %}{{ det.pole.code }}{% endif %} {% if det.hardware %}{{ det.hardware }}{% endif %} {% if det.status != 'active' %}{{ det.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun détecteur" %}

{% endif %} {% endwith %}
{# ── Block 3 : Hardware réseau ── #}

{% with net_list=ctrl.sorted_network_hardwares %} {% if net_list %}
    {% for net in net_list %}
  • {{ net.code }} {% if net.name %}{{ net.name }}{% endif %} {% if net.hardware %}{{ net.hardware }}{% endif %} {% if net.status != 'active' %}{{ net.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun hardware réseau" %}

{% endif %} {% endwith %}
{# ── Block 4 : Hardware Tension ── #}

{% with volt_list=ctrl.sorted_voltage_hardwares %} {% if volt_list %}
    {% for volt in volt_list %}
  • {{ volt.code }} {% if volt.name %}{{ volt.name }}{% endif %} {% if volt.hardware %}{{ volt.hardware }}{% endif %} {% if volt.status != 'active' %}{{ volt.get_status_display }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun hardware tension" %}

{% endif %} {% endwith %}
{# /accordion #} {% endwith %} {% else %}
{% translate "Aucun contrôleur" %}
{% endif %}
{% endif %} {% if not intersection.is_radar %} {# ── Onglet Programmation ── #}
{# ── Programmations ── #} {% with prog_list=intersection.programmations.all %} {% if prog_list %}
{% translate "Programmations" %} {{ prog_list|length }} {% if 'create' in allowed_location_actions %} {% endif %}
    {% for prog in prog_list %}
  • {# Index - colonne fixe #} {% if prog.index %}{{ prog.index }}{% endif %} {# Statut - colonne fixe #} {{ prog.get_status_display }} {# Code + nom #} {{ prog.code }} {% if prog.get_name %}{{ prog.get_name }}{% endif %} {# Date alignée à droite #} {% if prog.commissioning_date %}{{ prog.commissioning_date|date:"d/m/Y" }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucune programmation" %}

{% if 'create' in allowed_location_actions %} {% endif %}
{% endif %} {% endwith %} {# ── Log files du contrôleur ── #} {% with ctrl=assets.controllers.first %} {% if ctrl %} {% with log_list=ctrl.logs.all|dictsortreversed:"filedate" %}

{% if log_list %}
    {% for log in log_list %}
  • {% private_file_url log 'file' as log_url %} {{ log.file.name|slice:"42:" }} {% if log.filedate %}{{ log.filedate|date:"d/m/Y" }}{% endif %}
  • {% endfor %}
{% else %}

{% translate "Aucun fichier de log" %}

{% endif %}
{% endwith %} {% endif %} {% endwith %}
{% endif %}
{# /tab-content #}

{% translate "Interventions" %}

{% for interv in interventions %} {% endfor %}
{% translate "Code" %} {% translate "Titre" %} {% translate "Début" %} {% translate "Statut" %}
{{ interv.code }} {{ interv.title }} {{ interv.begin_time|date:"d-m-Y H:i" }} {{ interv.get_status_display }}
{% translate "Plan" %}
{% if 'create' in allowed_location_actions %} {% endif %} {% endblock content%} {% block script %} {{ intersection.lon|json_script:"lon_value" }} {{ intersection.lat|json_script:"lat_value" }} {{ intersection.status|json_script:"status_value" }} {{ intersection.is_radar|json_script:"is_radar_value" }} {{ assets_geojson|json_script:"assets_geojson" }} {% if allowed_location_actions %} {% endif %} {# ── Location editing modals (edit / delete) ── #} {% if can_edit_location %} {% include "assets/components/location_edit_modals.html" with thematic_code=thematic_code location_type=location_type entry_label="Intersection" %} {# ── Contracts management modal ── #} {% endif %} {% endblock script %}