<div class="card panel-fcs-border shadow-sm">
    <div class="card-header">
        <span class="fcs-card-title h2">[% $user->gettext('Datenstruktur') %]</span>
    </div>
    <div class="card-body">

        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <span class="fcs-card-title h3">[% $user->gettext('Daten') %]</span>[% if $Tools->FCS_Count($nav.entries) %]<span class="fcs-card-title"> - [% $nav.entries %] [% $user->gettext('Eintr&auml;ge gefunden') %]</span>[% /if %]
            </div>
            <div class="card-body">

                <div class="card panel-info shadow-sm rounded">                  
                    <div class="card-body">
                        <form  action="index.php?module=user" method="post" name="hm" id="hm" class="form-inline fcs-form-padding">
                            <input type="hidden" name="sort" id="sort" value="[% $sort %]" />
                            <input type="hidden" name="sortorder" id="sortorder" value="[% $sortorder %]" />


                            <div class="form-group row mb-3">
                                <label  for="search">[% $user->gettext('Filter') %]</label>
                                <input type="text" name="search" id="search" size="15" class="form-control" value="[% $search %]" onkeyup="if (event.keyCode == 13) {
                                            submitForm();
                                        }" />
                            </div>         

                            <div class="btn-group pull-right">
                                <a  class="btn btn-outline-primary" type="button" href="index.php?module=employee&class=datastructure&event=create">
                                    [%$user->gettext('Neuer Eintrag')%] 
                                </a>
                            </div>                                    
                        </form>
                    </div>
                </div>


                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>

                                <th>#</th>
                                <th class="sort" id="filiale" >Filiale</th>                                
                                <th class="sort" id="mitarbeiter">Mitarbeiter</th>
                                <th class="sort" id="hmuser">Benutzerzuordnung</th>
                                <th class="sort" id="job">Jobbeschreibung</th>
                                <th></th>
                            </tr>                        
                        </thead>
                        <tbody>
                            [% foreach from=$Data item=d name=list %]
                                <tr>
                                    <td>[% $smarty.foreach.list.iteration %]</td>
                                    <td>[% $d.filiale %]</td>
                                    <td>[% $d.mitarbeiter %]</td>
                                    <td>[% $d.hmuser %]</td>
                                    <td>[% $d.jobbeschreibung %]</td>
                                    <td>
                                        <div class="btn-group">                                             
                                        </div>
                                    </td>
                                </tr>
                            [% /foreach %]
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="15">
                                    [% $Paging %]
                                </td>
                            </tr>
                        </tfoot>
                    </table>


                </div>
            </div>
        </div>
    </div>
</div>


<script>
    showSortIcon();


    $(".sort").on("click", function (e) {
        var sort = $(this).attr('id');
        var sortorder = 'asc';
        if (current_sort === sort) {
            if (current_sortorder === 'asc') {
                sortorder = 'desc';
            } else {
                sortorder = 'asc';
            }
        }
        $("#sort").val(sort);
        $("#sortorder").val(sortorder);
        submitForm();
    })

    function showSortIcon() {
        var content = $("#" + current_sort).html();
        if (current_sortorder == 'desc') {
            content += '<span class="fa fa-chevron-down"></span>';

        } else {
            content += '<span class="fa fa-chevron-up"></span>';
        }
        $("#" + current_sort).html(content);
    }
</script>
