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)</OPTION>
26 <OPTION VALUE="NULL">unprocessed</OPTION>
27 %# <OPTION VALUE="processing-tiered">processing</OPTION>
28 <OPTION VALUE="rated">prerated
29 <OPTION VALUE="no-charge">processed (included)</OPTION>
30 <OPTION VALUE="done">processed (billed)</OPTION>
31 <OPTION VALUE="skipped">skipped</OPTION>
32 <OPTION VALUE="failed">failed</OPTION>
37 % #if ( ) { # disable for everyone not using termination billing...
38 % foreach my $termpart ( 1..1 ) { #qsearch('part_termination
41 <TD ALIGN="right">Termination Status: </TD>
43 <SELECT NAME="termpart<%$termpart%>status">
44 <OPTION VALUE="">(all)
45 <OPTION VALUE="NULL">unprocessed
46 <OPTION VALUE="done">processed
54 <% include('/elements/tr-select-table.html',
55 field => 'cdrtypenum',
58 name_col => 'cdrtypename',
60 pre_options => [ '', 'all',
64 <% include ( '/elements/tr-input-beginning_ending.html' ) %>
67 <TD ALIGN="right">Source #: </TD>
69 <INPUT TYPE="text" NAME="src">
74 <TD ALIGN="right">Destination #: </TD>
76 <INPUT TYPE="text" NAME="dst">
81 <TD ALIGN="right">Destination Context: </TD>
83 <INPUT TYPE="text" NAME="dcontext">
89 <TD ALIGN="right">Charged Party #: </TD>
91 <INPUT TYPE="text" NAME="charged_party" VALUE="<% join(',', @charged_party) |h %>">
96 <TD ALIGN="right">Charged Party or Source #: </TD>
98 <INPUT TYPE="text" NAME="charged_party_or_src" VALUE="<% join(',', @charged_party_or_src ) |h %>" >
103 <TD ALIGN="right">Last Application: </TD>
105 <INPUT TYPE="text" NAME="lastapp" VALUE="" >
110 <TD ALIGN="right">Freeside service #: </TD>
112 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
116 <% include( '/elements/tr-input-lessthan_greaterthan.html',
117 'label' => 'Duration (sec)',
118 'field' => 'duration',
122 <% include( '/elements/tr-input-lessthan_greaterthan.html',
123 'label' => 'Billable duration (sec)',
124 'field' => 'billsec',
129 <TD ALIGN="right">Top</TD>
130 <TD><INPUT TYPE="TEXT" id="top_dst" NAME="top_dst" SIZE="7" onfocus="clearfield('top_src');"> destinations</TD>
134 <TD ALIGN="right">Top</TD>
135 <TD><INPUT TYPE="TEXT" id="top_src" NAME="top_src" SIZE="7" onfocus="clearfield('top_dst');"> sources</TD>
139 <TD ALIGN="right"></TD>
140 <TD><INPUT TYPE="TEXT" NAME="longest" SIZE="7"> longest calls</TD>
143 <% include( '/elements/tr-select-cdrbatch.html' ) %>
146 <TD ALIGN="right">Acct ID (one per-line):</TD>
147 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
151 <TD ALIGN="right">Acct Code (one per-line):</TD>
152 <TD><TEXTAREA NAME="accountcode"></TEXTAREA></TD>
156 <TH CLASS="background" COLSPAN=2> </TH>
160 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
163 <INPUT TYPE="hidden" NAME="show" VALUE="1">
167 <% include('/elements/checkboxes.html',
168 'names_list' => $names_list,
169 'element_name_prefix' => 'show_',
170 'checked_callback' => sub { $show_default{$_[1]} },
171 # my($cgi, $name) = @_;
180 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
184 <% include('/elements/footer.html') %>
188 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
190 my @fields = fields('cdr');
191 my $labels = FS::cdr->table_info->{'fields'};
193 my $conf = new FS::Conf;
194 my $default_phone_countrycode =
195 $conf->config('default_phone_countrycode') || '1';
198 my @show_default = qw(
199 calldate clid src dst dcontext charged_party
200 startdate answerdate enddate duration billsec
201 disposition amaflags accountcode userfield
202 rated_price upstream_price carrierid
203 svcnum freesidestatus freesiderewritestatus
205 my %show_default = map { $_=>1 } @show_default;
207 my $names_list = [ map {
209 'label' => 'Show '. ( $labels->{$_} || $_ )
216 my @charged_party = ();
217 my @charged_party_or_src = ();
219 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
222 my $cust_main = qsearchs( {
223 'table' => 'cust_main',
224 'hashref' => { 'custnum' => $custnum },
225 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
227 die "Customer not found!" unless $cust_main;
229 #historical packages? It would help, it was still usage, it happened
230 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
233 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
234 if ( scalar(@voip_pkgs) > 1 ) {
235 die "multiple voip_cdr packages bundled\n";
236 } elsif ( !@voip_pkgs ) {
239 my $voip_pkg = @voip_pkgs[0];
241 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
242 || 'svc_phone.phonenum';
244 my @cust_svc = $cust_pkg->cust_svc; #historical?
246 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
248 my @svc_phone = map $_->svc_x,
249 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
252 my $number = $_->phonenum;
253 $number = $_->countrycode. $number
254 unless $_->countrycode eq $default_phone_countrycode;
259 if ( $voip_pkg->option('disable_src') ) {
260 push @charged_party, @numbers;
262 push @charged_party_or_src, @numbers;
265 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
266 my @svc_pbx = map $_->svc_x,
267 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
268 push @charged_party, map $_->title, @svc_pbx;
269 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
270 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
271 push @svcnum, map $_->svcnum, @cust_svc_pbx;
276 die "No CDR packages for customer $custnum\n"
277 unless @charged_party || @charged_party_or_src || @svcnum;
279 #die "Multiple matching metods for customer $custnum\n"
280 # if #there's more than one