const AppointmentDataTable = {
    templateUrl : 'js/app/components/appointments/appointment-data-table.html',
    create : function( appointments )
    {
        var app = this.app;
        this.render( { apps: appointments.getAll(), activeGroup : this.app.user.getActiveGroup() } );

        $( this.container ).on( 'click', '[data-type="btn-detail-appointment"]', function()
        {
            app.openInApp( '/#/appointment/' + $( this ).attr( 'data-appointment-id' ) );
        });

        $( this.container ).on( 'click', '[data-type="btn-attendees-appointment"]', function()
        {
            app.openInApp( '/#/appointment/' + $( this ).attr( 'data-appointment-id' ) + '/attendee' );
        });

        $( this.container ).on( 'click', '[data-type="btn-chat-appointment"]', function()
        {
            app.openInApp( '/#/appointment/' + $( this ).attr( 'data-appointment-id' ) + '/chat' );
        });

        $( this.container ).find( '.datatable' ).DataTable( {
            pageLength: 50,
            responsive: true,
            dom: '<"html5buttons"B>lTfgitp',
            language : {
                search      : 'Suche',
                emptyTable  : 'Keine Einträge vorhanden.',
                zeroRecords : 'Keine Einträge vorhanden.',
                info        : 'Zeige _START_ bis _END_ von _TOTAL_ Einträgen',
                lengthMenu : 'Zeige _MENU_ Einträge',
                paginate : {
                    first : 'Erste',
                    previous : 'Vorherige',
                    next : 'Nächste',
                    last : 'Letzte'
                },
            },
            buttons: [
                { extend: 'copy'},
                {extend: 'csv'},
                {extend: 'excel', title: 'Termine'},
                {extend: 'pdf', title: 'Termine'},

                {extend: 'print',
                    customize: function (win){
                        $(win.document.body).addClass('white-bg');
                        $(win.document.body).css('font-size', '10px');

                        $(win.document.body).find('table')
                            .addClass('compact')
                            .css('font-size', 'inherit');
                    }
                }
            ]

        });
    },

    destroy : function()
    {

    }
};

export { AppointmentDataTable };