{% extends 'layout.twig' %}

{% block body %}
<section class="contenu">
	<h1>{{ 'Fournisseurs' | trad }}</h1>

    {{ ariane() }}
    <h2>
        {{ 'Fournisseur' | trad }}{{ colon() }}
        {{ entityLabel(fourniss, 'CODE', 'RS') }}
    </h2>
    {{ arianeSub() }}
    
    {% if not info %}
    <article class="box-form mb-base">
        <p>{{ 'Aucune information disponible.' | trad }}</p>
    </article>
    {% endif %}

    <div class="{{ not info ? 'd-none' }}">
        {% set ident = info.SupplierIdentification %}
        <article class="box-form mb-base">
            <h3>{{ 'Identité' | trad}}</h3>
            <div class="bs-row gutter-x-base">
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'N° CSD' | trad}}</dt>
                    <dd>{{ ident.SupplierNumber }}</dd>
                    <dt>{{ 'Actif' | trad}}</dt>
                    <dd>{{ ident.IsActive ? 'Oui' | trad : 'Non' | trad }}</dd>
                    <dt>{{ 'Type' | trad}}</dt>
                    <dd>{{ ident.SupplierType }}</dd>
                    <dt>{{ 'Sous-type' | trad}}</dt>
                    <dd>{{ ident.SupplierSubType }}</dd>
                </dl>
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'Pays d’origine' | trad}}</dt>
                    <dd>{{ ident.CountryOfOriginCode }}</dd>
                    <dt>{{ 'Raison sociale' | trad}}</dt>
                    <dd>{{ ident.LegalName }}</dd>
                    <dt>{{ 'Nom d’enseigne' | trad}}</dt>
                    <dd>{{ ident.TradingName }}</dd>
                    <dt>{{ 'N° SA' | trad}}</dt>
                    <dd>{{ ident.SACompanyNumber }}</dd>
                </dl>
            </div>
        </article>
        <article class="box-form mb-base">
            <h3>{{ 'Taxe' | trad}}</h3>
            {% set tax = info.Tax %}
            <div class="bs-row gutter-x-base">
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'N° TVA' | trad}}</dt>
                    <dd>{{ tax.VATNumber }}</dd>
                    <dt>{{ 'N° Taxe sur le revenu' | trad}}</dt>
                    <dd>{{ tax.IncomeTaxNumber }}</dd>
                </dl>
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'N° PAYE' | trad}}</dt>
                    <dd>{{ tax.PAYENumber }}</dd>
                </dl>
            </div>
        </article>
        <article class="box-form mb-base">
            <h3>{{ 'BBBEE' }}</h3>
            {% set bee = info.BBBEE %}
            <div class="bs-row gutter-x-base">
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'Propriété noire' | trad}}</dt>
                    <dd>{{ bee.BlackOwnership | prix }} %</dd>
                </dl>
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'Propriété femme noire' | trad}}</dt>
                    <dd>{{ bee.BlackWomanOwnership | prix }} %</dd>
                </dl>
                <dl class="dl-info bs-col-half">
                    <dt>{{ 'Date d’expiration' | trad}}</dt>
                    <dd>{{ bee.CertificateExpiryDate == '1900-01-01T00:00:00' 
                        ? '' 
                        : bee.CertificateExpiryDate | date('Ymd') | dateTrad
                    }}</dd>
                </dl>
            </div>
        </article>

        <article class="box-form mb-base">
            <h3>{{ 'Liste des contacts' | trad }}</h3>
            <table class="table">
                <thead class="thead-dark">
                    <th>{{ 'Nom' | trad }}</th>
                    <th>{{ 'Prénom' | trad }}</th>
                    <th>{{ 'Email' | trad }}</th>
                    <th>{{ 'Téléphone mobile' | trad }}</th>
                    <th>{{ 'Fax' | trad }}</th>
                    <th>{{ 'Téléphone' | trad }}</th>
                    <th>{{ 'Site web' | trad }}</th>
                    <th>{# Note #}</th>
                </thead>
                <tbody>
                {% for contact in info.Contacts ?? [] %}
                    <tr>
                        <td>{{ contact.Name }}</td>
                        <td>{{ contact.Surname }}</td>
                        <td>{{ contact.EmailAddress }}</td>
                        <td>{{ contact.CellphoneNumber }}</td>
                        <td>{{ contact.FaxNumber }}</td>
                        <td>{{ contact.TelephoneNumber }}</td>
                        <td>{{ contact.WebsiteAddress }}</td>
                        <td>{{ contact.IsPreferred ? 'Contact préféré' | trad }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>

            <h3>{{ 'Liste des adresses' | trad }}</h3>
            <table class="table">
                <thead class="thead-dark">
                    <th>{{ 'Rue' | trad }}</th>
                    <th>{{ 'Banlieue (Code)' | trad }}</th>
                    <th>{{ 'Ville' | trad }}</th>
                    <th>{{ 'Province' | trad }}</th>
                    <th>{{ 'Code postal' | trad }}</th>
                    <th>{{ 'Pays' | trad }}</th>
                    <th>{{ 'Adresse de livraison' | trad }}</th>
                    <th>{{ 'Adresse de physique' | trad }}</th>
                    <th>{{ 'Adresse de facturation' | trad }}</th>
                    <th>{{ 'Active' | trad }}</th>
                    <th>{# Note #}</th>
                </thead>
                <tbody>
                {% for address in info.Addresses ?? [] %}
                    <tr>
                        <td>{{ [
                            address.AddressLine1 | trim,
                            address.AddressLine2 | trim,
                        ] | filter(item => item is not empty) | join(' ') }}</td>
                        <td>{{ address.SuburbCode }}</td>
                        <td>{{ address.City }}</td>
                        <td>{{ address.Province }}</td>
                        <td>{{ address.PostalCode }}</td>
                        <td>{{ address.CountryCode }}</td>
                        <td>{{ address.IsDeliveryAddress ? 'Oui' | trad : 'Non' | trad }}</td>
                        <td>{{ address.IsPhysicalAddress ? 'Oui' | trad : 'Non' | trad }}</td>
                        <td>{{ address.IsPaymentAddress ? 'Oui' | trad : 'Non' | trad }}</td>
                        <td>{{ address.IsActive ? 'Oui' | trad : 'Non' | trad }}</td>
                        <td>{{ address.IsPrefered ? 'Adresse préféré' }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>

            <h3>{{ 'Liste des comptes bancaires' | trad }}</h3>
            <table class="table">
                <thead class="thead-dark">
                    <th>{{ 'Banque' | trad }}</th>
                    <th>{{ 'Code banque' | trad }}</th>
                    <th>{{ 'Branche' | trad }}</th>
                    <th>{{ 'Code branche' | trad }}</th>
                    <th>{{ 'Compte' | trad }}</th>
                    <th>{{ 'Titulaire' | trad }}</th>
                    <th>{{ 'Actif' | trad }}</th>
                    <th>{# Note #}</th>
                </thead>
                <tbody>
                {% for account in info.BankAccounts ?? [] %}
                    <tr>
                        <td>{{ account.BankName }}</td>
                        <td>{{ account.BankCode }}</td>
                        <td>{{ account.BranchName }}</td>
                        <td>{{ account.BranchNumber }}</td>
                        <td>{{ account.AccountNumber }}</td>
                        <td>{{ account.AccountHolder }}</td>
                        <td>{{ account.IsActive ? 'Oui' | trad : 'Non' | trad }}</td>
                        <td>{{ account.IsPrefered ? 'Adresse préféré' }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </article>
    </div>

</section>
{% endblock %}