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">Last Application: </TD>
90 <INPUT TYPE="text" NAME="lastapp" VALUE="" >
95 <TD ALIGN="right">Freeside service #: </TD>
97 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
101 <% include( '/elements/tr-input-lessthan_greaterthan.html',
102 'label' => 'Duration (sec)',
103 'field' => 'duration',
107 <% include( '/elements/tr-input-lessthan_greaterthan.html',
108 'label' => 'Billable duration (sec)',
109 'field' => 'billsec',
114 <TD ALIGN="right">Top</TD>
115 <TD><INPUT TYPE="TEXT" id="top_dst" NAME="top_dst" SIZE="7" onfocus="clearfield('top_src');"> destinations</TD>
119 <TD ALIGN="right">Top</TD>
120 <TD><INPUT TYPE="TEXT" id="top_src" NAME="top_src" SIZE="7" onfocus="clearfield('top_dst');"> sources</TD>
124 <TD ALIGN="right"></TD>
125 <TD><INPUT TYPE="TEXT" NAME="longest" SIZE="7"> longest calls</TD>
128 <% include( '/elements/tr-select-cdrbatch.html' ) %>
131 <TD ALIGN="right">Acct ID (one per-line):</TD>
132 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
136 <TH CLASS="background" COLSPAN=2> </TH>
140 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
143 <INPUT TYPE="hidden" NAME="show" VALUE="1">
147 <% include('/elements/checkboxes.html',
148 'names_list' => $names_list,
149 'element_name_prefix' => 'show_',
150 'checked_callback' => sub { $show_default{$_[1]} },
151 # my($cgi, $name) = @_;
160 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
164 <% include('/elements/footer.html') %>
168 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
170 my @fields = fields('cdr');
171 my $labels = FS::cdr->table_info->{'fields'};
174 my @show_default = qw(
175 calldate clid src dst dcontext charged_party
176 startdate answerdate enddate duration billsec
177 disposition amaflags accountcode userfield
178 rated_price upstream_price carrierid
179 svcnum freesidestatus freesiderewritestatus
181 my %show_default = map { $_=>1 } @show_default;
183 my $names_list = [ map {
185 'label' => 'Show '. ( $labels->{$_} || $_ )
192 my @charged_party = ();
193 my @charged_party_or_src = ();
195 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
198 my $cust_main = qsearchs( {
199 'table' => 'cust_main',
200 'hashref' => { 'custnum' => $custnum },
201 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
203 die "Customer not found!" unless $cust_main;
206 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
209 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
210 if ( scalar(@voip_pkgs) > 1 ) {
211 die "multiple voip_cdr packages bundled\n";
212 } elsif ( !@voip_pkgs ) {
215 my $voip_pkg = @voip_pkgs[0];
217 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
218 || 'svc_phone.phonenum';
220 my @cust_svc = $cust_pkg->cust_svc; #historical?
222 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
224 my @svc_phone = map $_->svc_x,
225 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
228 my $number = $_->phonenum;
229 $number = $_->countrycode. $number
230 unless $_->countrycode eq '1';
235 if ( $voip_pkg->option('disable_src') ) {
236 push @charged_party, @numbers;
238 push @charged_party_or_src, @numbers;
241 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
242 my @svc_pbx = map $_->svc_x,
243 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
244 push @charged_party, map $_->title, @svc_pbx;
245 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
246 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
247 push @svcnum, map $_->svcnum, @cust_svc_pbx;
252 die "No CDR packages for customer $custnum\n"
253 unless @charged_party || @charged_party_or_src || @svcnum;
255 #die "Multiple matching metods for customer $custnum\n"
256 # if #there's more than one