v4 style
[freeside.git] / httemplate / elements / bill.html
1 <%doc>
2
3 Clickable link to bill a customer.
4
5 Example:
6 <% include( '/elements/bill.html',
7             ###
8             # required
9             ###
10             custnum   => $custnum,
11             label     => 'Bill Now!',
12
13             ###
14             # recommended
15             ###
16             url       => $p.'view/cust_main.cgi?'.$custnum,
17
18             ###
19             # optional, can contain any FS::cust_main::bill_and_collect options
20             ###
21             bill_opts => { 'batch_card' => 'yes' },
22             formname  => 'MyBillNowLink', # if for some reason you want this
23 ) %>
24
25 </%doc>
26 <FORM NAME="<%$formname%>" STYLE="display:inline">
27 <% include('/elements/progress-init.html',
28           $formname,
29           [ 'custnum', @opt_keys ],
30           $p.'misc/bill.cgi',
31           \%args,
32           $formname, # use it as 'key'
33 ) %>
34 <A HREF="javascript:void(0);" onclick="javascript:<%$formname%>process();"><%$label%></A>
35 <INPUT TYPE="hidden" NAME="custnum" VALUE="<%$custnum%>">
36 % foreach(@opt_keys) {
37 <INPUT TYPE="hidden" NAME="<%$_%>" VALUE="<%$bill_opts->{$_}%>">
38 % }
39 </FORM>
40 <%init>
41
42 my %opt = @_;
43 my $custnum   = $opt{'custnum'};
44 my $label     = $opt{'label'};
45 # formname no longer needs to be passed from outside, but we still 
46 # need one and it needs to be unique
47 my $formname  = $opt{'formname'} ||
48                 'bill'.sprintf('%04d',random_id(4)).$custnum;
49 my $bill_opts = $opt{'bill_opts'} || {};
50 my @opt_keys  = keys(%$bill_opts);
51 my @opt_vals  = values(%$bill_opts);
52
53 my %args = ( 'message' => $opt{'message'} || mt('Customer billed') );
54 $args{url} = $opt{url} if $opt{url};
55
56 </%init>