Examples:
include( 'elements/cust_pay_or_refund.html',
- 'thing' => 'pay',
- 'amount_field' => 'paid',
- 'name_singular' => 'payment',
- 'name_verb' => 'paid',
+ 'thing' => 'pay',
+ 'amount_field' => 'paid',
+ 'name_singular' => 'payment',
+ 'name_verb' => 'paid',
)
include( 'elements/cust_pay_or_refund.html',
- 'thing' => 'refund',
- 'amount_field' => 'refund',
- 'name_singular' => 'refund',
- 'name_verb' => 'refunded',
+ 'thing' => 'refund',
+ 'amount_field' => 'refund',
+ 'name_singular' => 'refund',
+ 'name_verb' => 'refunded',
)
+ include( 'elements/cust_pay_or_refund.html',
+ 'thing' => 'pay_pending',
+ 'amount_field' => 'paid',
+ 'name_singular' => 'pending payment',
+ 'name_verb' => 'pending',
+ 'disable_link' => 1,
+ 'disable_by' => 1,
+ 'html_init' => '',
+ 'addl_header' => [],
+ 'addl_fields' => [],
+ 'redirect_empty' => $redirect_empty,
+ )
+
</%doc>
<% include( 'search.html',
- 'title' => $title,
- 'name_singular' => $name_singular,
- 'query' => $sql_query,
- 'count_query' => $count_query,
- 'count_addl' => [ '$%.2f total '.$opt{name_verb}, ],
- 'header' => [ "\u$name_singular",
- 'Amount',
- 'Date',
- 'By',
- FS::UI::Web::cust_header(),
- ],
- 'fields' => [
+ 'title' => $title,
+ 'name_singular' => $name_singular,
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'count_addl' => [ '$%.2f total '.$opt{name_verb}, ],
+ 'redirect_empty' => $opt{'redirect_empty'},
+ 'header' => [ "\u$name_singular",
+ 'Amount',
+ 'Date',
+ @header,
+ FS::UI::Web::cust_header(),
+ ],
+ 'fields' => [
'payby_payinfo_pretty',
sub { sprintf('$%.2f', shift->$amount_field() ) },
sub { time2str('%b %d %Y', shift->_date ) },
- sub { my $o = shift->otaker;
- $o = 'auto billing' if $o eq 'fs_daily';
- $o = 'customer self-service' if $o eq 'fs_selfservice';
- $o;
- },
+ @fields,
\&FS::UI::Web::cust_fields,
],
#'align' => 'lrrrll',
- 'align' => 'rrrc'.FS::UI::Web::cust_aligns(),
+ 'align' => 'rrr'.
+ join('', map 'c', @fields ).
+ FS::UI::Web::cust_aligns(),
'links' => [
$link,
$link,
$link,
- '',
+ ( map '', @fields ),
( map { $_ ne 'Cust. Status' ? $cust_link : '' }
FS::UI::Web::cust_header()
),
'',
'',
'',
- '',
+ ( map '', @fields ),
FS::UI::Web::cust_colors(),
],
'style' => [
'',
'',
'',
- '',
+ ( map '', @fields ),
FS::UI::Web::cust_styles(),
],
)
my %opt = @_;
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
+ unless $curuser->access_right('Financial reports');
my $thing = $opt{'thing'};
my $amount_field = $opt{'amount_field'};
my $name_singular = $opt{'name_singular'};
my $title = "\u$name_singular Search Results";
+
+my @header = ();
+my @fields = ();
+unless ( $opt{'disable_by'} ) {
+ push @header, 'By';
+ push @fields, sub { my $o = shift->otaker;
+ $o = 'auto billing' if $o eq 'fs_daily';
+ $o = 'customer self-service' if $o eq 'fs_selfservice';
+ $o;
+ };
+}
+
+push @header, @{ $opt{'addl_header'} }
+ if $opt{'addl_header'};
+push @fields, @{ $opt{'addl_fields'} }
+ if $opt{'addl_fields'};
+
my( $count_query, $sql_query );
if ( $cgi->param('magic') ) {
my $orderby;
if ( $cgi->param('magic') eq '_date' ) {
-
if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) {
push @search, "agentnum = $1"; # $search{'agentnum'} = $1;
my $agent = qsearchs('agent', { 'agentnum' => $1 } );
die "unknown agentnum $1" unless $agent;
$title = $agent->agent. " $title";
}
-
+
+ if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+ push @search, "custnum = $1";
+ }
+
if ( $cgi->param('payby') ) {
$cgi->param('payby') =~
/^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/
push @search, "cust_$thing.payinfo = '$1'";
}
+ if ( $cgi->param('otaker') =~ /^(\w+)$/ ) {
+ push @search, "cust_$thing.otaker = '$1'";
+ }
+
+ #for cust_pay_pending... statusNOT=done
+ if ( $cgi->param('statusNOT') =~ /^(\w+)$/ ) {
+ push @search, "status != '$1'";
+ }
+
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
push @search, "_date >= $beginning ",
"_date <= $ending";
+ if ( $thing eq 'pay_void' ) {
+ my($v_beginning, $v_ending) =
+ FS::UI::Web::parse_beginning_ending($cgi, 'void');
+ push @search, "void_date >= $v_beginning ",
+ "void_date <= $v_ending";
+ }
+
push @search, FS::UI::Web::parse_lt_gt($cgi, $amount_field );
$orderby = '_date';
}
#here is the agent virtualization
- push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
+ push @search, $curuser->agentnums_sql;
my $search = ' WHERE '. join(' AND ', @search);
$count_query = "SELECT COUNT(*), SUM($amount_field) FROM cust_$thing".
" WHERE payinfo = '$payinfo' AND payby = '$payby'".
- " AND ". $FS::CurrentUser::CurrentUser->agentnums_sql;
+ " AND ". $curuser->agentnums_sql;
$sql_query = {
'table' => "cust_$thing",
'hashref' => { 'payinfo' => $payinfo,
'payby' => $payby },
- 'extra_sql' => $FS::CurrentUser::CurrentUser->agentnums_sql.
+ 'extra_sql' => $curuser->agentnums_sql.
" ORDER BY _date",
};
}
my $link = '';
-if ( $thing eq 'pay' ) { #XXX no refund receipts yet
- $link = [ "${p}view/cust_pay.html?paynum=", 'paynum' ]
- if $FS::CurrentUser::CurrentUser->access_right('View invoices'); #XXX for now
- #later# if $FS::CurrentUser::CurrentUser->access_right('View customer payments');
+if ( ( $curuser->access_right('View invoices') #XXX for now
+ || $curuser->access_right('View customer payments')
+ )
+ && ! $opt{'disable_link'}
+ )
+{
+ my $key = $thing eq 'pay_void' ? 'paynum' : $thing.'num';
+ my $q = ( $thing eq 'pay_void' ? 'void=1;' : '' ). "$key=";
+ $link = [ "${p}view/cust_$thing.html?$q", $key ]
}
my $cust_link = sub {