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

 <link rel="stylesheet" href="includes/bs5/select2/select2.min.css" />
<link rel="stylesheet" href="includes/bs5/select2/select2-bootstrap-5-theme.min.css" />

<!-- QUILLJS -->
<link href="includes/js/quill.snow.css" rel="stylesheet">
<script src="includes/js/quill.js"></script>
<script src="includes/js/quill-magic-url.js"></script>


<script  src="includes/js/quill-image.js"></script>
<!-- END QULL -->
<link
            href="includes/bs5/fontawesome/css/all.min.css"
            rel="stylesheet"
            />      
<script src="includes/bs5/select2/select2.full.min.js"></script>
<style>
        .fancybox-close{
        top: 0px !important;
        right: 0px !important;
    }
</style>
<style type="text/css" media="print">

    * {
        box-sizing: border-box !important;
        padding: 0px !important; margin: 0px !important;
        margin: 0 !important;
    }
    [% 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;

    }

    .select2{
        min-width: 100% !important;
    }

    .panel-info > .card-header, .panel-info > .card-footer {
        color: #000;
        background-color: #e2e3e5;
        border-color: #e2e3e5;
    }

    .panel-info {
        border-color: #e2e3e5;
        background-color: #fff;
    }   

</style>
<style>
    a.btnasicon:hover > img,
    a.btnasicon:focus > img
    { 
        filter: brightness(0) invert(1);
    }

    a.btnasicon
    { 
        padding: 0.5em !important;
    }
</style>
<form action="index.php?module=ticket&event=manualMailTicket" method="POST" id="hm" class="form-horizontal" [% if $export %]style="font-size: 0.75em !important;"[% /if %]>
    <input type='hidden' name='save' value='1'>
    <input type='hidden' name='id' id="tid" value='[% $ticket.id %]'>
    <div class="card panel-fcs-border shadow-sm">
        <div class="card-header">

            <h1 class="card-title">[% $user->gettext(' Ticket') %] #[% $ticket.id %]: [% $ticket.ticketdescr|truncate:60:"...":true %]</h1>
        </div>
        <div class="card-body">
            [% if $successManualMail %]
                <div class="alert alert-success">
                    [% $user->gettext('Ticket wurde verschickt.') %]
                </div>
            [% /if %]
            [% if $failedManualMail %]
                <div class="alert alert-danger">
                    [% $user->gettext('Ticket konnte nicht verschickt werden. Bitte prüfen Sie die Email Addressen, die Sie eingegeben haben.') %]
                </div>
            [% /if %]
            [% if !$export %]
                <div class="card panel-info shadow-sm rounded">
                    <div class="card-body" style="padding-left: 25px; padding-right: 25px;">

                        <div class="form-group row mb-3">
                            <label class="control-label col-sm-3">
                                [% if $Sennebogen %]
                                    [% $user->gettext('Email eingeben ') %] <span class="fa fa-info" title="[% $user->gettext('Email-Adressen von Empfänger, durch ; getrennt') %]"></span>
                                [% else %]
                                    [% $user->gettext('Empfänger auswählen') %]
                                [% /if %]
                            </label>
                            <div class="col-sm-9">
                                [% if $Sennebogen %]
                                    <input type="text" class="form-control" name="emails" placeholder="" required="required">
                                [% else %]
                                    <select name="eMailcontact[]" class="form-control" id="eMailcontact" multiple="multiple" style="width:100%;" >

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

                        </div>
                        [% if !$Sennebogen %]
                            <div class="form-group row mb-3">
                                <label class="control-label col-sm-3">
                                    [% $user->gettext('Weitere E-Mail-Adresse') %] <span class="fa fa-info-circle" title="[% $user->gettext('Email-Adressen von Empfänger, durch ; getrennt') %]"></span>

                                </label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="other_emails" placeholder="" style="width: 100%;">
                                </div>

                            </div>
                        [% /if %]
                        <div class="form-group row mb-3">
                            <label class="control-label col-sm-3">
                                [% $user->gettext('Nachricht') %] <span class="fa fa-info-circle" title="[% $user->gettext('zusätzliche Nachricht') %]"></span>

                            </label>
                            <div class="col-sm-9">
                                <div id="quillEditor">
                                    [% $user->getQuillToolbar() %]
                                    <div id="editor" style="min-height: 200px;">

                                    </div>
                                </div>
                                <textarea class="form-control" id="LongDescr" name="message" placeholder="Ihre Nachricht"  style="height: 0px; visibility:hidden;"></textarea>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-sm-3"></div>
                            <div class="col-sm-4">
                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            <input class="form-check-input" type="checkbox" value="" id="NotProtocol" checked="checked" onclick="hideProtocols();">
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Protokolleinträge anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" type="checkbox" onclick="toggleDetails();" id="CBShowDetails" checked="checked" name="show[showdetails]">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Ticketdetail anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" onclick="toggleContact();" type="checkbox" id="CBShowContact" checked="checked" name="show[showcontact]">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Kontaktdetail anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" onclick="toggleDescr();" type="checkbox" checked="checked" id="CBShowDescr" name="show[showdescr]" checked="checked">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Beschreibungen anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>

                            </div>

                            <div class="col-sm-4">
                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" onclick="toggleEvents();" type="checkbox" checked="checked" id="CBShowEvents" name="show[showticketevents]" checked="checked">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Ticketbearbeitungen anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" onclick="toggleFormData();" type="checkbox" checked="checked" id="CBShowFormData" name="show[formdata]" checked="checked">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Formular-Daten anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" onclick="toggleAttachments();" type="checkbox" checked="checked" id="CBShowAttachments" name="show[documents]" checked="checked">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Anhänge anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group row mb-3">
                                    <label class="control-label">
                                    </label>
                                    <div class="">
                                        <div class="form-check">
                                            [% if !$export %]<input class="form-check-input" onclick="toggleAssets();" type="checkbox" checked="checked" id="CBShowAssets" name="show[assets]" checked="checked">[% /if %]
                                            <label class="form-check-label" for="flexCheckDefault">
                                                [% $user->gettext('Assets anzeigen') %]
                                            </label>
                                        </div>
                                    </div>
                                </div>

                            </div>

                        </div>
                        <div class="form-group row mb-3">
                            <div class="col-sm-3">

                            </div>
                            <div class="col-sm-9">
                                <a onclick="$('#load').show();
                                        $('#hm').submit();" class="btn btn-outline-primary btnasicon">[% if $smarty.const.SHOWBUTTONSASIMAGES %]<img src="images/TicketButtons/SendMail.png" width="32" height="32" alt="" border="0" />[% else %][% $user->gettext('Mail senden') %][% /if %]</a>
                            </div>
                        </div>


                        <p>  <div id="load" style="display:none;" style="font-style:italic"><img src="images/ajax-loader.gif" /> [% $user->gettext('Ticketdaten werden generiert') %]...</div></p>

                    </div>
                </div>
            [% /if %]
            [% if $message %]
                <h2 style="padding: 0px !important; margin: 0px !important;">[% $user->gettext('Nachricht')%]</h2>

                [% $message %]
            [% /if %]
         
            
            <div class="SortPanel">
                [% foreach $PanelOrders as $Panel %]
                [% if $Panel == 'DetailsPanel' && (!$export || $show.showdetails) %]
                    <div id="DetailsDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;">[% $user->gettext('Ticketdetail') %]</h2>
                        <table class='table table-striped table-condensed'>
                            <tbody>
                                [% if !$export || $show.ticketdetail.shortdescr %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][shortdescr]">[% /if %] [% $user->gettext('Kurzbeschr.') %]</td>
                                        <td>[% $ticket.ticketdescr %]</td>
                                    </tr>
                                [% /if %]
                                [% if !$export || $show.ticketdetail.id %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][id]">[% /if %] [% $user->gettext('Ticket ID') %]</td>
                                        <td>[% $ticket.id %]</td>
                                    </tr>
                                [% /if %]
                                [% if !$export || $show.ticketdetail.createdate %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][createdate]">[% /if %] [% $user->gettext('Erstelldatum') %]</td>
                                        <td>[% $ticket.editdate|date_format:"%d.%m.%Y %H:%M" %]</td>
                                    </tr>
                                [% /if %]
                                [% if !$export || $show.ticketdetail.company  %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][company]">[% /if %] [% $user->gettext('Kontakt') %]</td>
                                        <td>[% $ticket.name %] [% if $ticket.company != '' %]([% $ticket.company %])[% /if %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.group) && $ticket.benutzergruppe|trim != '' && ($user->hasRight(52) || $user->hasRight(54)) %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][group]">[% /if %] [% $user->gettext('Benutzergruppe') %]</td>
                                        <td>[% $ticket.benutzergruppe %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.group) && $ticket.gruppe|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][group]">[% /if %] [% $user->gettext('Gruppe') %]</td>
                                        <td>[% $ticket.gruppe %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.supporter) && $ticket.supporter|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][supporter]">[% /if %] [% $user->gettext('Supporter') %]</td>
                                        <td>[% $ticket.supporter %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.cat1) && $ticket.category1|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][cat1]">[% /if %] [% $user->gettext('Kategorie') %] 1</td>
                                        <td>[% $ticket.category1 %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.cat2) && $ticket.category2|trim != '' && !$user->hasRight(51) %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][cat2]">[% /if %] [% $user->gettext('Kategorie') %] 2</td>
                                        <td>[% $ticket.category2 %]</td>
                                    </tr>
                                [% /if %]
                                [% if !$export || $show.ticketdetail.desiredate %]
                                    <tr>
                                        <td>
                                            [% if $hmcompany|strpos:"AVAG HOLDING" !== false %]
                                                [% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][desiredate]">[% /if %] [% $user->gettext('Wiedervorlage am') %]
                                            [% else %]
                                                [% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][desiredate]">[% /if %] [% $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 %]
                                [% if (!$export || $show.ticketdetail.solutiondate) && $hmcompany|strpos:"AVAG HOLDING" !== false %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][solutiondate]">[% /if %] [% $user->gettext('L&ouml;sung bis') %] </td>
                                        <td>[% if $ticket.solutiondate != "" %][% $ticket.solutiondate|date_format:"%d.%m.%Y %H:%M" %][% /if %]</td>
                                    </tr>
                                [% /if %]
                                [% if !$export || $show.ticketdetail.ticketprio %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][ticketprio]">[% /if %] [% $user->gettext('Priorit&auml;t') %]</td>
                                        <td>[% $user->gettext($ticket.priority) %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.onhold) && $ticket.diffonhold > 0 %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][onhold]">]">[% /if %] [% $user->gettext('Zur&uuml;ckgestellt bis zum') %]</td>
                                        <td>[% $ticket.onhold|date_format:"%d.%m.%Y %H:%M" %]</td>
                                    </tr>
                                [% /if %]
                                [% if !$export || $show.ticketdetail.ticketstatus %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][ticketstatus]">[% /if %] [% $user->gettext('Status') %]</td>
                                        <td>[% $user->gettext($ticket.tstatus) %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.ticketreferenzid) && !$ticket.master && $ticket.ticketreferenzid > 0 %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][ticketreferenzid]">[% /if %] [% $user->gettext('TicketRef. ID') %]</td>
                                        <td>[% $ticket.ticketreferenzid %]</td>
                                    </tr>
                                [% /if %]
                                [% if  (!$export || $show.ticketdetail.expense) &&  $ticket.expense > 0 %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][expexpense]">[% /if %] [% $user->gettext('Aufwand in Min') %]</td>
                                        <td>[% $ticket.expense %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.master) && $ticket.master %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][master]">[% /if %] [% $user->gettext('Masterticket') %]</td>
                                        <td><img src="images/master.gif" width="16" height="16" alt="" title="[% $user->gettext('Masterticket') %]" border="0"  /></td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.ticketdetail.maxescalation) && $ticket.maxescalation %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[ticketdetail][escalation]">[% /if %] [% $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>
                                [% /if %]
                            </tbody>
                        </table>
                    </div>
                [% /if %]
                [% if $Panel == 'ContactDiv' && (!$export || $show.showcontact) %]
                    <div id="ContactDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;">[% $user->gettext('Kontaktdetail') %]</h2>
                        <table class="table table-striped table-condensed">

                            <tbody>
                                [% if (!$export || $show.contact.name) && $ticket.name|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][name]">[% /if %] [% $user->gettext('Name') %]</td>
                                        <td>&nbsp;[% $ticket.name %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.company) && $ticket.company|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][company]">[% /if %] [% $user->gettext('Firma') %]</td>
                                        <td>&nbsp;[% $ticket.company %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.email) && $ticket.email|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][email]">[% /if %] [% $user->gettext('E-Mail') %]</td>
                                        <td>&nbsp;[% $ticket.email %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.position) && $ticket.com_position|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][position]">[% /if %] [% $user->gettext('Position') %]</td>
                                        <td>&nbsp;[% $ticket.com_position %]</td>
                                    </tr>
                                [% /if %]


                                [% if (!$export || $show.contact.building) && $ticket.building|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][building]">[% /if %] [% $user->gettext('Gebäude') %]</td>
                                        <td>&nbsp;[% $ticket.building %]</td>
                                    </tr>
                                [% /if %]

                                [% if (!$export || $show.contact.floor) && $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 (!$export || $show.contact.department) && $AssetDesk && $ticket.department|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][department]">[% /if %] [% $user->gettext('Abteilung') %]</td>
                                        <td>&nbsp;[% $ticket.department %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.personalno) && $ticket.personalno|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][personalno]">[% /if %][% $user->gettext('Personalnr.') %]</td>
                                        <td>&nbsp;[% $ticket.personalno %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.costcenter) && $ticket.costcenter|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][costcenter]">[% /if %] [% $user->gettext('Kostenstelle') %]</td>
                                        <td>&nbsp;[% $ticket.costcenter %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.street) && $ticket.street|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][street]">[% /if %] [% $user->gettext('Strasse') %]</td>
                                        <td>&nbsp;[% $ticket.street %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.plz) && $ticket.plz|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][plz]">[% /if %] [% $user->gettext('PLZ') %]</td>
                                        <td>&nbsp;[% $ticket.plz %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.city) && $ticket.city|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][city]">[% /if %] [% $user->gettext('Ort') %]</td>
                                        <td>&nbsp;[% $ticket.city %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.state) && $ticket.state|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][state]">[% /if %] [% $user->gettext('Bundesland') %]</td>
                                        <td>&nbsp;[% $ticket.state %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.country) && $ticket.country|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][country]">[% /if %] [% $user->gettext('Land') %]</td>
                                        <td>&nbsp;[% $ticket.country %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.phone) && $ticket.phone|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][phone]">[% /if %] [% $user->gettext('Telefon') %]</td>
                                        <td>&nbsp;[% $ticket.phone %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.fax) && $ticket.fax|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][fax]">[% /if %] [% $user->gettext('Fax') %]</td>
                                        <td>&nbsp;[% $ticket.fax %]</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.mobile) && $ticket.mobil|trim != '' %]
                                    <tr>
                                        <td>[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][mobile]">[% /if %] [% $user->gettext('Mobil') %]</td>
                                        <td>&nbsp;[% $ticket.mobil %]</td>
                                    </tr>
                                [% /if %]

                                [% if (!$export || $show.contact.misc) && $ticket.misc|trim != '' %]
                                    <tr>
                                        <td valign="top">[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][misc]">[% /if %] [% $user->gettext('Zusatzinformation') %]</td>
                                        <td valign="top">[% $ticket.misc %]&nbsp;</td>
                                    </tr>
                                [% /if %]
                                [% if (!$export || $show.contact.image) && $ticket.image != NULL %]
                                    <tr>
                                        <td valign="top">[% if !$export %]<input type="checkbox" checked="checked" name="show[contact][image]">[% /if %] [% $user->gettext('Avatar') %]</td>
                                        <td valign="top"><img src="upload/[% $ticket.image %]">&nbsp;</td>
                                    </tr>
                                [% /if %]
                            </tbody>
                        </table>
                    </div>
                [% /if %]
                [% if $Panel == 'DescrDiv' && (!$export || $show.showdescr) %]
                    <div id="DescrDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;"> [% $user->gettext('Beschreibung') %]</h2>
                        [% if $TicketDescrFromMail %]
                               <p>[% $TicketDescrFromMail %]</p>
                            [% else %]
                                   <p>[% $formatedTicketDescription|nl2br %]</p>
                                [% /if %]
                     
                    </div>
                [% /if %]
                [% if $Panel == 'EventsDiv' && (!$export || $show.showticketevents) && $Tools->FCS_Count($events) %]
                    <div id="EventsDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;">

                            [% $user->gettext('Bearbeitungen') %]
                        </h2>
                        [% foreach from=$events item=event name=TicketEvents %]
                            [% if !$mail %]
                                <div class="card panel-info shadow-sm rounded">
                                    <div class="card-header">
                                        [% if !$export %]<input type="checkbox" class="evCB [% if !$event.protocolevent %]no-protocol[% else %]protocol[% /if %]" checked="checked" name="show[ticketevents][[% $event.id %]]">[% /if %][[% $event.eventdate|date_format:"%d.%m.%Y %H:%M" %] - [% $event.name %] - [% $event.expense|intval %] [% $user->gettext('Min') %]]
                                    </div>
                                    <div class="card-body">
                                        [% $event.eventdescr|nl2br %]
                                        
                                    </div>
                                </div>
                            [% else %]
                                <p><i>[% $event.eventdate|date_format:"%d.%m.%Y %H:%M" %] - [% $event.name %] - [% $event.expense|intval %] [% $user->gettext('Min') %]</i><br> [% $event.eventdescr %]</p>
                            [% /if %]
                            [% /foreach %]
                        [% if (!$export || $show.deffields) && $type.type_id && $Tools->FCS_Count($finalFieldList) > 0  %]
                        <h2>[% if !$export %]<input type="checkbox" checked="checked" name="show[deffields]">[% /if %] [% $user->gettext('Benutzerdefinierte Felder') %]</h2>

                        [% foreach from=$finalFieldList item=field %]
                            [% if !$field.UDF %]
                                <p>
                                    [% $field.field_name %]: 
                                    [% 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' %]
                                        [% if $field.value == 1 %]
                                            [% $user->gettext('Ja') %]
                                        [% /if %]
                                    [% elseif $field.field_type == 'select' %]

                                    [% /if %]
                                </p>

                            [% else %]
                                <p>
                                    [% $field.fieldname %]:  
                                    [% foreach from=$field.fieldvalues item=$value %]
                                        [% if $Tools->FCS_InArray($value.userdeffieldvalueid, $field.selectedvalue)  %]
                                            [% $value.value %]<br/>
                                        [% /if %]
                                    [% /foreach %]
                                </p>
                            [% /if %]
                        [% /foreach %]
                        [% /if %]
                    </div>
                [% /if %]
                [% if $Panel == 'FormDataDiv' && (!$export || $show.formdata) && ($Tools->FCS_Count($Formulars.1) || $Tools->FCS_Count($Formulars.2) || $Tools->FCS_Count($Formulars.3))  %]
                    <div id="FormDataDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;">
                            [% if !$export && false %]
                                <input type="checkbox" checked="checked" name="show[formdata]">&nbsp;
                            [% /if %] 
                            [% $user->gettext('Formulardaten') %]
                        </h2>
                        [% if $Tools->FCS_Count($Formulars.1) %]
                            <h2>
                                [% $user->gettext('Formular') %]
                                [% $Formulars.1.formname %]
                                [% if $Formulars.1.categoryname != '' %]
                                    ([% $user->gettext('Kategorie') %]: [% $Formulars.1.categoryname %])
                                [% /if %]
                            </h2>
                            <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 %]</td>
                                        </tr>
                                    [% /foreach %]
                                </tbody>
                            </table>

                        [% /if %]


                        [% if $Tools->FCS_Count($Formulars.2) %]
                            <h2 style="padding: 0px !important; margin: 0px !important;">
                                [% $user->gettext('Formular') %]
                                [% $Formulars.2.formname %]
                                [% if $Formulars.2.categoryname != '' %]
                                    ([% $user->gettext('Kategorie') %]: [% $Formulars.2.categoryname %])
                                [% /if %]                        
                            </h2>
                            <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 %]&nbsp;</td>
                                    </tr>
                                [% /foreach %]

                            </table>
                        [% /if %]

                        [% if $Tools->FCS_Count($Formulars.3) %]
                            <h2>
                                [% $user->gettext('Formular') %]
                                [% $Formulars.3.formname %]
                                [% if $Formulars.3.categoryname != '' %]
                                    ([% $user->gettext('Kategorie') %]: [% $Formulars.3.categoryname %])
                                [% /if %]
                            </h2>

                            <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 %]&nbsp;</td>
                                        </tr>
                                    [% /foreach %]
                                </tbody>
                            </table>

                        [% /if %]
                    </div>
                [% /if %]
                [% if $Panel == 'AttachmentsDiv' && $AttachmentCount > 0 && (!$export || $show.documents) %]
                    <div id="AttachmentsDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;">
                            [% if !$export && false %]
                                <input type="checkbox" id="MainDoc" onclick="changeDoc();" checked="checked" name="show[documents]">
                            [% /if %] [% $user->gettext('Dokumente') %]
                        </h2>
                        <ul style="list-style: none;   list-style-type: none; margin: 0; padding: 0;">

                            [% foreach from = $atts item = att key=key %] 
                                <li>
                                    [% if !$export %]
                                        <input type='checkbox' checked='checked' class="docCB" name='show[documents][[% $key %]]'>
                                    [% /if %] 
                                    [% $att.name %]

                                    [% if $att.mimetype|strstr:"image"%]
                                        <img src="[% $smarty.const.HTTPURL %]index.php?module=upload&class=download&event=ShowImage&name=[% $att.real_name %]" alt="[% $att.name %]" style="max-width:200px;">
                                    [% /if %]
                                </li>
                            [% /foreach %]
                        </ul>
                    </div>
                [% /if %]

                [% if $Panel == 'AssetsDiv' && (!$export || $show.assets) && $user->hasRight(13) && $DeviceCount > 0 %]
                    <div id="AssetsDiv" class="sortable">
                        <h2 style="padding: 0px !important; margin: 0px !important;">
                            [% if !$export && false%]
                                <input type="checkbox" checked="checked" name="show[assets]">
                            [% /if %]
                            [% $user->gettext('Assets') %]
                        </h2>
                        <table class='table table-striped'>
                            <tr>
                                <th>[% $user->gettext('Host') %]</th>
                                <th>[% $user->gettext('Name') %]</th>
                            </tr>
                            [% foreach $Devices as $Dev %]
                                <tr>
                                    <td>[% $Dev.hostname %]/[% $Dev.domainname %]</td>
                                    <td>[% $Dev.devicename %]</td>
                                </tr>
                            [% /foreach %]
                        </table>
                        </div>
                    [% /if %]
                
                [% /foreach %]
            </div>
        </div>
    </div>
</form>
<script  src="includes/js/hm-quill.js"></script>
[% if !$export %]
    <script>
                                    function hideProtocols() {
                                        if ($('#NotProtocol').is(":checked")) {
                                            $('.protocol').prop('checked', true);
                                        } else {
                                            $('.protocol').prop('checked', false);
                                        }
                                    }

                                    function changeDoc() {
                                        if ($('#MainDoc').is(":checked")) {
                                            $('.docCB').prop('checked', true);
                                        } else {
                                            $('.docCB').prop('checked', false);
                                        }
                                    }

                                    function changeEv() {
                                        if ($('#MainEv').is(":checked")) {
                                            $('.evCB').prop('checked', true);
                                        } else {
                                            $('.evCB').prop('checked', false);
                                        }
                                    }

                                    function changeEv() {
                                        if ($('#MainEv').is(":checked")) {
                                            $('.evCB').prop('checked', true);
                                        } else {
                                            $('.evCB').prop('checked', false);
                                        }
                                    }

                                    function toggleDescr() {
                                        if ($('#CBShowDescr').is(":checked")) {
                                            $('#DescrDiv').show();
                                        } else {
                                            $('#DescrDiv').hide();
                                        }
                                    }

                                    function toggleDetails() {
                                        if ($('#CBShowDetails').is(":checked")) {
                                            $('#DetailsDiv').show();
                                        } else {
                                            $('#DetailsDiv').hide();
                                        }
                                    }

                                    function toggleContact() {
                                        if ($('#CBShowContact').is(":checked")) {
                                            $('#ContactDiv').show();
                                        } else {
                                            $('#ContactDiv').hide();
                                        }
                                    }

                                    function toggleEvents() {
                                        if ($('#CBShowEvents').is(":checked")) {
                                            $('#EventsDiv').show();
                                        } else {
                                            $('#EventsDiv').hide();
                                        }
                                    }

                                    function toggleFormData() {
                                        if ($('#CBShowFormData').is(":checked")) {
                                            $('#FormDataDiv').show();
                                        } else {
                                            $('#FormDataDiv').hide();
                                        }
                                    }

                                    function toggleDocuments() {
                                        if ($('#CBShowDocuments').is(":checked")) {
                                            $('#DocumentsDiv').show();
                                        } else {
                                            $('#DocumentsDiv').hide();
                                        }
                                    }

                                    function toggleAssets() {
                                        if ($('#CBShowAssets').is(":checked")) {
                                            $('#AssetsDiv').show();
                                        } else {
                                            $('#AssetsDiv').hide();
                                        }
                                    }
                                    $(document).ready(function () {


                                        $("#eMailcontact").select2({theme: 'bootstrap-5',
                                            minimumInputLength: 0,
                                            width: 'resolve',
                                            ajax: {
                                                url: "index.php?module=contact&event=getJsonContacts&useMailAsID=1",
                                                dataType: 'json',
                                                delay: 250,
                                                data: function (params) {
                                                    return {
                                                        q: params.term, // search term
                                                        page: params.page,
                                                        ContactID: 0
                                                    };
                                                },
                                                processResults: function (data) {
                                                    return {
                                                        results: data.items
                                                    };
                                                }
                                            },
                                            escapeMarkup: function (markup) {
                                                return markup;
                                            },
                                            templateSelection: formatContact
                                        });

                                        function formatContact(opt) {
                                            if (typeof opt.name !== 'undefined') {
                                                return opt.name;
                                            }
                                            return opt.text;
                                        }
                                    });
                                    /**
                                     *
                                     */
                                    var ids = [];
                                    function updatePanelOrder() {
                                        ids = [];
                                        $(".sortable").each(function () {
                                            ids.push(this.id);
                                        });
                                        console.log(JSON.stringify(ids));
                                        $.post('index.php?module=ticket&event=saveMailPanelOrder', {'panelorders': JSON.stringify(ids)}, function (res) {
                                            console.log("Panel orders saved.");
                                        });

                                    }
                                    $(".SortPanel").sortable(
                                            {
                                                start: function () {


                                                },

                                                update: function (event, ui) {
                                                    updatePanelOrder();

                                                },
                                               
                                                connectWith: ".sortable"
                                            });


    </script>

[% /if %]
