1 <% include("/elements/header-popup.html", 'One-time charge entry', '',
2 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
5 % if ( $cgi->param('error') ) {
7 <FONT SIZE="+1" COLOR="#ff0000"><% $cgi->param('error') %></FONT><BR><BR>
10 <SCRIPT TYPE="text/javascript">
12 function enable_quick_charge () {
13 if ( document.QuickChargeForm.amount.value
14 && document.QuickChargeForm.pkg.value ) {
15 document.QuickChargeForm.submit.disabled = false;
17 document.QuickChargeForm.submit.disabled = true;
21 function enable_quick_charge_desc () {
22 if ( document.QuickChargeForm.amount.value ) {
23 document.QuickChargeForm.submit.disabled = false;
25 document.QuickChargeForm.submit.disabled = true;
29 function enable_quick_charge_amount () {
30 if ( document.QuickChargeForm.pkg.value ) {
31 document.QuickChargeForm.submit.disabled = false;
33 document.QuickChargeForm.submit.disabled = true;
37 function validate_quick_charge () {
38 var pkg = document.QuickChargeForm.pkg.value;
39 var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ ;
40 var amount = document.QuickChargeForm.amount.value;
41 var amount_regex = /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ;
44 if ( ! amount_regex.test(amount) ) {
45 alert('Illegal amount - enter an amount to charge, for example, "5" or "43" or "21.46".');
48 if ( String(pkg).length < 1 ) {
51 if ( ! pkg_regex.test(pkg) ) {
55 for (i=0; i < rownum; i++) {
56 if (! eval('pkg_regex.test(document.QuickChargeForm.description' + i + '.value)')){
66 alert('Enter a description for the one-time charge');
70 alert('Illegal description - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' );
78 <FORM ACTION="process/quick-charge.cgi" NAME="QuickChargeForm" METHOD="POST" onsubmit="document.QuickChargeForm.submit.disabled=true;return validate_quick_charge();">
80 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cgi->param('custnum') %>">
81 <TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
86 $<INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $cgi->param('amount') %>" onChange="enable_quick_charge()" on KeyPress="enable_quick_charge_amount()">
89 <% include('/elements/select-taxclass.html') %>
94 <INPUT TYPE="text" NAME="pkg" SIZE="60" MAXLENGTH="65" VALUE="<% $cgi->param('pkg') %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_desc()">
98 % if ( $cgi->param('error') ) {
99 % my $param = $cgi->Vars;
101 % for ( $row = 0; exists($param->{"description$row"}); $row++ ) {
106 <INPUT TYPE="text" NAME="description<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $param->{"description$row"} %>" rownum="<% $row %>" onkeyup = "possiblyAddRow;" >
116 <INPUT TYPE="submit" NAME="submit" VALUE="Add one-time charge" DISABLED>
121 <SCRIPT TYPE="text/javascript">
123 var rownum = <% $row %>;
125 function possiblyAddRow() {
126 if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
133 var table = document.getElementById('QuickChargeTable');
134 var tablebody = table.getElementsByTagName('tbody').item(0);
136 var row = document.createElement('TR');
138 var empty_cell = document.createElement('TD');
139 row.appendChild(empty_cell);
141 var description_cell = document.createElement('TD');
143 var description_input = document.createElement('INPUT');
144 description_input.setAttribute('name', 'description'+rownum);
145 description_input.setAttribute('id', 'description'+rownum);
146 description_input.setAttribute('size', 60);
147 description_input.setAttribute('maxlength', 65);
148 description_input.setAttribute('rownum', rownum);
149 description_input.onkeyup = possiblyAddRow;
150 description_cell.appendChild(description_input);
152 row.appendChild(description_cell);
154 tablebody.appendChild(row);