
<!-- ###CONTENT### begin -->
<script type="text/javascript" src="includes/js/jquery.tablesorter.min.js"></script>
<style>
    .sla-form .form-group row mb-3 select{
        min-width: 180px;
    }
</style>
<div class="card panel-fcs-border shadow-sm">
    <div class="card-header">
        <span class="fcs-card-title h2">[% $user->gettext('Service Level Agreements') %]</span>
    </div>
    <div class="card-body">
        <div class="card panel-info shadow-sm rounded">
            <div class="card-body">
                <form  action="" method="post" name="hm" id="hm" enctype="multipart/form-data" class="fcs-form-padding form-inline sla-form form-vertical">
                    [%*
                    <div class="form-group row mb-3">
                    <label class="control-label" for="entries_per_page">[% $user->gettext('Eintr&auml;ge pro Seite') %]:</label>
                    <select name="entries_per_page" id="entries_per_page" onchange="document.hm.submit();" class="form-control select2">
                    <option value="10" [% if $entries_per_page == 10 %]selected="selected"[% /if %]>10</option>
                    <option value="20" [% if $entries_per_page == 20 %]selected="selected"[% /if %]>20</option>
                    <option value="50" [% if $entries_per_page == 50 %]selected="selected"[% /if %]>50</option>
                    <option value="100" [% if $entries_per_page == 100 %]selected="selected"[% /if %]>100</option>
                    </select>
                    </div>
                    *%]
                    <div class="form-group row mb-3">
                        <label class="control-label" for="companyids">[% $user->gettext('Firma') %]:</label>
                        <select name="Filter[CompanyIDs][]" id="companyids" multiple onchange="document.hm.submit();" class="form-control select2">
                            [% html_options options=$FilterData.Companies selected=$usedFilters.CompanyIDs %]                                       
                        </select>
                    </div>

                    <div class="form-group row mb-3">
                        <label class="control-label" for="companyids">[% $user->gettext('Mandant') %]:</label>
                        <select name="Filter[MandantIDs][]" id="companyids" multiple onchange="document.hm.submit();" class="form-control select2">
                            [% html_options options=$FilterData.Mandants selected=$usedFilters.MandantIDs %]                                       
                        </select>
                    </div>

                    <div class="form-group row mb-3">
                        <label class="control-label" for="companyids">[% $user->gettext('Abteilung') %]:</label>
                        <select name="Filter[Departments][]" id="companyids" multiple onchange="document.hm.submit();" class="form-control select2">
                            [% html_options options=$FilterData.Departments selected=$usedFilters.Departments %]                                       
                        </select>
                    </div>

                    <div class="form-group row mb-3">
                        <label class="control-label" for="serviceids">[% $user->gettext('Service') %]:</label>
                        <select name="Filter[ServiceIDs][]" id="serviceids" multiple onchange="document.hm.submit();" class="form-control select2">
                            [% html_options options=$FilterData.Services selected=$usedFilters.ServiceIDs %]
                        </select>
                    </div>

                    <div class="form-group row mb-3">
                        <label class="control-label" for="companyids">[% $user->gettext('Servicelevel') %]:</label>
                        <select  name="Filter[ServiceLvlIDs][]" id="companyids" multiple onchange="document.hm.submit();" class="form-control select2">
                            [% html_options options=$FilterData.ServiceLvls selected=$usedFilters.ServiceLvlIDs %]                                       
                        </select>
                    </div>

                    <div class="form-group row mb-3">
                        <label class="control-label" for="companyids">[% $user->gettext('Servicetyp') %]:</label>
                        <select  name="Filter[ServiceTypeIDs][]" id="servicetypeids" multiple onchange="document.hm.submit();" class="form-control select2">
                            [% html_options options=$FilterData.ServiceTypes selected=$usedFilters.ServiceTypeIDs %]                                       
                        </select>
                    </div>
                    <div class="form-group row mb-3">
                        <label class="control-label" for="date">[% $user->gettext('Datum') %]:</label>
                        <div class="input-group">
                            <div class="input-group-text">[% $user->gettext('von')%]</div>
                            <input type="date" class="form-control datepicker"  name="Filter[Startdate]" value="[% $usedFilters.Startdate %]">
                            <div class="input-group-text">[% $user->gettext('bis')%]</div>
                            <input type="date" class="form-control datepicker" name="Filter[Enddate]" value="[% $usedFilters.Enddate %]">
                        </div>

                    </div>

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

        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <span class="fcs-card-title h3">SLA Reports</span>
            </div>
            <div class="card-body">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <td colspan="3">Kunde</td>
                            <td colspan="5">SLA</td>
                            <td colspan="11">Ticketdaten</td>
                        </tr>
                        <tr class="fields">
                            <th>[% $user->gettext('Firma') %]</th>
                            <th>[% $user->gettext('Mandant') %]</th>
                            <th>[% $user->gettext('Abteilung') %]</th>     
                            <th>[% $user->gettext('Service') %]</th>
                            <th>[% $user->gettext('Servicelevel') %]</th>                        
                            <th>[% $user->gettext('Servictyp') %]</th>    
                            <th>[% $user->gettext('Startdatum') %]</th>
                            <th>[% $user->gettext('Enddatum') %]</th>
                            <th>[% $user->gettext('Laufzeit') %]</th>

                            <th>[% $user->gettext('Anzahl Tickets') %]</th>

                            <th>[% $user->gettext('InTime') %]</th>
                            <th>[% $user->gettext('OutTime') %]</th>

                            <th>[% $user->gettext('Major Incidents') %]</th>
                            <th>[% $user->gettext('Problems') %]</th>
                            <th>[% $user->gettext('Vorfall') %]</th>

                            <th>[% $user->gettext('Offene') %]</th>
                            <th>[% $user->gettext('Geschlossene') %]</th>

                            <th>[% $user->gettext('Aufwand (Stunden)') %]</th>
                            <th>[% $user->gettext('Kosten') %]</th>                       
                        </tr>
                    </thead>
                    <tbody>

                        [% foreach from=$SLAs item=sla %]
                        <tralign="center" >

                            <td>[% $sla.companyname %]</td>
                            <td>[% $sla.mandant %]</td>
                            <td>[% $sla.department %]</td>
                            <td>[% $sla.servicetitle %]</td>
                            <td>[% $sla.servicelevel %]</td>                            
                            <td>[% $sla.servicetype %]</td>       
                            <td>[% $sla.startdate|date_format:"%d.%m.%Y" %]</td>
                            <td>[% $sla.enddate|date_format:"%d.%m.%Y" %]</td>
                            <td>[% $sla.laufzeit %] / [% $sla.totallaufzeit %]</td>

                            <td><a href="index.php?module=ticketlist&withSearchData=1&StatusID[]=99&ServiceIDs[]=[% $sla.serviceid %]&ServiceLevelIDs[]=[% $sla.servicelvlid %]" target="_blank">[% $sla.ticketstotal %]</a></td>

                            <td>[% $sla.outtime %]</td>
                            <td>[% $sla.intime %]</td>

                            <td>[% $sla.majorincidents %]</td>
                            <td>[% $sla.problems %]</td>
                            <td>[% $sla.noproblems %]</td>

                            <td><a href="index.php?module=ticketlist&withSearchData=1&StatusID[]=0&ServiceIDs[]=[% $sla.serviceid %]&ServiceLevelIDs[]=[% $sla.servicelvlid %]" target="_blank">[% $sla.opentickets %]</a></td>                            
                            <td><a href="index.php?module=ticketlist&withSearchData=1&StatusID[]=3&ServiceIDs[]=[% $sla.serviceid %]&ServiceLevelIDs[]=[% $sla.servicelvlid %]" target="_blank">[% $sla.closedtickets %]</a></td>


                            <td>[% $sla.aufwandgesamt %]</td>
                            <td>[% $sla.kostengesamt %]</td>                          
                            </tr>       
                        [% foreachelse %]     

                        [% /foreach %]                                        
                        </tbody>

                        <tr align="center" >
                            [%*
                            <td>[% $SLATotal.companyname %] </td>
                            <td>[% $SLATotal.mandant %] </td>
                            <td>[% $SLATotal.department %]</td>            
                            *%]
                            <td colspan="3">[% $user->gettext('Summe') %]</td>
                            <td>
                                [% $SLATotal.slasgesamt %]
                            </td>
                            <td>
                                [% $SLATotal.servicelevel %]
                            </td>
                            <td colspan="4">

                            </td>
                            <td>[% $SLATotal.ticketstotal %] </td>                        
                            <td>[% $SLATotal.outtime %] </td>
                            <td>[% $SLATotal.intime %]</td>

                            <td>[% $SLATotal.majorincidents %]</td>
                            <td>[% $SLATotal.problems %]</td>
                            <td>[% $SLATotal.noproblems %]</td>

                            <td>[% $SLATotal.opentickets %]</td>                    
                            <td>[% $SLATotal.closedtickets %]</td>


                            <td>[% $SLATotal.aufwandgesamt %]</td>
                            <td>[% $SLATotal.kostengesamt %]</td>                               
                        </tr>       

                </table>
                </table>
            </div>
        </div>
        [% $Paging %]
    </div>
</div>

<script type="text/javascript">
    <!--
    function switchPage(pos) {
        document.getElementById("pos").value = pos;
        submitForm();
    }

    $('.select2').select2({theme: 'bootstrap-5',
        closeOnSelect: false
    }).on("select2:close", function (e) {
        document.hm.submit();
    });


    $(".multiple").multiselect({
    buttonClass: 'form-select',
    templates: {
        button: '<button type="button" class="multiselect dropdown-toggle" data-bs-toggle="dropdown"><span class="multiselect-selected-text"></span></button>',
    },
        checkAllText: '[% $user->gettext("Alle") %]',
        uncheckAllText: '[% $user->gettext("Keine") %]',
        noneSelectedText: '[% $user->gettext("Wählen Sie") %]',
        selectedText: '# [% $user->gettext("gewählt") %]',
        selectedList: 1,
        header: true,
        multiple: false
    });



    $.tablesorter.addParser({
        id: 'germandate',
        is: function (s) {
            return false;
        },
        format: function (s) {
            var a = s.split('.');
            a[1] = a[1].replace(/^[0]+/g, "");
            return new Date(a.reverse().join("/")).getTime();
        },
        type: 'numeric'
    });

    $("#reportTable").tablesorter({
        headers: {6: {sorter: 'germandate'}, 7: {sorter: 'germandate'}}
    });
    $(".datepicker").datepicker();

    //-->
</script>
<!-- Component User begin -->

