diff options
-rw-r--r-- | FS/FS/Schema.pm | 7 | ||||
-rw-r--r-- | FS/FS/cdr.pm | 48 | ||||
-rw-r--r-- | httemplate/elements/checkboxes.html | 10 | ||||
-rw-r--r-- | httemplate/search/cdr.html | 23 | ||||
-rw-r--r-- | httemplate/search/report_cdr.html | 65 |
5 files changed, 137 insertions, 16 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 52e1190..67ef612 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2142,7 +2142,12 @@ sub tables_hashref { ], 'primary_key' => 'acctid', 'unique' => [], - 'index' => [ [ 'calldate' ], [ 'src' ], [ 'dst' ], [ 'charged_party' ], [ 'accountcode' ], [ 'carrierid' ], [ 'freesidestatus' ], [ 'freesiderewritestatus' ], [ 'cdrbatch' ], ], + 'index' => [ [ 'calldate' ], + [ 'src' ], [ 'dst' ], [ 'dcontext' ], [ 'charged_party' ], + [ 'accountcode' ], [ 'carrierid' ], + [ 'freesidestatus' ], [ 'freesiderewritestatus' ], + [ 'cdrbatch' ], + ], }, 'cdr_termination' => { diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 7b1ee7a..96132ec 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -153,6 +153,54 @@ points to. You can ask the object for a copy with the I<hash> method. sub table { 'cdr'; } +sub table_info { + { + 'fields' => { +#XXX fill in some (more) nice names + #'acctid' => '', + 'calldate' => 'Call date', + 'clid' => 'Caller ID', + 'src' => 'Source', + 'dst' => 'Destination', + 'dcontext' => 'Dest. context', + 'channel' => 'Channel', + 'dstchannel' => 'Destination channel', + #'lastapp' => '', + #'lastdata' => '', + 'startdate' => 'Start date', + 'answerdate' => 'Answer date', + 'enddate' => 'End date', + 'duration' => 'Duration', + 'billsec' => 'Billable seconds', + 'disposition' => 'Disposition', + 'amaflags' => 'AMA flags', + 'accountcode' => 'Account code', + #'uniqueid' => '', + 'userfield' => 'User field', + #'cdrtypenum' => '', + 'charged_party' => 'Charged party', + #'upstream_currency' => '', + 'upstream_price' => 'Upstream price', + #'upstream_rateplanid' => '', + #'ratedetailnum' => '', + 'rated_price' => 'Rated price', + #'distance' => '', + #'islocal' => '', + #'calltypenum' => '', + #'description' => '', + #'quantity' => '', + 'carrierid' => 'Carrier ID', + #'upstream_rateid' => '', + 'svcnum' => 'Freeside service', + 'freesidestatus' => 'Freeside status', + 'freesiderewritestatus' => 'Freeside rewrite status', + 'cdrbatch' => 'Batch', + }, + + }; + +} + =item insert Adds this record to the database. If there is an error, returns the error, diff --git a/httemplate/elements/checkboxes.html b/httemplate/elements/checkboxes.html index 1262245..b120ada 100644 --- a/httemplate/elements/checkboxes.html +++ b/httemplate/elements/checkboxes.html @@ -10,8 +10,9 @@ Example: 'names_list' => [ 'value', 'other value', - [ 'complex value' => { 'desc' => "Add'l description", - 'note' => ' *', + [ 'complex value' => { 'label' => 'Display value', + 'desc' => "Add'l description", + 'note' => ' *', } ], ], @@ -40,7 +41,10 @@ Example: % foreach my $item ( @{ $opt{'names_list'} } ) { % % my $name = ref($item) ? $item->[0] : $item; -% ( my $display = $name ) =~ s/ / /g; +% my $display = ( ref($item) && $item->[1]{label} ) +% ? $item->[1]{label} +% : $name; +% $display =~ s/ / /g; % $display .= $item->[1]{note} if ref($item) && $item->[1]{note}; % my $desc = ref($item) && $item->[1]{desc} ? $item->[1]{desc} : ''; % diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html index 26eac75..126c4fd 100644 --- a/httemplate/search/cdr.html +++ b/httemplate/search/cdr.html @@ -158,6 +158,12 @@ if ( $cgi->param('dst') =~ /^\s*([\d\-\+ ]+)\s*$/ ) { push @search, "dst = '$dst'"; } +if ( $cgi->param('dcontext') =~ /^\s*(.+)\s*$/ ) { + my $dcontext = $1; + $hashref->{'dcontext'} = $dcontext; + push @search, "dcontext = '$dcontext'"; +} + if ( $cgi->param('charged_party') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) { ( my $charged_party = $1 ) =~ s/\D//g; #$hashref->{'charged_party'} = $charged_party; @@ -203,24 +209,17 @@ $qsearch = ( scalar(keys %$hashref) ? ' AND ' : ' WHERE ' ) . $qsearch # display fields ### -#XXX fill in some (more) nice names -my %header = ( - 'calldate' => 'Call Date', - 'clid' => 'Caller ID', - 'charged_party' => 'Charged party', - 'src' => 'Source', - 'dst' => 'Destination', - 'dcontext' => 'Destination Context', - 'channel' => 'Channel', - 'dstchannel' => 'Destination Channel', - 'freesidestatus' => 'Freeside status', -); +my %header = %{ FS::cdr->table_info->{'fields'} }; my @first = qw( acctid calldate clid charged_party src dst dcontext ); my %first = map { $_=>1 } @first; my @fields = ( @first, grep !$first{$_}, fields('cdr') ); +if ( $cgi->param('show') ) { + @fields = grep $cgi->param("show_$_"), @fields; +} + my @header = map { if ( exists($header{$_}) ) { $header{$_}; diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index 6a0b89b..c5f728c 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -5,6 +5,12 @@ <TABLE BGCOLOR="#cccccc" CELLSPACING=0> <TR> + <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"> + <FONT SIZE="+1">Search options</FONT> + </TH> + </TR> + + <TR> <TD ALIGN="right">Status: </TD> <TD> <SELECT NAME="freesidestatus"> @@ -48,6 +54,21 @@ </TD> </TR> + <TR> + <TD ALIGN="right">Destination Context: </TD> + <TD> + <INPUT TYPE="text" NAME="dcontext"> + </TD> + </TR> + + + <TR> + <TD ALIGN="right">Charged Party #: </TD> + <TD> + <INPUT TYPE="text" NAME="charged_party"> + </TD> + </TR> + <% include( '/elements/tr-input-lessthan_greaterthan.html', 'label' => 'Duration (sec)', 'field' => 'duration', @@ -62,6 +83,28 @@ <% include( '/elements/tr-select-cdrbatch.html' ) %> + <TR> + <TH BGCOLOR="#e8e8e8" COLSPAN=2> </TH> + </TR> + + <TR> + <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH> + </TR> + + <INPUT TYPE="hidden" NAME="show" VALUE="1"> + + <TR> + <TD COLSPAN=2> + <% include('/elements/checkboxes.html', + 'names_list' => $names_list, + 'element_name_prefix' => 'show_', + 'checked_callback' => sub { $show_default{$_[1]} }, + # my($cgi, $name) = @_; + ) + %> + </TD> + </TR> + </TABLE> <BR> @@ -73,4 +116,26 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('List rating data'); +my @fields = fields('cdr'); +my $labels = FS::cdr->table_info->{'fields'}; + +#XXX config +my @show_default = qw( + calldate clid src dst dcontext charged_party + startdate answerdate enddate duration billsec + disposition amaflags accountcode userfield + rated_price upstream_price carrierid + svcnum freesidestatus freesiderewritestatus cdrbatch +); +my %show_default = map { $_=>1 } @show_default; + +my $names_list = [ map { + [ $_ => { + 'label' => 'Show '. ( $labels->{$_} || $_ ) + } + ] + } + @fields + ]; + </%init> |