invoice_sections_with_taxes per-agent, RT#79636
[freeside.git] / httemplate / elements / bill.html
index 335779a..6ba8b7e 100644 (file)
@@ -1,15 +1,14 @@
 <%doc>
+
 Clickable link to bill a customer.
 
 Example:
-<FORM name="MyForm">
 <% include( '/elements/bill.html',
             ###
             # required
             ###
             custnum   => $custnum,
             label     => 'Bill Now!',
-            formname  => 'MyForm',
 
             ###
             # recommended
@@ -20,30 +19,38 @@ Example:
             # 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
 ) %>
-</FORM>
+
 </%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 },
-          $key,
+          \%args,
+          $formname, # use it as 'key'
 ) %>
-<A HREF="javascript:void(0);" onclick="javascript:<%$key%>process();"><%$label%></A>
+<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'};
-my $formname  = $opt{'formname'};
-my $key       = $formname.'bill'.$custnum;
-my $url       = $opt{'url'} || '';
-my $message   = $opt{'message'} || 'Finished!';
+# 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',random_id(4)).$custnum;
 my $bill_opts = $opt{'bill_opts'} || {};
 my @opt_keys  = keys(%$bill_opts);
 my @opt_vals  = values(%$bill_opts);
+
+my %args = ( 'message' => $opt{'message'} || mt('Customer billed') );
+$args{url} = $opt{url} if $opt{url};
+
 </%init>