RT# 79737 - Added ability to us a cc surcharge of a flat fee.
[freeside.git] / httemplate / elements / tr-select-payment_options.html
1 <%doc>
2
3 Example:
4
5   include( '/elements/tr-select-payment_options.html',
6
7     #opt - most get used in /elements/tr-amount-fee
8     'custnum'              => 4,     # customer number needed for selecting invoices
9     'prefix'               => 'pre', # prefix to fields and row ID's
10     'amount'               => 1,     # payment amount
11     'process-pkgpart'      => scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
12     'process-display'      => scalar($conf->config('manual_process-display')),
13     'process-skip_first'   => $conf->exists('manual_process-skip_first'),
14     'num_payments'         => scalar($cust_main->cust_pay),
15     'surcharge_percentage' =>
16       ( $payby eq 'CARD'
17           ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
18           : 0
19       ),
20     'surcharge_flatfee' =>
21       ( $payby eq 'CARD'
22           ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
23           : 0
24       ),
25   )
26
27 </%doc>
28
29   <TR STYLE="display:block">
30     <TH ALIGN="right"><% mt('Payment options') |h %></TH>
31     <TD COLSPAN=7>
32      <SELECT
33           ID       = "<% $opt{prefix} %>payment_option"
34           NAME     = "<% $opt{prefix} %>payment_option"
35           onChange = "<% $opt{prefix} %>payment_option_changed(this)"
36           <% $opt{disabled} %>
37         >
38                 <OPTION VALUE="select">Select payment option</OPTION>
39                 <OPTION VALUE="<% $opt{amount} %>">Pay full balance</OPTION>
40                 <OPTION VALUE="invoice">Pay specific invoice</OPTION>
41                 <OPTION VALUE="">Pay specific amount</OPTION>
42         </SELECT>       
43     </TD>
44   </TR>
45
46   <& /elements/tr-select-invoice.html,
47        'custnum' => $opt{custnum},
48        'prefix'  => $opt{prefix},
49   &>
50
51   <& /elements/tr-amount_fee.html,
52        'row_style'  => 'STYLE="display:none;"',
53        %opt
54   &>
55
56   <SCRIPT TYPE="text/javascript">
57
58       function <% $opt{prefix} %>payment_option_changed(what) {
59
60         if ( what.value == 'select' ) {
61                 document.getElementById('payment_amount_row').style.display = 'none';
62                 document.getElementById('invoice_row').style.display = 'none';
63           document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
64                 document.getElementById('amount').value = '';
65         }
66         else if ( what.value == 'invoice' ) {
67                 document.getElementById('payment_amount_row').style.display = 'none';
68                 document.getElementById('invoice_row').style.display = 'block';
69                 document.getElementById('amount').value = '';
70         }
71         else {
72                 document.getElementById('payment_amount_row').style.display = 'block';
73                 document.getElementById('invoice_row').style.display = 'none';
74           document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
75                 document.getElementById('amount').value = what.value;
76         }
77
78       }
79
80       function <% $opt{prefix} %>invoice_select_changed(what) {
81
82         if ( what.value == 'select' ) {
83                 document.getElementById('payment_amount_row').style.display = 'none';
84                 document.getElementById('amount').value = '';
85         }
86         else {
87                 document.getElementById('payment_amount_row').style.display = 'block';
88                 document.getElementById('amount').value = what.value;
89         }
90
91       }
92
93 </SCRIPT>
94
95 <%init>
96
97 my %opt = @_;
98
99 </%init>