1 <% include('/elements/header.html', 'Call Detail Record Search' ) %>
3 <FORM ACTION="cdr.html" METHOD="GET">
5 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
8 <TH CLASS="background" COLSPAN=2 ALIGN="left">
9 <FONT SIZE="+1">Search options</FONT>
14 <TD ALIGN="right">Status: </TD>
16 <SELECT NAME="freesidestatus">
17 <OPTION VALUE="">(all)
18 <OPTION VALUE="NULL">unprocessed
19 <OPTION VALUE="done">processed
24 % #if ( ) { # disable for everyone not using termination billing...
25 % foreach my $termpart ( 1..1 ) { #qsearch('part_termination
28 <TD ALIGN="right">Termination Status: </TD>
30 <SELECT NAME="termpart<%$termpart%>status">
31 <OPTION VALUE="">(all)
32 <OPTION VALUE="NULL">unprocessed
33 <OPTION VALUE="done">processed
41 <% include ( '/elements/tr-input-beginning_ending.html' ) %>
44 <TD ALIGN="right">Source #: </TD>
46 <INPUT TYPE="text" NAME="src">
51 <TD ALIGN="right">Destination #: </TD>
53 <INPUT TYPE="text" NAME="dst">
58 <TD ALIGN="right">Destination Context: </TD>
60 <INPUT TYPE="text" NAME="dcontext">
66 <TD ALIGN="right">Charged Party #: </TD>
68 <INPUT TYPE="text" NAME="charged_party" VALUE="<% join(',', @charged_party) |h %>">
73 <TD ALIGN="right">Charged Party or Source #: </TD>
75 <INPUT TYPE="text" NAME="charged_party_or_src" VALUE="<% join(',', @charged_party_or_src ) |h %>" >
80 <TD ALIGN="right">Freeside service #: </TD>
82 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
86 <% include( '/elements/tr-input-lessthan_greaterthan.html',
87 'label' => 'Duration (sec)',
88 'field' => 'duration',
92 <% include( '/elements/tr-input-lessthan_greaterthan.html',
93 'label' => 'Billable duration (sec)',
98 <% include( '/elements/tr-select-cdrbatch.html' ) %>
101 <TD ALIGN="right">Acct ID (one per-line):</TD>
102 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
106 <TH CLASS="background" COLSPAN=2> </TH>
110 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
113 <INPUT TYPE="hidden" NAME="show" VALUE="1">
117 <% include('/elements/checkboxes.html',
118 'names_list' => $names_list,
119 'element_name_prefix' => 'show_',
120 'checked_callback' => sub { $show_default{$_[1]} },
121 # my($cgi, $name) = @_;
130 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
134 <% include('/elements/footer.html') %>
138 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
140 my @fields = fields('cdr');
141 my $labels = FS::cdr->table_info->{'fields'};
144 my @show_default = qw(
145 calldate clid src dst dcontext charged_party
146 startdate answerdate enddate duration billsec
147 disposition amaflags accountcode userfield
148 rated_price upstream_price carrierid
149 svcnum freesidestatus freesiderewritestatus
151 my %show_default = map { $_=>1 } @show_default;
153 my $names_list = [ map {
155 'label' => 'Show '. ( $labels->{$_} || $_ )
162 my @charged_party = ();
163 my @charged_party_or_src = ();
165 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
168 my $cust_main = qsearchs( {
169 'table' => 'cust_main',
170 'hashref' => { 'custnum' => $custnum },
171 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
173 die "Customer not found!" unless $cust_main;
176 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
179 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
180 if ( scalar(@voip_pkgs) > 1 ) {
181 die "multiple voip_cdr packages bundled\n";
182 } elsif ( !@voip_pkgs ) {
185 my $voip_pkg = @voip_pkgs[0];
187 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
188 || 'svc_phone.phonenum';
190 my @cust_svc = $cust_pkg->cust_svc; #historical?
192 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
194 my @svc_phone = map $_->svc_x,
195 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
198 my $number = $_->phonenum;
199 $number = $_->countrycode. $number
200 unless $_->countrycode eq '1';
205 if ( $voip_pkg->option('disable_src') ) {
206 push @charged_party, @numbers;
208 push @charged_party_or_src, @numbers;
211 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
212 my @svc_pbx = map $_->svc_x,
213 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
214 push @charged_party, map $_->title, @svc_pbx;
215 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
216 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
217 push @svcnum, map $_->svcnum, @cust_svc_pbx;
222 die "No CDR packages for customer $custnum\n"
223 unless @charged_party || @charged_party_or_src || @svcnum;
225 #die "Multiple matching metods for customer $custnum\n"
226 # if #there's more than one