const HourReportingDataTable = {
    templateUrl : 'js/app/components/kkspecial/hour-reporting-datatable.html',
    create : function( params )
    {
        const app = this.app,
            self = this,
            $container = $( this.container ),
            members = params.getAll();

        let dTable = null;

        this.render( { members: members } );


        dTable = $( 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: 'Auswertung',
                    exportOptions: {
                        format : {
                            body : function ( data, row, column, node )
                            {
                                if ( typeof data !== 'undefined' )
                                {
                                    if ( data != null )
                                    {
                                        if ( column === 1 || column === 2 || column === 3 || column === 4 || column === 5 || column === 6 )
                                        {
                                            data = data.toString().replace( ',', '.' );
                                        }
                                    }
                                }
                                return data;
                            }
                        }
                    }
                },
                {
                    extend: 'pdf',
                    title: 'Auswertung',
                    orientation : 'landscape'
                },
                {
                    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 { HourReportingDataTable };