{% extends 'layout.twig' %}

{% block body %}
    <div class="contenu clearfix"  id="sbs_entes">
        <h1>
            {{ 'Articles' | trad }}
            {{ Button(
                'Export' | trad,
                false,
                '',
                'ajaxPopup(\''~path('Stock.StockArticle.popupExport')~'\', \''~'Export Article' | trad~'\', \'\', \'\', \'\', \'modal_export \')', ''
            ) }}
        </h1>
        {{ ariane() }}

        {% set formFilterName = "filtres_stock_article"  %}
        <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="colonne2">
                            <div class="row mb-0">
                                {{ inputAdvance('TEXT', {
                                    'titre' : 'Recherche sur désignation d\'article' | trad,
                                    'name' : 'filter_SA#point#DESIGN',
                                    'value' : post['filter_SA#point#DESIGN'],
                                    'bulle' : 'true',
                                    'inputAttr': {
                                        'data-multifilter': 'form_DESIGN',
                                        'data-multifilter-twin': 'table_DESIGN'
                                    },
                                    'bulle': true
                                }) }}
                            </div>
                        </div>
                        <div class="colonne2 last">
                            <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>
                        </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 class="thead-dark" >
                        <tr>
                            <th scope="col" width="150px">
                                {{ triTable('CODE_ART', post.tri_CODE_ART, 'Code article' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="600px">
                                {{ triTable('DESIGN', post.tri_DESIGN,'Désignation' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="150px">
                                {{ triTable('QTE_PHY', post.tri_QTE_PHY,'Quantité physique' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="150px">
                                {{ triTable('UNITE_STK', post.tri_UNITE_STK,'Unité stockée' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="110px">
                                {{ triTable('TYPE_VALO', post.tri_TYPE_VALO,'Type de valorisation' | trad, '', '', formFilterName) }}
                            </th>
                            {% if is_prix_visible() %}
                                <th scope="col" width="150px">
                                    {{ triTable('VALEUR', post.tri_VALEUR,'Valeur' | trad, '', '', formFilterName) }}
                                </th>
                            {% endif %}
                            <th scope="col" width="110px">
                                {{ triTable('STRATEG',post.tri_STRATEG, 'Stratégique' | trad, '', '', formFilterName) }}
                            </th>
                            <th scope="col" width="40px">{{ 'Actions' | trad }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="recherche">
                            <td>
                                {{ zoomFilter("egal_SA#point#CODE_ART", post['filter_egal_SA#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' | trad, false, false, 'readonly', null, null, null,
                                    {
                                        'data-multifilter': 'table_DESIGN',
                                        'data-multifilter-twin': 'form_DESIGN'
                                    }
                                ) }}
                            </td>
                            <td>{{ filterTable('montant_SA#point#QTE_PHY', post['filter_montant_SA#point#QTE_PHY'], '', '', '', formFilterName,'', 'Quantité physique' | trad) }}</td>
                            <td>{{ filterTable('egal_SA#point#UNITE_STK', post['filter_egal_SA#point#UNITE_STK'], '', '', '', formFilterName,'', 'Unité' | trad) }}</td>
                            <td>{{ filterSelect('egal_SA#point#TYPE_VALO', post['filter_egal_SA#point#TYPE_VALO'], listeFiltreTypeValo, formFilterName, '', '','', '', 'Type de valorisation' | trad) }}</td>
                            {% if is_prix_visible() %}
                                <td>{{ filterTable('montant_SA#point#VALEUR', post['filter_montant_SA#point#VALEUR'], '', '', '',formFilterName, '', 'Valeur' | trad) }}</td>
                            {% endif %}
                            <td>{{ filterSelect('egal_SA#point#STRATEG', post['filter_egal_SA#point#STRATEG'], listeFiltreBool,formFilterName, '', '', '', '', 'Stratégique ?' | trad) }}</td>
                            <td></td>
                        </tr>

                        {% for stockArticle in stockArticles %}
                            <tr id="sarticle{{ stockArticle.CODE_ART }}" class="{% if loop.index is divisible by(2) %}even{% else %}odd{% endif %}">
                                <td
                                        class="code toggleSlide"
                                        onclick="toggleSlide('{{ path('Stock.StockArticle.ligne', { codeArt: stockArticle.CODE_ART }) }}','sarticle{{ stockArticle.CODE_ART }}detail', {id : '{{ stockArticle.CODE_ART }}'});"
                                >
                                    {{ stockArticle.CODE_ART }}
                                </td>
                                <td>{{ stockArticle.DESIGN }}</td>
                                <td class="text-right">{{ stockArticle.QTE_PHY | qte }}</td>
                                <td>{{ stockArticle.UNITE_STK }}</td>
                                <td>{{ listeFiltreTypeValo[stockArticle.TYPE_VALO] }}</td>
                                {% if is_prix_visible() %}
                                    <td class="text-right">{{ stockArticle.VALEUR | prix ~ ' ' ~ devise }}</td>
                                {% endif %}
                                <td>{{ stockArticle.STRATEG == '54' ? ('Oui' | trad) : ('Non' | trad) }}</td>
                                <td class="parametrage">
                                    {{ menuContextuel('sarticle' ~ stockArticle.CODE_ART, false, stockArticle.menuContextuel, 10) }}
                                </td>
                            </tr>
                            <tr class="detail_ligne hide_detail" id="sarticle{{ stockArticle.CODE_ART }}detail"></tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    {{ paginations(
                        path('Stock.StockArticle.gestion'),
                        infoPagination.nombreDePage,
                        infoPagination.page,
                        infoPagination.post,
                        formFilterName
                    ) }}
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript" src="{{ baseUrl('js/Modules/Stock/multiForm.js') }}"></script>
{% endblock %}