{% extends 'layout.twig' %}

{% block body %}
    <div class="contenu clearfix"  id="sbs_entes">
        <H1>
            {{ 'Bons de transfert' | trad }}
            <a href="{{ path('Stock.BonTransfert.nouveauForm') }}" class="button principal ajout button_right mr-0">
                {{ 'Nouveau' | trad }}
            </a>
            {{ Button(
                'Export' | trad,
                false,
                '',
                'ajaxPopup(\''~path('Stock.BonTransfert.popupExport')~'\', \''~'Export Bons de transfert' | trad~'\', \'\', \'\', \'\', \'modal_export \')', ''
            ) }}
        </H1>

        {{ ariane() }}

        {% set formFilterName = "filtres_bon_transfert"  %}
        <div class="tab-content" id="tab-content">
            <p></p>
            <form method="post" name="{{ formFilterName }}" id="{{ formFilterName }}">
                <div class="tab-content">
                    <div id="filtre" class="tab-pane active in clearfix bg_form padding_form border_form filtre_facture">
                        <div class="filtre">
                            {{ inputAdvance('ZOOMADVANCE', {
                                'titre': 'Magasinier' | trad,
                                'name' : 'filter_egal_SE#point#MAG',
                                'value' : post['filter_egal_SE#point#MAG'],
                                'pahtZoom' : path('Ajax.liste.magasiniers'),
                                'entity' : 'HASTUTIL',
                                'titleZoom' : 'Liste des magasiniers' | trad,
                                'pathConvert' : path('Ajax.outil.convertLibelle'),
                                'convertLibelle' : 'convertLibelleGlobal',
                                'pathValidator' : path('Ajax.validator.zoom'),
                                'paramsValidator' : "{'entity' : 'HASTUTIL','nomChamp' : '"~ 'Magasinier' | trad ~"', 'null' : true}",
                                'bulle' :  'true',
                                'inputAttr': {
                                    'data-multifilter': 'form_MAG',
                                    'data-multifilter-twin': 'table_MAG'
                                },
                                'faceAttr': {
                                    'data-zoomLink': 'input_filter_egal_SE#point#MAG'
                                },
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('ZOOMADVANCE', {
                                'titre': 'Société' | trad,
                                'name' : 'filter_egal_SE#point#CODE_STE',
                                'value' : post['filter_egal_SE#point#CODE_STE'],
                                'pahtZoom' : path('Ajax.liste.societe'),
                                'entity' : 'Societe',
                                'titleZoom' : 'Liste des sociétés' | trad,
                                'pathConvert' : path('Ajax.outil.convertLibelle'),
                                'convertLibelle' : 'convertLibelleGlobal',
                                'bulle' :  'true',
                                'inputAttr': {
                                    'data-multifilter': 'form_CODE_STE',
                                    'data-multifilter-twin': 'table_CODE_STE'
                                },
                                'faceAttr': {
                                    'data-zoomLink': 'input_filter_egal_SE#point#CODE_STE'
                                },
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('ZOOMADVANCE', {
                                'titre': 'N° de DS' | trad,
                                'name' : 'filter_egal_SL#point#NO_DS',
                                'value' : post['filter_egal_SL#point#NO_DS'],
                                'pahtZoom' : path('Ajax.liste.demandesServices'),
                                'paramZoom' : "{'filter_SE#point#SOLDE_DS' : 'E'}",
                                'entity' : 'DemandeService',
                                'titleZoom' : 'Liste des demandes de service à satisfaire' | trad,
                                'bulle' :  'true',
                                'widthPopup' : 'modal_large',
                                'inputAttr': {
                                    'data-multifilter': 'form_NO_DS',
                                    'data-multifilter-twin': 'table_NO_DS'
                                },
                                'faceAttr': {
                                    'data-zoomLink': 'input_filter_egal_SE#point#NO_DS'
                                },
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('SELECT', {
                                'titre' : 'Etat' | trad,
                                'name' : 'ETAT',
                                'value' : post.ETAT,
                                'listeValue' : listeFiltreEtat,
                                'bulle' :  'true',
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('ZOOMADVANCE', {
                                'titre': 'Site d\'origine' | trad,
                                'name' : 'filter_egal_SE#point#SITE',
                                'value' : post['filter_egal_SE#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',
                                'faceAttr': {
                                    'data-zoomLink': 'input_filter_egal_SE#point#SITE'
                                },
                                'inputAttr': {
                                    'data-multifilter': 'form_SITE',
                                    'data-multifilter-twin': 'table_SITE'
                                },
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('ZOOMADVANCE', {
                                'titre': 'Site destinataire' | trad,
                                'name' : 'filter_egal_SE#point#SITE_DEST',
                                'value' : post['filter_egal_SE#point#SITE_DEST'],
                                'pahtZoom' : path('Ajax.liste.siteStockAccessible'),
                                'entity' : 'SSiteSto',
                                'titleZoom' : 'Liste des sites de stockage' | trad,
                                'pathConvert' : path('Ajax.outil.convertLibelle'),
                                'convertLibelle' : 'convertLibelleGlobal',
                                'bulle' :  'true',
                                'faceAttr': {
                                    'data-zoomLink': 'input_filter_egal_SE#point#SITE_DEST'
                                },
                                'inputAttr': {
                                    'data-multifilter': 'form_SITE_DEST',
                                    'data-multifilter-twin': 'table_SITE_DEST'
                                },
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('TEXT', {
                                'titre' : 'Mots Clés' | trad,
                                'name' : 'MOTCLE',
                                'value' : post.MOTCLE,
                                'bulle' :  'true',
                            }) }}
                        </div>
                        <div class="filtre mb-base">
                            {{ inputAdvance('SWITCH', {
                                'titre' : 'Tous les mots ?' | trad,
                                'name' : 'TOUS_LES_MOTS',
                                'value' : post.TOUS_LES_MOTS,
                            }) }}
                        </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('{{ formFilterName }}');">
                                {{ 'Vider les champs' | trad }}
                            </button>
                            <button type="button" class="secondaire button button_right" onClick="resetFormFilters('{{ formFilterName }}', 'filter_egal_SE#point#CODE_STE');">
                                {{ 'Vider les champs (sauf société)' | trad }}
                            </button>
                        </div>
                    </div>
                </div>

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

                <div id='refreshTable'>
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th scope="col" width="70px">
                                {{ triTable('NO_BT',post.tri_NO_BT,'N° BT' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('DTE_CREAT',post.tri_DTE_CREAT,'Date création' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('DTE_VAL_S',post.tri_DTE_VAL_S,'Date validation sortie' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('DTE_VAL_E',post.tri_DTE_VAL_E,'Date validation entrée' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="250px">
                                {{ triTable('SITE',post.tri_SITE,'Site d\'origine' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="250px">
                                {{ triTable('SITE_DEST',post.tri_SITE_DEST,'Site destinataire' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="250px">
                                {{ triTable('MAG',post.tri_MAG,'Magasinier' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="70px">
                                {{ triTable('NO_DS',post.tri_NO_DS,'N°DS' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="40px">{{ 'Actions' | trad }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="recherche">
                            <td>
                                {{ filterTable('egal_SE#point#NO_BT',post['filter_egal_SE#point#NO_BT'],'', '', '',formFilterName, '','N° BT' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('date_SE#point#DTE_CREAT', post['filter_date_SE#point#DTE_CREAT'], '', '', '',formFilterName, 'datepicker', 'Date de création' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('date_SE#point#DTE_VAL_S', post['filter_date_SE#point#DTE_VAL_S'], '', '', '',formFilterName, 'datepicker', 'Date de validation de sortie' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('date_SE#point#DTE_VAL_E', post['filter_date_SE#point#DTE_VAL_E'], '', '', '',formFilterName, 'datepicker', 'Date de validation d\'entrée' | trad) }}
                            </td>
                            <td>
                                {{ filterTable(
                                    'egal_SE#point#SITE',
                                    post['filter_egal_SE#point#SITE'],
                                    '', '', '', formFilterName,'',
                                    'Site' | trad, false, false, 'readonly', null, null, null,
                                    {
                                        'data-multifilter': 'table_SITE',
                                        'data-multifilter-twin': 'form_SITE'
                                    }
                                ) }}
                            </td>
                            <td>
                                {{ filterTable(
                                    'egal_SE#point#SITE_DEST',
                                    post['filter_egal_SE#point#SITE_DEST'],
                                    '', '', '', formFilterName,'',
                                    'Site destinataire' | trad, false, false, 'readonly', null, null, null,
                                    {
                                        'data-multifilter': 'table_SITE_DEST',
                                        'data-multifilter-twin': 'form_SITE_DEST'
                                    }
                                ) }}
                            </td>
                            <td>
                                {{ filterTable(
                                    'egal_SE#point#MAG',
                                    post['filter_egal_SE#point#MAG'],
                                    '', '', '', formFilterName,'',
                                    'Magasinier' | trad, false, false, 'readonly', null, null, null,
                                    {
                                        'data-multifilter': 'table_MAG',
                                        'data-multifilter-twin': 'form_MAG'
                                    }
                                ) }}
                            </td>
                            <td>
                                {{ filterTable(
                                    'egal_SL#point#NO_DS',
                                    post['filter_egal_SL#point#NO_DS'],
                                    '', '', '',formFilterName, '',
                                    'N° DS' | trad, false, false, 'readonly', null, null, null,
                                    {
                                        'data-multifilter': 'table_NO_DS',
                                        'data-multifilter-twin': 'form_NO_DS'
                                    }
                                ) }}
                            </td>
                            <td></td>
                        </tr>

                        {% for bonTransfert in bonsTransfert %}
                            <tr id="sbtEnte{{ bonTransfert.NO_BT }}" class="{% if loop.index is divisible by(2) %}even{% else %}odd{% endif %}">
                                <td
                                        class="code montant toggleSlide"
                                        onclick="toggleSlide('{{ path('Stock.BonTransfert.ligne', { noBt: bonTransfert.NO_BT }) }}','sbtEnte{{ bonTransfert.NO_BT }}detail', {id : {{ bonTransfert.NO_BT }}});"
                                >
                                    {{ bonTransfert.NO_BT }}
                                </td>
                                <td>{{ bonTransfert.DTE_CREAT | dateTrad }}</td>
                                <td>{{ bonTransfert.DTE_VAL_S | dateTrad | visualise }}</td>
                                <td>{{ bonTransfert.DTE_VAL_E | dateTrad | visualise }}</td>
                                <td>{{ (bonTransfert.SITE_DESIGN ~ ' (' ~ bonTransfert.SITE ~ ')')|visualise }}</td>
                                <td>{{ (bonTransfert.SITE_DEST_DESIGN ~ ' (' ~ bonTransfert.SITE_DEST ~ ')')|visualise }}</td>
                                <td>{{ bonTransfert.MAG_LIBELLE ~ ' (' ~ bonTransfert.MAG ~ ')' }}</td>
                                <td class="text-right">{{ bonTransfert.NO_DS | visualise }}</td>
                                <td class="parametrage">
                                    {% if bonTransfert.NB_DOC > 0 %}
                                        {{ include('@Stock/Composant/Bouton/_doc_att_button.twig', { module: 'BonTransfert', id: bonTransfert.NO_BT, enteLabel: 'bon de transfert' | trad }) }}
                                    {% endif %}
                                    {{ menuContextuel('sbtEnte' ~ bonTransfert.NO_BT, false, bonTransfert.menuContextuel, 10) }}
                                </td>
                            </tr>
                            <tr class="detail_ligne hide_detail" id="sbtEnte{{ bonTransfert.NO_BT }}detail"></tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    {{ paginations(
                        path('Stock.BonTransfert.gestion'),
                        infoPagination.nombreDePage,
                        infoPagination.page,
                        infoPagination.post,
                        formFilterName
                    ) }}
                </div>
            </form>
        </div>
    </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/validerEntete.js') }}"></script>
    <script type="application/javascript" src="{{ baseUrl('js/Modules/Stock/zoomAdvanceReinitialiser.js') }}"></script>
{% endblock %}