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">Last Application: </TD>
98 <INPUT TYPE="text" NAME="lastapp" VALUE="" >
103 <TD ALIGN="right">Freeside service #: </TD>
105 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
109 <% include( '/elements/tr-input-lessthan_greaterthan.html',
110 'label' => 'Duration (sec)',
111 'field' => 'duration',
115 <% include( '/elements/tr-input-lessthan_greaterthan.html',
116 'label' => 'Billable duration (sec)',
117 'field' => 'billsec',
122 <TD ALIGN="right">Top</TD>
123 <TD><INPUT TYPE="TEXT" id="top_dst" NAME="top_dst" SIZE="7" onfocus="clearfield('top_src');"> destinations</TD>
127 <TD ALIGN="right">Top</TD>
128 <TD><INPUT TYPE="TEXT" id="top_src" NAME="top_src" SIZE="7" onfocus="clearfield('top_dst');"> sources</TD>
132 <TD ALIGN="right"></TD>
133 <TD><INPUT TYPE="TEXT" NAME="longest" SIZE="7"> longest calls</TD>
136 <% include( '/elements/tr-select-cdrbatch.html' ) %>
139 <TD ALIGN="right">Acct ID (one per-line):</TD>
140 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
144 <TH CLASS="background" COLSPAN=2> </TH>
148 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
151 <INPUT TYPE="hidden" NAME="show" VALUE="1">
155 <% include('/elements/checkboxes.html',
156 'names_list' => $names_list,
157 'element_name_prefix' => 'show_',
158 'checked_callback' => sub { $show_default{$_[1]} },
159 # my($cgi, $name) = @_;
168 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
172 <% include('/elements/footer.html') %>
176 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
178 my @fields = fields('cdr');
179 my $labels = FS::cdr->table_info->{'fields'};
182 my @show_default = qw(
183 calldate clid src dst dcontext charged_party
184 startdate answerdate enddate duration billsec
185 disposition amaflags accountcode userfield
186 rated_price upstream_price carrierid
187 svcnum freesidestatus freesiderewritestatus
189 my %show_default = map { $_=>1 } @show_default;
191 my $names_list = [ map {
193 'label' => 'Show '. ( $labels->{$_} || $_ )
200 my @charged_party = ();
201 my @charged_party_or_src = ();
203 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
206 my $cust_main = qsearchs( {
207 'table' => 'cust_main',
208 'hashref' => { 'custnum' => $custnum },
209 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
211 die "Customer not found!" unless $cust_main;
214 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
217 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
218 if ( scalar(@voip_pkgs) > 1 ) {
219 die "multiple voip_cdr packages bundled\n";
220 } elsif ( !@voip_pkgs ) {
223 my $voip_pkg = @voip_pkgs[0];
225 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
226 || 'svc_phone.phonenum';
228 my @cust_svc = $cust_pkg->cust_svc; #historical?
230 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
232 my @svc_phone = map $_->svc_x,
233 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
236 my $number = $_->phonenum;
237 $number = $_->countrycode. $number
238 unless $_->countrycode eq '1';
243 if ( $voip_pkg->option('disable_src') ) {
244 push @charged_party, @numbers;
246 push @charged_party_or_src, @numbers;
249 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
250 my @svc_pbx = map $_->svc_x,
251 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
252 push @charged_party, map $_->title, @svc_pbx;
253 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
254 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
255 push @svcnum, map $_->svcnum, @cust_svc_pbx;
260 die "No CDR packages for customer $custnum\n"
261 unless @charged_party || @charged_party_or_src || @svcnum;
263 #die "Multiple matching metods for customer $custnum\n"
264 # if #there's more than one