summaryrefslogtreecommitdiff
path: root/httemplate/elements/bill.html
blob: 6ba8b7e60d8d19ff2d1ab279500bf5e41609f68e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<%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',
          \%args,
          $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',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>