<!-- ###CONTENT### begin -->
<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">
                <div class="row">
                    <div class="col-lg-10">
                        <form  action="" method="post" name="hm" id="hm" enctype="multipart/form-data" class="form-inline fcs-form-padding">
                            <input type="hidden" name="sort" id="sort" value="[% $sort %]" />
                            <input type="hidden" name="sortorder" id="sortorder" value="[% $sortorder %]" />
                            <input type="hidden" name="pos" value="[% $pos %]" id="pos">
                            <input type="hidden" name="Filter[]" value="submit" />
                            <div class="form-group">
                                <label  class="control-label">[% $user->gettext('Firma') %]:</label>
                                <select name="Filter[CompanyIDs][]"  multiple onchange="document.hm.submit();" class="form-select multiple">
                                    [% html_options options=$FilterData.Companies selected=$usedFilters.CompanyIDs %]
                                </select>
                            </div>

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

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

                            <div class="form-group">
                                <label  class="control-label">[% $user->gettext('Service Level') %]:</label>
                                <select name="Filter[ServiceLvlIDs][]"  multiple onchange="document.hm.submit();" class="form-select multiple" style="width: 5em !important;">
                                    [% html_options options=$FilterData.ServiceLvls selected=$usedFilters.ServiceLvlIDs %]
                                </select>
                            </div>


                        </form>
                    </div>
                    <div class="col-lg-2 text-end">
                        <div class="btn-group">
                            <input type="button" class="btn btn-outline-primary" value="[% $user->gettext('Neuer SLA') %]" onclick="window.location.href = 'index.php?module=services&class=sla&event=create'">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <span class="fcs-card-title h3">[% $user->gettext('SLA Liste') %]</span>
            </div>
            <div class="card-body">
                <table class="table table-striped">
                    <thead>
                        <tr class="fields">

                            <th style="cursor:pointer;" onclick="document.getElementById(
                                [% if $sort == "Mandant" %]'sortorder').value = '[% if $sortorder == "DESC" %]ASC[% else %]DESC[% /if %]'
                                [% else %]'sort').value = 'Mandant'
                                [% /if %];
                                            submitForm();">
                                [% $user->gettext('Mandant') %]
                                [% if $sort == "Mandant" %]&nbsp;<span class="fa fa-chevron-[% if $sortorder == "DESC" %]down[% else %]up[% /if %]"></span>[% /if %]
                            </th>
                            <th style="cursor:pointer;" onclick="document.getElementById(
                                [% if $sort == "Department" %]'sortorder').value = '[% if $sortorder == "DESC" %]ASC[% else %]DESC[% /if %]'
                                [% else %]'sort').value = 'Department'
                                [% /if %];
                                            submitForm();">
                                [% $user->gettext('Abteilung') %]
                                [% if $sort == "Department" %]&nbsp;<span class="fa fa-chevron-[% if $sortorder == "DESC" %]down[% else %]up[% /if %]"></span>[% /if %]
                            </th>

                            <th>[% $user->gettext('Service') %]</th>
                            <th>[% $user->gettext('Servicelevel') %]</th>
                            <th>[% $user->gettext('Startdatum') %]</th>
                            <th>[% $user->gettext('Enddatum') %]</th>
                            <th>[% $user->gettext('Anzahl Tickets') %]</th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>

                        [% foreach from=$SLAs key=companys item=Companies %]
                            <tr align="center" style="color: #31708f; background-color: #d9edf7; border-color: #bce8f1;">
                                <td colspan="7">[% $Companies.company %]  </td>
                                <td><a href="index.php?module=services&amp;class=reports&amp;Filter[CompanyIDs][]=[% $companys %]" class="btn btn-outline-secondary"><span class="fa fa-search" title="[% $user->gettext('Zeige Ticketreport') %]"></span></a>
                                </td>
                            </tr>
                            [% foreach from=$Companies.mandants key=Mandant item=Mandants %]
                                [% foreach from=$Mandants.departments key=Department item=Departments %]
                                    [% foreach from=$Departments.slas item=SLA %]
                                        <tr >
                                            <td>[% $SLA.mandant %]</td>
                                            <td>[% $SLA.department %]</td>
                                            <td>[% $SLA.servicetitle %] </td>
                                            <td>[% $SLA.servicelvltitle %] </td>
                                            <td>[% $SLA.startdate|date_format:"%d.%m.%Y"  %] </td>
                                            <td>[% $SLA.enddate|date_format:"%d.%m.%Y"  %] </td>
                                            <td>[% $SLA.cnttickets %]</td>

                                            <td>
                                                <a href="index.php?module=services&amp;class=sla&amp;event=edit&amp;id=[% $SLA.id %]" class="btn btn-outline-secondary"><span class="fa fa-pencil" title="[% $user->gettext('Bearbeiten')%]"></span></a>

                                                <a href="index.php?module=services&amp;class=sla&amp;event=copy&amp;id=[% $SLA.id %]" class="btn btn-outline-secondary"><span class="fa fa-copy" title="[% $user->gettext('Kopieren')%]"></span></a>

                                                <a href="index.php?module=services&class=reports&amp;Filter[SLAs][]=[% $SLA.id %]" class="btn btn-outline-secondary"><span class="fa fa-search" title="[% $user->gettext('Zeige Ticketreport')%]"></span></a>
                                                    [% if $SLA.cnttickets == 0 %]
                                                    <a href="index.php?module=services&amp;class=sla&amp;event=delete&amp;id=[% $SLA.id %]" class="btn btn-outline-secondary"><span class="fa fa-trash" title="[% $user->gettext('L&ouml;schen')%]"></span></a>
                                                    [% /if %]
                                            </td>
                                        </tr>
                                    [% /foreach %]

                                [% /foreach %]

                            [% /foreach %]

                        [% /foreach %]

                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="15">
                                [% $Paging %]
                            </td>
                        </tr>
                    </tfoot>
                </table>
                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

    function switchPage(pos) {
        document.getElementById("pos").value = pos;
        submitForm();
    }

    $('.select2service').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
    });

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