<!-- Component Default begin -->
<form action="" method="post" name="hm" id="HM-Form-Report" enctype="multipart/form-data" style="margin:0;padding:0;" class="form-inline">

    <script language="JavaScript" src="modules/reporting/javascript/reporting.js" type="text/JavaScript"></script>

    <input type="hidden" name="pos" id="pos" value="[% $pos %]" />
    <input type="hidden" name="sorting" id="sorting" value="[% $sorting %]" />
    <input type="hidden" name="sortOrder" id="sortOrder" value="[% $sortOrder %]" />
    <input type="hidden" name="action" id="action" value="" />




    <div class="card panel-fcs-border shadow-sm">
    <div class="card-header">
        <span class="fcs-card-title h2">
            [% $ReportingHeader %]
        </span>
    </div>
    <div class="card-body">
       
                <div class="card panel-info shadow-sm rounded">
                    <div class="card-body"> 
                        <div class="col-lg-10">
                            <div class="form-group">
                                <label class="control-label">[% $user->gettext('Filter')%]:</label>
                                <input type="text" class="form-control" name="filter" id="filter" value="[% $smarty.session.Reporting.filter %]" >
                            </div>
                            
                            [% if $ReportingUsedTicketDate %]
                                <div class="form-group">             
                                    <select name='TicketDateType' class='form-control' onchange="setAction(''); $('#HM-Form-Report').submit();">
                                        <option value='EditDate' [% if $TicketDateType != 'UpdateDate' %]selected[% /if %]>[% $user->gettext('Erstelldatum') %]</option>
                                        <option value='UpdateDate' [% if $TicketDateType == 'UpdateDate' %]selected[% /if %]>[% $user->gettext('Bearbeitungsdatum') %]</option>
                                    </select>
                                </div>     
                            [% /if %]
                        
                            <div class="form-group">
                                <label class="control-label">[% $user->gettext('Von')%]:</label>
                                <input type="text" class="form-control datepicker" value="[% $smarty.session.Reporting.startdate %]" name="startdate" id="startdate" onkeyup="keyEvent(event)" />
                            </div>
                            
                             <div class="form-group">
                                <label class="control-label">[% $user->gettext('Bis')%]:</label>
                                <input type="text" class="form-control datepicker" value="[% $smarty.session.Reporting.enddate %]" name="enddate" id="enddate" onkeyup="keyEvent(event)" />
                            </div>
                             
                             <div class="form-group">
                                <select class="form-control" name="period" onchange="changePeriod(this);">
                                    <option value="0" selected="selected">[% $user->gettext('Zeitraum') %]</option>
                                    <option value="99" >[% $user->gettext('Heute') %]</option>
                                    <option value="1" >[% $user->gettext('Gestern') %]</option>
                                    <option value="2" >[% $user->gettext('Letzte Woche') %]</option>
                                    <option value="3" >[% $user->gettext('Letzten Monat') %]</option>
                                    <option value="4" >[% $user->gettext('Letztes Jahr') %]</option>
                                    <option value="5" >[% $user->gettext('Aktuelles Jahr') %]</option>
                                    [% if $timing_add %]
                                        [% foreach from=$timing_add key=k item=v %]
                                            <option value="[% $v.id %]">[% $k %]</option>
                                        [% /foreach %]
                                    [% /if %]                         
                                </select>
                            </div>
                             
    
    

                     
    
      
  
                                [% if $devtypes %]
                                <div class="form-group">
                                   <label class="control-label">[% $user->gettext('Ger&auml;tetyp')%]:</label>
                                   <select class="form-control" name="devtype" onchange="$('#HM-Form-Report').submit();" class="multiple" >
                                        <option value="">[% $user->gettext('-- Alle --') %]</option>
                                        [% foreach from=$devtypes item=dev %]
                                            <option value="[% if $dev.typeid > 0 %][% $dev.typeid %][% else %][% $dev.devicetypeid %][% /if %]" [% if ($devtype == $dev.typeid && $dev.typeid > 0) || ($devtype == $dev.devicetypeid && $dev.devicetypeid > 0 ) %]selected="selected"[% /if %]>[% $dev.typename %]</option>
                                        [% /foreach %]
                                    </select>
                                </div>
                                [% /if %]                
                             
                              <div class="form-group">
                                <label class="control-label">[% $user->gettext('Eintr&auml;ge / Seite')%]:</label>
                                <select class="form-control" id="EntriesPerPage" name="EntriesPerPage" class="textbox" onchange="setAction('');$('#HM-Form-Report').submit();">
                                    <option value="5" [% if $EntriesPerPage == 5 %]selected="selected"[% /if %]>5</option>
                                    <option value="10" [% if $EntriesPerPage == 10 %]selected="selected"[% /if %]>10</option>
                                    <option value="20" [% if $EntriesPerPage == 20 || !$EntriesPerPage %]selected="selected"[% /if %]>20</option>
                                    <option value="50" [% if $EntriesPerPage == 50 %]selected="selected"[% /if %]>50</option>
                                    <option value="100" [% if $EntriesPerPage == 100 %]selected="selected"[% /if %]>100</option>
                                </select>
                            </div>
                               <div class="form-group">
                                 <a onclick="setAction('');$('#HM-Form-Report').submit();" class="btn btn-outline-primary" ><span class="fa fa-search" title="[% $user->gettext('Suchen')%]"></span></a>
                               </div>
                        </div>
                        <div class="col-lg-2 text-end">
                            <div class="btn-group">
                                <a href="#" onclick="setAction('xls');$('#HM-Form-Report').submit();return false;" title="[% $user->gettext('Excel Export') %]"><img src="images/excel.gif" width="16" height="16"  border="0" /></a>
                           </div>
                        </div>
                        
                    </div>
                </div>
                
                <div class="card panel-info shadow-sm rounded">
                    
                    <div class="card-header">
                        <span class="fcs-card-title h3">[% $entries %] [%$user->gettext('Geräte gefunden')%]</span>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                     <tr class="fields">
                                        <th onclick="[% if $sorting == "Name" %]toggleSortOrder();[% else %]sortList('Name')[% /if %];" style="cursor:pointer">
                                            [% $GridHeader %]
                                            [% if $sorting == "Name" %]
                                                <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                            [% /if %]
                                        </th>
            
                                        [% if $report_type == "tdevnew" %]
                                            <th onclick="[% if $sorting == "Type" %]toggleSortOrder();[% else %]sortList('Type')[% /if %];" style="cursor:pointer;">
                                                [% $user->gettext('Ger&auml;tetyp') %]
                                                [% if $sorting == "Type" %]
                                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                        [% /if %]
            
                                        <th onclick="[% if $sorting == "Count" %]toggleSortOrder();[% else %]sortList('Count')[% /if %];" style="cursor:pointer;" class="text-end">
                                            [% $user->gettext('Anzahl Tickets') %]
                                            [% if $sorting == "Count" %]
                                                <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                            [% /if %]
                                        </th>
                                        [% if $hmcompany != 'LANDKREIS SCHAUMBURG' %]
                                            <th onclick="[% if $sorting == "Expense" %]toggleSortOrder();[% else %]sortList('Expense');[% /if %]" style="cursor:pointer;" class="text-end">
                                                [% $user->gettext('Zeitaufwand') %]
                                                [% if $sorting == "Expense" %]
                                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                        [% /if %]
                                        <th onclick="[% if $sorting == "Expense" %]toggleSortOrder();[% else %]sortList('Expense');[% /if %]" style="cursor:pointer;" class="text-end">
                                            [% $user->gettext('Zeitaufwand [m]') %]
                                            [% if $sorting == "Expense" %]
                                                <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                            [% /if %]
                                        </th>
            
                                        [% if $hmcompany != 'LANDKREIS SCHAUMBURG' %]
                                            <th onclick="[% if $sorting == "Expense" %]toggleSortOrder();[% else %]sortList('Expense');[% /if %]" style="cursor:pointer;" class="text-end">
                                                [% $user->gettext('Zeitaufwand [h]') %]
                                                [% if $sorting == "Expense" %]
                                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                        [% /if %]
            
            
                                        <th onclick="[% if $sorting == "Kosten" %]toggleSortOrder();[% else %]sortList('Kosten');[% /if %]" style="cursor:pointer;" class="text-end">
                                            [% $user->gettext('Kosten') %]
                                            [% if $sorting == "Kosten" %]
                                                <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                            [% /if %]
                                        </th>
            
       <th onclick="[% if $sorting == "ExpExpense" %]toggleSortOrder();[% else %]sortList('ExpExpense');[% /if %]" style="cursor:pointer;" class="text-end">
                                [% $user->gettext('Erw. Aufwand') %]
                                [% if $sorting == "ExpExpense" %]
                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                [% /if %]
                            </th>                                             
            
                                        [% if $hmcompany != 'LANDKREIS SCHAUMBURG' %]
                                            <th onclick="[% if $sorting == "ProcessTime" %]toggleSortOrder();[% else %]sortList('ProcessTime');[% /if %]" style="cursor:pointer;" class="text-end">
                                                [% $user->gettext('Liegezeit [h]') %]
                                                [% if $sorting == "ProcessTime" %]
                                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                            <th onclick="[% if $sorting == "AvgProcessTime" %]toggleSortOrder();[% else %]sortList('AvgProcessTime');[% /if %]" style="cursor:pointer;" class="text-end">
                                                &Oslash;  [% $user->gettext('Liegezeit [h]') %]
                                                [% if $sorting == "AvgProcessTime" %]
                                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                        [% else %]
                                            <th onclick="[% if $sorting == "ProcessTime" %]toggleSortOrder();[% else %]sortList('ProcessTime');[% /if %]" style="cursor:pointer;" class="text-end">
                                                [% $user->gettext('Liegezeit [m]') %]
                                                [% if $sorting == "ProcessTime" %]
                                                   <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                            <th onclick="[% if $sorting == "AvgProcessTime" %]toggleSortOrder();[% else %]sortList('AvgProcessTime');[% /if %]" style="cursor:pointer;" class="text-end">
                                                &Oslash;  [% $user->gettext('Liegezeit [m]') %]
                                                [% if $sorting == "AvgProcessTime" %]
                                                    <span class="fa fa-chevron-[% if $sortOrder == "DESC" %]down[% else %]up[% /if %]"></span>
                                                [% /if %]
                                            </th>
                                        [% /if %]
                                    </tr>
                                </thead>
                                <tbody>
            
            
                                    [% foreach from=$tickets item=ticket %]
                                        <tr onclick="document.getElementById('listuid').value=[% $ticket.id %];document.lform.submit();" style="cursor:pointer;">
            
                                            <td>[% $ticket.name %]</td>
            
                                            [% if $report_type == "tdevnew" %]
                                                <td>[% $ticket.typename %]&nbsp;</td>
                                            [% /if %]
            
                                            <td class="text-end">[% $ticket.anzahl %]</td>
            
                                            [% if $hmcompany != 'LANDKREIS SCHAUMBURG' %]
                                                <td class="text-end">[% $ticket.aufwand %]</td>
                                            [% /if %]
            
                                            <td class="text-end">[% $ticket.aufwand %]</td>
            
                                            [% if $hmcompany != 'LANDKREIS SCHAUMBURG' %]
                                                <td class="text-end">[% $ticket.zeitaufwandstunden %]</td>
                                            [% /if %]
            
                                            <td class="text-end">[% $ticket.kosten %] [% if $hmcompany == 'OTTO FISCHER AG' %]CHF[% else %][% $user->getCurrencyDescr() %][% /if %]</td>
                                            <td class="text-end">[% $ticket.expexpense|default:0 %] [% $user->gettext('Min.') %]</td> 
                                            <td class="text-end">[% $ticket.processtime %]</td>
                                            <td class="text-end">[% $ticket.avgprocesstime %]</td>
                                        </tr>
                                    [% foreachelse %]
                                        <tr class="even">
                                            <td colspan="[% if $hmcompany != 'LANDKREIS SCHAUMBURG' %][% if $report_type == "tdevnew" %]9[% else %]8[% /if %][% else %][% if $report_type == "tdevnew" %]9[% else %]8[% /if %][% /if %]" style="text-align:center !important;">[% $user->gettext('Keine Tickets im Zeitraum gefunden') %]</td>
                                        </tr>
                                    [% /foreach %]
            
                                </tbody>
                       
     
                            </table>
                            <div class="text-center">
                            [% $Paging %]
                            </div>
                        </div>
                    </div>
                </div>
            
    </div>
</div>

</form>

<script language="JavaScript" type="text/JavaScript">
    <!--

    function changePeriod(element) {

        var value = element.options[element.selectedIndex].value;
        var startdate = document.forms['hm'].elements['startdate'];
        var enddate = document.forms['hm'].elements['enddate'];
        var now = new Date();
        var Tag = now.getDate();
        var Monat = now.getMonth();

        if (value == 0) {
            startdate.value = "[% $today %]";
            enddate.value = startdate.value;
        } else if (value == 1) {
            startdate.value = "[% $yesterday %]";
            enddate.value = startdate.value;
        } else if (value == 2) {
            startdate.value = "[% $lastweek %]";
            enddate.value = "[% $today %]";
        } else if (value == 3) {
            startdate.value = "[% $lastmonth_start %]";
            enddate.value = "[% $lastmonth_end %]";
        } else if (value == 4) {
            startdate.value = "[% $lastyear_start %]";
            enddate.value = "[% $lastyear_end %]";
        } else if (value == 5) {
            startdate.value = "[% $currentyear_start %]";
            enddate.value = "[% $currentyear_end %]";
        }
    [% if $timing_add %]
            [% foreach from=$timing_add item=timing2 %]
                    else if (value == [% $timing2.id %]){

                        startdate.value = "[% $timing2.start %]";
                        enddate.value = "[% $timing2.end %]";
                    }
        [% /foreach %]
    [% /if %]

            }

            function setAction(action) {
                document.getElementById("action").value = action;
            }

            $(document).ready(function() {

                $(".datepicker").datepicker();

                $(".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: false,
                    multiple:false
                });

            })

            // -->
</script>


<!-- Component Default end -->
</form>

<form action="index.php?module=reporting&event=showTickets" method="post" name="lform" target="_blank" />
<input type="hidden" name="[% $list_field %]" id="listuid" value="" />
<input type="hidden" name="Sorting" value="[% $sorting %]" />
<input type="hidden" name="SortOrder" value="[% $sortOrder %]" />

</form>
