1 <% include('/elements/header-popup.html', 'Tax adjustment' ) %>
3 <% include('/elements/error.html') %>
5 <SCRIPT TYPE="text/javascript">
7 function enable_tax_adjustment () {
8 if ( document.TaxAdjustmentForm.amount.value
9 && document.TaxAdjustmentForm.taxname.selectedIndex > 0 ) {
10 document.TaxAdjustmentForm.submit.disabled = false;
12 document.TaxAdjustmentForm.submit.disabled = true;
16 function validate_tax_adjustment () {
17 var comment = document.TaxAdjustmentForm.comment.value;
18 var comment_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ ;
19 var amount = document.TaxAdjustmentForm.amount.value;
20 var amount_regex = /^\s*\$?\s*(\d*(\.?\d{1,2}))\s*$/ ;
23 if ( ! amount_regex.test(amount) ) {
24 alert('Illegal amount - enter the amount of the tax adjustment, for example, "5" or "43" or "21.46".');
27 if ( ! comment_regex.test(comment) ) {
28 alert('Illegal comment - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' );
37 <FORM ACTION="process/cust_tax_adjustment.html" NAME="TaxAdjustmentForm" ID="TaxAdjustmentForm" METHOD="POST" onsubmit="document.TaxAdjustmentForm.submit.disabled=true;return validate_tax_adjustment();">
39 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
41 <TABLE ID="TaxAdjustmentTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc">
44 <TD ALIGN="right">Tax </TD>
46 <SELECT NAME="taxname" ID="taxname" onChange="enable_tax_adjustment()" onKeyPress="enable_tax_adjustment()">
47 <OPTION VALUE=""></OPTION>
48 % foreach my $taxname (@taxname) {
49 <OPTION VALUE="<% $taxname %>"><% $taxname %></OPTION>
56 <TD ALIGN="right">Amount </TD>
58 $<INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $amount %>" onChange="enable_tax_adjustment()" onKeyPress="enable_tax_adjustment()">
63 <TD ALIGN="right">Comment </TD>
65 <INPUT TYPE="text" NAME="comment" SIZE="50" MAXLENGTH="50" VALUE="<% $comment %>" onChange="enable_tax_adjustment()" onKeyPress="enable_tax_adjustment()">
72 <INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="Add tax adjustment" <% $cgi->param('error') ? '' :' DISABLED' %>>
81 unless $FS::CurrentUser::CurrentUser->access_right('Add customer tax adjustment');
83 my $sql = 'SELECT DISTINCT(taxname) FROM cust_main_county';
84 my $sth = dbh->prepare($sql) or die dbh->errstr;
85 $sth->execute() or die $sth->errstr;
86 my @taxname = map { $_->[0] || 'Tax' } @{ $sth->fetchall_arrayref([]) };
88 my $conf = new FS::Conf;
90 $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
94 if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) {
98 $cgi->param('comment') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/
99 or die 'illegal description';