<!-- Component TicketTemplate begin -->
<form action="" method="post" name="hm" id="hm-ServiceForm" enctype="multipart/form-data" >
    <!-- ###CONTENT### begin -->
    <div id="content">
        <div class="wrapper">
            <div class="border">
                <table width="100%" class="listview formview" id="ServiceForm" cellspacing="0" border="0">
                    <thead>
                        <tr>
                            <th colspan="1"><strong>[% $user->gettext('Serviceticket anlegen') %]</strong>
                            <th colspan="3">
                                <input type="button" value="[% $user->gettext('Normales Ticket anlegen') %]" onclick="document.location.href = 'index.php?module=ticket&amp;event=newTicket';" class="button button-green" />
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="even">
                            <td width="30%">[% $user->gettext('Kontakt') %]</td>
                            <td width="70%">
                                <select name="contactid" id="ContactID" style="width: 100%;">
                                </select>
                            </td>
                        </tr>
                        <tr id="ServiceListRow" style="display:none;">
                            <td colspan="2">
                                <div id="ServiceList"></div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</form>


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

$("#ContactID").select2({theme: 'bootstrap-5',
  ajax: {
    url: "index.php?module=contact&event=getJsonContacts",
//    dataType: 'json',
    delay: 250,
    data: function (params) {
      return {
        q: params.term
      };
    },
    processResults: function (data) {
      return {
        results: data.items
      };
    }
  }
}).on("select2:select", function (e) {getServicesForContactID($("#ContactID").val()) });

function getServicesForContactID(ContactID){
    $.get( "index.php?module=services&class=sla&event=getServicesForContactID&cid="+ContactID, function( data ) {
        $("#ServiceListRow").show();
        $( "#ServiceList" ).html(data.Servicelist)
    }, "json" );
}
    //-->
</script>

<!-- Component Ticket end -->