var ticket = {
    settings: {
        ajaxUrl: '',
        account_user_autocompleteUrl: ''
    },
    init: function() {
        ticket.initDataTable();
        global.autocomplete.bind(ticket.settings.account_user_autocompleteUrl, '#assigned_to', '#assigned_to_id', {
            onSelect: function (d) {
                ticket.dataList.draw();
            }
        });
    },
    initDataTable: function() {

        var callBack = function() {
        };

        ticket.dataList = jQ('#ticket-datalist').DataTable({
            'processing': true,
            'serverSide': true,
            'ajax': {
                'url': ticket.settings.ajaxUrl,
                'data': function(d) {
                    d.url = global.settings.url;
                    d.month = jQ("#month-filter-type").val();
                    d.ticketStatus = jQ("#ticketStatus").val();
                    d.assignedTo = jQ("#assigned_to_id").val();
                }
            },
            'deferRender': true,
            'columnDefs': [
                { 'orderable': false, 'targets': 8 },
                { 'searchable': false, 'targets': 8 }
            ],
            drawCallback: function() {
                callBack();
            },
            responsive: {
                details: {
                    renderer: function( api,rowIdx ) {
                        return global.dataTableResponsiveCallBack(api, rowIdx, callBack);
                    }
                }
            }
        });


        jQ('#month-filter-type').on('change', function(){
            ticket.dataList.draw();
        });

        jQ('#ticketStatus').on('change', function(){
            ticket.dataList.draw();
        });

        jQ('.content-container').removeClass('has-loading');
        jQ('.content-container-content').removeClass('hide');
    }
};