[%
    IF subscriber.provisioning_voip_subscriber.is_pbx_group;
        site_config.title = c.loc('PBX Group Preferences for [_1]@[_2]', subscriber.username, subscriber.domain.domain);
    ELSE;
        site_config.title = c.loc('Subscriber Preferences for [_1]@[_2]', subscriber.username, subscriber.domain.domain);
    END;
-%]

[% 
    helper.name = c.loc('Subscriber');
    helper.messages = messages;
    
    helper.edit_preference = edit_preference;
    helper.preference = preference;
    helper.preference_meta = preference_meta;
    helper.preference_values = preference_values;
    helper.pref_groups = pref_groups;
    helper.form = form;
    helper.base_uri = c.uri_for(subscriber.id,'preferences');
    helper.rewrite_rule_sets = rwr_sets;
    helper.ncos_levels = ncos_levels;
    helper.sound_sets = sound_sets;
    helper.contract_sound_sets = contract_sound_sets;
    helper.aip_grp_rs = aip_grp_rs;
    helper.man_aip_grp_rs = man_aip_grp_rs;
    helper.skip_head = 1;

    PROCESS "helpers/modal.tt";
%]

<div class="row">
    <span>
    <a class="btn btn-primary btn-large" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i> [% c.loc('Back') %]</a>
    </span>
</div>
[% back_created = 1 %]

[% IF helper.messages -%]
<div class="row">
    [% FOREACH m IN helper.messages -%]
        <div class="alert alert-[% m.type %]">[% m.text %]</div>
    [% END -%]
</div>
[% END -%]

<div class="ngcp-separator"></div>

<div class="accordion" id="preference_groups">


    [% IF 
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && special_prefs.check && special_prefs.callforward.active) ||
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && !special_prefs.check) ||
        c.user.roles == "admin" || c.user.roles == "reseller" -%]

    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_cf">[% c.loc('Call Forwards') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_cf">
            <div class="accordion-inner">

                <table class="table table-bordered table-striped table-highlight table-hover" id="preferences_table_cf">
                    <thead>
                        <tr>
                            <th>[% c.loc('Type') %]</th>
                            <th>[% c.loc('Answer Timeout') %]</th>
                            <th>[% c.loc('Destinations') %]</th>
                            <th>[% c.loc('Timeset') %]</th>
                            [% # one for actions -%]
                            <th class="ngcp-actions-column"></th>
                        </tr>
                    </thead>
                    <tbody>
                    [% FOR cf IN [ { type = "cfu", desc = c.loc("Call Forward Unconditional") },
                                   { type = "cfb", desc = c.loc("Call Forward Busy") },
                                   { type = "cft", desc = c.loc("Call Forward Timeout") },
                                   { type = "cfna", desc = c.loc("Call Forward Unavailable") } ] -%]
                        [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" -%]
                          [% NEXT IF special_prefs.check && !special_prefs.callforward.${cf.type} -%]
                        [% END -%]
                        <tr class="sw_action_row">
                            <td>[% cf.desc %]</td>
                            <td>
                                [% cf_ringtimeout _ 's' IF cf.type == "cft" && cf_destinations.${cf.type}.size %]
                            </td>
                            <td>
                                [% idx = 0 -%]
                                [% FOR maps IN cf_destinations.${cf.type} -%]
                                    [% IF maps.dset_name.search('^quickset_') && maps.destinations.size == 1 %]
                                        [% maps.destinations.0.as_string %] <span class="pull-right">for [% maps.destinations.0.timeout %]s</span>
                                    [% ELSE %]
                                        [% jdx = 0 -%]
                                        [% maps.dset_name -%]

                                        [% dset_unique_id = cf.type _ "dset" _ idx _ jdx _ maps.id -%]
                                        <a href="#" data-toggle="modal" data-target="#[% dset_unique_id %]" class="pull-right"><i class="icon-question-sign"></i></a>
                                        [% modal_header_dynamic(m.header = c.loc('Destination Set "[_1]" Details', maps.dset_name), m.id=dset_unique_id) %]
                                        <div class="modal-body">
                                            [% FOR d IN maps.destinations -%]
                                                [% d.as_string %] <span class="pull-right">for [% d.timeout %]s</span><br/>
                                                [% jdx = jdx + 1 -%]
                                            [% END -%]
                                        </div>
                                        [% modal_footer() %]

                                        [% idx = idx + 1 -%]
                                    [% END %]
                                    <br/>
                                [% END -%]
                            </td>
                            <td>
                                [% idx = 0 -%]
                                [% FOR maps IN cf_destinations.${cf.type} -%]
                                    [% jdx = 0 -%]
                                    [% UNLESS maps.tset_name.defined -%]
                                        always
                                        [% jdx = jdx + 1 %]
                                    [% END -%]
                                    [% maps.tset_name -%]
                                    [% IF maps.tset_name.defined -%]
                                        [% tset_unique_id = cf.type _ idx _ jdx _ maps.id -%]
                                        <a href="#" data-toggle="modal" data-target="#[% tset_unique_id %]" class="pull-right"><i class="icon-question-sign"></i></a>
                                        [% modal_header_dynamic(m.header = c.loc('Timeset "[_1]" Details', maps.tset_name), m.id=tset_unique_id) %]
                                        <div class="modal-body">
                                        [% FOR p IN maps.periods -%]
                                            [% p.as_string %]<br/>
                                        [% END -%]
                                        </div>
                                        [% modal_footer() %]
                                    [% END %]
                                    [% idx = idx + 1 -%]
                                    <br/>
                                [% END -%]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% UNLESS (c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/preferences_callforward", [c.req.captures.0], cf.type) %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    [% IF cf_destinations.${cf.type}.size -%]
                                    <a class="btn btn-secondary btn-small" data-confirm="Delete" href="[% c.uri_for_action("/subscriber/preferences_callforward_delete", [c.req.captures.0], cf.type) %]"><i class="icon-trash"></i> [% c.loc('Delete') %]</a>
                                    [% END -%]
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                    [% END -%]
                    </tbody>
                </table>

            </div>
        </div>
    </div>
    [% END -%]

    [% IF 
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && special_prefs.check && special_prefs.voice_mail.active) ||
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && !special_prefs.check) ||
        c.user.roles == "admin" || c.user.roles == "reseller" -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_vm">[% c.loc('Voicemail and Voicebox') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_vm">
            <div class="accordion-inner">

                <table class="table table-bordered table-striped table-highlight table-hover" id="preferences_table_vm">
                    <thead>
                        <tr>
                            <th>[% c.loc('Name') %]</th>
                            <th>[% c.loc('Value') %]</th>
                            [% # one for actions -%]
                            <th class="ngcp-actions-column"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="sw_action_row">
                            <td>[% c.loc('PIN') %]</td>
                            <td>
                                [% subscriber.provisioning_voip_subscriber.voicemail_user.password %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_voicebox", [c.req.captures.0], 'pin') %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Email') %]</td>
                            <td>
                                [% subscriber.provisioning_voip_subscriber.voicemail_user.email %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_voicebox", [c.req.captures.0], 'email') %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Delete after sending Email') %]</td>
                            <td>
                                [% subscriber.provisioning_voip_subscriber.voicemail_user.get_column('delete') %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_voicebox", [c.req.captures.0], 'delete') %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Attach WAV in Email') %]</td>
                            <td>
                                [% subscriber.provisioning_voip_subscriber.voicemail_user.attach %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_voicebox", [c.req.captures.0], 'attach') %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
    [% END -%]

    [% IF c.config.features.faxserver  && (
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && special_prefs.check && special_prefs.fax_server.active) ||
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && !special_prefs.check) ||
        c.user.roles == "admin" || c.user.roles == "reseller"
    ) -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_fax">[% c.loc('Fax2Mail and Sendfax') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_fax">
            <div class="accordion-inner">

                <table class="table table-bordered table-striped table-highlight table-hover" id="preferences_table_fax">
                    <thead>
                        <tr>
                            <th>[% c.loc('Name') %]</th>
                            <th>[% c.loc('Value') %]</th>
                            [% # one for actions -%]
                            <th class="ngcp-actions-column"></th>
                        </tr>
                    </thead>
                    <tbody>
                        [% 
                            faxpref = subscriber.provisioning_voip_subscriber.voip_fax_preference;
                            faxdests = subscriber.provisioning_voip_subscriber.voip_fax_destinations.all; 
                        -%]
                        <tr class="sw_action_row">
                            <td>[% c.loc('Name in Fax Header for Sendfax') %]</td>
                            <td>
                                [% faxpref.name %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_fax", [c.req.captures.0], 'name') %]">
                                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                                    </a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Password for Sendfax') %]</td>
                            <td>
                                [% faxpref.password %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_fax", [c.req.captures.0], 'password') %]">
                                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                                    </a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Active') %]</td>
                            <td>
                                [% faxpref.active ? c.loc('yes') : c.loc('no') %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_fax", [c.req.captures.0], 'active') %]">
                                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                                    </a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Send Reports') %]</td>
                            <td>
                                [% faxpref.send_status ? c.loc('yes') : ('no') %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_fax", [c.req.captures.0], 'send_status') %]">
                                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                                    </a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Send Copies') %]</td>
                            <td>
                                [% faxpref.send_copy ? c.loc('yes') : c.loc('no') %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_fax", [c.req.captures.0], 'send_copy') %]">
                                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                                    </a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        <tr class="sw_action_row">
                            <td>[% c.loc('Destinations') %]</td>
                            <td>
                                [% FOR faxdest IN faxdests -%]
                                    [% c.loc('[_1] as [_2]', faxdest.destination, faxdest.filetype) %]<br/>
                                [% END -%]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_fax", [c.req.captures.0], 'destinations') %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
    [% END -%]

    [% IF c.config.features.cloudpbx && billing_mapping.product.class == 'pbxaccount' && (
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && special_prefs.check && special_prefs.auto_attendant.active) ||
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && !special_prefs.check) ||
        c.user.roles == "admin" || c.user.roles == "reseller" 
    ) -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_aa">[% c.loc('Auto Attendant Slots') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_aa">
            <div class="accordion-inner">

                [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                <a class="btn btn-tertiary btn-large" href="[% c.uri_for_action('/subscriber/edit_autoattendant', [c.req.captures.0]) %]">
                    <i class="icon-star"></i> [% c.loc('Edit Slots') %]
                </a>
                [% END -%]
[%
    helper.messages = '';
    helper.name = c.loc('Autoattendant');
    helper.identifier = 'autoattendant';
    helper.column_sort = 'choice';
    helper.dt_columns = aa_dt_columns;
    helper.length_change = 1;
    helper.ajax_uri = c.uri_for_action('/subscriber/ajax_autoattendant', [c.req.captures.0]);

    helper.dt_buttons = [
        { name = c.loc('Delete'), uri = "preferences/autoattendant/'+full.id+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
    ];

    PROCESS 'helpers/datatables.tt';
%]
            </div>
        </div>
    </div>
    [% END -%]

    [% IF 
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && special_prefs.check && special_prefs.speed_dial.active) ||
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && !special_prefs.check) ||
        c.user.roles == "admin" || c.user.roles == "reseller" -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_speed">[% c.loc('Speed Dial') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_speed">
            <div class="accordion-inner">

                [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                <a class="btn btn-tertiary btn-large" href="[% c.uri_for_action('/subscriber/create_speeddial', [c.req.captures.0]) %]"><i class="icon-star"></i> [% c.loc('Create Slot') %]</a>
                [% END -%]
[%
    helper.messages = '';
    helper.name = c.loc('Speeddial');
    helper.identifier = 'subs_speeddial';
    helper.column_sort = 'slot';
    helper.dt_columns = sd_dt_columns;
    helper.ajax_uri = c.uri_for_action('/subscriber/ajax_speeddial', [c.req.captures.0]);

    helper.dt_buttons = [
        { name = c.loc('Edit'), uri = "preferences/speeddial/'+full.id+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
        { name = c.loc('Delete'), uri = "preferences/speeddial/'+full.id+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
    ];

    PROCESS 'helpers/datatables.tt';
%]
            </div>
        </div>
    </div>
    [% END -%]

    [% IF 
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && special_prefs.check && special_prefs.reminder.active) ||
        ((c.user.roles == "subscriber" || c.user.roles == "subscriberadmin") && !special_prefs.check) ||
        c.user.roles == "admin" || c.user.roles == "reseller" -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_rm">[% c.loc('Reminder') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_rm">
            <div class="accordion-inner">

                <table class="table table-bordered table-striped table-highlight table-hover" id="preferences_table_rm">
                    <thead>
                        <tr>
                            <th>[% c.loc('Time') %]</th>
                            <th>[% c.loc('Recurrence') %]</th>
                            [% # one for actions -%]
                            <th class="ngcp-actions-column"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="sw_action_row">
                            <td>
                                [% subscriber.provisioning_voip_subscriber.voip_reminder.get_column('time') %]
                            </td>
                            <td>
                                [% subscriber.provisioning_voip_subscriber.voip_reminder.recur %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_reminder", [c.req.captures.0]) %]">
                                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                                    </a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
    [% END -%]

    [% IF c.config.features.callingcard && (
        c.user.roles == "admin" || c.user.roles == "reseller" 
    ) -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_ccmap">[% c.loc('Callthrough CLIs') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_ccmap">
            <div class="accordion-inner">

                [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" || ((c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1) -%]
                <a class="btn btn-tertiary btn-large" href="[% c.uri_for_action('/subscriber/edit_ccmapping', [c.req.captures.0]) %]">
                    <i class="icon-star"></i> [% c.loc('Edit Callthrough CLIs') %]
                </a>
                [% END -%]
[%
    helper.messages = '';
    helper.name = c.loc('foobar');
    helper.identifier = 'ccmapentries';
    helper.column_sort = undef;
    helper.dt_columns = ccmap_dt_columns;
    helper.length_change = 1;
    helper.ajax_uri = c.uri_for_action('/subscriber/ajax_ccmappings', [c.req.captures.0]);

    helper.dt_buttons = [
        { name = c.loc('Delete'), uri = "/subscriber/"_ c.req.captures.0 _"/preferences/ccmappings/'+full.id+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
    ];

    PROCESS 'helpers/datatables.tt';
%]
            </div>
        </div>
    </div>
    [% END -%]


[% UNLESS c.user.roles == 'subscriber' || c.user.roles == 'subscriberadmin' -%]
    <div class="accordion-group">
        <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_ts">[% c.loc('Trusted Sources') %]</a>
        </div>
        <div class="accordion-body collapse" id="collapse_ts">
            <div class="accordion-inner">

                [% IF (c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1 -%]
                <a class="btn btn-tertiary btn-large" href="[% c.uri_for_action("/subscriber/create_trusted", [c.req.captures.0]) %]">
                    <i class="icon-star"></i> [% c.loc('Create') %]
                </a>
                [% END -%]
                <div class="ngcp-separator"></div>

                <table class="table table-bordered table-striped table-highlight table-hover" id="preferences_table_ts">
                    <thead>
                        <tr>
                            <th>[% c.loc('Source IP') %]</th>
                            <th>[% c.loc('Protocol') %]</th>
                            <th>[% c.loc('From-Pattern') %]</th>
                            [% # one for actions -%]
                            <th class="ngcp-actions-column"></th>
                        </tr>
                    </thead>
                    <tbody>
                        [% FOR trusted IN subscriber.provisioning_voip_subscriber.voip_trusted_sources.all -%]
                        <tr class="sw_action_row">
                            <td>
                                [% trusted.src_ip %]
                            </td>
                            <td>
                                [% trusted.protocol %]
                            </td>
                            <td>
                                [% trusted.from_pattern %]
                            </td>
                            <td class="ngcp-actions-column">
                                <div class="sw_actions">
                                    [% IF (c.user.roles == "admin" || c.user.roles == "reseller") && c.user.read_only != 1 -%]
                                    <a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/edit_trusted", [c.req.captures.0, trusted.id]) %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                                    <a class="btn btn-secondary btn-small" href="[% c.uri_for_action("/subscriber/delete_trusted", [c.req.captures.0, trusted.id]) %]" data-confirm="Delete"><i class="icon-trash"></i> [% c.loc('Delete') %]</a>
                                    [% END -%]
                                </div>

                            </td>
                        </tr>
                        [% END %]
                    </tbody>
                </table>

            </div>
        </div>
    </div>
[% END -%]



[% 
    PROCESS 'helpers/pref_table.tt';
%]

[% IF edit_cf_flag -%]
[%
    PROCESS "helpers/modal.tt";
    modal_header(m.name = cf_description);
-%]

[% IF cf_form.has_for_js -%]
[% cf_form.render_repeatable_js %]
[% END -%]
[% translate_form(cf_form).render %]

[%
    modal_footer();
    modal_script(m.close_target = close_target ? close_target : c.uri_for_action('/subscriber/preferences', [c.req.captures.0]));
-%]
[% ELSIF edit_cfset_flag -%]
[%
    PROCESS "helpers/modal.tt";
    modal_header(m.name = cf_description);
-%]

    <div class="modal-body">
    <div class="row" style="margin-left: 10px">
        <a class="btn btn-primary btn-medium" href="[% c.uri_for_action('/subscriber/preferences_callforward_destinationset_create', [c.req.captures.0], cf_type) %]"><i class="icon-star"></i>[% c.loc('Create New') %]</a>
    </div>
    <div class="ngcp-separator"></div>
    [% IF cf_sets.size -%]
    <table class="table table-bordered table-striped table-highlight table-hover">
        <thead>
            <tr>
                <th>[% c.loc('Name') %]</th>
                <th>[% c.loc('Values') %]</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
        [% FOREACH set IN cf_sets -%]
            <tr class="sw_action_row">
                <td>[% set.name %]</td>
                <td>
                    [% FOREACH d IN set.destinations -%]
                        [% c.loc('[_1]<span class="pull-right">for [_2]s</span>', d.as_string, d.timeout) %]<br/>
                    [% END -%]
                </td>
                <td class="ngcp-actions-column">
                    <div class="sw_actions pull-right">
                        <a class="btn btn-small btn-primary" href="[% c.uri_for_action('/subscriber/preferences_callforward_destinationset_edit', [ c.req.captures.0, set.id ], cf_type) %]">
                            <i class="icon-edit"></i> [% c.loc('Edit') %]
                        </a>
                        <a class="btn btn-small btn-secondary" data-confirm="Delete" href="[% c.uri_for_action('/subscriber/preferences_callforward_destinationset_delete', [ c.req.captures.0, set.id ], cf_type) %]">
                            <i class="icon-trash"></i> [% c.loc('Delete') %]
                        </a>
                    </div>
                </td>
            </tr>
        [% END -%]
        </tbody>
    </table>
    [% END -%]
    </div>

[%
    modal_footer();
    modal_script(m.close_target = close_target ? close_target : c.uri_for_action('/subscriber/preferences', [c.req.captures.0]));
-%]
[% ELSIF edit_timeset_flag -%]
[%
    PROCESS "helpers/modal.tt";
    modal_header(m.name = cf_description);
-%]

    <div class="modal-body">
    <div class="row" style="margin-left: 10px">
        <a class="btn btn-primary btn-medium" href="[% c.uri_for_action('/subscriber/preferences_callforward_timeset_create', [c.req.captures.0], cf_type) %]"><i class="icon-star"></i>[% c.loc('Create New') %]</a>
    </div>
    <div class="ngcp-separator"></div>
    [% IF cf_sets.size -%]
    <table class="table table-bordered table-striped table-highlight table-hover">
        <thead>
            <tr>
                <th>[% c.loc('Name') %]</th>
                <th>[% c.loc('Values') %]</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
        [% FOREACH set IN cf_sets -%]
            <tr class="sw_action_row">
                <td>[% set.name %]</td>
                <td>
                    [% FOREACH p IN set.periods -%]
                        [% p.as_string %]<br/>
                    [% END -%]
                </td>
                <td class="ngcp-actions-column">
                    <div class="sw_actions pull-right">
                        <a class="btn btn-small btn-primary" href="[% c.uri_for_action('/subscriber/preferences_callforward_timeset_edit', [ c.req.captures.0, set.id ], cf_type) %]">
                            <i class="icon-edit"></i> [% c.loc('Edit') %]
                        </a>
                        <a class="btn btn-small btn-secondary" data-confirm="Delete" href="[% c.uri_for_action('/subscriber/preferences_callforward_timeset_delete', [ c.req.captures.0, set.id ], cf_type) %]">
                            <i class="icon-trash"></i> [% c.loc('Delete') %]
                        </a>
                    </div>
                </td>
            </tr>
        [% END -%]
        </tbody>
    </table>
    [% END -%]
    </div>

[%
    modal_footer();
    modal_script(m.close_target = close_target ? close_target : c.uri_for_action('/subscriber/preferences', [c.req.captures.0]));
-%]
[% ELSIF edit_ccmap_flag -%]
[%
    PROCESS "helpers/modal.tt";
    modal_header(m.name = 'Callthrough CLIs');
-%]

    [% IF ccmap_form.has_for_js -%]
    [% ccmap_form.render_repeatable_js %]
    [% END -%]
    [% translate_form(ccmap_form).render %]

[%
    modal_footer();
    modal_script(m.close_target = close_target ? close_target : c.uri_for_action('/subscriber/preferences', [c.req.captures.0]));
-%]
[% END -%]

[% # vim: set tabstop=4 syntax=html expandtab: -%]

