{% extends 'layout.twig' %}

{% block body %}
    <div class="contenu clearfix"  id="sstocklos">
        <h1>
            {{ 'Stocks locaux' | trad }}
            {% if hasCreateAccessRights %}
                <a href="{{ path('Stock.StockLocal.nouveauForm') }}" class="button principal ajout mr-0">{{ 'Ajout article' | trad }}</a>
            {% endif %}
            {{ Button(
                'Export' | trad,
                false,
                '',
                'ajaxPopup(\''~path('Stock.StockLocal.popupExport')~'\', \''~'Export Stocks locaux' | trad~'\', \'\', \'\', \'\', \'modal_export \')', ''
            ) }}
        </h1>

        {{ ariane() }}

        {% set formFilterName = "filtres_stock_local"  %}
        <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">
                        <div class="filtre">
                            {{ inputAdvance('TEXT', {
                                'titre' : 'Recherche sur désignation d\'article' | trad,
                                'name' : 'filter_SA#point#DESIGN',
                                'value' : post['filter_SA#point#DESIGN'],
                                'inputAttr': {
                                    'data-multifilter': 'form_DESIGN',
                                    'data-multifilter-twin': 'table_DESIGN'
                                },
                                'faceAttr': {
                                    'data-zoomLink': 'input_filter_egal_SA#point#DESIGN'
                                },
                                'bulle': true
                            }) }}
                        </div>
                        <div class="filtre">
                            {{ inputAdvance('SWITCH', {'titre' : 'Multilingue' | trad, 'name' : 'MULTILINGUE', 'value' : post.MULTILINGUE }) }}
                        </div>
                        <button type="submit" class="principal button btn_filtre button_right mr-0">
                            {{ '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>
                    </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 class="thead-dark" >
                        <tr>
                            <th scope="col" width="100px">
                                {{ triTable('SITE', post.tri_SITE, 'Code site' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="150px">
                                {{ triTable('SITE_DESIGN', post.tri_SITE_DESIGN, 'Désignation site' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="90px">
                                {{ triTable('EMPLAC', post.tri_EMPLAC, 'Emplacement' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="90px">
                                {{ triTable('CODE_ART',post.tri_CODE_ART, 'Code article' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="300px">
                                {{ triTable('ART_DESIGN',post.tri_ART_DESIGN, 'Désignation article' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('QTE_PHYS',post.tri_QTE_PHYS, 'Quantité physique' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('QTE_RES',post.tri_QTE_RES, 'Quantité réservée' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('QTE_INDIS',post.tri_QTE_INDIS, 'Quantité indisponible' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="100px">
                                {{ triTable('QTE_DISPO',post.tri_QTE_DISPO, 'Quantité disponible' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="40px">{{ 'Actions' | trad }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="recherche">
                            <td>
                                {{ zoomFilter("egal_STO#point#SITE", post['filter_egal_STO#point#SITE'], "", formFilterName, path('Ajax.liste.siteStockAccessible'), 'Code site' | trad, '','','','','','Code site') }}
                            </td>
                            <td>
                                {{ filterTable('SI#point#DESIGN', post['filter_SI#point#DESIGN'], '', '', '',formFilterName, '', 'Désignation site' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('STO#point#EMPLAC', post['filter_STO#point#EMPLAC'], '', '', '',formFilterName, '', 'Emplacement' | trad) }}
                            </td>
                            <td>
                                {{ zoomFilter("egal_STO#point#CODE_ART", post['filter_egal_STO#point#CODE_ART'], "", formFilterName, path('Ajax.liste.stockArticles'), 'Code article' | trad, '','','','','','Code article') }}
                            </td>
                            <td>
                                {{ filterTable(
                                    'SA#point#DESIGN',
                                    post['filter_SA#point#DESIGN'],
                                    '', '', '',formFilterName, '',
                                    'Désignation article' | trad, false, false, 'readonly', null, null, null,
                                    {
                                        'data-multifilter': 'table_DESIGN',
                                        'data-multifilter-twin': 'form_DESIGN'
                                    }
                                ) }}
                            </td>
                            <td>
                                {{ filterTable('egal_STO#point#QTE_PHYS', post['filter_egal_STO#point#QTE_PHYS'], '', '', '',formFilterName, '', 'Quantité physique' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('egal_STO#point#QTE_RES', post['filter_egal_STO#point#QTE_RES'], '', '', '',formFilterName, '', 'Quantité réservée' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('egal_STO#point#QTE_INDIS', post['filter_egal_STO#point#QTE_INDIS'], '', '', '',formFilterName, '', 'Quantité indisponible' | trad) }}
                            </td>
                            <td>
                                {{ filterTable('egal_S#point#QTE_DISPO', post['filter_egal_S#point#QTE_DISPO'], '', '', '',formFilterName, '', 'Quantité disponible' | trad) }}
                            </td>
                            <td></td>
                        </tr>

                        {% for stockLocal in stockLocaux %}
                            <tr id="sstocklo{{ stockLocal.CODE_ART }}" class="{% if loop.index is divisible by(2) %}even{% else %}odd{% endif %}">
                                <td>{{ stockLocal.SITE }}</td>
                                <td>{{ stockLocal.SITE_DESIGN }}</td>
                                <td>{{ stockLocal.EMPLAC }}</td>
                                <td>{{ stockLocal.CODE_ART }}</td>
                                <td>{{ stockLocal.ART_DESIGN }}</td>
                                <td class="text-right">{{ (stockLocal.QTE_PHYS | qte) ~ ' ' ~ stockLocal.UNITE_STK }}</td>
                                <td class="text-right">{{ (stockLocal.QTE_RES | qte) ~ ' ' ~ stockLocal.UNITE_STK }}</td>
                                <td class="text-right">{{ (stockLocal.QTE_INDIS | qte) ~ ' ' ~ stockLocal.UNITE_STK }}</td>
                                <td class="text-right">{{ (stockLocal.QTE_DISPO | qte) ~ ' ' ~ stockLocal.UNITE_STK }}</td>
                                <td class="parametrage">
                                    {% if stockLocal.NB_DOC > 0 %}
                                        <a href="{{ path(
                                            'GlobalApplication.DocumentRattaches.document',
                                            {MODULE: 'StockLocal', id: stockLocal.idDoc}
                                        ) }}" class="documents_attaches white-tooltip">
                                            <span class="infos_tooltip top-left">
                                                {{ strBuild('Présence de documents rattachés pour ce @1@. Cliquer pour les visualiser' | trad, ['stock local' | trad]) }}
                                            </span>
                                        </a>
                                    {% endif %}
                                    {{ menuContextuel('sstocklo' ~ stockLocal.CODE_ART, false, stockLocal.menuContextuel, 10) }}
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    {{ paginations(
                        path('Stock.StockLocal.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/zoomAdvanceReinitialiser.js') }}"></script>
{% endblock %}