import 'jquery';

import 'datatables.net-bs5';


/**************************************Service************************************* */

//window.getRendezVous = getRendezVous;

$(document).ready(function(){

    var table = $('#dataTablesRdv').DataTable({
        language: {
            url: '../../../../assets/json/fr-FR.json',
        },
        bFilter: false,
        bInfo: false,
        pageLength: 5,
        dom: 'rtip',
        autoWidth: false, // might need this
    });

    $("#btn-show-rdv").click(function() {

        $.post( pathGetListRDV, {}, function( data ) {

            $.each( data, function( key, value ) {
                var td1 = '<b>'+key+'</b>';

                var td2 = '<div class="row">';
                $.each( value, function( key, value ) {
                    td2 += '<div class="col-md-3" style="margin-bottom:7px;">';
                        td2 += '<a class="btn btn-yellow" href="'+pathSelectRDV+'?id='+value.idRdv+'">'+value.debut+' - '+value.fin+'</a>';
                    td2 += '</div>';
                }); 
                td2 += '</div>';
                
                table.row.add([td1, td2]).draw(false);
                
            });
           
        }).fail(function(response) {
            console.error('Error: ' + response.responseText);
        });

    });

});



/**************************************Article************************************* */


$('#addPanier').click(function(){

    var qtyVal = $('#qty-val').val();

    window.open(pathAddArticlePanier+'?qty='+qtyVal, "_self");
});

$('#qty-asc').click(function(){
    var qtyVal = $('#qty-val').val();
    if(qtyVal>1){
        qtyVal--;
        $('#qty-val').val(qtyVal);
    }
});

$('#qty-desc').click(function(){
    var qtyVal = $('#qty-val').val();
    qtyVal++;
    $('#qty-val').val(qtyVal);
});



