var reminder = {
    settings: {
        ajaxUrl: '',
        account_user_autocompleteUrl: ''
    },
    dataList: null,
    init: function() {
        reminder.initDataTable();

        global.autocomplete.bind(reminder.settings.account_user_autocompleteUrl, '#assigned_to', '#assigned_to_id', {
            onSelect: function (d) {
                reminder.dataList.draw();
            }
        });
    },
    initDataTable: function() {

        var callBack = function() {
        };

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

        jQ('#reminderType').on('change', function(){
            reminder.dataList.draw();
        });


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

        jQ('#status').on('change', function(){
            reminder.dataList.draw();
        });

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