
        var dataSet = JSON.parse('{% autoescape false %}{{ app.data_set|json_encode() }}{% endautoescape %}');
        var lic_count_set = JSON.parse('{% autoescape false %}{{ app.lic_count_set|json_encode() }}{% endautoescape %}');
        var status_set = JSON.parse('{% autoescape false %}{{ app.status_set|json_encode() }}{% endautoescape %}');
        var licsServerErrors = JSON.parse('{% autoescape false %}{{ app.licsServerErrors|json_encode() }}{% endautoescape %}');

        function TestTable1() {
            $.ajax({
                url: "{{app.request_context.baseUrl}}/plugins/datatables/dataTables.sortingDateDE.js",
                dataType: "script",
                cache: true
            });
            $.ajax({
                url: "{{app.request_context.baseUrl}}/plugins/datatables/dataTables.sortingFormattedNumbers.js",
                dataType: "script",
                cache: true
            });

            $.fn.dataTable.ext.search.push(
                    function( settings, data, dataIndex ) {
                        return checkLicCountFilter(data[1]) && checkStatusFilter(data[4]);
                    }
            );

            $('#datatable-1').on('xhr.dt', function (e, settings, json) {
                if (typeof (json.data) == 'object') {
                    for (var i in json.data) {
                        json.data[i] = rowDataPrepare(json.data[i]);
                    }
                }
            }).dataTable({
                "processing": false,
                "serverSide": false,
                "ajax" : {
                    "url" : "{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/current-list-json"
                },
                "language": {
                    "url": "{{ app.datatable_lang_file }}"
                },
                {% if attribute(app, 'dropdownAttribute') is defined %}
                {{ main_macro.get_datatable_column(app['dropdownAttribute']) }}
                {% endif %}
                "bFilter": true,
                "bPaginate": true,
                "bInfo": true,
                "aoColumnDefs": [
                    /*{className: "action-menu", "targets": [-1]},*/
                    {"searchable": false/*, "targets": [0, 2, 3, 5, 7, -1]*/},
                    {"sortable": false/*, "targets": [0, 5, 6, -1]*/},
                    { "type": 'formatted-num', targets: [1] },
                    { "type": 'de_date', targets: [2, 3] }
                ]
            }).prev('.dataTables_processing').hide('');
        }

        function yelp() {
            $(document).ready(function () {

                if (licsServerErrors instanceof Array) {
                    $.each(licsServerErrors, function(){
                        licsServerErrorsModal(this);
                    });
                }

                $(document).on('click', "a.main_ajax", function (e) {
                    e.stopPropagation();
                    e.preventDefault();
                    var _this = this;
                    $("#modalbox").data('complete', 0);
                    var sendData = $(_this).data();
                    if ($(_this).attr("disabled")) {
                        JSErrorModalBox({msg: "{{ 'Action is not available'|trans }}"});
                    } else {
                        ajaxPostSend($(_this).attr('href'), sendData, false );
                    }
                    $(this).closest('div.open').removeClass('open');
                    return false;
                });

                $(document).on('click', "#modalbox, #modalbox a.close-link, #modalbox a.close-link *", function (e) {
                    if (e.currentTarget != e.target) {
                        return;
                    }
                    e.stopPropagation();
                    e.preventDefault();
                    if ($("#modalbox").data('complete') && $("#modalbox").data('complete') == 1) {
                        JScloseModalBox();
                    } else {
                        for (i = 0; i < 3; i++) {
                            $('#modalbox > div').fadeTo('slow', 0.5).fadeTo('slow', 1.0);
                        }
                    }
                    return false;
                });
                $("#iptv_list").on('click', 'div[data-tvfilter] ul a', function(e){
                    e.stopPropagation();
                    e.preventDefault();
                    $(this).closest('.open').removeClass('open');
                    $(this).closest('[data-tvfilter]').data('filterval', $(this).data('filter')).find("span:nth-of-type(2)").text($(this).text());
                    $("#datatable-1").DataTable().draw();
                });

                LoadDataTablesScripts(TestTable1);
            });
        }

        document.addEventListener("DOMContentLoaded", yelp, false);

        function licsServerErrorsModal(error){
            var zIndex = 200000;

            $("div[id^='server_error_warn_']").each(function(){
                var cZIndex = $(this).css('zIndex');
                if (zIndex < cZIndex) {
                    zIndex = cZIndex + 1;
                }
            });

            $('body').prepend("\n\
                    <div id='server_error_warn_"+ zIndex +"' class='box-content ' style='z-index: "+ zIndex +"; position: fixed; top: 0; left: 0; width: 100%;'>\n\
                        <div class='row'>\n\
                            <div class='col-xs-6 col-xs-offset-3'>\n\
                                <h4 class='text-center'>\n\
                                    <img src='{{app.request_context.baseUrl}}/img/warning-icon.png'/>\n\
                                    &nbsp;&nbsp;\n\
                                    <strong>" + error + "</strong>\n\
                                </h4>\n\
                            </div>\n\
                            <div id='warn_close_"+zIndex+"' class='col-xs-3 txt-center pull-right'>\n\
                                <i class='fa fa-times'></i>\n\
                            </div>\n\
                        </div>\n\
                    </div>");

            $("div[id^='server_error_warn_']").on("click", "div[id^='warn_close_'] i", function(){
                $(this).closest("div[id^='server_error_warn_']").remove();
            });
        }

        function rowDataPrepare(item){
            item.lic_count = typeof (lic_count_set[item.lic_count]) != 'undefined'? lic_count_set[item.lic_count]: item.lic_count;
            var status = item.status;
            item.status = status_set[item.status];
            if (item.awaiting) {
                item.status = "<a class='main_ajax txt-success no_context_menu' href='{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/certificate-install' data-id='" + item.id + "'>{{ 'Install'|trans }}</a>";
            } else if ( status == 5 ) {
                item.status += "<br><a class='txt-danger' href='{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/certificate-request?id=" + item.id + "'>{{ 'Сertificate request'|trans }}</a>";
            }
            var dateSet = new Date();
            dateSet.setTime(item.cert_begin * 1000);
            item.cert_begin = dateSet.toLocaleFormat("%d.%m.%Y");
            dateSet.setTime(item.cert_end * 1000);
            item.cert_end = dateSet.toLocaleFormat("%d.%m.%Y");

            if (item.expires_30_days) {
                item.cert_end += "<br><a class='txt-danger' href='{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/certificate-request?id=" + item.id + "'>{{ 'Сertificate request'|trans }}</a>";
            }

            item.id = "<a href='{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/certificate-detail?id=" + item.id + "'>" + item.id + "</a>";
            return item;
        }

        function checkLicCountFilter(val){
            return (val == lic_count_set[$('[data-tvfilter="lic_count"]').data('filterval')]) || ($('[data-tvfilter="lic_count"]').data('filterval') == '0');
        }

        function checkStatusFilter(val){
            return (val.search(status_set[$('[data-tvfilter="status"]').data('filterval')]) != -1) || ($('[data-tvfilter="status"]').data('filterval') == 0);
        }
