RT# 34134 - fixed error where payment amount field is hidden in self service.
[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        'row_style'  => 'STYLE="display:none;"',
48        %opt
49   &>
50
51   <SCRIPT TYPE="text/javascript">
52
53       function <% $opt{prefix} %>payment_option_changed(what) {
54
55         if ( what.value == 'select' ) {
56                 document.getElementById('payment_amount_row').style.display = 'none';
57                 document.getElementById('invoice_row').style.display = 'none';
58           document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
59                 document.getElementById('amount').value = '';
60         }
61         else if ( what.value == 'invoice' ) {
62                 document.getElementById('payment_amount_row').style.display = 'none';
63                 document.getElementById('invoice_row').style.display = 'block';
64                 document.getElementById('amount').value = '';
65         }
66         else {
67                 document.getElementById('payment_amount_row').style.display = 'block';
68                 document.getElementById('invoice_row').style.display = 'none';
69           document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
70                 document.getElementById('amount').value = what.value;
71         }
72
73       }
74
75       function <% $opt{prefix} %>invoice_select_changed(what) {
76
77         if ( what.value == 'select' ) {
78                 document.getElementById('payment_amount_row').style.display = 'none';
79                 document.getElementById('amount').value = '';
80         }
81         else {
82                 document.getElementById('payment_amount_row').style.display = 'block';
83                 document.getElementById('amount').value = what.value;
84         }
85
86       }
87
88 </SCRIPT>
89
90 <%init>
91
92 my %opt = @_;
93
94 </%init>