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-select-table.html',
50 field => 'cdrtypenum',
53 name_col => 'cdrtypename',
54 post_options => [ 'none', 'none' ] )
57 <% include ( '/elements/tr-input-beginning_ending.html' ) %>
60 <TD ALIGN="right">Source #: </TD>
62 <INPUT TYPE="text" NAME="src">
67 <TD ALIGN="right">Destination #: </TD>
69 <INPUT TYPE="text" NAME="dst">
74 <TD ALIGN="right">Destination Context: </TD>
76 <INPUT TYPE="text" NAME="dcontext">
82 <TD ALIGN="right">Charged Party #: </TD>
84 <INPUT TYPE="text" NAME="charged_party" VALUE="<% join(',', @charged_party) |h %>">
89 <TD ALIGN="right">Charged Party or Source #: </TD>
91 <INPUT TYPE="text" NAME="charged_party_or_src" VALUE="<% join(',', @charged_party_or_src ) |h %>" >
96 <TD ALIGN="right">Freeside service #: </TD>
98 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
102 <% include( '/elements/tr-input-lessthan_greaterthan.html',
103 'label' => 'Duration (sec)',
104 'field' => 'duration',
108 <% include( '/elements/tr-input-lessthan_greaterthan.html',
109 'label' => 'Billable duration (sec)',
110 'field' => 'billsec',
115 <TD ALIGN="right">Top</TD>
116 <TD><INPUT TYPE="TEXT" id="top_dst" NAME="top_dst" SIZE="7" onfocus="clearfield('top_src');"> destinations</TD>
120 <TD ALIGN="right">Top</TD>
121 <TD><INPUT TYPE="TEXT" id="top_src" NAME="top_src" SIZE="7" onfocus="clearfield('top_dst');"> sources</TD>
125 <TD ALIGN="right"></TD>
126 <TD><INPUT TYPE="TEXT" NAME="longest" SIZE="7"> longest calls</TD>
129 <% include( '/elements/tr-select-cdrbatch.html' ) %>
132 <TD ALIGN="right">Acct ID (one per-line):</TD>
133 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
137 <TH CLASS="background" COLSPAN=2> </TH>
141 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
144 <INPUT TYPE="hidden" NAME="show" VALUE="1">
148 <% include('/elements/checkboxes.html',
149 'names_list' => $names_list,
150 'element_name_prefix' => 'show_',
151 'checked_callback' => sub { $show_default{$_[1]} },
152 # my($cgi, $name) = @_;
161 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
165 <% include('/elements/footer.html') %>
169 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
171 my @fields = fields('cdr');
172 my $labels = FS::cdr->table_info->{'fields'};
175 my @show_default = qw(
176 calldate clid src dst dcontext charged_party
177 startdate answerdate enddate duration billsec
178 disposition amaflags accountcode userfield
179 rated_price upstream_price carrierid
180 svcnum freesidestatus freesiderewritestatus
182 my %show_default = map { $_=>1 } @show_default;
184 my $names_list = [ map {
186 'label' => 'Show '. ( $labels->{$_} || $_ )
193 my @charged_party = ();
194 my @charged_party_or_src = ();
196 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
199 my $cust_main = qsearchs( {
200 'table' => 'cust_main',
201 'hashref' => { 'custnum' => $custnum },
202 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
204 die "Customer not found!" unless $cust_main;
207 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
210 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
211 if ( scalar(@voip_pkgs) > 1 ) {
212 die "multiple voip_cdr packages bundled\n";
213 } elsif ( !@voip_pkgs ) {
216 my $voip_pkg = @voip_pkgs[0];
218 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
219 || 'svc_phone.phonenum';
221 my @cust_svc = $cust_pkg->cust_svc; #historical?
223 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
225 my @svc_phone = map $_->svc_x,
226 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
229 my $number = $_->phonenum;
230 $number = $_->countrycode. $number
231 unless $_->countrycode eq '1';
236 if ( $voip_pkg->option('disable_src') ) {
237 push @charged_party, @numbers;
239 push @charged_party_or_src, @numbers;
242 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
243 my @svc_pbx = map $_->svc_x,
244 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
245 push @charged_party, map $_->title, @svc_pbx;
246 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
247 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
248 push @svcnum, map $_->svcnum, @cust_svc_pbx;
253 die "No CDR packages for customer $custnum\n"
254 unless @charged_party || @charged_party_or_src || @svcnum;
256 #die "Multiple matching metods for customer $custnum\n"
257 # if #there's more than one