5 include( '/elements/tr-select-payment_options.html',
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' =>
17 ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
20 'surcharge_flatfee' =>
22 ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
29 <TR STYLE="display:block">
30 <TH ALIGN="right"><% mt('Payment options') |h %></TH>
33 ID = "<% $opt{prefix} %>payment_option"
34 NAME = "<% $opt{prefix} %>payment_option"
35 onChange = "<% $opt{prefix} %>payment_option_changed(this)"
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="specific">Pay specific amount</OPTION>
46 <& /elements/tr-select-invoice.html,
47 'custnum' => $opt{custnum},
48 'prefix' => $opt{prefix},
51 <& /elements/tr-amount_fee.html,
52 'row_style' => 'STYLE="display:none;"',
56 <SCRIPT TYPE="text/javascript">
58 function <% $opt{prefix} %>payment_option_changed(what) {
61 if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_percentage')) {
62 surcharge = (+what.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value;
64 else { surcharge = 0; }
65 var amount = +what.value + +surcharge;
66 document.getElementById('amount').disabled = true;
68 if ( what.value == 'select' ) {
69 document.getElementById('payment_amount_row').style.display = 'none';
70 document.getElementById('invoice_row').style.display = 'none';
71 document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
72 document.getElementById('amount').value = '';
74 else if ( what.value == 'invoice' ) {
75 document.getElementById('payment_amount_row').style.display = 'none';
76 document.getElementById('invoice_row').style.display = 'block';
77 document.getElementById('amount').value = '';
79 else if ( what.value == 'specific' ) {
80 document.getElementById('payment_amount_row').style.display = 'block';
81 document.getElementById('invoice_row').style.display = 'none';
82 document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
83 document.getElementById('amount').value = '0.00';
84 document.getElementById('amount').disabled = false;
85 if (document.getElementById('ajax_surcharge_cell')) {
86 document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>0.00 is included in this payment</FONT>';
90 document.getElementById('payment_amount_row').style.display = 'block';
91 document.getElementById('invoice_row').style.display = 'none';
92 document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
93 document.getElementById('amount').value = amount.toFixed(2);
94 if (document.getElementById('ajax_surcharge_cell')) {
95 document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>';
101 function <% $opt{prefix} %>invoice_select_changed(what) {
104 if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_percentage')) {
105 surcharge = (+what.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value;
107 else { surcharge = 0; }
108 var amount = +what.value + +surcharge;
110 if ( what.value == 'select' ) {
111 alert("we have select");
112 document.getElementById('payment_amount_row').style.display = 'none';
113 document.getElementById('amount').value = '';
116 document.getElementById('payment_amount_row').style.display = 'block';
117 document.getElementById('amount').value = amount.toFixed(2);
118 if (document.getElementById('ajax_surcharge_cell')) {
119 document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>';
131 my $conf = new FS::Conf;
132 my $money_char = $conf->config('money_char') || '$';