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">Last Application: </TD>
82 <INPUT TYPE="text" NAME="lastapp" VALUE="" >
87 <TD ALIGN="right">Freeside service #: </TD>
89 <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
93 <% include( '/elements/tr-input-lessthan_greaterthan.html',
94 'label' => 'Duration (sec)',
95 'field' => 'duration',
99 <% include( '/elements/tr-input-lessthan_greaterthan.html',
100 'label' => 'Billable duration (sec)',
101 'field' => 'billsec',
105 <% include( '/elements/tr-select-cdrbatch.html' ) %>
108 <TD ALIGN="right">Acct ID (one per-line):</TD>
109 <TD><TEXTAREA NAME="acctid"></TEXTAREA></TD>
113 <TH CLASS="background" COLSPAN=2> </TH>
117 <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
120 <INPUT TYPE="hidden" NAME="show" VALUE="1">
124 <% include('/elements/checkboxes.html',
125 'names_list' => $names_list,
126 'element_name_prefix' => 'show_',
127 'checked_callback' => sub { $show_default{$_[1]} },
128 # my($cgi, $name) = @_;
137 <INPUT TYPE="submit" VALUE="Search Call Detail Records">
141 <% include('/elements/footer.html') %>
145 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
147 my @fields = fields('cdr');
148 my $labels = FS::cdr->table_info->{'fields'};
151 my @show_default = qw(
152 calldate clid src dst dcontext charged_party
153 startdate answerdate enddate duration billsec
154 disposition amaflags accountcode userfield
155 rated_price upstream_price carrierid
156 svcnum freesidestatus freesiderewritestatus
158 my %show_default = map { $_=>1 } @show_default;
160 my $names_list = [ map {
162 'label' => 'Show '. ( $labels->{$_} || $_ )
169 my @charged_party = ();
170 my @charged_party_or_src = ();
172 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
175 my $cust_main = qsearchs( {
176 'table' => 'cust_main',
177 'hashref' => { 'custnum' => $custnum },
178 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
180 die "Customer not found!" unless $cust_main;
183 foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
186 grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
187 if ( scalar(@voip_pkgs) > 1 ) {
188 die "multiple voip_cdr packages bundled\n";
189 } elsif ( !@voip_pkgs ) {
192 my $voip_pkg = @voip_pkgs[0];
194 my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
195 || 'svc_phone.phonenum';
197 my @cust_svc = $cust_pkg->cust_svc; #historical?
199 if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
201 my @svc_phone = map $_->svc_x,
202 grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
205 my $number = $_->phonenum;
206 $number = $_->countrycode. $number
207 unless $_->countrycode eq '1';
212 if ( $voip_pkg->option('disable_src') ) {
213 push @charged_party, @numbers;
215 push @charged_party_or_src, @numbers;
218 } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
219 my @svc_pbx = map $_->svc_x,
220 grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
221 push @charged_party, map $_->title, @svc_pbx;
222 } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
223 my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
224 push @svcnum, map $_->svcnum, @cust_svc_pbx;
229 die "No CDR packages for customer $custnum\n"
230 unless @charged_party || @charged_party_or_src || @svcnum;
232 #die "Multiple matching metods for customer $custnum\n"
233 # if #there's more than one