<form action="" method="post" name="hm" onsubmit="return false" id="hm" enctype="multipart/form-data" style="margin:0;padding:0;">

    <input type="hidden" name="sort" id="sort" value="[% $sort %]" />
    <input type="hidden" name="sortorder" id="sortorder" value="[% $sortorder %]" />

    <div class="card panel-fcs-border shadow-sm">
        <div class="card-header">
            <h2 class="card-title-fcs">[% $user->gettext('Textbausteine') %]</h2>
        </div>

        <div class="card-body">
            
                <div class="card panel-info shadow-sm rounded">
                    <div class="card-header">
                        <div class="row">
                            <div class="col-lg-6 text-left" >
                                <h3 class="card-title-fcs">[% $user->gettext('Rubriken verwalten')%]</h3> 
                            </div>
                            <div class="col-lg-6 text-end" >
                                <input type="button" id="btnNewRubric" onclick="window.location.href = 'index.php?module=ticket&class=snippets&event=AddRubric'" value="[% $user->gettext('Rubrik hinzuf&uuml;gen') %]" class="btn btn-outline-secondary" />
                            </div>
                        </div>
                    </div>

                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-striped" id="newsList">
                                <thead>

                                    <tr>
                                        <th style="cursor:pointer;" onclick="document.getElementById(
                                            [% if $sort == "Name" %]
                                                'sortorder').value = '[% if $sortorder == "DESC" %]ASC[% else %]DESC[% /if %]'
                                            [% else %]
                                                        'sort'
                                                                ).value = 'Name'
                                            [% /if %];
                                                        submitForm();">
                                            [% $user->gettext('Rubriktitel') %]
                                            [% if $sort == "Name" %] <img src="images/sort[% if $sortorder == "DESC" %]desc[% else %]asc[% /if %].gif" width="11" height="11" border="0" alt=""  />[% /if %]
                                        </th>
                                        <th style="cursor:pointer;" onclick="document.getElementById(
                                            [% if $sort == "Description" %]
                                                'sortorder').value = '[% if $sortorder == "DESC" %]ASC[% else %]DESC[% /if %]'
                                            [% else %]
                                                        'sort'
                                                                ).value = 'Description'
                                            [% /if %];
                                                        submitForm();">
                                            [% $user->gettext('Beschreibung') %]
                                            [% if $sort == "Description" %] <img src="images/sort[% if $sortorder == "DESC" %]desc[% else %]asc[% /if %].gif" width="11" height="11" border="0" alt=""  />[% /if %]
                                        </th>
                                        <th> </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    [% foreach from=$SnippetRubrics item=SnippetRubric %]
                                        <tr>
                                            <td width="45%">[% $SnippetRubric.Name %] </td>
                                            <td width="45%">[% $SnippetRubric.Description|truncate:5000:" ..." %] </td>
                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-outline-secondary btn-sm" href="index.php?module=ticket&class=snippets&event=EditSnippetRubric&SnippetRubricID=[% $SnippetRubric.SnippetRubricID %]" ><span class="fa fa-pencil"></span></a>
                                                    <button class="btn btn-outline-secondary btn-sm" [% if $SnippetRubric.IsInUse %]disabled[% /if %] onclick="bootbox.confirm('[% $user->gettext('Sicher, dass die Rubrik gelöscht werden soll?') %]', function(result){if(result){window.location.href = 'index.php?module=ticket&class=snippets&event=DeleteSnippetRubric&SnippetRubricID=[% $SnippetRubric.SnippetRubricID %]';} })"><span class="fa fa-trash"></span></button>
                                                </div>
                                            </td>
                                        </tr>
                                    [% /foreach %]
                                <tbody>
                            </table>
                        </div>
                    </div>               
            </div>
        </div>
    </div>

</form>
