diff options
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/edit/part_bill_event.cgi | 13 | ||||
-rw-r--r-- | httemplate/elements/menu.html | 13 | ||||
-rwxr-xr-x | httemplate/search/cust_pay_batch.cgi | 88 | ||||
-rw-r--r-- | httemplate/search/elements/search.html | 23 | ||||
-rwxr-xr-x | httemplate/search/pay_batch.cgi | 128 |
5 files changed, 171 insertions, 94 deletions
diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index 243975558..da11fc774 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -215,16 +215,17 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %> % }, % % 'batch-card' => { -% 'name' => 'Add card to the pending credit card batch', +% 'name' => 'Add card or check to a pending batch', % 'code' => '$cust_bill->batch_card(%options);', % 'weight' => 40, % }, % -% 'retriable' => { -% 'name' => 'Mark batched card event as retriable', -% 'code' => '$cust_pay_batch->retriable();', -% 'weight' => 60, -% }, +% +% #'retriable' => { +% # 'name' => 'Mark batched card event as retriable', +% # 'code' => '$cust_pay_batch->retriable();', +% # 'weight' => 60, +% #}, % % 'send' => { % 'name' => 'Send invoice (email/print/fax)', diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 65907339a..14c471d58 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -157,10 +157,13 @@ tie my %report_financial, 'Tie::IxHash', 'Sales, Credits and Receipts' => [ $fsurl.'graph/report_money_time.html', 'Sales, credits and receipts summary graph' ], 'Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg.html', 'Sales report and graph (by agent, package class and/or date range)' ], 'Credit Report' => [ $fsurl.'search/report_cust_credit.html', 'Credit report (by employee and/or date range)' ], - 'Payment Report' => [ $fsurl.'search/report_cust_pay.html', 'Credit report (by type and/or date range)' ], - 'A/R Aging' => [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ], - 'Prepaid Income' => [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue) report' ], - 'Sales Tax Liability' => [ $fsurl.'search/report_tax.html', 'Sales tax liability report' ], + 'Payment Report' => [ $fsurl.'search/report_cust_pay.html', 'Payment report (by type and/or date range)' ], +; +$report_financial{'Payment Batch Report'} = [ $fsurl.'search/pay_batch.html', 'Payment batches (by status and/or date range)' ] + if $conf->exists('batch-enable'); +$report_financial{'A/R Aging'} = [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ]; +$report_financial{'Prepaid Income'} = [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue) report' ]; +$report_financial{'Sales Tax Liability'} = [ $fsurl.'search/report_tax.html', 'Sales tax liability report' ]; ; tie my %report_menu, 'Tie::IxHash'; @@ -197,6 +200,8 @@ tie my %tools_exporting, 'Tie::IxHash', tie my %tools_menu, 'Tie::IxHash', (); $tools_menu{'Quick payment entry'} = [ $fsurl.'misc/batch-cust_pay.html', 'Enter multiple payments in a batch' ] if $curuser->access_right('Post payment batch'); +$tools_menu{'Process payment batches'} = [ $fsurl.'search/pay_batch.cgi?magic=_date;open=1;intransit=1', 'Process credit card and electronic check batches' ] + if $conf->exists('batch-enable') && $curuser->access_right('Process batches'); $tools_menu{'Job Queue'} = [ $fsurl.'search/queue.html', 'View pending job queue' ] if $curuser->access_right('Job queue'); $tools_menu{'Importing'} = [ \%tools_importing, 'Import tools' ] diff --git a/httemplate/search/cust_pay_batch.cgi b/httemplate/search/cust_pay_batch.cgi index 1b0bf6abf..d12e3c44f 100755 --- a/httemplate/search/cust_pay_batch.cgi +++ b/httemplate/search/cust_pay_batch.cgi @@ -1,18 +1,17 @@ -% -% -%my ($count_query, $sql_query, $batchnum); +%my( $count_query, $sql_query ); %my $hashref = {}; %my @search = (); %my $orderby = 'paybatchnum'; % +%my( $pay_batch, $batchnum ) = ( '', ''); %if ( $cgi->param('batchnum') && $cgi->param('batchnum') =~ /^(\d+)$/ ) { % push @search, "batchnum = $1"; -% my $pay_batch = qsearchs('pay_batch', { 'batchnum' => $1 } ); +% $pay_batch = qsearchs('pay_batch', { 'batchnum' => $1 } ); % die "Batch $1 not found!" unless $pay_batch; % $batchnum = $pay_batch->batchnum; %} % -%if ( $cgi->param('payby') ) { +%if ( $cgi->param('payby') ) { % $cgi->param('payby') =~ /^(CARD|CHEK)$/ % or die "illegal payby " . $cgi->param('payby'); % @@ -24,7 +23,7 @@ %} % %my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); -%unless ($batchnum){ +%unless ($pay_batch){ % push @search, "pay_batch.upload >= $beginning" if ($beginning); % push @search, "pay_batch.upload <= $ending" if ($ending < 4294967295);#2^32-1 % $orderby = "pay_batch.download,paybatchnum"; @@ -46,30 +45,55 @@ % 'LEFT JOIN pay_batch USING ( batchnum ) ' . % "$search ORDER BY $orderby"; % -%my $html_init = <<EOF; -%<FORM ACTION="$p/misc/download-batch.cgi" METHOD="POST"> -%Download batch in format <SELECT NAME="format"> -%<OPTION VALUE="">Default batch mode</OPTION> -%<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV file for TD Canada Trust Merchant PC Batch</OPTION> -%<OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION> -%<OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION> -%</SELECT><INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum"><INPUT TYPE="submit" VALUE="Download"></FORM> -%<BR><BR> -% -%<FORM ACTION="$p/misc/upload-batch.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> -%Upload results<BR> -%Filename <INPUT TYPE="file" NAME="batch_results"><BR> -%Format <SELECT NAME="format"> -%<OPTION VALUE="">Default batch mode</OPTION> -%<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV results from TD Canada Trust Merchant PC Batch</OPTION> -%<OPTION VALUE="PAP">264 byte results for TD Canada Trust PAP Batch</OPTION> -%<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION> -%</SELECT><BR> -%<INPUT TYPE="submit" VALUE="Upload"></FORM> -%<BR> -%EOF -% -%if ($batchnum) { +%my $html_init = ''; +%if ( $pay_batch ) { +% my $conf = new FS::Conf; +% my $fixed = $conf->config('batch-fixed_format-'. $pay_batch->payby); +% if ( +% $pay_batch->status eq 'O' +% || ( $pay_batch->status eq 'I' +% && $FS::CurrentUser::CurrentUser->access_right('Reprocess batches') +% ) +% ) { +% $html_init .= qq!<FORM ACTION="$p/misc/download-batch.cgi" METHOD="POST">!; +% if ( $fixed ) { +% $html_init .= qq!<INPUT TYPE="hidden" NAME="format" VALUE="$fixed">!; +% } else { +% $html_init .= qq!Download batch in format <SELECT NAME="format">!. +% qq!<OPTION VALUE="">Default batch mode</OPTION>!. +% qq!<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV file for TD Canada Trust Merchant PC Batch</OPTION>!. +% qq!<OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION>!. +% qq!<OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION>!. +% qq!</SELECT>!; +% } +% $html_init .= qq!<INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum"><INPUT TYPE="submit" VALUE="Download"></FORM><BR>!; +% } +% +% if ( +% $pay_batch->status eq 'I' +% || ( $pay_batch->status eq 'R' +% && $FS::CurrentUser::CurrentUser->access_right('Reprocess batches') +% ) +% ) { +% $html_init .= qq!<FORM ACTION="$p/misc/upload-batch.cgi" METHOD="POST" ENCTYPE="multipart/form-data">!. +% qq!Upload results<BR>!. +% qq!Filename <INPUT TYPE="file" NAME="batch_results"><BR>!; +% if ( $fixed ) { +% $html_init .= qq!<INPUT TYPE="hidden" NAME="format" VALUE="$fixed">!; +% } else { +% $html_init .= qq!Format <SELECT NAME="format">!. +% qq!<OPTION VALUE="">Default batch mode</OPTION>!. +% qq!<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV results from TD Canada Trust Merchant PC Batch</OPTION>!. +% qq!<OPTION VALUE="PAP">264 byte results for TD Canada Trust PAP Batch</OPTION>!. +% qq!<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION>!. +% qq!</SELECT><BR>!; +% } +% $html_init .= '<INPUT TYPE="submit" VALUE="Upload"></FORM><BR>'; +% } +% +%} +% +%if ($pay_batch) { % my $sth = dbh->prepare($count_query) or die dbh->errstr. "doing $count_query"; % $sth->execute or die "Error executing \"$count_query\": ". $sth->errstr; % my $cards = $sth->fetchrow_arrayref->[0]; @@ -90,7 +114,7 @@ 'menubar' => ['Main Menu' => $p,], 'query' => $sql_query, 'count_query' => $count_query, - 'html_init' => $batchnum ? $html_init : '', + 'html_init' => $pay_batch ? $html_init : '', 'header' => [ '#', 'Inv #', 'Customer', @@ -124,7 +148,7 @@ sub { shift->[7] =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; my( $mon, $year ) = ( $2, $1 ); - $mon = "0$mon" if $mon < 10; + $mon = "0$mon" if length($mon) == 1; "$mon/$year"; }, sub { diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index cbf0887a6..14e1dd095 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -4,8 +4,13 @@ % # (everything not commented required is optional) % # % # # basic options, required -% # 'title' => 'Page title', -% # 'name' => 'items', #name for the records returned +% # 'title' => 'Page title', +% # +% # 'name_singular' => 'item', #singular name for the records returned +% # #OR# # (preferred, will be pluralized automatically) +% # 'name' => 'items', #plural name for the records returned +% # # (deprecated, will be singularlized +% # # simplisticly) % # % # # some HTML callbacks... % # 'menubar' => '', #menubar arrayref @@ -282,10 +287,18 @@ % my( $url, $method ) = @$redirect; % redirect( $url. $rows->[0]->$method() ); % } else { +% if ( $opt{'name_singular'} ) { +% $opt{'name'} = PL($opt{'name_singular'}); +% } % ( my $xlsname = $opt{'name'} ) =~ s/\W//g; -% #$opt{'name'} =~ s/s$// if $total == 1; -% $opt{'name'} =~ s/((s)e)?s$/$2/ if $total == 1; #should use Lingua::bs -% # to "depluralize" +% if ( $total == 1 ) { +% if ( $opt{'name_singular'} ) { +% $opt{'name'} = $opt{'name_singular'} +% } else { +% #$opt{'name'} =~ s/s$// if $total == 1; +% $opt{'name'} =~ s/((s)e)?s$/$2/ if $total == 1; +% } +% } % % my @menubar = (); % if ( $opt{'menubar'} ) { diff --git a/httemplate/search/pay_batch.cgi b/httemplate/search/pay_batch.cgi index fcfa8bef2..7b2b9f00b 100755 --- a/httemplate/search/pay_batch.cgi +++ b/httemplate/search/pay_batch.cgi @@ -37,55 +37,89 @@ % %my $extra_sql = scalar(@where) ? 'WHERE ' . join(' AND ', @where) : ''; % +%my $link = [ "${p}search/cust_pay_batch.cgi?batchnum=", 'batchnum' ]; % <% include( 'elements/search.html', - 'title' => 'Credit Card Batches', - 'menubar' => [ 'Main Menu' => $p, ], - 'name' => 'batches', - 'query' => { 'table' => 'pay_batch', - 'hashref' => $hashref, - 'extra_sql' => "$extra_sql ORDER BY batchnum DESC", - }, - 'count_query' => "$count_query $extra_sql", - 'header' => [ 'Batch', - 'First Download', - 'Last Upload', - 'Item Count', - 'Amount', - 'Status', - ], - 'align' => 'lllrrl', - 'fields' => [ 'batchnum', - sub { - my $_date = shift->download; - $_date ? time2str("%a %b %e %T %Y", $_date) : '' - }, - sub { - my $_date = shift->upload; - $_date ? time2str("%a %b %e %T %Y", $_date) : '' - }, - sub { - my $st = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=" . shift->batchnum; - my $sth = dbh->prepare($st) - or die dbh->errstr. "doing $st"; - $sth->execute - or die "Error executing \"$st\": ". $sth->errstr; - $sth->fetchrow_arrayref->[0]; - }, - sub { - my $st = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=" . shift->batchnum; - my $sth = dbh->prepare($st) - or die dbh->errstr. "doing $st"; - $sth->execute - or die "Error executing \"$st\": ". $sth->errstr; - $sth->fetchrow_arrayref->[0]; - }, - sub { - $statusmap{shift->status}; - }, - ], - 'links' => [ [ "${p}search/cust_pay_batch.cgi?batchnum=", 'batchnum',], - ], + 'title' => 'Payment Batches', + 'name_singular' => 'batch', + 'query' => { 'table' => 'pay_batch', + 'hashref' => $hashref, + 'extra_sql' => "$extra_sql ORDER BY batchnum DESC", + }, + 'count_query' => "$count_query $extra_sql", + 'header' => [ 'Batch', + 'Type', + 'First Download', + 'Last Upload', + 'Item Count', + 'Amount', + 'Status', + ], + 'align' => 'rcllrrc', + 'fields' => [ 'batchnum', + sub { + FS::payby->shortname(shift->payby); + }, + sub { + my $self = shift; + my $_date = $self->download; + if ( $_date ) { + time2str("%a %b %e %T %Y", $_date); + } elsif ( $self->status eq 'O' ) { + 'Download batch'; + } else { + ''; + } + }, + sub { + my $self = shift; + my $_date = $self->upload; + if ( $_date ) { + time2str("%a %b %e %T %Y", $_date); + } elsif ( $self->status eq 'I' ) { + 'Upload results'; + } else { + ''; + } + }, + sub { + my $st = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=" . shift->batchnum; + my $sth = dbh->prepare($st) + or die dbh->errstr. "doing $st"; + $sth->execute + or die "Error executing \"$st\": ". $sth->errstr; + $sth->fetchrow_arrayref->[0]; + }, + sub { + my $st = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=" . shift->batchnum; + my $sth = dbh->prepare($st) + or die dbh->errstr. "doing $st"; + $sth->execute + or die "Error executing \"$st\": ". $sth->errstr; + $sth->fetchrow_arrayref->[0]; + }, + sub { + $statusmap{shift->status}; + }, + ], + 'links' => [ + $link, + '', + sub { shift->status eq 'O' ? $link : '' }, + sub { shift->status eq 'I' ? $link : '' }, + ], + 'size' => [ + '', + '', + sub { shift->status eq 'O' ? "+1" : '' }, + sub { shift->status eq 'I' ? "+1" : '' }, + ], + 'style' => [ + '', + '', + sub { shift->status eq 'O' ? "b" : '' }, + sub { shift->status eq 'I' ? "b" : '' }, + ], ) %> |