{% block body %}
<form method="post" name="filtre_facture" id="filtre_facture" style="display: none;">
    <div class="padding_form bg_form border_form" id="filtre_standard">
        {# <div class="filtre">
            <div class="row">
                {{ inputAdvance('SELECT', {
                    'titre' : 'Type de fournisseur' | trad ~ ' :',
                    'name' : 'supplier_type',
                    'value' : post.supplier_type,
                    'listeValue' : supplierTypes,
                    'myFunction' : 'visibiliteAxeImputation',
                    'myParams' : '["'~ params.SISECTOR ~'", "'~ params.CDCSECTO ~'", "'~ params.SCASECTO ~'"]',
                }) }}
            </div>
        </div>
        {# les deux prochains filtres servent à maintenir les filtres en place visuellement TODO MCH trouver une meilleure solution #}
        {# <div class="filtre">
        </div>
        <div class="filtre">
        </div> #} 
        {# filtres Chiffre d'affaires #}
            <fieldset class="scheduler-border tableNote">
                <legend class="scheduler-border tableNote">{{ 'Chiffre d\'affaires' | trad }}</legend>
                    <div class="filtre filtre3 last">
                        <div class="row">
                            {{ inputAdvance('ZOOMADVANCE', {
                                'titre'             : 'Période' | trad ~ ' :',
                                'name'              : 'turnover_year',
                                'value'             : post.turnover_year,
                                'placeholder'       : 'Choisissez une période' | trad,
                                'pahtZoom'          : path('Ajax.liste.periodes'),
                                'paramZoom'         : "{}",
                                'entity'            : 'Periodes',
                                'titleZoom'         : 'Liste des périodes' | trad,
                                'pathConvert'       : path('Ajax.outil.convertLibelle'),
                                'convertLibelle'    : 'convertLibelleGlobal',
                            }) }}
                        </div>
                    </div>
                    {# filtre CA déclaré #}
                        <div class="row" style="margin: 0 0 0 0;">
                            <div class="filtre filtre3 last">
                                <div class="row">
                                    {{ inputAdvance('SELECT', {
                                        'titre'             : 'CA déclaré' | trad ~ ' :',
                                        'name'              : 'declared_turnover_rule',
                                        'value'             : post.declared_turnover_rule,
                                        'listeValue'        : turnoverRules,
                                        'addStyle'          : 'numeric_rule'
                                    }) }}
                                </div>
                            </div>
                            <div class="filtre filtre3 filtre_double">
                                <div class="row">
                                    {{ inputText(
                                        '', 
                                        'declared_turnover_min_value',
                                        post.declared_turnover_min_value,
                                        'Montant' | trad,
                                        params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                                        false,
                                        '', 'input_value', 'display: none;',
                                        false, '', '', '', '', '', '', '', '', '', 
                                        true,
                                    ) }}
                                    {{ inputText(
                                        '', 
                                        'declared_turnover_max_value',
                                        post.declared_turnover_max_value,
                                        'Montant' | trad,
                                        params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                                        false,
                                        '', 'max_value', 'display: none;',
                                        false, '', '', '', '', '', '', '', '', '', 
                                        true,
                                    ) }}
                                </div>
                            </div>
                        </div>
                    {# filtre CA généré #}
                        <div class="row" style="margin: 0 0 0 0;">
                            <div class="filtre filtre3 last">
                                <div class="row">
                                    {{ inputAdvance('SELECT', {
                                        'titre'             : 'CA généré' | trad ~ ' :',
                                        'name'              : 'generated_turnover_type',
                                        'value'             : post.generated_turnover_type,
                                        'listeValue'        : turnoverTypes,
                                        'addStyle'          : ''
                                    }) }}
                                </div>
                            </div>
                            <div class="filtre filtre3 filtre_double">
                                <div class="row">
                                    {{ inputSelect(
                                        '',
                                        'generated_turnover_rule',
                                        numericRules,
                                        post.generated_turnover_rule,
                                        params.CODE_CDC_LOCK ? 'DISABLED' : '',
                                        '',
                                        '',
                                        false,
                                        '',
                                        '[]',
                                        'numeric_rule',
                                        false, '', false, false, '', '', '', '', '', 'display: none;'
                                    ) }}
                                    {{ inputText(
                                        '', 
                                        'generated_turnover_min_value',
                                        post.generated_turnover_min_value,
                                        'Montant' | trad,
                                        params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                                        false,
                                        '', 'input_value', 'display: none;',
                                        false, '', '', '', '', '', '', '', '', '', 
                                        true,
                                    ) }}
                                    {{ inputText(
                                        '', 
                                        'generated_turnover_max_value',
                                        post.generated_turnover_max_value,
                                        'Montant' | trad,
                                        params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                                        false,
                                        '', 'max_value', 'display: none;',
                                        false, '', '', '', '', '', '', '', '', '', 
                                        true,
                                    ) }}
                                </div>
                            </div>
                        </div>
            </fieldset>

        {# filtres Documents #}
            <fieldset class="scheduler-border tableNote">
                <legend class="scheduler-border tableNote">{{ 'Documents' | trad }}</legend>
                {# filtre Appel d'offres #}
                    <div class="filtre filtre3 last">
                        <div class="row">
                            {{ inputAdvance('SELECT', {
                                'titre' : 'Appels d\'offres' | trad ~ ' :',
                                'name' : 'tenders_filters',
                                'value' : post.tenders_filters,
                                'listeValue' : documentRules,
                            }) }}
                        </div>
                    </div>
                    <div class="filtre filtre_double last">
                        <div class="row">
                            {{ inputSelect(
                                '',
                                'tenders_rule',
                                numericRules,
                                post.tenders_rule,
                                params.CODE_CDC_LOCK ? 'DISABLED' : '',
                                '',
                                '',
                                false,
                                '',
                                '[]',
                                'numeric_rule',
                                false,
                            ) }}
                            {{ inputText(
                                '', 
                                'tenders_min_value',
                                post.tenders_min_value,
                                'Nombre' | trad,
                                params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                                false,
                                '', 'min_value', 'display: none;',
                                false, '', '', '', '', '', '', '', '', '', 
                                true,
                            ) }}
                            {{ inputText(
                                '', 
                                'tenders_max_value',
                                post.tenders_max_value,
                                'Nombre' | trad,
                                params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                                false,
                                '', 'max_value', 'display: none;',
                                false, '', '', '', '', '', '', '', '', '', 
                                true,
                            ) }} 
                        </div>
                    </div>
                {# filtre commandes #}
                <div class="filtre filtre3 last">
                    <div class="row">
                        {{ inputAdvance('SELECT', {
                            'titre' : 'Commandes' | trad ~ ' :',
                            'name' : 'orders_filters',
                            'value' : post.orders_filters,
                            'listeValue' : documentRules,
                        }) }}
                    </div>
                </div>
                <div class="filtre filtre_double last">
                    <div class="row">
                        {{ inputSelect(
                            '',
                            'orders_rule',
                            numericRules,
                            post.orders_rule,
                            params.CODE_CDC_LOCK ? 'DISABLED' : '',
                            '',
                            '',
                            false,
                            '',
                            '[]',
                            'numeric_rule',
                            false, 
                        ) }}
                        {{ inputText(
                            '', 
                            'orders_min_value',
                            post.orders_min_value,
                            'Nombre' | trad,
                            params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                            false,
                            '', 'min_value', 'display: none;',
                            false, '', '', '', '', '', '', '', '', '', 
                            true,
                        ) }}
                        {{ inputText(
                            '', 
                            'orders_max_value',
                            post.orders_max_value,
                            'Nombre' | trad,
                            params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                            false,
                            '', 'max_value', 'display: none;',
                            false, '', '', '', '', '', '', '', '', '', 
                            true,
                        ) }} 
                    </div>
                </div>
                {# filtre factures #}
                <div class="filtre filtre3 last">
                    <div class="row">
                        {{ inputAdvance('SELECT', {
                            'titre' : 'Factures' | trad ~ ' :',
                            'name' : 'invoices_filters',
                            'value' : post.invoices_filters,
                            'listeValue' : documentRules,
                        }) }}
                    </div>
                </div>
                <div class="filtre filtre_double last">
                    <div class="row">
                        {{ inputSelect(
                            '',
                            'invoices_rule',
                            numericRules,
                            post.invoices_rule,
                            params.CODE_CDC_LOCK ? 'DISABLED' : '',
                            '',
                            '',
                            false,
                            '',
                            '[]',
                            'numeric_rule',
                            false,
                        ) }}
                        {{ inputText(
                            '', 
                            'invoices_min_value',
                            post.invoices_min_value,
                            'Nombre' | trad,
                            params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                            false,
                            '', 'min_value', 'display: none;',
                            false, '', '', '', '', '', '', '', '', '', 
                            true,
                        ) }}
                        {{ inputText(
                            '', 
                            'invoices_max_value',
                            post.invoices_max_value,
                            'Nombre' | trad,
                            params.CODE_CDC_LOCK ? 'DISABLED' : '', '', '',
                            false,
                            '', 'max_value', 'display: none;',
                            false, '', '', '', '', '', '', '', '', '', 
                            true,
                        ) }} 
                    </div>
                </div>
            </fieldset>

        {# boutons et filtres avancés #}
        <div class="filtreBtn" style="margin-top: 10px;">
            <button class="principal button btn_filtre last button_right" onclick="refrechDiv('{{ path('Evaluation.Campaign.supplierList',{id:campaign.ID_CAMP}) }}', 'divRefreshFrs', 'filtre_facture');return false;">{{ 'Filtrer' | trad }}</button>
            <button class="secondaire button ajout button_right" id="buttonCollapseFA" data-toggle="collapse" href="#filtre_avances" >
                {{  'Filtres avancés' | trad }}
            </button>
            <a class="secondaire button button_right" id="reset_filters" onclick="clearFilters();">
                {{  'Réinitialiser' | trad }}
            </a>
            <input type="hidden" id="retract" value="{{'Retracter' | trad}}">
            <input type="hidden" id="advancedFilters" value="{{ 'Filtres avancés' | trad }}">
        </div>
    </div>
    <div id="filtre_avances" class="collapse clearfix">
        {{ filtreAvance(post, filtreAvance, initFiltreAvance) }}  
    </div>
    <div class="resultat_filtre">
        {{ bullFiltre(post, 'filtre_facture') }}
    </div>
</form>
<script>
    $('#input_generated_turnover_type').change(function(){
        if ($(this).val() == '') {
            $('#input_generated_turnover_rule').hide();
        } else {
            $('#input_generated_turnover_rule').show();
        }
    })
    $('.numeric_rule').change(function(){
        let id_min = '#' + $(this).attr('id').slice(0, -5) + '_min_value';
        let id_max = '#' + $(this).attr('id').slice(0, -5) + '_max_value';
        if ($(this).val() == 'B') {
            $(id_min).show();
            $(id_max).show();
        } else if ($(this).val() != '') {
            $(id_min).show();
            $(id_max).hide();
        } else {
            $(id_min).hide();
            $(id_max).hide();
        }
    })
    $(window).on('load', function(){
        clearFilters();
    });
    function clearFilters() {
        $(':input','#filtre_standard')
            .not(':button, :submit, :reset, :hidden')
            .val('')
            .prop('checked', false)
            .prop('selected', false);
        $('#input_generated_turnover_rule').hide();
        $('.max_value').hide();
        $('.min_value').hide();
        $('.input_value').hide();
    }
</script>
<style>
    #show_filters {
        margin: 10px 0 0 0 !important;
    }
    
    form .filtre3 {
	width:33% !important;
	}

    form .filtre_double {
	width:66.3% !important;
	}

    form .filtre-full {
	width:99.55% !important;
	}

    form .input_value {
	margin-right: 2% !important;
	}

    form .filtre_double select{
        float: left;
        width:30% !important;
        margin: 0 20px 0 0 !important;
    }

    form .filtre-full select{
        float: left;
        width:17.55% !important;
    }

    form .filtre-full label{
        float: left;
        width:13.2% !important;
        margin-right: 1% !important;
    }

    form .filtre_double input{
        float: left;
        width:30% !important;
        margin: 0 20px 0 0 !important;
    }

    form .filtre-full input{
        float: left;
        width:20.475% !important;
    }

</style>
{% endblock %}
