diff options
Diffstat (limited to 'httemplate/elements/bill.html')
-rw-r--r-- | httemplate/elements/bill.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/httemplate/elements/bill.html b/httemplate/elements/bill.html new file mode 100644 index 0000000..64a1a6d --- /dev/null +++ b/httemplate/elements/bill.html @@ -0,0 +1,55 @@ +<%doc> + +Clickable link to bill a customer. + +Example: +<% include( '/elements/bill.html', + ### + # required + ### + custnum => $custnum, + label => 'Bill Now!', + + ### + # recommended + ### + url => $p.'view/cust_main.cgi?'.$custnum, + + ### + # optional, can contain any FS::cust_main::bill_and_collect options + ### + bill_opts => { 'batch_card' => 'yes' }, + formname => 'MyBillNowLink', # if for some reason you want this +) %> + +</%doc> +<FORM NAME="<%$formname%>" STYLE="display:inline"> +<% include('/elements/progress-init.html', + $formname, + [ 'custnum', @opt_keys ], + $p.'misc/bill.cgi', + $url ? { url => $url } : { message => $message }, + $formname, # use it as 'key' +) %> +<A HREF="javascript:void(0);" onclick="javascript:<%$formname%>process();"><%$label%></A> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<%$custnum%>"> +% foreach(@opt_keys) { +<INPUT TYPE="hidden" NAME="<%$_%>" VALUE="<%$bill_opts->{$_}%>"> +% } +</FORM> +<%init> + +my %opt = @_; +my $custnum = $opt{'custnum'}; +my $label = $opt{'label'}; +# formname no longer needs to be passed from outside, but we still +# need one and it needs to be unique +my $formname = $opt{'formname'} || + 'bill'.sprintf('%04d',int(rand(10000))).$custnum; +my $url = $opt{'url'} || ''; +my $message = $opt{'message'} || 'Finished!'; +my $bill_opts = $opt{'bill_opts'} || {}; +my @opt_keys = keys(%$bill_opts); +my @opt_vals = values(%$bill_opts); + +</%init> |