[% site_config.title = c.loc('Call List for [_1]@[_2] ([_3] [_4] [_5])', subscriber.username, subscriber.domain.domain, subscriber.primary_number.cc, subscriber.primary_number.ac, subscriber.primary_number.sn) -%]

<div class="row">
    <span class="pull-left" style="margin:0 5px 0 5px;">
        <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 -%]
<script type="text/javascript" src="/js/background.js"></script>
<script>
function showCallDetails(callId){
    var divId = 'call_details';
    var uri = '[%c.uri_for_action('/subscriber/ajax_call_details', [c.req.captures.0, 'call_id'])%]';
    uri=uri.replace('call_id', callId);
    fetch_into(
        'call_details_container',
        uri,
        '',
        function(){
            $('#'+divId).draggable({
                handle: '.modal-header',
                cursor: 'crosshair',
            }).css('display','block').find($('.mod_close')).click(function(event) {
                $('#'+divId).css('display','none');
            });
        },
        'GET'
    );
}
</script>
<div class="ngcp-separator"></div>


<select onChange="changeCalllist(this);" id="Calls_table_external_filter">
<option value="[% c.uri_for_action('/subscriber/ajax_calls', [c.req.captures.0], undef, {callid => callid}) -%]">[% c.loc('Show all calls') %]</option>
<option value="[% c.uri_for_action('/subscriber/ajax_calls_out', [c.req.captures.0], undef, {callid => callid}) -%]">[% c.loc('Show outgoing calls only') %]</option>
<option value="[% c.uri_for_action('/subscriber/ajax_calls_in', [c.req.captures.0], undef, {callid => callid}) -%]">[% c.loc('Show incoming calls only') %]</option>
</select>
<script>
function changeCalllist(selection) {
    $('#Calls_table').dataTable().fnSettings().sAjaxSource = selection.value;
    $('#Calls_table').dataTable().api().ajax.reload();
    //$('#Calls_table').dataTable().api().ajax.url(selection.value).load();
}
</script>

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

[%PROCESS 'subscriber/call_details_wrapper.tt' %]
[%
    helper.name = 'Calls';
    helper.dt_columns = calls_dt_columns;
    helper.length_change = 1;
    helper.column_sort = 'start_time';
    helper.form_object = form;
    helper.ajax_uri = c.uri_for_action('/subscriber/ajax_calls', [c.req.captures.0], undef, {callid => callid_enc});
    helper.show_footer = 1;

    IF (c.user.roles == "admin" || c.user.roles == "reseller");
        IF c.config.features.callflow;
    helper.dt_buttons = [
        { name = c.loc('Call Flow'), uri = "/callflow/'+encodeURIComponent(full.call_id_url)+'/callmap", class = 'btn-small btn-primary', icon = 'icon-random' },
    ];
        END;
    details_button = { name = c.loc('Call Details'), uri = "javascript:showCallDetails(\\''+encodeURIComponent(full.id)+'\\');void(0);" , class = 'btn-small btn-primary', icon = 'icon-edit' };
    helper.dt_buttons.push( details_button );
    END;

    PROCESS 'helpers/datatables.tt';
%]

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