@fields, #XXX fill in some pretty-print
#processing, etc.
],
+ 'links' => \@links,
'html_form' => qq!<FORM NAME="cdrForm" ACTION="$p/misc/cdr.cgi" METHOD="POST">!,
#false laziness w/queue.html
my $edit_data = $FS::CurrentUser::CurrentUser->access_right('Edit rating data');
+my $conf = new FS::Conf;
+
my $areboxes = 0;
my $title = 'Call Detail Records';
###
my $str2time_sql = str2time_sql;
+my $closing = str2time_sql_closing;
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
-push @search, "$str2time_sql calldate) >= $beginning ",
- "$str2time_sql calldate) <= $ending";
+push @search, "$str2time_sql calldate $closing >= $beginning ",
+ "$str2time_sql calldate $closing <= $ending";
###
# duration / billsec
$search =
"NOT EXISTS ( SELECT 1 FROM cdr_termination WHERE $where_term )";
- } elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) {
+ } elsif ( $status =~ /^([\w ]+)$/ ) {
#false lazienss w/cdr_termination.pm (i should be a part_termination method)
my $where_term =
}
###
-# src/dest/charged_party
+# src/dest/charged_party/svcnum
###
-if ( $cgi->param('src') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) {
- ( my $src = $1 ) =~ s/\D//g;
+my $phonenum = qr/^\s*([\d\-\+\ ]+)\s*$/;
+my $x = qr/\D/;
+if ( $conf->exists('svc_phone-allow_alpha_phonenum') ) {
+ $phonenum = qr/^\s*([\d\-\+\ A-Za-z]+)\s*$/;
+ $x = qr/[^\dA-Za-z]/;
+}
+
+if ( $cgi->param('src') =~ $phonenum ) {
+ ( my $src = $1 ) =~ s/$x//g;
$hashref->{'src'} = $src;
push @search, "src = '$src'";
}
-if ( $cgi->param('dst') =~ /^\s*([\d\-\+ ]+)\s*$/ ) {
- ( my $dst = $1 ) =~ s/\D//g;
+if ( $cgi->param('dst') =~ $phonenum ) {
+ ( my $dst = $1 ) =~ s/$x//g;
$hashref->{'dst'} = $dst;
push @search, "dst = '$dst'";
}
push @search, "dcontext = '$dcontext'";
}
-if ( $cgi->param('charged_party') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) {
- ( my $charged_party = $1 ) =~ s/\D//g;
- #$hashref->{'charged_party'} = $charged_party;
- #push @search, "charged_party = '$charged_party'";
- #XXX countrycode
+if ( $cgi->param('charged_party') ) {
- my $search = " ( charged_party = '$charged_party'
- OR charged_party = '1$charged_party' ) ";
+ my @cp = map { $_, "1$_" }
+ split(/\s*,\s*/, $cgi->param('charged_party') );
+
+ my $search = 'charged_party IN ('. join(',', map dbh->quote($_), @cp). ')';
push @search, $search;
push @qsearch, $search;
}
+if ( $cgi->param('charged_party_or_src') ) {
+
+ my @cp = map { $_, "1$_" }
+ split(/\s*,\s*/, $cgi->param('charged_party_or_src') );
+ my $in = join(',', map dbh->quote($_), @cp);
+
+ my $search = "( charged_party IN ($in) OR src IN ($in) )";
+
+ push @search, $search;
+ push @qsearch, $search;
+}
+
+if ( $cgi->param('svcnum') =~ /^([\d, ]+)$/ ) {
+ my $svcnum = $1;
+ my $search = "svcnum IN ($svcnum)";
+ push @search, $search;
+ push @qsearch, $search;
+}
+
+###
+# cdrbatchnum (or legacy cdrbatch)
+###
+
+if ( $cgi->param('cdrbatch') ) {
+
+ my $cdr_batch =
+ qsearchs('cdr_batch', { 'cdrbatch' => scalar($cgi->param('cdrbatch')) } );
+ if ( $cdr_batch ) {
+ $hashref->{cdrbatchnum} = $cdr_batch->cdrbatchnum;
+ push @search, 'cdrbatchnum = '. $cdr_batch->cdrbatchnum;
+ } else {
+ die "unknown cdrbatch ". $cgi->param('cdrbatch');
+ }
+
+} elsif ( $cgi->param('cdrbatchnum') ne '__ALL__' ) {
+
+ if ( $cgi->param('cdrbatchnum') eq '' ) {
+ my $search = "( cdrbatchnum IS NULL )";
+ push @qsearch, $search;
+ push @search, $search;
+ } elsif ( $cgi->param('cdrbatchnum') =~ /^(\d+)$/ ) {
+ $hashref->{cdrbatchnum} = $1;
+ push @search, "cdrbatchnum = $1";
+ }
+
+}
+
###
-# cdrbatch
+# acctid
###
-if ( $cgi->param('cdrbatch') ne '__ALL__' ) {
- if ( $cgi->param('cdrbatch') eq '' ) {
- my $search = "( cdrbatch IS NULL OR cdrbatch = '' )";
+if ( $cgi->param('acctid') =~ /\d/ ) {
+ my $acctid = $cgi->param('acctid');
+ $acctid =~ s/\r\n/\n/g; #browsers?
+ my @acctid = map { /^\s*(\d+)\s*$/ or die "guru meditation #4"; $1; }
+ grep { /^\s*(\d+)\s*$/ }
+ split(/\n/, $acctid);
+ if ( @acctid ) {
+ my $search = 'acctid IN ( '. join(',', @acctid). ' )';
push @qsearch, $search;
push @search, $search;
- } else {
- $hashref->{cdrbatch} = $cgi->param('cdrbatch');
- push @search, 'cdrbatch = '. dbh->quote($cgi->param('cdrbatch'));
}
}
$header{$_};
} else {
my $header = $_;
- $header =~ s/\_/ /g;
+ $header =~ s/\_/ /g; #//wtf
ucfirst($header);
}
} @fields;
+my $date_sub_factory = sub {
+ my $column = shift;
+ sub {
+ #my $cdr = shift;
+ my $date = shift->$column();
+ $date ? time2str( '%Y-%m-%d %T', $date ) : ''; #config time2str format?
+ };
+};
+
+my %fields = (
+ #any other formatters?
+ map { $_ => &{ $date_sub_factory }($_) } qw( startdate answerdate enddate )
+);
+
+my %links = (
+ 'svcnum' =>
+ sub { $_[0]->svcnum ? [ $p.'view/svc_phone.cgi?', 'svcnum' ] : ''; },
+);
+
+@fields = map { exists($fields{$_}) ? $fields{$_} : $_ } @fields;
+
+ #checkbox column
+my @links = ( '', map { exists($links{$_}) ? $links{$_} : '' } @fields );
+
</%init>