       
<script src="includes/js/bootstrap-select-1.12.4/dist/js/bootstrap-select.min.js"></script>
<link rel="stylesheet" href="includes/js/bootstrap-select-1.12.4/dist/css/bootstrap-select.min.css">
<script src="includes/js/bootstrap-select-1.12.4/dist/js/i18n/defaults-[% if $user->language_type == "de" %]de_DE[% else %]en_US[% /if %].min.js"></script>



<link rel="stylesheet" type="text/css" href="includes/js/datatables_1.11.5/datatables.min.css"/>
<script type="text/javascript" src="includes/js/datatables_1.11.5/datatables.min.js"></script>

<form action="index.php?module=errorpatterns&event=addErrorPatternToClassification" method="post" class='form-horizontal form-label-left'>

    <input type="hidden" name="EP[AssetTypeID]" id="AssetTypeID" value="[% $AssetTypeID %]"/>
    <input type="hidden" name="EP[MainGroupID]" id="MainGroupID" value="[% $MainGroupID %]"/>
    <input type="hidden" name="EP[SubGroupID]" id="SubGroupID" value="[% $SubGroupID %]"/>


    <input type='hidden' name='save' value='1' />
    <div class="card panel-fcs-border shadow-sm">
        <div class="card-header">
            <span class="fcs-card-title h2">[% $user->gettext('Fehlerbilder') %]</span>
        </div>
        <div class="card-body">
            <div class="card panel-info shadow-sm rounded">
                <div class="card-header">
                    <div class="row">
                        <div class="col-sm-6">
                            <span class="fcs-card-title h4">
                                [% $user->gettext('Fehlerbilder zufügen') %]

                            </span>
                            [% if $AssetTypeID > 0 %]
                                <small>[% $CodeString %]</small>
                            [% /if %]
                        </div>
                        <div class="col-sm-6 text-end">
                            <div class="btn-group">
                                <input type='submit' class='btn btn-outline-primary' value="[% $user->gettext('Speichern') %]" />                           
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <div class="form-group row mb-3">
                        <label class="col-lg-4 control-label">[% $user->gettext('Fehlerbilder wählen') %]</label>
                        <div class="col-lg-8">
                            <select name="selectedEPIDs[]" id="selectedEPIDs" class="form-control selectpicker" multiple data-size="10"  data-live-search="true" data-selected-text-format="count>0" data-count-selected-text= "[%$user->gettext('Fehlerbilder')%] ({0} [%$user->gettext('gewählt')%])" data-title="[% $user->gettext('Fehlerbilder wählen') %]" title="[% $user->gettext('Fehlerbilder') %]">
                                <option vlaue="0">-- [% $user->gettext('Fehlerbilder wählen') %] --</option>
                                [% html_options options=$selectErrorPatterns selected=$selectedEPIDs %]
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            [% if $Tools->FCS_Count($ErrorPatterns) %]
                <div class="card panel-info shadow-sm rounded">
                    <div class="card-header">
                        <div class="row">
                            <div class="col-sm-6">
                                <span class="fcs-card-title h4">[% $user->gettext('Zugewiesene Fehlerbilder') %]</span>
                            </div>
                            <div class="col-sm-6 text-end">
                                <div class="btn-group">

                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <table id="reportTable" class="table">
                            <thead>
                                <tr>
                                    <th>[% $user->gettext('Fehlerbild de') %]</th>
                                    <th>[% $user->gettext('Fehlerbild en') %]</th>
                                    <th>[% $user->gettext('Code') %]</th>
                                    <th>[% $user->gettext('Aktionen') %]</th>
                                </tr>
                            </thead>        

                            <tbody>
                                [% foreach $ErrorPatterns as $row %]
                                    <tr>
                                        <td>
                                            [% $row['epdescr_de'] %]
                                            [% $row['epprep_de'] %]
                                            [% $row['epobject_de'] %]
                                        </td>
                                        <td>
                                            [% $row['epdescr_en'] %]
                                            [% $row['epprep_en'] %]
                                            [% $row['epobject_en'] %]
                                        </td>
                                        <td>
                                            &lt;
                                            [% $row['epdescr_id'] %] --
                                            [% $row['epprep_id'] %] --
                                            [% $row['epobject_id'] %]
                                            &gt;
                                        </td>
                                        <td>
                                            <a href="index.php?module=errorpatterns&event=removeFromClassification&atid=[% $AssetTypeID %]&mgid=[% $MainGroupID %]&sgid=[% $SubGroupID %]&epid=[% $row['errorpatternid'] %]" class="btn btn-sm btn-outline-secondary" title="[% $user->gettext('Zuordnung entfernen') %]"><span class="fa fa-times"></span></a>
                                        </td>
                                    </tr>
                                [% /foreach %]
                            </tbody>
                            <tfoot>

                            </tfoot>
                        </table>                                            

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


<script>
    $(document).ready(function () {

        $(".selectpicker").selectpicker();

        table = $('#reportTable').DataTable({
            stateSave: true,
            "sPaginationType": "full_numbers",
            "bLengthChange": true,
            "iDisplayLength": 10,
            "oLanguage": {
                "sLengthMenu": '[% $user->gettext("Zeige _MENU_ Eintr&auml;ge") %]',
                "sZeroRecords": '[% $user->gettext("Keine Eintr&auml;ge gefunden") %]',
                "sInfo": '[% $user->gettext("Eintrag _START_ bis _END_ (von _TOTAL_)") %]',
                "sInfoEmpty": " ",
                "sInfoFiltered": '[% $user->gettext(" - gefiltert aus _MAX_ Eintr&auml;gen") %]',
                "sSearch": "Filter",
                "oPaginate": {
                    "sFirst": "&lt;&lt;",
                    "sLast": "&gt;&gt;",
                    "sNext": "&gt;",
                    "sPrevious": "&lt;"
                },
                "aaSorting": [[1, "asc"]]
            }
        });
        var data = table.buttons.exportData({
            columns: ':visible'
        });

    });
</script>
