function ajax_parameters(){
    return {
        invoice_status: function () { return $("#invoice-status-selection option:selected").val(); },
        invoice_destination: function(){return viewModel.chosen_dest() ? viewModel.chosen_dest().id : '';},
        invoice_number: function () { return $("#invoice-number").val(); },
        wo_stock: function () { return $("#wo-stock").val(); },
        client_name: function () { return $("#client").val(); },
        equipment: function () { return $("#equipment").val(); },
        invoice_date_from: function () { return $("#invoice-date-from").val(); },
        invoice_date_to: function () { return $("#invoice-date-to").val(); }
    };
}
function clear_ajax_parameters(){
    if(viewModel.chosen_dest())
        viewModel.chosen_dest(null);
    if($("#invoice-status-selection").val() != '0')
        $("#invoice-status-selection").val(0);
    $("#invoice-number").val(null);
    $("#wo-stock").val(null);
    $("#client").val(null);
    $("#equipment").val(null);
    $("#invoice-date-from").val(null);
    $("#invoice-date-to").val(null);
}

var viewModel = {
    chosen_dest: ko.observable(null),
    invoice_destinations: ko.observableArray(new Array())
};

function loadPageFeatures(){
    if(check_device() == 2){
        var min_date = new Date();
        min_date = new Date(min_date.setFullYear(min_date.getFullYear() - 1));
        var max_date = new Date();
        max_date = new Date(max_date.setFullYear(max_date.getFullYear() + 1));
        $('.datepicker').datetimepicker({
            language:  'en',
            format: 'MM/yyyy',
            weekStart: 0,
            startDate: min_date,
            endDate: max_date,
            daysOfWeekDisabled: [0],
            autoclose: true,
            startView: 3,
            minView: 3,
            todayHighlight: true,
            forceParse: true,
            todayBtn:  true
        });
    }
    else{
        $('.datepicker').each(function(){
            var value = new Date($(this).val());
            this.type="date";
            value = value.getFullYear() + '-'
                + (value.getMonth() < 9 ? '0' + (value.getMonth() + 1) : (value.getMonth() + 1)) + "-"
                + (value.getDate() < 10 ? '0' + value.getDate() : value.getDate());
            $(this).val(value);});
    }
}