{% extends "main/layout.html" %}
{% load static %}
{% block content %}
<div class="breadcrumb-holder">
    <div class="container-fluid">
        <ul class="breadcrumb">
            <li class="breadcrumb-item"><a href="{% url 'train-c-dash' %}">PAINEL TREINAMENTO</a></li>
            <li class="breadcrumb-item active">{{ legend|upper }}</li>
        </ul>
    </div>
</div>
<div class="container-fluid"><br/>
	<div class="row">
		<div class="col-sm-12">
			<div class="card shadow-lg pt-1 border-primary rounded">
                <div class="card-header border-primary">
                    <h2 align="center">{{ legend|upper }}</h2>
                </div>
                <div class="card-body">
                    <table id="example" class="table table-sm table-bordered responsive" style="width:100%">
                        <thead>
                            <tr>
                                <th>Nu.</th>
                                <th>Materia Formasaun</th>
                                <th>Tipu</th>
                                <th>Fatin</th>
                                <th>Divizaun</th>
                                <th>Tinan</th>
                                <th class="text-center">Ekipa</th>
                                <th>Funsionario Nebe Tuir Treinamento</th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for obj in objects %}
                            <tr>
                                <td>{{ forloop.counter }}</td>
                                <td>{{ obj.0.subject }}</td>
                                <td>{{ obj.0.type }}</td>
                                <td>{{ obj.0.place }}</td>
                                <td>{{ obj.0.unit }}</td>
                                <td>{{ obj.0.year }}</td>
                                <td>
                                    <ul>
                                        {% for obj0 in obj.2  %}
                                        <li>

                                            {{obj0.department}}
                                        </li>
                                        {% endfor %}
                                    </ul>
                                </td>
                                <td>
                                    <ul>
                                        {% for obj1 in obj.3 %}
                                        <li>

                                            {{ obj1 }}
                                        </li>
                                        {% endfor %}
                                    </ul>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div> <!--end card-body-->
			</div> <!--end card-->
		</div> <!--end col-->
	</div> <!--end row-->
</div><!--end container-->
{% endblock %}
{% block scripts %}
<link href="{% static 'main/vendor/datatables/css/searchBuilder.dataTables.min.css' %}" rel="stylesheet">
<link href="{% static 'main/vendor/datatables/css/searchBuilder.bootstrap4.min.css' %}" rel="stylesheet">
<link href="{% static 'main/vendor/datatables/css/buttons.dataTables.min.css' %}" rel="stylesheet">
<style type="text/css">
    .dtsb-searchBuilder{
        background: #b9c7e6 !important;
        padding: 5px
    }
    .dt-button, .dtsb-add {
        background: white !important;
    }
</style>
<script src="{% static 'main/vendor/datatables/js/dataTables.searchBuilder.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/searchBuilder.bootstrap4.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/dataTables.buttons.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/jszip.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/pdfmake.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/vfs_fonts.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/buttons.html5.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/buttons.print.min.js' %}"></script>
<script src="{% static 'main/vendor/datatables/js/buttons.colVis.min.js' %}"></script>
<script>
    var doc = {
    pageSize: config.pageSize,
    pageOrientation: config.orientation,
    content: [
        {
            table: {
                headerRows: 1,
                body: rows
            },
            layout: 'Borders'
        }
    ],
    styles: {
        tableHeader: {
            bold: true,
            fontSize: 10,
            color: 'white',
            fillColor: '#2d4154',
            alignment: 'center'
        },
        tableBodyEven: {},
        tableBodyOdd: {
            fillColor: '#f3f3f3'
        },
        tableFooter: {
            bold: true,
            fontSize: 10,
            color: 'white',
            fillColor: '#2d4154'
        },
        title: {
            alignment: 'center',
            fontSize: 12
        },
        message: {}
    },
    defaultStyle: {
        fontSize: 9
    }
};
</script>
<script type="text/javascript">
    $(document).ready( function () {
        var table = $('#example').removeAttr('width').DataTable( {
            "scrollY": "50vh",
            "scrollX": true,
            "scrollCollapse": true,
            "paging": true,
            searchBuilder: true,
            buttons:[
                {
                    extend: 'excelHtml5', autoFilter: true, sheetName: 'Exported data'
                },
                {
                    extend: 'pdfHtml5', orientation: 'landscape', pageSize: 'A4', messageTop: '',
                    title: "REPÚBLICA DEMOCRÁTICA DE TIMOR-LESTE" + "\n" + "MINISTÉRIO DO PLANO E ORDENAMENTO" +"\n"+ "AGÊNCIA DE DESENVOLVIMENTO NACIONAL, INSTITUTO PÚBLICO",
                    customize: function(doc) {
                        doc.defaultStyle.fontSize = 9; //<-- set fontsize to 16 instead of 10 
                    }
                },
                {
                    extend: 'print', orientation: 'landscape', pageSize: 'LEGAL',
                    exportOptions: { columns: ':visible' },
                    title: '<center><h5>REPÚBLICA DEMOCRÁTICA DE TIMOR-LESTE <br/>\
                        MINISTÉRIO DO PLANO E ORDENAMENTO<br/>\
                        AGÊNCIA DE DESENVOLVIMENTO NACIONAL, INSTITUTO PÚBLICO</h5></center><hr/>',
                    customize: function ( win ) {
                        $(win.document.body)
                            .css( 'font-size', '10pt' )
                            .prepend(
                                '<center><img src="#" style="width:80px;" /></center><br/>'
                            );
 
                        $(win.document.body).find( 'table' )
                            .addClass( 'compact' )
                            .css( 'font-size', 'inherit' );
                    }
                },
                'colvis',
            ],
            dom: 'Bfrtip',
            "deferRender": true
        });
        table.searchBuilder.container().prependTo(table.table().container());
    } );
</script>
{% endblock %}