summaryrefslogtreecommitdiff
path: root/httemplate/elements/bill.html
blob: 64a1a6d2cc56367686a85818890a198a49e94365 (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
<%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>