{% extends 'layout.twig' %}

{% block body %}
    <div class="contenu clearfix">
        <H1>{{ 'Stocks locaux' | trad }}</H1>
        {{ ariane() }}
        <div class="tab-content" id="tab-content">
            <form method="post" name="stock" id="sds-ente-form">
                <h3 class="mb-base">
                    {{ strBuild('Visualisation du stock local de l\'article : @1@ - @2@' | trad, [stockArticle.CODE_ART, stockArticle.DESIGN]) }}
                    <input type="hidden" id="input_SSTOCKLO[SITE]" value="{{ siteStock.SITE }}">
                    <input type="hidden" id="input_SSTOCKLO[CODE_ART]" value="{{ stockArticle.CODE_ART }}">
                </h3>
                <div class="tab-content">
                    <div class="tab-pane active in clearfix bg_form border_form pr-base pl-base">
                        <fieldset class="scheduler-border">
                            <legend class="scheduler-border">{{ 'Stock local' | trad}}</legend>
                            <div class="colonne2">
                                <div class="informations">
                                    <p>
                                        <span class="champs_label">{{ 'Site' | trad }}</span>
                                        <span class="resultat">{{ siteStock.DESIGN ~ ' (' ~ siteStock.SITE ~ ')' }}</span>
                                    </p>
                                    <p>
                                        <span class="champs_label">{{ 'Société' | trad }}</span>
                                        <span class="resultat">{{ societe.RAIS_SOC ~ ' (' ~ societe.CODE_STE ~ ')' }}</span>
                                    </p>
                                </div>
                            </div>
                            <div class="colonne2 last">
                                <div class="informations">
                                    <p>
                                        <span class="champs_label">{{ 'Article stocké' | trad }}</span>
                                        <span class="resultat">{{ stockArticle.CODE_ART }}</span>
                                    </p>
                                    <p>
                                        <span class="champs_label">{{ 'Stratégique' | trad }}</span>
                                        <span class="resultat">{{ stockArticle.STRATEG ? ('Oui' | trad) : ('Non' | trad) }}</span>
                                    </p>
                                </div>
                            </div>
                        </fieldset>
                        {% embed '@Stock/StockLocal/Composant/_toggle_tab.twig' %}
                            {% block stock %}
                                <div class="row">
                                    <div class="colonne2">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Quantité physique' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_PHYS | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Quantité réservée' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_RES | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Quantité en prévision' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_PREV | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Quantité indisponible' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_INDIS | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Quantité en réappro' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_REAP | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Dont en commande' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_LIV | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Dont en acheminement' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_ACHEM | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="colonne2 last">
                                        <input type="hidden" name="SSTOCKLO[SITE]" value="{{ stockLocal.SITE }}" id="input_SSTOCKLO[SITE]">
                                        {{ include('@Stock/StockLocal/Composant/Bouton/_voir_cumuls_conso.twig') }}

                                        {% if stockArticle.TRACABLE == '54' %}
                                            <input type="hidden" name="SSTOCKLO[CODE_ART]" value="{{ stockLocal.CODE_ART }}" id="input_SSTOCKLO[CODE_ART]">
                                            {{ include('@Stock/StockLocal/Composant/Bouton/_voir_lots.twig') }}
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="row mb-0">
                                    <hr>
                                    <div class="colonne2">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Quantité disponible' | trad }}</span>
                                                <span class="resultat text-right">
                                                    {{  qte_stock_local_disponible(stockLocal) | qte ~ ' ' ~ stockArticle.UNITE_STK }}
                                                </span>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="colonne2 last">
                                        <div class="informations">
                                            {% if is_prix_visible() %}
                                                <p>
                                                    <span class="champs_label">{{ 'Valeur unitaire' | trad }}</span>
                                                    <span class="resultat text-right">{{  stockLocal.VAL_LOCAL | prix ~ ' ' ~ siteStock.DEVISE }}</span>
                                                </p>
                                            {% endif %}
                                        </div>
                                    </div>
                                </div>
                            {% endblock %}

                            {% block reapprovisionnement %}
                                <div class="colonne2">
                                    <div class="row">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Délai d\'Appro' | trad }}</span>
                                                <span class="resultat text-right">{{  strBuild('@1@ jours' | trad, [stockLocal.DELAI_APP]) }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Stock de protection' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.STK_PRO | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Conso. Prévue par an' | trad }}</span>
                                                <span class="resultat text-right">{{ strBuild('@1@ @2@ /an' | trad, [stockLocal.CONSO_ANU | qte, stockArticle.UNITE_STK]) }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Type de réappro' | trad }}</span>
                                                <span class="resultat">{{  listeTypeReappro[stockLocal.TYPE_REA] }}</span>
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="colonne2 last">
                                    <div class="row">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Quantité Maxi stockable' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_MAX | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Quantité Economique' | trad }}</span>
                                                <span class="resultat text-right">{{  stockLocal.QTE_ECO | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Seuil de commande' | trad }}</span>
                                                <span class="resultat text-right">{{  ((stockLocal.STK_PRO|number_format(2, '.', '') + 0) + ((stockLocal.CONSO_ANU|number_format(2, '.', '') + 0) / 365) * (stockLocal.DELAI_APP|number_format(2, '.', '') + 0)) | qte ~ ' ' ~ stockArticle.UNITE_STK }}</span>
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            {% endblock %}

                            {% block details %}
                                <fieldset class="scheduler-border">
                                    <legend class="scheduler-border">{{ 'Inventaire' | trad }}</legend>
                                    <div class="colonne2">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Emplacement' | trad }}</span>
                                                <span class="resultat">{{  stockLocal.EMPLAC }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Périodicité (en jours)' | trad }}</span>
                                                <span class="resultat">{{  stockLocal.PERIO_INV }}</span>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="colonne2 last">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Date du prochain inventaire' | trad }}</span>
                                                <span class="resultat">{{  stockLocal.DTE_INV | dateTrad }}</span>
                                            </p>
                                        </div>
                                    </div>
                                </fieldset>
                                <fieldset class="scheduler-border">
                                    <legend class="scheduler-border">
                                        {{ strBuild('Mouvements sur le site @1@ (@2@)' | trad, [siteStock.DESIGN, siteStock.SITE]) }}
                                    </legend>
                                    <div class="colonne2">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Date de dernière entrée' | trad }}</span>
                                                <span class="resultat">{{ dernierEntreeData.DTE_MVT | dateTrad | visualise }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Date de dernière sortie' | trad }}</span>
                                                <span class="resultat">{{ dernierSortieData.DTE_MVT | dateTrad | visualise }}</span>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="colonne2 last">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Quantité dernière entrée' | trad }}</span>
                                                <span class="resultat text-right">{{ (dernierEntreeData.SUM_QTE ? dernierEntreeData.SUM_QTE | qte ~ ' ' ~ stockArticle.UNITE_STK: '') | visualise }}</span>
                                            </p>
                                            <p class="mb-large">
                                                <span class="champs_label">{{ 'Quantité dernière sortie' | trad }}</span>
                                                <span class="resultat text-right">{{ (dernierSortieData.SUM_QTE ? dernierSortieData.SUM_QTE | qte ~ ' ' ~ stockArticle.UNITE_STK: '') | visualise }}</span>
                                            </p>
                                            {% if (dernierEntreeData or dernierSortieData) and hasSmouvemeAccessRights %}
                                                <button type="button" class="button principal button_right last" id="mouvements">
                                                    {{ 'Mouvements' | trad }}
                                                </button>
                                            {% endif %}
                                        </div>
                                    </div>
                                </fieldset>
                                <fieldset class="scheduler-border">
                                <legend class="scheduler-border">{{ 'Imputations' | trad }}</legend>
                                    <div class="colonne2">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Section d\'imputation' | trad }}</span>
                                                <span class="resultat">{{ (sectionImputation.LIBELLE ~ ' (' ~ stockLocal.STKLO_SI ~ ')') | visualise }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Sous-compte d\'analyse' | trad }}</span>
                                                <span class="resultat">{{ (sousCompteAnalyse.LIBELLE ~ ' (' ~ stockLocal.STKLO_SCA ~ ')') | visualise }}</span>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="colonne2 last">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Code complémentaire' | trad }}</span>
                                                <span class="resultat">{{ (codeComplementaire.LIBELLE ~ ' (' ~ stockLocal.STKLO_CDC ~ ')') | visualise }}</span>
                                            </p>
                                        </div>
                                    </div>
                                </fieldset>
                                <fieldset class="scheduler-border mb-0">
                                    <legend class="scheduler-border">{{ 'Gamme' | trad }}</legend>
                                    <div class="colonne2">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Fabricant' | trad }}</span>
                                                <span class="resultat">{{ article.CODEFAB | visualise }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Gamme' | trad }}</span>
                                                <span class="resultat">{{ article.CODEGAM | visualise }}</span>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="colonne2 last">
                                        <div class="informations">
                                            <p>
                                                <span class="champs_label">{{ 'Référence fabricant' | trad }}</span>
                                                <span class="resultat">{{ article.REFARTFAB | visualise }}</span>
                                            </p>
                                            <p>
                                                <span class="champs_label">{{ 'Date de fermeture' | trad }}</span>
                                                <span class="resultat">{{ stockLocal.DTE_FERM | dateTrad | visualise }}</span>
                                            </p>
                                        </div>
                                    </div>
                                </fieldset>
                            {% endblock %}

                            {% block champsSupplementaires %}
                                {{ VisualisationCS('SSTOCKLO', stockLocal.SITE ~ stockLocal.CODE_ART) }}
                            {% endblock %}
                        {% endembed %}
                    </div>
                </div>
            </form>
        </div>
    </div>
    {% if hasSmouvemeAccessRights %}
        {{ include('@Stock/StockLocal/Composant/_js_mouvements.twig') }}
    {% endif %}
{% endblock %}