1 <% include('/elements/header.html', 'Call Detail Record Search' ) %>
3 <SCRIPT type="text/javascript">
4 function clearfield(which){
5 var f = document.getElementById(which);
6 if ( f == null) return;
11 <FORM ACTION="cdr.html" METHOD="GET">
13 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
16 <TH CLASS="background" COLSPAN=2 ALIGN="left">
17 <FONT SIZE="+1">Search options</FONT>
22 <TD ALIGN="right">Status: </TD>
24 <SELECT NAME="freesidestatus">
25 <OPTION VALUE="">(all)
26 <OPTION VALUE="NULL">unprocessed
27 <OPTION VALUE="done">processed
32 % #if ( ) { # disable for everyone not using termination billing...
33 % foreach my $termpart ( 1..1 ) { #qsearch('part_termination
36 <TD ALIGN="right">Termination Status: </TD>
38 <SELECT NAME="termpart<%$termpart%>status">
39 <OPTION VALUE="">(all)
40 <OPTION VALUE="NULL">unprocessed
41 <OPTION VALUE="done">processed
49 <% include ( '/elements/tr-input-beginning_ending.html' ) %>
52 <TD ALIGN="right">Source #: </TD>
54 <INPUT TYPE="text" NAME="src">
59 <TD ALIGN="right">Destination #: </TD>
61 <INPUT TYPE="text" NAME="dst">
66 <TD ALIGN="right">Destination Context: </TD>
68 <INPUT TYPE="text" NAME="dcontext">
74 <TD ALIGN="right">Charged Party #: </TD>
76 <INPUT TYPE="text" NAME="charged_party" VALUE="<% join(',', @charged_party) |h %>">
81 <TD ALIGN="right">Charged Party or Source #: </TD>
83 <INPUT TYPE="text" NAME="charged_party_or_src" VALUE="<% join(',', @charged_party_or_src ) |h %>" >
88 <TD ALIGN="right">Freeside service #: </TD>
90 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
94 <% include( '/elements/tr-input-lessthan_greaterthan.html',
95 'label' => 'Duration (sec)',
96 'field' => 'duration',
100 <% include( '/elements/tr-input-lessthan_greaterthan.html',
101 'label' => 'Billable duration (sec)',
102 'field' => 'billsec',
107 <TD ALIGN="right">Top</TD>
108 <TD><INPUT TYPE="TEXT" id="top_dst" NAME="top_dst" SIZE="7" onfocus="clearfield('top_src');"> destinations</TD>
112 <TD ALIGN="right">Top</TD>
113 <TD><INPUT TYPE="TEXT" id="top_src" NAME="top_src" SIZE="7" onfocus="clearfield('top_dst');"> sources</TD>
117 <TD ALIGN="right"></TD>
118 <TD><INPUT TYPE="TEXT" NAME="longest" SIZE="7"> longest calls</TD>
121 <% include( '/elements/tr-select-cdrbatch.html' ) %>
124 <TD ALIGN="right">Acct ID (one per-line):</TD>
125 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
129 <TH CLASS="background" COLSPAN=2> </TH>
133 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
136 <INPUT TYPE="hidden" NAME="show" VALUE="1">
140 <% include('/elements/checkboxes.html',
141 'names_list' => $names_list,
142 'element_name_prefix' => 'show_',
143 'checked_callback' => sub { $show_default{$_[1]} },
144 # my($cgi, $name) = @_;
153 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
157 <% include('/elements/footer.html') %>
161 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
163 my @fields = fields('cdr');
164 my $labels = FS::cdr->table_info->{'fields'};
167 my @show_default = qw(
168 calldate clid src dst dcontext charged_party
169 startdate answerdate enddate duration billsec
170 disposition amaflags accountcode userfield
171 rated_price upstream_price carrierid
172 svcnum freesidestatus freesiderewritestatus
174 my %show_default = map { $_=>1 } @show_default;
176 my $names_list = [ map {
178 'label' => 'Show '. ( $labels->{$_} || $_ )
185 my @charged_party = ();
186 my @charged_party_or_src = ();
188 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
191 my $cust_main = qsearchs( {
192 'table' => 'cust_main',
193 'hashref' => { 'custnum' => $custnum },
194 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
196 die "Customer not found!" unless $cust_main;
199 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
202 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
203 if ( scalar(@voip_pkgs) > 1 ) {
204 die "multiple voip_cdr packages bundled\n";
205 } elsif ( !@voip_pkgs ) {
208 my $voip_pkg = @voip_pkgs[0];
210 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
211 || 'svc_phone.phonenum';
213 my @cust_svc = $cust_pkg->cust_svc; #historical?
215 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
217 my @svc_phone = map $_->svc_x,
218 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
221 my $number = $_->phonenum;
222 $number = $_->countrycode. $number
223 unless $_->countrycode eq '1';
228 if ( $voip_pkg->option('disable_src') ) {
229 push @charged_party, @numbers;
231 push @charged_party_or_src, @numbers;
234 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
235 my @svc_pbx = map $_->svc_x,
236 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
237 push @charged_party, map $_->title, @svc_pbx;
238 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
239 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
240 push @svcnum, map $_->svcnum, @cust_svc_pbx;
245 die "No CDR packages for customer $custnum\n"
246 unless @charged_party || @charged_party_or_src || @svcnum;
248 #die "Multiple matching metods for customer $custnum\n"
249 # if #there's more than one