function getResult() {
    var saveid = document.getElementById("saveid").value;
    var from = document.getElementById("datepicker_from").value;
    var to = document.getElementById("datepicker_to").value;

    if (from != "" && to != "") {
        $('#resultDiv').load('supplierReportsControllerAjax.php?from=' + from + '&to=' + to + '', function (response, status, xhr) {

            //$('select').chosen();
            $.getScript('../views/default/js/jqueryui_init.js');
        });
        return false;
    }
}


$("[id^='delbtn']").live('click', function (e) {
    $('#currentItr').val($(this).attr("data-itr"));
    $('#ddbtn').data('useBtnId', 'delbtn');//cash
    $("#myModal155").modal("show");
});
$("[id^='delbtn_cheques']").live('click', function (e) {
    $('#currentItr').val($(this).attr("data-itr"));
    $('#ddbtn').data('useBtnId', 'delbtn_cheques');//cheque
    $("#myModal155").modal("show");
});

$('#ddbtn').live('click', function (e) {
    $("#myModal155").modal("hide");
    var itr = Number($('#currentItr').val());
    if (itr > 0) {
        var useBtnId = $('#ddbtn').data('useBtnId');
        var debBtnAction = $('#' + useBtnId + itr).attr('data-action');
        $('#supDel').attr('action', debBtnAction);
        $('#supDel').submit();
        $(this).prop('disabled', true);
    }

});

$("#paySerialNu").select2({
    allowClear: true,
    placeholder: "كل الايصالات",
    //minimumInputLength: document.getElementById("searchvalue").value,
    minimumInputLength: 0,
    multiple: false,
    quietMillis: 100,
    ajax: {
        url: "supplierPayedDeptControllerAjax.php?do=select2paySerialNo",
        dataType: 'json',
        data: function (term, page) {
            return {
                term: term, //search term
                page_limit: 7, // page size
            };
        },
        results: function (data) {
            return { results: data };
        }
    },
    formatResult: function (data) {
        return '<span>' + data.text + '</span >';

    },
    initSelection: function (element, callback) {
        var item = element.val().split(':');
        //  var data = {id: item[0], text: item[1]};
        var data = { id: item[0], text: item[1], productquantity: item[2], price: item[3] };
        callback(data);
    },
    //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
});
