<script type="text/javascript" src="includes/js/ajax.js"></script>


<style type="text/css" media="print">
    [% if $smarty.const.PRINTSIZE != 'PRINTSIZE' || $smarty.const.PRINTSIZE === 0 %]
        * {
            font-size: [% $smarty.const.PRINTSIZE %]pt !important;
        }

    [% /if %]

    .dontPrint{
        display:none;
    }
    /*Drucklayout auf A4 anpassen*/
    @page {
        size: A4;
        /* margin: 40px; */
        margin: 0mm;
    }
    html, body {
        width: 1024px;
    }
</style>

<div class="card panel-fcs-border shadow-sm">
    <div class="card-header">

        <h3 class="card-title">[% $user->gettext(' Ticket') %] #[% $ticket.id %]: [% $ticket.ticketdescr|truncate:60:"...":true %]</h3>
    </div>
    <div class="card-body">

        <div class="card panel-info shadow-sm rounded dontPrint">
            <div class="card-body">
                <form action="" method="POST" id="Printform" class="form-inline fcs-form-padding">
                    <input type="hidden" name="EventOrderAsc" id="EventOrderAsc" value="0" />


                    <div class="form-group row mb-3">
                        <input type="button" class="btn btn-outline-primary" onclick="print();" value="[% $user->gettext('Drucken') %]" />
                    </div>
                    <div class="form-group row mb-3">
                        <div class="checkbox">
                            <label>
                            [% $user->gettext('Reihenfolge Ticketbearbeitungen ändern') %]: [% if $EventOrder == 'DESC' %][% $user->gettext('Neueste zuerst') %][% else %][% $user->gettext('Älteste zuerst') %][% /if %]
                            <input type="checkbox" name="EventOrderDesc" value="1" [% if $EventOrderDesc %]checked="checked"[% /if %] onclick="$('#EventOrderAsc').val(!$('#EventOrderDesc').val());
                                    document.getElementById('Printform').submit();" />
                        </label>
                    </div>
                </div>

                <div class="form-group row mb-3">
                    <div class="checkbox">
                        <label>[% $user->gettext('Ohne Protokolleintr&auml;ge') %] <input type="checkbox" name="NoProtocol" value="1" [% if $NoProtocol %]checked="checked"[% /if %] onclick="document.getElementById('Printform').submit();" /></label>
                    </div>
                </div>

                <div class="form-group row mb-3">
                    <div class="checkbox">
                        <label>[% $user->gettext('Bild statt Thumbnail drucken') %] <input type="checkbox" name="FullImage" value="1" [% if $FullImage %]checked="checked"[% /if %] onclick="document.getElementById('Printform').submit();" /></label>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="row">

        <div class="col-sm-6">
            <div class="card panel-info shadow-sm rounded">
                <div class="card-header">
                    <h3 class="card-title">[% $user->gettext('Ticketdetails') %]</h3>
                </div>
                <div class="card-body">

                    <table class='table table-striped table-condensed'>
                        <tbody>

                            <tr>
                                <td>[% $user->gettext('Kurzbeschr.') %] :</td>
                                <td>[% $ticket.ticketdescr %]</td>
                            </tr>
                            <tr>
                                <td>[% $user->gettext('Ticket ID') %] :</td>
                                <td>[% $ticket.id %]</td>
                            </tr>
                            <tr>
                                <td>[% $user->gettext('Erstelldatum') %] :</td>
                                <td>[% $ticket.editdate|date_format:"%d.%m.%Y %H:%M" %]</td>
                            </tr>
                            <tr>
                                <td>[% $user->gettext('Kontakt') %] :</td>
                                <td>[% $ticket.name %] [% if $ticket.company != '' %]([% $ticket.company %])[% /if %]</td>
                            </tr>

                            [% if $ticket.benutzergruppe|trim != '' && ($user->hasRight(52) || $user->hasRight(54)) %]
                                <tr>
                                    <td>[% $user->gettext('Benutzergruppe') %] :</td>
                                    <td>[% $ticket.benutzergruppe %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.gruppe|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Gruppe') %] :</td>
                                    <td>[% $ticket.gruppe %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.supporter|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Supporter') %] :</td>
                                    <td>[% $ticket.supporter %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.category1|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Kategorie 1') %]:</td>
                                    <td>[% $ticket.category1 %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.category2|trim != '' && !$user->hasRight(51) %]
                                <tr>
                                    <td>[% $user->gettext('Kategorie 2') %]:</td>
                                    <td>[% $ticket.category2 %]</td>
                                </tr>
                            [% /if %]
                            <tr>
                                <td>
                                    [% if $hmcompany|strpos:"AVAG HOLDING" !== false %]
                                        [% $user->gettext('Wiedervorlage am') %]
                                    [% else %]
                                        [% $user->gettext('F&auml;llig am') %]
                                    [% /if %] :</td>
                                <td>[% if $ticket.desiredate != "" %][% $ticket.desiredate|date_format:"%d.%m.%Y %H:%M" %][% /if %]</td>
                            </tr>
                            [% if $hmcompany|strpos:"AVAG HOLDING" !== false %]
                                <tr>
                                    <td>[% $user->gettext('L&ouml;sung bis') %] :</td>
                                    <td>[% if $ticket.solutiondate != "" %][% $ticket.solutiondate|date_format:"%d.%m.%Y %H:%M" %][% /if %]</td>
                                </tr>
                            [% /if %]
                            <tr>
                                <td>[% $user->gettext('Priorit&auml;t') %] :</td>
                                <td>[% $user->gettext($ticket.priority) %]</td>
                            </tr>
                            [% if $ticket.diffonhold > 0 %]
                                <tr>
                                    <td>[% $user->gettext('Zur&uuml;ckgestellt bis zum') %] :</td>
                                    <td>[% $ticket.onhold|date_format:"%d.%m.%Y %H:%M" %]</td>
                                </tr>
                            [% /if %]
                            <tr>
                                <td>[% $user->gettext('Status') %] :</td>
                                <td>[% $user->gettext($ticket.tstatus) %]</td>
                            </tr>
                            [% if !$ticket.master && $ticket.ticketreferenzid > 0 %]
                                <tr>
                                    <td>[% $user->gettext('TicketRef. ID') %] :</td>
                                    <td>[% $ticket.ticketreferenzid %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.expense > 0 %]
                                <tr>
                                    <td>[% $user->gettext('Aufwand in Min') %] :</td>
                                    <td>[% $ticket.expense %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.master %]
                                <tr>
                                    <td>[% $user->gettext('Masterticket') %] :</td>
                                    <td><img src="images/master.gif" width="16" height="16" alt="" title="[% $user->gettext('Masterticket') %]" border="0"  /></td>
                                </tr>
                            [% /if %]
                            <tr>
                                <td>[% $user->gettext('Eskalationsstufe') %] :</td>
                                <td><img src="images/escalation[% if $ticket.escalationlevel > 0 %][% $ticket.escalationlevel %][% else %]0[% /if %].gif" width="57" height="13" alt="" title="[% $user->gettext('Eskalation') %]: -[% if $ticket.escalationlevel > 0 %][% $ticket.escalationlevel %][% else %]0[% /if %]-" /></td>
                            </tr>
                            <tr>
                                <td>[% $user->gettext('max. Eskalationsstufe') %] :</td>
                                <td><img src="images/escalation[% if $ticket.maxescalation > 0 %][% $ticket.maxescalation %][% else %]0[% /if %].gif" width="57" height="13" alt="" title="[% $user->gettext('max. Eskalation') %]: -[% if $ticket.maxescalation > 0 %][% $ticket.maxescalation %][% else %]0[% /if %]-" /></td>
                            </tr>
                        </tbody>
                    </table>

                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="card panel-info shadow-sm rounded">
                <div class="card-header">
                    <h3 class="card-title">[% $user->gettext('Kontaktdetails') %]</h3>
                </div>
                <div class="card-body">

                    <table class="table table-striped table-condensed">

                        <tbody>
                            [% if $ticket.name|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Name') %] :</td>
                                    <td>&nbsp;[% $ticket.name %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.company|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Firma') %] :</td>
                                    <td>&nbsp;[% $ticket.company %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.email|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('E-Mail') %] :</td>
                                    <td>&nbsp;[% $ticket.email %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.com_position|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Position') %] :</td>
                                    <td>&nbsp;[% $ticket.com_position %]</td>
                                </tr>
                            [% /if %]


                            [% if $ticket.building|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Gebäude') %] :</td>
                                    <td>&nbsp;[% $ticket.building %]</td>
                                </tr>
                            [% /if %]

                            [% if $ticket.floor|trim != '' || $ticket.room|trim != ''%]
                                <tr>
                                    <td>
                                        [% if $ticket.floor|trim != ''%] [% $user->gettext('Stockwerk') %] [% /if %]
                                        [% if $ticket.floor|trim != '' && $ticket.room|trim != '' %] / [% /if %]
                                        [% if $ticket.room|trim != ''%] [% $user->gettext('Raum') %] [% /if %]
                                        :
                                    </td>
                                    <td>&nbsp;
                                        [% if $ticket.floor|trim != ''%] [% $ticket.floor %] [% /if %]
                                        [% if $ticket.floor|trim != '' && $ticket.room|trim != '' %] / [% /if %]
                                        [% if $ticket.room|trim != ''%] [% $ticket.room %] [% /if %]
                                    </td>
                                </tr>
                            [% /if %]


                            [% if $AssetDesk && $ticket.department|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Abteilung') %] :</td>
                                    <td>&nbsp;[% $ticket.department %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.personalno|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Personalnr.') %] :</td>
                                    <td>&nbsp;[% $ticket.personalno %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.street|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Strasse') %] :</td>
                                    <td>&nbsp;[% $ticket.street %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.plz|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('PLZ') %] :</td>
                                    <td>&nbsp;[% $ticket.plz %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.city|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Ort') %] :</td>
                                    <td>&nbsp;[% $ticket.city %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.state|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Bundesland') %] :</td>
                                    <td>&nbsp;[% $ticket.state %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.country|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Land') %] :</td>
                                    <td>&nbsp;[% $ticket.country %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.phone|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Telefon') %] :</td>
                                    <td>&nbsp;[% $ticket.phone %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.fax|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Fax') %] :</td>
                                    <td>&nbsp;[% $ticket.fax %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.mobil|trim != '' %]
                                <tr>
                                    <td>[% $user->gettext('Mobil') %] :</td>
                                    <td>&nbsp;[% $ticket.mobil %]</td>
                                </tr>
                            [% /if %]
                            [% if $ticket.misc|trim != '' %]
                                <tr>
                                    <td valign="top">[% $user->gettext('Zusatzinformation') %] :</td>
                                    <td valign="top">[% $ticket.misc|nl2br %]&nbsp;</td>
                                </tr>
                            [% /if %]
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>

    <div class="card panel-info shadow-sm rounded">
        <div class="card-header">
        <div class="row">
            <div class="col-sm-8">
                <h3 class="card-title-fcs">[% $user->gettext('Beschreibung') %]</h3>
            </div>
            <div class="col-sm-4 text-end dontPrint">
            <span>[% $user->gettext('Dieses Panel nicht mit drucken') %] <input type="checkbox" class="addDoNotPrint"></span>
            </div>
        </div>
            </div>
        <div class="card-body">

            [% $formatedTicketDescription|nl2br %]

        </div>
    </div>

    <div class="card panel-info shadow-sm rounded">
        <div class="card-header">
            <h3 class="card-title">[% $user->gettext('Bearbeitungen') %]</h3>
        </div>
        <div class="card-body">

            [% foreach from=$events item=event name=TicketEvents %]
                <div class="card [% if !($event.ticketstatusid == 1 || $event.ticketstatusid == 2 || $event.ticketstatusid == 13 || $event.ticketstatusid == 6 || $status == 1) %] panel-info [% else %] panel-default [% /if %]" >
                    <div class="card-header" >
                        <ul class="horizontalJustifiedList">
                            <li title="Bearbeitungsdatum" data-toggle="tooltip"><span class="fa fa-calendar" aria-hidden="true"></span> [% $event.eventdate|date_format:"%d.%m.%Y %H:%M" %]</li>
                            [% if !$user->hasRight(243) %]
                            <li title="Erstellt von" data-toggle="tooltip"><span class="fa fa-user" aria-hidden="true"></span> [% $event.name %]</li>
                            [% /if %]
                                [% if $user->hasRight(524) %]
                                <li title="Aufwand in Minuten" data-toggle="tooltip"><span class="fa fa-clock" aria-hidden="true"></span> [% $event.expense|intval %] [% $user->gettext('Min') %]</li>
                                [% /if %]
                                [% if $user->hasRight(48) %]
                                <li title="Kosten" data-toggle="tooltip"><span class="fa fa-euro" aria-hidden="true"></span> [% $event.eventcosts %] [% $event.symbol %]</li>
                                [% /if %]

                            <li  title="Status der Bearbeitung" data-toggle="tooltip">[% $event.descr %]</li>

                            [% if $event.mailssentto.count > 0 %]
                                <li title="Benachrichtigungen" data-toggle="tooltip">
                                    [% foreach key=name item=recipients from=$event.mailssentto %]
                                        [% if $name != 'count' %]
                                            [% if $name == 'Contact' %]
                                                <img src="images/identity.png"  alt="" border="0" title="[% $user->gettext('An Kontakt') %]: [% $recipients %]"/>
                                            [% /if %]
                                            [% if $name == 'Supporter' %]
                                                <img src="images/user14.png"  alt="" width="16" height="16" border="0" title="[% $user->gettext('An Supporter') %]: [% $recipients %]"/>
                                            [% /if %]
                                            [% if $name == 'other' %]
                                                <img src="images/mail.png"  alt="" width="16" height="16" border="0" title="[% $user->gettext('Weitere Empfänger') %]: [% $recipients %]"/>
                                            [% /if %]
                                        [% /if %]
                                    [% /foreach %]
                                </li>
                            [% /if %]
                        </ul>
                    </div>
                    <div class="card-body">
                        [% if $event.mailinfos.sender.count > 0 %]
                            <div class="SendFrom SendFrom_header" id="[% $event.id %]SendFrom_header" onclick="ShowHide('[% $event.id %]SendFrom');">
                                <span title="Mail2Ticket">[% $user->gettext('Per Mail angelegt.') %]</span>
                            </div>
                            <div class="SendFrom" id="[% $event.id %]SendFrom" style="display:none;">
                                [% foreach key=name item=senders from=$event.mailinfos.sender %]
                                    [% if $name != 'count' && $senders %]
                                        [% $user->gettext($name) %]: [% $senders %] <hr />
                                    [% /if %]
                                [% /foreach %]
                            </div>
                        [% /if %]

                        [% if $event.notpublic == 1 %]<b>[% $user->gettext('Interne Notiz') %]</b><hr />[% /if %]
                        [% if $event.ticketactionrequired %]<b>[% $user->gettext('Aktion gefordert:') %]</b><hr />[% /if %]

                        <div class="TicketEventContent" class="collapse in collapsed" style="min-height: 1em;">
                            <div class="TicketContent" >
                                [% if $event.mailpartid %]
                                    [% $event.mailpartid %]
                                [% else %]
                                    [% $event.eventdescr|nl2br %]
                                [% /if %]
                            </div>

                        </div>
                        [% if $event.mailinfos.mailto.count > 0 %]
                            <div class="SendFrom SendTo_header" id="[% $event.id %]SendTo_header" onclick="ShowHide('[% $event.id %]SendTo');">
                                <span title="Mail2Ticket">[% $user->gettext('Benachrichtigungen an:') %]</span>
                            </div>
                            <div class="SendFrom" id="[% $event.id %]SendTo" style="display:none;">
                                [% foreach key=name item=senders from=$event.mailinfos.mailto %]
                                    [% if $name != 'count' && $senders %]
                                        [% $user->gettext($name) %]: [% $senders %] <hr />
                                    [% /if %]
                                [% /foreach %]
                            </div>
                        [% /if %]
                    </div>
                </div>

            [% /foreach %]

        </div>
    </div>


            [% if $type.type_id && $Tools->FCS_Count($finalFieldList) > 0  %]


                <div class="card panel-info shadow-sm rounded">
                    <div class="card-header">
                        <h3 class="card-title">
                            [% $user->gettext('Benutzerdefinierte Daten für') %] <strong>[% $type.type_name %]</strong>
                        </h3>
                    </div>
                    <div class="card-body">

                        <table class="table table-striped table-condensed">
                        <tbody>

                        [% foreach from=$finalFieldList item=field %]
                            [% if !$field.UDF %]
                            <tr>
                                <td>[% $field.field_name %]</td>
                                <td>
                                    [% if $field.field_type=='text' %]
                                        [% if $field.field_validation.check=='dmY' %]
                                                    [% if $field.value && $field.value != '' && $field.value != '1900-01-01' %]
                                                        [% $field.value|date_format:"%d.%m.%Y" %]
                                                    [% /if %]
                                        [% elseif $field.field_validation.check=='dmYhm' %]
                                            [% if $field.value && $field.value != '' %]
                                                [%$field.value|date_format:"%d.%m.%Y %H:%M" %]
                                            [% /if %]
                                        [% else %]
                                            [%$field.value %]
                                        [% /if %]
                                    [% elseif $field.field_type == 'textarea' %]
                                        [% $field.value %]

                                    [% elseif $field.field_type == 'radio' %]

                                    [% elseif $field.field_type == 'checkbox' %]
                                        <input type="checkbox" name="field[[% $field.field_id %]]" [% if $field.value == 1 %]checked[% /if %]>[% $option %]
                                    [% elseif $field.field_type == 'select' %]

                                    [% /if %]
                                </td>
                            </tr>

                            [% else %]
                                <tr>
                                <td>[% $field.fieldname %]</td>
                                <td>
                                [% foreach from=$field.fieldvalues item=$value %]
                                    [% if $Tools->FCS_InArray($value.userdeffieldvalueid, $field.selectedvalue)  %][% $value.value %]<br/>[% /if %]
                                [% /foreach %]
                                </td>
                            [% /if %]
                        [% /foreach %]
                        </tbody>
                        </table>

[%*
                        [% foreach from=$finalFieldList item=field %]
                            [% if !$field.UDF %]
                                <div class="form-group row mb-3">
                                    <label class="col-sm-3 control-label">
                                        [% $field.field_name %]
                                    </label>
                                    <div class="col-sm-9">
                                        [% if $field.field_type=='text' %]

                                            <p class='form-control-static'>


                                                [% if $field.field_validation.check=='dmY' %]
                                                    [% if $field.value && $field.value != '' && $field.value != '1900-01-01' %]
                                                        [% $field.value|date_format:"%d.%m.%Y" %]
                                                    [% /if %]
                                                [% elseif $field.field_validation.check=='dmYhm' %]
                                                    [% if $field.value && $field.value != '' %]
                                                        [%$field.value|date_format:"%d.%m.%Y %H:%M" %]
                                                    [% /if %]
                                                [% else %]
                                                    [%$field.value %]
                                                [% /if %]
                                            [% elseif $field.field_type == 'textarea' %]
                                                [% $field.value %]

                                            [% elseif $field.field_type == 'radio' %]

                                            [% elseif $field.field_type == 'checkbox' %]
                                                <input type="checkbox" name="field[[% $field.field_id %]]" [% if $field.value == 1 %]checked[% /if %]>[% $option %]
                                            [% elseif $field.field_type == 'select' %]

                                            [% /if %]
                                        </p>
                                    </div>
                                </div>
                            [% else %]
                                <div class="form-group row mb-3">
                                    <label class="col-sm-3 control-label">
                                        [% $field.fieldname %]
                                    </label>
                                    <div class="col-sm-9">
                                        <p class='form-control-static'>

                                            [% foreach from=$field.fieldvalues item=$value %]
                                                [% if $Tools->FCS_InArray($value.userdeffieldvalueid, $field.selectedvalue)  %][% $value.value %]<br/>[% /if %]
                                            [% /foreach %]
                                        </p>
                                    </div>
                                </div>
                            [% /if %]
                        [% /foreach %]

*%]
                    </div>
                </div>

            [% /if %]

        [% if $Tools->FCS_Count($Formulars.1) %]

        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <h3 class="card-title">[% $user->gettext('Formular') %]
                    [% $Formulars.1.formname %]
                    [% if $Formulars.1.categoryname != '' %]
                        ([% $user->gettext('Kategorie') %]: [% $Formulars.1.categoryname %])
                    [% /if %]
                </h3>
            </div>
            <div class="card-body">
                <table class="table table-striped table-condensed">

                    <tbody>
                        [% foreach from= $Formulars.1.fields item=value key=fieldname %]
                            <tr>
                                <td width="30%" valign="top" nowrap="nowrap">[% $fieldname %]:&nbsp;</td>
                                <td width="600px" valign="top" >[% $value|wordwrap:80:"\n":true|nl2br %]</td>
                            </tr>
                        [% /foreach %]
                    </tbody>
                </table>
            </div>
        </div>

    [% /if %]


    [% if $Tools->FCS_Count($Formulars.2) %]
        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <h3 class="card-title"> [% $user->gettext('Formular') %]
                    [% $Formulars.2.formname %]
                    [% if $Formulars.2.categoryname != '' %]
                        ([% $user->gettext('Kategorie') %]: [% $Formulars.2.categoryname %])
                    [% /if %]
                </h3>
            </div>
            <div class="card-body">
                <table class="table table-striped table-condensed">


                    [% foreach from= $Formulars.2.fields item=value key=fieldname %]
                        <tr>
                            <td width="30%" valign="top" nowrap="nowrap">[% $fieldname %]:&nbsp;</td>
                            <td width="70%" valign="top" >[% $value|wordwrap:80:"\n":true|nl2br %]&nbsp;</td>
                        </tr>
                    [% /foreach %]

                </table>
            </div>
        </div>
    [% /if %]

    [% if $Tools->FCS_Count($Formulars.3) %]
        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <h3 class="card-title"> [% $user->gettext('Formular') %]
                    [% $Formulars.3.formname %]
                    [% if $Formulars.3.categoryname != '' %]
                        ([% $user->gettext('Kategorie') %]: [% $Formulars.3.categoryname %])
                    [% /if %]
                </h3>
            </div>
            <div class="card-body">
                <table class="table table-striped table-condensed">

                    <tbody>
                        [% foreach from= $Formulars.3.fields item=value key=fieldname %]
                            <tr>
                                <td width="30%" valign="top" nowrap="nowrap">[% $fieldname %]:&nbsp;</td>
                                <td width="70%" valign="top" >[% $value|wordwrap:80:"\n":true|nl2br %]&nbsp;</td>
                            </tr>
                        [% /foreach %]
                    </tbody>
                </table>
            </div>
        </div>
    [% /if %]


    [% if $AttachmentCount > 0 %]
        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <h3 class="card-title">[% $user->gettext('Dokumente') %]</h3>
            </div>
            <div class="card-body">
                <div id="DocumentContent"><div id="AttachmentList"></div></div>
            </div>
        </div>
    [% /if %]

    [% if $user->hasRight(13) && $DeviceCount > 0 %]
        <div class="card panel-info shadow-sm rounded">
            <div class="card-header">
                <h3 class="card-title">[% $user->gettext('Assets') %]</h3>
            </div>
            <div class="card-body">
                <div id="Devices"></div>
            </div>
        </div>
    [% /if %]
</div>
</div>

[% if $AttachmentCount > 0 %]
    <script>

        var DocHeaders = ["[% $user->gettext('Dateiname') %]", "[% $user->gettext('Icon') %]",
            "[% $user->gettext('Dateigr&ouml;&szlig;e') %]", "[% $user->gettext('Beschreibung') %]",
            "[% $user->gettext('Thumbnail') %]", "[% $user->gettext('Erstellt am') %]",
            "[% $user->gettext('Benutzer') %]"];

        function getAttachments()
        {
            objAttachmentList = document.getElementById("AttachmentList");
            objAttachmentList.innerHTML = "";
            makeHttpRequest("index.php?module=upload&event=AJAXUploadList&tid=" +[% $ticket.id %], "buildAttachmentList", true);
        }

        function buildAttachmentList(xmldoc)
        {
            var attachments = xmldoc.getElementsByTagName("attachment");

            var HTMLOutput = "<table class=\"listview formview\" cellspacing=\"0\" style=\"text-align:left;margin:0 auto;width:99%;\">";
            HTMLOutput += "  <tr>\n";
            HTMLOutput += "	   <th>" + DocHeaders[0] + "</th>\n	   <th>" + DocHeaders[1] + "</th>\n";
            HTMLOutput += "    <th>" + DocHeaders[2] + "</th>\n	   <th>" + DocHeaders[3] + "</th>\n";
            HTMLOutput += "	   <th>" + DocHeaders[4] + "</th>\n    <th>" + DocHeaders[5] + "</th>\n";
            HTMLOutput += "    <th>" + DocHeaders[6] + "</th>\n";
            HTMLOutput += "  </tr>\n";

            if (attachments.length > 0) {
                for (i = 0; i < attachments.length; i++) {

                    row = attachments[i];
                    typ = row.getAttribute("typ");

                    HTMLOutput += (i % 2 == 0) ? "<tr class=\"odd\">" : "<tr class=\"even\">\n";
                    if (typ == 1 || row.getAttribute("fname")) {
                        HTMLOutput += "    <td>&nbsp;" + row.getAttribute("fname") + "</td>\n";
                    } else if (typ == 2 || row.getAttribute("url")) {
                        HTMLOutput += "    <td>&nbsp;" + row.getAttribute("url") + "</td>\n";
                    } else {
                        HTMLOutput += "    <td>&nbsp;&nbsp;</td>\n";
                    }

                    HTMLOutput += "    <td><img src=\"" + row.getAttribute("mime") + "\" /></td>\n";
                    HTMLOutput += (row.getAttribute("size"))
                            ? "    <td>" + row.getAttribute("size") + " KB</td>\n"
                            : "    <td>&nbsp;</td>\n";
                    HTMLOutput += (row.getAttribute("shortdescr"))
                            ? "    <td>" + row.getAttribute("shortdescr") + "</td>\n"
                            : "    <td>&nbsp;</td>\n";
                    HTMLOutput += (row.getAttribute("thumbnail"))
                            ? "    <td><img src=\"index.php?module=upload&event=ShowImage&name=" + row.getAttribute("thumbnail") + "\" border=\"0\" title=\"(" + row.getAttribute("width") + "x" + row.getAttribute("height") + ")\" /></td>\n"
                            : "    <td>&nbsp;</td>\n";
                    HTMLOutput += "    <td>" + row.getAttribute("cdate") + "</td>\n";
                    HTMLOutput += "    <td>" + row.getAttribute("cuser") + "</td>\n";
                    HTMLOutput += "  </tr>\n"
                }
            }
            HTMLOutput += "</table>\n";

            objAttachmentList.innerHTML = HTMLOutput;
        }

        getAttachments();

    </script>
[% /if %]

[% if $user->hasRight(13) && $DeviceCount > 0 %]

    <script>

        function getPrintDevices(tid)
        {
            PrintTicketID = (tid > 0) ? "&tid=" + tid : "";
            makeHttpRequest("index.php?module=device&event=getDeviceListXML&limit=1" + PrintTicketID, "buildPrintDeviceList", true);
        }

        function buildPrintDeviceList(xmldoc)
        {
            var HTMLOutput = "<table class=\"listview formview\" cellspacing=\"0\" style=\"text-align:left;margin:0 auto;width:99%;\">";
            HTMLOutput += "<tr><th>[% $user->gettext('Asset') %]</th><th>[% $user->gettext('Domain') %]</th><th>[% $user->gettext('Name') %]</th><th>[% $user->gettext('Hersteller') %]</th><th>[% $user->gettext('Modell') %]</th></tr>";

            var devices = xmldoc.getElementsByTagName("device");

            if (devices.length > 0) {
                for (i = 0; i < devices.length; i++) {

                    hostnameNode = devices[i].getElementsByTagName('Hostname')[0];
                    devicenameNode = devices[i].getElementsByTagName('DeviceName')[0];
                    modelNode = devices[i].getElementsByTagName('Model')[0];
                    manufactNode = devices[i].getElementsByTagName('Manufacturer')[0];
                    typenameNode = devices[i].getElementsByTagName('TypeName')[0];
                    domainNode = devices[i].getElementsByTagName('DomainName')[0];
                    hostnameVal = hostnameNode.firstChild.nodeValue;
                    devicenameVal = devicenameNode.firstChild.nodeValue;
                    modelVal = modelNode.firstChild.nodeValue;
                    manufactVal = manufactNode.firstChild.nodeValue;
                    typenameVal = typenameNode.firstChild.nodeValue;
                    domainVal = domainNode.firstChild.nodeValue;

                    HTMLOutput += (i % 2 == 0) ? "<tr class=\"odd\">" : "<tr class=\"even\">";
                    HTMLOutput += "<td>" + hostnameVal + " (" + typenameVal + ")</td>";
                    HTMLOutput += "<td>" + domainVal + "</td>";
                    HTMLOutput += "<td>" + devicenameVal + "</td>";
                    HTMLOutput += "<td>" + manufactVal + "</td>";
                    HTMLOutput += "<td>" + modelVal + "</td>";
                    HTMLOutput += "</tr>";
                }
            }
            document.getElementById('Devices').innerHTML = HTMLOutput + "</table>";
        }

        getPrintDevices([% $ticket.id %]);


    </script>
[% /if %]
<script>
    $(document).on('change', 'table thead input', function () {
        var checked = $(this).is(":checked");

        var index = $(this).parent().index();
        $('#TicketEvents tbody tr').each(function () {
            if (checked) {
                $(this).find("td").eq(index).removeClass('dontPrint');
                $('#TicketEvents thead tr').find("td").eq(index).removeClass('dontPrint');
            } else {
                $(this).find("td").eq(index).addClass('dontPrint');
                $('#TicketEvents thead tr').find("td").eq(index).addClass('dontPrint');
            }
        });
    });

    $(".addDoNotPrint").on('click', function(){
        if($(this).is(':checked')){
            //$(this).parent('.panel').addClass('dontPrint');
            $(this).closest('div.panel-info').addClass('dontPrint');
            console.log("Nicht drucken");
        } else {
            console.log("Doch drucken");
            //$(this).parent('.panel').removeClass('dontPrint');
            $(this).closest('div.panel-info').removeClass('dontPrint');
        }
    });

</script>
<!-- Component Ticket end -->

</body>
</html>
