X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pay.cgi;h=5d74365e7223bc418034230cfe0a3afe15501edb;hb=e80770898cc86365b335845dd1a02b4d82bd7e40;hp=d1823d4b306ea5e72ad99e0dc4c8559f585b2e2f;hpb=3d671921441ba8422650b54435a1959ad1d4c71d;p=freeside.git diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index d1823d4b3..5d74365e7 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,69 +1,182 @@ -<% -# +% if ( $link eq 'popup' ) { + <& /elements/header-popup.html, $title &> +% } else { + <& /elements/header.html, $title, '' &> +% } -use strict; -use vars qw( $cgi $invnum $p1 $_date $payby $payinfo $paid ); -use Date::Format; -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl); +<& /elements/init_calendar.html &> -$cgi = new CGI; -cgisuidsetup($cgi); +<& /elements/error.html &> -if ( $cgi->param('error') ) { - $invnum = $cgi->param('invnum'); - $paid = $cgi->param('paid'); - $payby = $cgi->param('payby'); - $payinfo = $cgi->param('payinfo'); -} else { - my ($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $invnum = $1; - $paid = ''; - $payby = "BILL"; - $payinfo = ""; -} -$_date = time; +% unless ( $link eq 'popup' ) { + <% small_custview($custnum, $conf->config('countrydefault')) %> +% } -$p1 = popurl(1); -print $cgi->header( '-expires' => 'now' ), header("Enter payment", ''); +
+ + + + -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); +
-print < -
-END
+<% mt('Payment') |h %> 
+<% ntable("#cccccc", 2) %>
+
+% my %date_args = (
+%   'name'    =>  '_date',
+%   'label'   => emt('Date'),
+%   'value'   => $_date,
+%   'format'  => $date_format. ' %r',
+%   'colspan' => 2,
+% );
+% if ( $FS::CurrentUser::CurrentUser->access_right('Backdate payment') ) {
+
+  <& /elements/tr-input-date-field.html, \%date_args &>
+
+% } else {
+
+  <& /elements/tr-fixed-date.html, \%date_args &>
+
+% }
+
+
+  <% mt('Amount') |h %>
+  <% $money_char |h %> <% mt('by') |h %> <% mt(FS::payby->payname($payby)) |h %>
+
+
+% if ( $conf->exists('part_pkg-term_discounts') ) {
+    <& /elements/tr-select-discount_term.html,
+         'custnum'   => $custnum,
+         'amount_id' => 'paid',
+    &>
+% }
+
+% if ( $payby eq 'BILL' ) { 
+  
+    <% mt('Check #') |h %>
+    
+  
+% }
+% elsif ( $payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) {
+  
+    <% mt('Bank') |h %>
+    
+  
+  
+    <% mt('Check #') |h %>
+    
+  
+  
+    <% mt('Teller #') |h %>
+    
+  
+  
+    <% mt('Depositor') |h %>
+    
+  
+  
+    <% mt('Account #') |h %>
+    
+  
+% }
+
+
+% if ( $link eq 'custnum' || $link eq 'popup' ) { 
+
+  <% mt('Auto-apply to invoices') |h %>
+  
+    
+  
+
+% } elsif ( $link eq 'invnum' ) { 
+
+  <% mt('Apply to') |h %>
+  Invoice #<% $linknum %> only
+  
+
+% } 
+
+
+% if ( $conf->exists('pkg-balances') ) {
+  <& /elements/tr-select-cust_pkg-balances.html,
+               'custnum' => $custnum,
+               'cgi'     => $cgi
+  &>
+% } else {
+  
+% }
+
+
 
-print qq!Invoice #$invnum!;
+
+ -print qq!
Date: !, time2str("%D",$_date), qq!!; + -print qq!
Amount \$!; +% if ( $link eq 'popup' ) { + + +% } else { + <& /elements/footer.html &> +% } -print qq!
Payby: $payby!; +<%init> -#payinfo (check # now as payby="BILL" hardcoded.. what to do later?) -print qq!
Check #!; +my $conf = new FS::Conf; -#paybatch -print qq!!; +my $money_char = $conf->config('money_char') || '$'; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; -print < -
- -END +my($link, $linknum, $paid, $payby, $payinfo, $_date); +if ( $cgi->param('error') ) { + $link = $cgi->param('link'); + $linknum = $cgi->param('linknum'); + $paid = $cgi->param('paid'); + $payby = $cgi->param('payby'); + $payinfo = $cgi->param('payinfo'); + $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time; +} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { + $link = $cgi->param('popup') ? 'popup' : 'custnum'; + $linknum = $1; + $paid = ''; + $payby = $cgi->param('payby') || 'BILL'; + $payinfo = ''; + $_date = time; +} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { + $link = 'invnum'; + $linknum = $1; + $paid = ''; + $payby = $cgi->param('payby') || 'BILL'; + $payinfo = ""; + $_date = time; +} else { + die "illegal query ". $cgi->keywords; +} + +my @rights = ('Post payment'); +push @rights, 'Post check payment' if $payby eq 'BILL'; +push @rights, 'Post cash payment' if $payby eq 'CASH'; -print <access_right(\@rights); - - - -END +my $paybatch = "webui-$_date-$$-". rand() * 2**32; + +my $title = mt('Post '. FS::payby->payname($payby). ' payment'); +$title .= mt(" against Invoice #[_1]",$linknum) if $link eq 'invnum'; + +my $custnum; +if ( $link eq 'invnum' ) { + my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } ) + or die "unknown invnum $linknum"; + $custnum = $cust_bill->custnum; +} elsif ( $link eq 'custnum' || $link eq 'popup' ) { + $custnum = $linknum; +} -%> +