{% extends app['twig_theme'] ~ '/' ~ 'layout.twig' %}
{% import  app['twig_theme'] ~ '/macro/iptw_macro.twig' as main_macro %}

{% set title = 'Users'|trans ~ ': ' ~ (app.userEdit ? ('Edit user'|trans ~ " '"~ app.userName ~ "'"): 'Add user'|trans) %}
{% set active_alias = 'users-list' %}


{% block footer_js %}

        {{ parent() }}

        <script src="{{app.request_context.baseUrl}}/plugins/multiselect_transfer/jquery.selso.js"></script>

        {% include app.twig_theme ~ "/basic_templates/scripts-datatables.twig" %}
        {% include app.twig_theme ~ "/basic_templates/scripts-select2.twig" %}

{% endblock %}
{% block footer %}

        {{ parent() }}
        <script type="text/javascript" src="./js/jquery.tmpl.min.js" defer=""></script>
        <script type="text/javascript" defer>
            {% include (app.twig_theme ~ "/Users/add_users/add_users.js.twig") %}
        </script>

{% endblock %}


{% block content %}
    {% if app.resellerUserLimit %}
        <div id="add_channel">
            {{ form_start(app['form'], {'method': 'POST', 'action': (app.request_context.baseUrl ~ '/' ~ app.controller_alias  ~ '/' ~ app.action_alias) | trans, 'attr': {'class': 'form-horizontal', 'role': 'form', 'id': 'form_'}}) }}
            <div class="bg-danger">
                <div class="bg-danger">
                    {{ form_errors(app['form']) }}
                </div>
            </div>
            <div class="row">
                <div class="box">

                    <h4 class="section-header"><span>{{ 'Profile'|trans }}</span></h4>

                    <div class="box-content">
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Name'|trans }}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-6">
                                    {{ form_widget(app['form'].id, {'attr': {'class': 'form-control'}}) }}
                                    {{ form_widget(app['form'].fname, {'attr': {'class': 'form-control'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].fname) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Login'|trans }}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-6">
                                    {{ form_widget(app['form'].login, {'attr': {'class': 'form-control',
                                        'data-validation': 'server',
                                        'data-validation-postpone': '200',
                                        'data-validation-optional' : 'true',
                                        'data-validation-url': app.request_context.baseUrl ~ '/'~ app.controller_alias ~'/check-login',
                                        'data-validation-param-name': 'login'
                                    }}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].login) }}
                                    </div>
                                </div>
                                <i class="i-hint"
                                    title="{{ 'Must be unique'|trans }}" >
                                    <img class="i-hint-sign" src="{{app.request_context.baseUrl}}/img/field-hint-sign.svg" />
                                </i>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Password'|trans }}{#<span class="icon-required">*</span>#}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-6">
                                    {{ form_widget(app['form'].password, {'attr': {'class': 'form-control'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].password) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Phone number'|trans }}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-6">
                                    {{ form_widget(app['form'].phone, {'attr': {'class': 'form-control'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].phone) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Account number'|trans }}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-6">
                                    {{ form_widget(app['form'].ls, {'attr': {'class': 'form-control'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].ls) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                        {% if app['userEdit'] %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'User group'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].group_id, {'attr': {'class': 'populate placeholder'}}) }}
                                        <div class="bg-danger">
                                            {{ form_errors(app['form'].group_id) }}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {% else %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">MAC</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].mac, {'attr': {'class': 'form-control',
                                            'data-validation': 'custom, server',
                                            'data-validation-postpone': '200',
                                            'data-validation-optional': 'true',
                                            'data-validation-regexp': '^([0-9A-Fa-f]{2}\:){5}([0-9A-Fa-f]{2})$',
                                            'data-validation-error-msg-custom': 'Enter MAC-address according to the format'|trans,
                                            'data-validation-url': app.request_context.baseUrl ~ '/'~ app.controller_alias ~'/check-console-item',
                                            'data-validation-param-name': 'mac'
                                        }}) }}
                                        {#<div class="ajax-check"></div>#}
                                        <div class="bg-danger">
                                            {{ form_errors(app['form'].mac) }}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {% if app['tariffPlanFlag'] and attribute(app, 'tariff_and_service_control') is defined and app['tariff_and_service_control'] > 0 %}
                                <div class="form-group">
                                    <label class="col-sm-2 control-label ">{{ 'Tariff plan'|trans }}</label>
                                    <div class="col-xs-10 col-sm-6">
                                        <div class=" col-xs-10 col-sm-4">
                                            {% if app['tariff_and_service_control'] > 1 %}
                                                {{ form_widget(app['form'].tariff_plan_id, {'attr': {'class': 'populate placeholder'}}) }}
                                                <div class="bg-danger">
                                                    {{ form_errors(app['form'].tariff_plan_id) }}
                                                </div>
                                            {% else %}
                                                <label class="control-label ">{% if app['form'].tariff_plan_id.vars.value and attribute(app, 'allTariffPlans') is defined and app['allTariffPlans'][app['form'].tariff_plan_id.vars.value] %}{{ app['allTariffPlans'][app['form'].tariff_plan_id.vars.value] }}{% else %}{{ 'None'|trans }}{% endif %}</label>
                                            {% endif %}
                                        </div>
                                    </div>
                                </div>
                            {% endif %}
                        {% endif %}

                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Status'|trans }}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-4">
                                    {{ form_widget(app['form'].status, {'attr': {'class': 'populate placeholder'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].status) }}
                                    </div>
                                </div>
                            </div>
                        </div>

                        {% if attribute(app, 'enableBilling') is defined and app.enableBilling and attribute(app, 'billing_date_control') is defined and app['billing_date_control'] > 0 %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Expire billing date'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {% if app['billing_date_control'] == 1 %}
                                            <label class="control-label ">{% if app['form'].expire_billing_date.vars.value %}{{ app['form'].expire_billing_date.vars.value }}{% else %}{{ 'Unlimited'|trans }}{% endif %}</label>
                                        {% else %}
                                            {{ form_widget(app['form'].expire_billing_date, {'attr': {'class': 'form-control'}}) }}
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                        {% endif %}

                        {% if not app['tariffPlanFlag'] %}
                            <div class="form-group form-group-checkbox">
                                <label class="col-sm-2 control-label">{{ 'Automatic License Key assignment'|trans }}</label>
                                <div class="col-xs-10 col-sm-8">
                                    <div class=" col-xs-10 col-sm-5">
                                        <div class="mswitch">
                                            {{ form_widget(app['form'].activation_code_auto_issue, {'attr': {}}) }}
                                            {{ form_label(app['form'].activation_code_auto_issue) }}
                                        </div>
                                    </div>
                                    <div>
                                        <div class="bg-danger">
                                            {{ form_errors(app['form'].activation_code_auto_issue) }}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {% endif %}

                        {% if attribute(app, 'reseller') is defined and not app['reseller'] and attribute(app, 'user_reseller_control') is defined and app['user_reseller_control'] > 0 %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Reseller'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-4">
                                        {% if app['user_reseller_control'] == 1 %}
                                            <label class="control-label ">{% if app['form'].reseller_id.vars.value and attribute(app, 'allResellers') is defined and app['allResellers'][app['form'].reseller_id.vars.value] %}{{ app['allResellers'][app['form'].reseller_id.vars.value] }}{% else %}{{ 'Empty'|trans }}{% endif %}</label>
                                        {% else %}
                                            {{ form_widget(app['form'].reseller_id, {'attr': {'class': 'populate placeholder'}}) }}
                                            <div class="bg-danger">
                                                {{ form_errors(app['form'].reseller_id) }}
                                            </div>
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                        {% endif %}
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ "User's theme"|trans }}</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-4">
                                    {{ form_widget(app['form'].theme, {'attr': {'class': 'populate placeholder'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].theme) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                        {% if app.userEdit %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'State'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                <span class="form-control-static col-xs-12 col-sm-12">
                                    {% if attribute(app, 'state') is defined and app.state %}
                                        <span class="txt-success">Online</span>
                                    {% else %}
                                        <span class="txt-danger">Offline</span>
                                    {% endif %}
                                </span>
                                </div>
                            </div>
                        {% endif %}
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">{{ 'Comments'|trans }}:</label>
                            <div class="col-xs-10 col-sm-6">
                                <div class=" col-xs-10 col-sm-8">
                                    {{ form_widget(app['form'].comment, {'attr': {'class': 'form-control'}}) }}
                                    <div class="bg-danger">
                                        {{ form_errors(app['form'].comment) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                        {% if not app['tariffPlanFlag'] and attribute(app, 'tariff_and_service_control') is defined and app['tariff_and_service_control'] > 0 %}
                            <p class="page-header"></p>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Additional services'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-4">
                                        {% if app['tariff_and_service_control'] > 1 %}
                                            {{ form_widget(app['form'].additional_services_on, {'attr': {'class': 'populate placeholder'}}) }}
                                            <div class="bg-danger">
                                                {{ form_errors(app['form'].additional_services_on) }}
                                            </div>
                                        {% else %}
                                            <label class="control-label ">{% if app['form'].additional_services_on.vars.value and attribute(app, 'additionalServices') is defined and app['additionalServices'][app['form'].additional_services_on.vars.value] %}{{ app['additionalServices'][app['form'].additional_services_on.vars.value] }}{% else %}{{ 'None'|trans }}{% endif %}</label>
                                        {% endif %}
                                    </div>
                                {% if app.userEdit %}
                                    <a class="btn btn-default" id="tv_subscription"  href="{{app.request_context.baseUrl}}/{{app.controller_alias}}/get-subscribed-tv" data-user_id="{{ app['form'].id.vars.value }}">{{ 'User subscription on tv-channels'|trans }}{# ({{ app.channelsCost }})#}</a>
                                {% endif %}
                                </div>
                            </div>
                        {% endif %}
                    </div>
                </div>

                {% if app.userEdit %}
                    <div class="box">
                        <a class="collapse-link">
                            <div class="box-header">
                                <div class="box-name">
                                    <div class="row">
                                        <div class="col-xs-10 col-sm-3">
                                            <span>{{ 'Device info'|trans }}</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="box-icons">
                                    <i class="fa fa-chevron-up"></i>
                                </div>
                                <div class="no-move"></div>
                            </div>
                        </a>
                        <div class="box-content" id="Additional">
                            {% if app['userEdit'] %}
                                <div class="form-group">
                                    <label class="col-sm-2 control-label ">MAC/ID</label>
                                    <div class="col-xs-10 col-sm-6">
                                        <div class=" col-xs-10 col-sm-6">
                                            {{ form_widget(app['form'].mac, {'attr': {'class': 'form-control'}}) }}
                                        </div>
                                    </div>
                                </div>
                            {% endif %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">IP</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].ip, {'attr': {'class': 'form-control'}}) }}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Account balance'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].account_balance, {'attr': {'class': 'form-control'}}) }}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Video out'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].video_out, {'attr': {'class': 'form-control', 'style' : 'text-transform: uppercase'}}) }}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Parental control'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].parent_password, {'attr': {'class': 'form-control'}}) }}
                                    </div>
                                    <div class=" col-xs-10 col-sm-6">
                                        <a href="{{app.request_context.baseUrl}}/{{app.controller_alias}}/reset-users-parent-password" data-userid = "{{ app.userID }}" class="btn btn-default pull-left main_ajax">{{ 'Reset'|trans }}</a>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Access control'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].settings_password, {'attr': {'class': 'form-control'}}) }}
                                    </div>
                                    <div class=" col-xs-10 col-sm-6">
                                        <a href="{{app.request_context.baseUrl}}/{{app.controller_alias}}/reset-users-settings-password" data-userid = "{{ app.userID }}" class="btn btn-default pull-left main_ajax">{{ 'Reset'|trans }}</a>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Favorite'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].fav_itv, {'attr': {'class': 'form-control'}}) }}
                                    </div>
                                    <div class=" col-xs-10 col-sm-6">
                                        <a href="{{app.request_context.baseUrl}}/{{app.controller_alias}}/reset-user-fav-tv" class="btn btn-default pull-left main_ajax" data-userid = "{{ app.userID }}">{{ 'Reset'|trans }}</a>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Version'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-6">
                                        {{ form_widget(app['form'].version, {'attr': {'class': 'form-control', 'rows': '6'}}) }}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endif%}

                {% if app['userEdit'] and attribute(app['form'], 'tariff_plan_id') is defined  and attribute(app, 'tariff_and_service_control') is defined and app['tariff_and_service_control'] > 0 %}
                    <div class="box">
                        <a class="collapse-link">
                            <div class="box-header">
                                <div class="box-name">
                                    <div class="row">
                                        <div class="col-xs-10 col-sm-3">
                                            <span>{{ 'Tariff plan'|trans }}</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="box-icons">
                                    <i class="fa fa-chevron-up"></i>
                                </div>
                                <div class="no-move"></div>
                            </div>
                        </a>
                        <div class="box-content" id="Additional2">
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Tariff plan'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-4">
                                        {{ form_widget(app['form']['tariff_plan_id'], {'attr': {'class': 'populate placeholder', 'disabled': app['tariff_and_service_control'] == 1, 'readonly': app['tariff_and_service_control'] == 1 }}) }}
                                        <div class="bg-danger">
                                            {{ form_errors(app['form']['tariff_plan_id'], {'attr': {}} ) }}
                                        </div>
                                    </div>
                                    <a class="btn btn-default pull-right" href="{{app.request_context.baseUrl}}/tariffs/subscribe-log?user_id={{ app['form'].id.vars.value }}">{{ 'Subscribe log'|trans }}</a>
                                    {% if app['tariffPlanSubscriptionFlag'] %}
                                        <span class="col-sm-1  pull-right">&nbsp;</span>
                                        <a class="btn btn-default pull-right" id="tv_subscription"  href="{{app.request_context.baseUrl}}/{{app.controller_alias}}/get-subscribed-tv" data-user_id="{{ app['form'].id.vars.value }}">{{ 'User subscription on tv-channels'|trans }}{# ({{ app.channelsCost }})#}</a>
                                    {% endif %}
                                </div>
                            </div>
                            {% if attribute(app, 'userTPs') is defined and app['userTPs']|length > 0 %}
                                <div class="form-group">
                                    <label class="col-sm-2 control-label ">{{ 'Packages of services'|trans }}</label>
                                    <div class="col-xs-10 col-sm-6">
                                        <div class=" col-xs-12 col-sm-12">
                                            <table class="table  table-hover" id="tariff_plan_table" data-planid="{{ app['form']['tariff_plan_id'].vars.value }}">
                                                <thead>
                                                <tr>
                                                    <th>{{ 'Package title'|trans }}</th>
                                                    <th>{{ 'Package type'|trans }}</th>
                                                    <th>{{ 'State'|trans }}</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <!-- Start: list_row -->
                                                {% for item in app['userTPs'] %}
                                                    <tr>
                                                        <td>
                                                            <label><a href="{{ app.request_context.baseUrl }}/tariffs/edit-service-package?id={{ item.services_package_id }}" data-placement="bottom" data-toggle="tooltip" data-original-title="{{ item.description }}">{{ item.name }}</a></label>
                                                        </td>
                                                        <td>
                                                            <label>
                                                                {% if item.optional == 1 %}
                                                                    <i>{{ 'Optional'|trans }}</i>
                                                                {% else %}
                                                                    {{ '-' }}
                                                                {% endif %}
                                                            </label>
                                                        </td>
                                                        <td>
                                                            <div class="col-sm-12">
                                                                <div class="mswitch">
                                                                    <input id="tariff_plan_packages[{{ item.package_id }}]"  type="checkbox" {% if item.optional == 0 or app['tariff_and_service_control'] == 1 %}readonly="readonly" disabled="disabled"{% endif %}  {% if item.subscribed == 1 %}value="on" checked="checked"{% else %}value="off"{% endif %} name="tariff_plan_packages[{{ item.package_id }}]"/>
                                                                    <label for="tariff_plan_packages[{{ item.package_id }}]" class="label-success"></label>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                {% endfor %}
                                                <!-- End: list_row -->
                                                </tbody>
                                            </table>
                                            <label id="tariff_plan_change" style="display: none;">{{ 'More detailed information about the connected packs will be available in the next editing session'|trans }}.</label>
                                        </div>
                                    </div>
                                </div>
                            {% endif %}
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'Valid until'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-4">
                                        {{ form_widget(app['form'].tariff_expired_date, {'attr': {'class': 'form-control datepicker', 'readonly': 'readonly', 'data-date-format': 'dd-mm-yy', 'data-oldvalue': app['form']['tariff_expired_date'].vars.value}}) }}
                                        <div class="bg-danger">
                                            {{ form_errors(app['form'].tariff_expired_date) }}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label ">{{ 'At the expiration of'|trans }}</label>
                                <div class="col-xs-10 col-sm-6">
                                    <div class=" col-xs-10 col-sm-4">
                                        {{ form_widget(app['form']['tariff_id_instead_expired'], {'attr': {'class': 'populate placeholder', 'disabled': app['tariff_and_service_control'] == 1, 'readonly': app['tariff_and_service_control'] == 1 }}) }}
                                        <div class="bg-danger">
                                            {{ form_errors(app['form']['tariff_id_instead_expired'], {'attr': {}} ) }}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endif %}

                {% autoescape false %}
                <script type="text/template" id="service_package_row">
                    <tr>
                        <td>
                            <label><a href="{{ app.request_context.baseUrl }}/tariffs/edit-service-package?id=${services_package_id}" data-placement="bottom" data-toggle="tooltip" data-original-title="${description}">${name}</a></label>
                        </td>
                        <td>
                            <label>
                                {{ '{{if optional==1 }}' }}
                                    <i>{{ 'Optional'|trans }}</i>
                                {{ '{{else}}' }}
                                    {{ '-' }}
                                {{ '{{/if}}' }}
                            </label>
                        </td>
                        <td>
                            <div class="col-sm-12">
                                <div class="mswitch">
                                    <input type="checkbox" id="tariff_plan_packages[${package_id}]" name="tariff_plan_packages[${package_id}]"
                                        {{ '{{if optional==0 || tariff_and_service_control==1}}' }}
                                            readonly="readonly" disabled="disabled"
                                        {{ '{{/if}}' }}
                                        {{ '{{if subscribed==1 }}' }}
                                            value="on" checked="checked"
                                        {{ '{{else}}' }}
                                            value="off"
                                        {{ '{{/if}}' }} />
                                    <label for="tariff_plan_packages[${package_id}]" class="label-success"></label>
                                </div>
                            </div>
                        </td>
                    </tr>
                </script>
                {% endautoescape %}

                {% if attribute(app, 'tracertStats') is defined %}
                    <div class="box">
                        <a class="collapse-link">
                            <div class="box-header">
                                <div class="box-name">
                                    <div class="row">
                                        <div class="col-xs-10 col-sm-6">
                                            <span>{{ 'Results of extended diagnostics'|trans }}. {{ 'Last update'|trans }}: {{ app['tracertStats']['changed']|date("H:i:s d-m-Y") }}</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="box-icons">
                                    <i class="fa fa-chevron-up"></i>
                                </div>
                                <div class="no-move"></div>
                            </div>
                        </a>
                        <div class="box-content" id="Additional3">
                            {% set tNum = 0 %}
                            {% for key, item in  app['tracertStats']['info'] %}
                                <div class="col-xs-12 col-sm-6">
                                    <div class="box">
                                        <a class="collapse-link">
                                            <div class="box-header">
                                                <div class="box-name">
                                                    <span>{{ 'Domain'|trans }}: {{ key }}</span>
                                                </div>
                                                <div class="circle-button box-icons">
                                                    <i class="fa fa-chevron-up"></i>
                                                </div>
                                                <div class="no-move"></div>
                                            </div>
                                        </a>
                                        <div class="box-content">
                                            <table class="table table-hover table-datatable" id="datatable-{{ tNum }}">
                                                {% if attribute(app, 'tracert_attr') is defined %}
                                                    {{ main_macro.get_datatable_head(app['tracert_attr']) }}
                                                {% endif %}
                                                <tbody>
                                                {%  autoescape false %}
                                                {% for val in item %}
                                                    <tr>
                                                        {% for a_item in app['tracert_attr'] %}
                                                            {% if not (a_item.name == 'all') %}
                                                        <td>{{ val[a_item.name] }}</td>
                                                            {% endif %}
                                                        {% endfor %}
                                                    </tr>
                                                {% endfor %}
                                                {% endautoescape %}
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                {% set tNum = tNum + 1 %}
                            {% endfor %}

                        </div>
                    </div>
                {% endif %}

                <div class="form-buttons col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="box">
                        <div class="box-content">
                            <div class="row">
                                <div class="pull-right">
                                    {{ form_widget(app['form'].save, { 'label': 'Save'|trans , attr: {'class': 'btn btn-success  pull-right'}}) }}
                                    <a href="{{app.request_context.baseUrl}}/{{app.controller_alias}}/users-list" class="btn btn-default pull-right">{{ 'Cancel'|trans }}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div style="display: none;">
                {{ form_rest(app.form) }}
            </div>
            {{ form_end(app['form']) }}
        </div>

        {% if app.userEdit and (not app['tariffPlanFlag'] or app['tariffPlanSubscriptionFlag']) %}
        <div id="modalbox_ad">
            <div class="devoops-modal">
                <div class="devoops-modal-header">
                    <div class="modal-header-name">
                        <span>{{ 'User subscription on tv-channels'|trans }}</span>
                    </div>
                    <div class="box-icons">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <form class="form-horizontal" role="form" action="{{app.request_context.baseUrl}}/{{app.controller_alias}}/save-subscribed-tv">
                    <div class="devoops-modal-inner">
                        <div class="box">
                            <div class="box-content" >
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <fieldset id="letters" class="col-sm-12">
                                            <div class="col-sm-4">
                                                <label class="col-sm-12 text-center">{{ 'Available'|trans }}</label>
                                                <select id="not_subscribed_tv" class="left populate placeholder col-sm-12" multiple="multiple" name="not_subscribed_tv" size="20">
                                                </select>
                                            </div>
                                            <div class="col-sm-3">
                                                <br><br><br><br><br><br><br>
                                                <button type="button" class="add all btn btn-block btn-default"> {{ 'all'|trans }} &gt;&gt; </button>
                                                <button type="button" class="add btn btn-block btn-default"> &gt; </button>
                                                <button type="button" class="remove btn btn-block btn-default"> &lt; </button>
                                                <button type="button" class="remove all btn btn-block btn-default"> &lt;&lt; {{ 'all'|trans }}</button>
                                            </div>
                                            <div class="col-sm-4">
                                                <label class="col-sm-12 text-center">{{ 'Selected'|trans }}</label>
                                                <select id="subscribed_tv" class="right populate placeholder col-sm-12" multiple="multiple" name="subscribed_tv" size="20">
                                                </select>
                                            </div>
                                        </fieldset>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="devoops-modal-bottom">
                        <div class="col-xs-12">
                            <button type="submit" class="btn btn-success col-sm-2 pull-right">{{ 'Save'|trans }}</button>
                            <button type="reset"  class="btn btn-default col-sm-2 pull-right">{{ 'Cancel'|trans }}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        {% endif %}

    {% else %}
    <div id="add_channel">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <h2 class="txt-danger">{{ 'Limit of number of the users has been reached'|trans }}</h2>
            </div>
        </div>
    </div>
    {% endif %}
{% endblock %}