{% extends 'layout.twig' %}
     
{% block body %}

<section class="contenu titre_div">
    <h1>{{ {
        'Tables': 'Tables' | trad,
        'ListeDA': 'Liste DA' | trad,
        'Fournisseur': 'Fournisseur' | trad,
        'signataire': 'Commandes' | trad,
    }[ MODULE ] | default('Commande' | trad) }}</h1>
    
    {{ ariane() }}
    
    <header class="bs-row">
        <h2>
            {{- strBuild(
                'Suivi de @4@la commande @1@ du fournisseur @2@ (@3@)' | trad,
                [
                    commande.NO_CDE,
                    commande.RS,
                    commande.CODE,
                    commande.AVENANT | trim is not empty ? strBuild('l’avenant N°@1@ de ',[
                        commande.AVENANT | trim
                    ]) : ''
                ]
            ) -}}
        </h2>
        <div class="bs-col text-right">
            
            {% if (droitActif and droit.HA_CA_CEV) or droitActif == false and MODULE != 'signataire' %}
            <a href="javascript:void(0)" 
                onclick="ajaxPopup('{{ path('Commande.Event.ajoutEvenementCommande', {idCommande:commande.NO_CDE}) }}', '{{ ('Ajout d\'un événement' |trad)  |e('js')|raw }}');" 
                class="principal ajout button"
            >
                {{- 'Nouvel évènement'|trad -}}
            </a>
            {% endif %}
            <form class="d-inline" 
                action="{{ path('Ajax.Outil.appelAsync') }}"
                onsubmit="return ajaxSubmit(event)"
                data-onsuccess="successPopupExport"
            >
                <input type="hidden" name="exportPathAction" 
                    value="{{ path('Commande.Event.export', {
                        idCommande: commande.NO_CDE,
                        MODULE: MODULE
                    }) | e('html_attr') }}"
                />
                <button type="submit" class="button secondaire">
                    {{- 'Exporter' | trad -}}
                </button>
            </form>
        </div>
    </header>
    
    {{ arianeSub() }}
    
    <div id="commandes" class="tab-pane pad-15 fade in active clearfix">
    
        <div class="block_edition">
            <div class="titre_block">
                {{ 'Commande' | trad }}
            </div>
            <div class="colonne3">
                <div class="informations">
                    <p>
                        <span class="champs_label">{{ 'N° commande :' | trad }}</span>
                        <span class="resultat">{{ commande.NO_CDE }}</span>
                    </p>
                    <p>
                        <span class="champs_label">{{ 'Fournisseur :' | trad }}</span>
                        <span class="resultat">{{ commande.RS }} ({{ commande.CODE }})</span>
                    </p>
                </div>
            </div>
            <div class="colonne3">
                <div class="informations">
                    <p>
                        <span class="champs_label">{{ 'Enregistrée le' | trad }} :</span>
                        <span class="resultat">{{ commande.DTE_CREAT | dateTrad }}</span>
                    </p>
                </div>
            </div>
            <div class="colonne3 last">
                <div class="informations">
                    <p>
                        <span class="champs_label">{{ 'Montant HT' | trad ~ colon() }}</span>
                        <span class="resultat">{{ commande.TOT_CDEHT | tva}} {{ commande.DEVISE }}</span>
                    </p>
                    <p>
                        <span class="champs_label">{{ 'Montant TTC' | trad ~ colon() }}</span>
                        <span class="resultat">{{ commande.TOT_TTC | tva}} {{ commande.DEVISE }}</span>
                    </p>
                </div>
            </div>
        </div>
        
            <table class="table" style="margin-top:20px;">
                    <thead class="thead-dark">
                        <tr>
                            <th scope="col" width="10%">{{ 'Date'|trad }}</th>
                            <th scope="col" width="10%">{{ 'Heure'|trad }}</th>                                    
                            <th scope="col">{{ 'Auteur'|trad }}</th> 
                            <!-- Ne s'affiche que dans certains cas -->
                            <th scope="col">{{ 'Signataire'|trad }}</th>                                  
                            <!--  -->
                            <th scope="col">{{ 'Libellé'|trad }}</th>
                            <th scope="col" width="5%">{{ 'Action'|trad }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for event in listeEvent %}
                            <tr id="evenement{{ loop.index }}">
                                <td class="loupe">{{ event.DTE | dateTrad }}</td>
                                <td>{{ event.HEURE | heureTrad }}</td>
                                <td>
                                    {% if event.UTIL %}
                                    {{ event.Utili_NOM }} ({{ event.UTIL }})
                                    {% endif %}
                                </td>
                                <td>
                                    {% if event.SIGNAT %}
                                    {{ event.Signataire_NOM }} ({{ event.SIGNAT }})
                                    {% endif %}
                                </td>
                                <td>{{ event.LIBELLE | trad }}</td>
                                <td class="parametrage" >
                                    {% if event.HAPLUS | boolSql == false %}
                                        {{ menuContextuel('evenement'~loop.index, false, event.menuContextuel) }}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr class="detail_ligne hide_detail" id="evenement{{ loop.index }}detail" >
                                <td colspan="6">
                                    <div class="single row">
                                        <div class="informations">
                                            <p class="gras">{{ 'Commentaires' | trad ~ colon() }}</p>
                                            <p>{{ event.CONTMEMO |nl2br }}</p>
                                        </div>
                                    </div>
                                    </td>
                                </tr>
                            {% endfor %}			
                        </tbody>
                    </table>     	
        
    </div>
    
</section>

{% endblock %}