X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pay.cgi;h=116eeebd651f739c3d805a3b6b625c972b1df687;hp=7f70802c3b375b7449270f2f6bbc23a6098179ee;hb=5f563d5ac7e6e1e93cca382baa42ee106f3db5a0;hpb=d0f483f47168e01eb6c28e8fc99a62050b245132 diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index 7f70802c3..116eeebd6 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,133 +1,182 @@ -<% -# - -use strict; -use vars qw( $cgi $link $linknum $p1 $_date $payby $payinfo $paid ); -use Date::Format; -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::Conf; -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl ntable small_custview); +% if ( $link eq 'popup' ) { + <& /elements/header-popup.html, $title &> +% } else { + <& /elements/header.html, $title, '' &> +% } -my $conf = new FS::Conf; +<& /elements/init_calendar.html &> -$cgi = new CGI; -cgisuidsetup($cgi); +<& /elements/error.html &> -if ( $cgi->param('error') ) { - $link = $cgi->param('link'); - $linknum = $cgi->param('linknum'); - $paid = $cgi->param('paid'); - $payby = $cgi->param('payby'); - $payinfo = $cgi->param('payinfo'); -} elsif ($cgi->keywords) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $link = 'invnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ""; -} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $link = 'custnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ''; -} else { - die "illegal query ". $cgi->keywords; -} -$_date = time; +% unless ( $link eq 'popup' ) { + <% small_custview($custnum, $conf->config('countrydefault')) %> +% } -$p1 = popurl(1); -print header("Post 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 { + +% } -my $custnum; -if ( $link eq 'invnum' ) { + - my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } ) - or die "unknown invnum $linknum"; - print "Invoice #$linknum". ntable("#cccccc",2). - 'Date'. - time2str("%D", $cust_bill->_date). ''. - 'Items'; - foreach ( $cust_bill->cust_bill_pkg ) { #false laziness with FS::cust_bill - if ( $_->pkgnum ) { - - my($cust_pkg)=qsearchs('cust_pkg', { 'pkgnum', $_->pkgnum } ); - my($part_pkg)=qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->pkgpart}); - my($pkg)=$part_pkg->pkg; - - if ( $_->setup != 0 ) { - print "$pkg Setup
"; # $money_char. sprintf("%10.2f",$_->setup); - print join('
', - map { " ". $_->[0]. ": ". $_->[1] } $cust_pkg->labels - ). '
'; - } - - if ( $_->recur != 0 ) { - print - "$pkg (" . time2str("%x",$_->sdate) . " - " . - time2str("%x",$_->edate) . ")
"; - #$money_char. sprintf("%10.2f",$_->recur) - print join('
', - map { '--->'. $_->[0]. ": ". $_->[1] } $cust_pkg->labels - ). '
'; - } - - } else { #pkgnum Tax - print "Tax
" # $money_char. sprintf("%10.2f",$_->setup) - if $_->setup != 0; - } - - } - print ''; +
+ - $custnum = $cust_bill->custnum; + -} elsif ( $link eq 'custnum' ) { - $custnum = $linknum; -} +% if ( $link eq 'popup' ) { + + +% } else { + <& /elements/footer.html &> +% } -print small_custview($custnum, $conf->config('countrydefault')); +<%init> -print qq!!; -print qq!!; +my $conf = new FS::Conf; -print '

Payment'. ntable("#cccccc", 2). - 'Date'. - time2str("%D",$_date). ''; +my $money_char = $conf->config('money_char') || '$'; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; -print qq!Amount\$!; +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; +} -print qq!Payby$payby!; +my @rights = ('Post payment'); +push @rights, 'Post check payment' if $payby eq 'BILL'; +push @rights, 'Post cash payment' if $payby eq 'CASH'; -#payinfo (check # now as payby="BILL" hardcoded.. what to do later?) -print qq!Check #!; +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right(\@rights); -print qq!Auto-apply
to invoices!; +my $paybatch = "webui-$_date-$$-". rand() * 2**32; -#paybatch -print qq!!; +my $title = mt('Post '. FS::payby->payname($payby). ' payment'); +$title .= mt(" against Invoice #[_1]",$linknum) if $link eq 'invnum'; -print < -
- - - - -END +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; +} -%> +