RT# 34134 - added documentation for new feature
[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   )
21
22 </%doc>
23
24   <TR STYLE="display:block">
25     <TH ALIGN="right"><% mt('Payment options') |h %></TH>
26     <TD COLSPAN=7>
27      <SELECT
28           ID       = "<% $opt{prefix} %>payment_option"
29           NAME     = "<% $opt{prefix} %>payment_option"
30           onChange = "<% $opt{prefix} %>payment_option_changed(this)"
31           <% $opt{disabled} %>
32         >
33                 <OPTION VALUE="select">Select payment option</OPTION>
34                 <OPTION VALUE="<% $opt{amount} %>">Pay full balance</OPTION>
35                 <OPTION VALUE="invoice">Pay specific invoice</OPTION>
36                 <OPTION VALUE="">Pay specific amount</OPTION>
37         </SELECT>       
38     </TD>
39   </TR>
40
41   <& /elements/tr-select-invoice.html,
42        'custnum' => $opt{custnum},
43        'prefix'  => $opt{prefix},
44   &>
45
46   <& /elements/tr-amount_fee.html,
47        %opt
48   &>
49
50   <SCRIPT TYPE="text/javascript">
51
52       function <% $opt{prefix} %>payment_option_changed(what) {
53
54         if ( what.value == 'select' ) {
55                 document.getElementById('payment_amount_row').style.display = 'none';
56                 document.getElementById('invoice_row').style.display = 'none';
57           document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
58                 document.getElementById('amount').value = '';
59         }
60         else if ( what.value == 'invoice' ) {
61                 document.getElementById('payment_amount_row').style.display = 'none';
62                 document.getElementById('invoice_row').style.display = 'block';
63                 document.getElementById('amount').value = '';
64         }
65         else {
66                 document.getElementById('payment_amount_row').style.display = 'block';
67                 document.getElementById('invoice_row').style.display = 'none';
68           document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
69                 document.getElementById('amount').value = what.value;
70         }
71
72       }
73
74       function <% $opt{prefix} %>invoice_select_changed(what) {
75
76         if ( what.value == 'select' ) {
77                 document.getElementById('payment_amount_row').style.display = 'none';
78                 document.getElementById('amount').value = '';
79         }
80         else {
81                 document.getElementById('payment_amount_row').style.display = 'block';
82                 document.getElementById('amount').value = what.value;
83         }
84
85       }
86
87 </SCRIPT>
88
89 <%init>
90
91 my %opt = @_;
92
93 </%init>