{% extends 'layout.twig' %}

{% block body %}
    <div class="contenu clearfix"  id="tiers">
    <h1>
        {{ 'Gestion des indisponibilités' | trad }}
        <a href="{{ path('Stock.Indisponibilite.miseEnIndisponibiliteForm') }}" class="button principal ajout mr-0">
            {{ 'Mise en indisponibilité' | trad }}
        </a>
        {{ Button(
            'Export' | trad,
            false,
            '',
            'ajaxPopup(\''~path('Stock.Indisponibilite.popupExport')~'\', \''~'Export Indisponibilité' | trad~'\', \'\', \'\', \'\', \'modal_export \')', ''
        ) }}
    </h1>
    {{ ariane() }}
    <div class="tab-content" id="tab-content">
        <p></p>
        {% set formName = "filtres_indisponibilite" %}
        <form method="post" name="{{ formName }}" id="{{ formName }}">
            <div class="tab-content">
                <div id="filtre" class="tab-pane active in clearfix bg_form padding_form border_form">
                    <div class="colonne2">
                        <div class="row">
                            {{ inputAdvance('ZOOMADVANCE', {
                                titre: 'Code site' | trad,
                                name : 'filter_egal_SI#point#SITE',
                                value : post['filter_egal_SI#point#SITE'],
                                pahtZoom : path('Ajax.liste.siteStockAccessible'),
                                paramZoom : "{'opened_only': true }",
                                entity : 'SSiteSto',
                                titleZoom : 'Liste des sites de stockage' | trad,
                                pathConvert : path('Ajax.outil.convertLibelle'),
                                convertLibelle : 'convertLibelleGlobal',
                                bulle :  'true',
                                inputAttr: {
                                    'data-multifilter': 'form_SITE',
                                    'data-multifilter-twin': 'table_SITE'
                                },
                                faceAttr: {
                                    'data-zoomLink': 'input_filter_egal_SI#point#SITE'
                                },
                            }) }}
                        </div>
                        <div class="row">
                            {% set exclude_empty_code = is_blanc_interdit_tiers() ? 'true': 'false' %}
                            {{ inputAdvance('ZOOMADVANCE', {
                                titre: 'Code tiers' | trad,
                                name: 'filter_egal_SI#point#COD_TIERS',
                                value: post['filter_egal_SI#point#COD_TIERS'],
                                pahtZoom : path('Ajax.liste.tiers'),
                                paramZoom: "{'exclude_empty_code': " ~ exclude_empty_code ~ "}",
                                entity: 'Tiers',
                                titleZoom: 'Liste des tiers' | trad,
                                pathConvert: path('Ajax.outil.convertLibelle'),
                                convertLibelle : 'convertLibelleGlobal',
                                bulle:  'true',
                                faceAttr: {
                                    'data-zoomLink': 'input_filter_egal_SI#point#COD_TIERS'
                                },
                                inputAttr: {
                                    'data-multifilter': 'form_COD_TIERS',
                                    'data-multifilter-twin': 'table_COD_TIERS'
                                },
                            }) }}
                            {{ include('@Stock/Composant/ZoomAdvance/_empty_code_tiers.twig') }}
                        </div>
                    </div>
                    <div class="colonne2 last">
                        <div class="row">
                            {{ inputAdvance('ZOOMADVANCE',{
                                titre: 'Code article' | trad,
                                name: 'filter_egal_SI#point#ART',
                                value : post['filter_egal_SI#point#ART'],
                                pahtZoom: path('Ajax.liste.stockLocal'),
                                entity: 'Articles',
                                titleZoom : 'Liste des code articles' | trad,
                                paramZoom: "{'filter_egal_STO#point#SITE': $('#'+CSS.escape('input_filter_egal_SI#point#SITE')).val() }",
                                pathConvert: path('Ajax.outil.convertLibelle'),
                                convertLibelle: 'convertLibelleGlobal',
                                faceAttr: {
                                    'data-zoomLink': 'input_filter_egal_SI#point#ART'
                                },
                                inputAttr: {
                                    'data-multifilter': 'form_ART',
                                    'data-multifilter-twin': 'table_ART'
                                },
                                bulle :  'true',
                            }) }}
                        </div>
                    </div>
                    <div class="filtreBtn">
                        <button type="submit" class="principal button btn_filtre button_right last">
                            {{ 'Filtrer' | trad }}
                        </button>
                        <button class="secondaire button button_right" id="buttonCollapseFA"  id="buttonCollapseFA"  data-toggle="collapse" href="#filtre_avances">
                            {{  'Filtres avancés' | trad }}
                        </button>
                        <button type="button" class="secondaire button button_right" onClick="resetFormFilters('{{ formName }}');">
                            {{ 'Vider les champs' | trad }}
                        </button>
                    </div>
                </div>
            </div>

            <div id="filtre_avances" class="collapse clearfix">
                {{ filtreAvance(post, filtreAvance, initFiltreAvance) }}
            </div>
            <div class="resultat_filtre">
                {{ bullFiltre(post, formName) }}
            </div>

            <div id='refreshTable'>
                <table class="table table-hover">
                    <thead class="thead-dark" >
                    <tr>
                        <th scope="col" width="90px">
                            {{ triTable('NO_INDISP',post.tri_NO_INDISP, 'N° Indispo' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="350px">
                            {{ triTable('SITE',post.tri_SITE,'Code site' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="350px">
                            {{ triTable('ART',post.tri_ART,'Code article' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="350px">
                            {{ triTable('ART_DESIGN',post.tri_ART_DESIGN,'Désignation article' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="150px">
                            {{ triTable('DTE_MISE',post.tri_DTE_MISE,'Date de mise en indispo' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="350px">
                            {{ triTable('MOTIF',post.tri_MOTIF,'Motif' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="150px">
                            {{ triTable('LIEU',post.tri_LIEU,'Zone stockage temporaire' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="150px">
                            {{ triTable('QTE',post.tri_QTE,'Quantité indisponible' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="150px">
                            {{ triTable('QTE_REST',post.tri_QTE_REST,'Quantité restante' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="150px">
                            {{ triTable('T_DESIGN',post.tri_T_DESIGN,'Tiers' | trad, '', '', formName) }}
                        </th>
                        <th scope="col" width="40px">{{ 'Actions' | trad }}</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="recherche">
                        <td>
                            {{ filterTable('egal_SI#point#NO_INDISP', post['filter_egal_SI#point#NO_INDISP'], '', '', '', formName, '', 'N° d\'indispo' | trad) }}
                        </td>
                        <td>
                            {{ filterTable(
                                'egal_SI#point#SITE',
                                post['filter_egal_SI#point#SITE'],
                                '', '', '',formName, '',
                                'Code site' | trad, '', false, 'readonly', null, null, null,
                                {
                                    'data-multifilter': 'table_SITE',
                                    'data-multifilter-twin': 'form_SITE'
                                }
                            ) }}
                        </td>
                        <td>
                            {{ filterTable(
                                'egal_SI#point#ART',
                                post['filter_egal_SI#point#ART'],
                                '', '', '',formName, '',
                                'Code article' | trad, '', false, 'readonly', null, null, null,
                                {
                                    'data-multifilter': 'table_ART',
                                    'data-multifilter-twin': 'form_ART'
                                }
                            ) }}
                        </td>
                        <td>
                            {{ filterTable('SA#point#DESIGN',post['filter_SA#point#DESIGN'],'', '', '',formName, '','Désignation article' | trad) }}
                        </td>
                        <td>
                            {{ filterTable('date_SI#point#DTE_MISE', post['filter_date_SI#point#DTE_MISE'], '', '', '', formName, 'datepicker', 'Date de mise en indispo' | trad) }}
                        </td>
                        <td>
                            {{ filterTable('SI#point#MOTIF', post['filter_SI#point#MOTIF'], '', '', '',formName, '', 'Motif' | trad) }}
                        </td>
                        <td>
                            {{ filterTable('SI#point#LIEU', post['filter_SI#point#LIEU'], '', '', '',formName, '', 'Lieu' | trad) }}
                        </td>
                        <td>
                            {{ filterTable('egal_SI#point#QTE', post['filter_egal_SI#point#QTE'], '', '', '',formName, '', 'Quantité' | trad) }}
                        </td>
                        <td>
                            {{ filterTable('egal_SI#point#QTE_REST', post['filter_egal_SI#point#QTE_REST'], '', '', '',formName, '', 'Quantité restante' | trad) }}
                        </td>
                        <td>
                            {{ filterTable('T#point#RS',post['filter_T#point#RS'],'', '', '',formName, '','Désignation tiers' | trad) }}
                        </td>
                        <td></td>
                    </tr>

                    {% for indisponibilite in indisponibilites %}
                        <tr id="sindispo{{ indisponibilite.NO_INDISP }}" class="{% if loop.index is divisible by(2) %}even{% else %}odd{% endif %}">
                            <td class="montant">{{ indisponibilite.NO_INDISP }}</td>
                            <td>{{ indisponibilite.SITE }}</td>
                            <td>{{ indisponibilite.ART }}</td>
                            <td>{{ indisponibilite.ART_DESIGN }}</td>
                            <td>{{ indisponibilite.DTE_MISE | dateTrad | visualise }}</td>
                            <td>{{ indisponibilite.MOTIF | visualise }}</td>
                            <td>{{ indisponibilite.LIEU | visualise }}</td>
                            <td class="text-right">{{ indisponibilite.QTE | qte ~ ' ' ~ indisponibilite.UNITE_STK }}</td>
                            <td class="text-right">{{ indisponibilite.QTE_REST | qte ~ ' ' ~ indisponibilite.UNITE_STK }}</td>
                            <td>{{ indisponibilite.T_DESIGN | visualise  }}</td>
                            <td class="parametrage">
                                {{ menuContextuel('sindispo' ~ indisponibilite.NO_INDISP,false,indisponibilite.menuContextuel,10) }}
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
                {{ paginations(
                    path('Stock.Indisponibilite.gestion'),
                    infoPagination.nombreDePage,
                    infoPagination.page,
                    infoPagination.post,
                    formName
                ) }}
            </div>
        </form>
    </div>
    <script type="text/javascript" src="{{ baseUrl('js/Modules/Stock/multiForm.js') }}"></script>
    <script type="text/javascript" src="{{ baseUrl('js/Modules/Stock/resetFormFilters.js') }}"></script>
    <script type="application/javascript" src="{{ baseUrl('js/Modules/Stock/zoomAdvanceReinitialiser.js') }}"></script>
{% endblock %}