diff options
Diffstat (limited to 'httemplate/edit/quick-charge.html')
-rw-r--r-- | httemplate/edit/quick-charge.html | 294 |
1 files changed, 0 insertions, 294 deletions
diff --git a/httemplate/edit/quick-charge.html b/httemplate/edit/quick-charge.html deleted file mode 100644 index a472915a1..000000000 --- a/httemplate/edit/quick-charge.html +++ /dev/null @@ -1,294 +0,0 @@ -<% include("/elements/header-popup.html", 'One-time charge', '', - ( $cgi->param('error') ? '' : 'onload="addRow()"' ), - ) -%> - -<LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2"> -<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT> - -<% include('/elements/error.html') %> - -<SCRIPT TYPE="text/javascript"> - -function enable_quick_charge () { - if ( document.QuickChargeForm.amount.value - && document.QuickChargeForm.pkg.value ) { - document.QuickChargeForm.submit.disabled = false; - } else { - document.QuickChargeForm.submit.disabled = true; - } -} - -function validate_quick_charge () { - var pkg = document.QuickChargeForm.pkg.value; - var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ ; - var amount = document.QuickChargeForm.amount.value; - var amount_regex = /^\s*\$?\s*(\d*(\.?\d{1,2}))\s*$/ ; - var rval = true; - - if ( ! amount_regex.test(amount) ) { - alert('Illegal amount - enter an amount to charge, for example, "5" or "43" or "21.46".'); - return false; - } - if ( String(pkg).length < 1 ) { - rval = false; - } - if ( ! pkg_regex.test(pkg) ) { - rval = false; - } - var i=0; - for (i=0; i < rownum; i++) { - if (! eval('pkg_regex.test(document.QuickChargeForm.description' + i + '.value)')){ - rval = false; - break; - } - } - if (rval == true) { - return true; - } - - if ( ! pkg ) { - alert('Enter a description for the one-time charge'); - return false; - } - - alert('Illegal description - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' ); - return false; -} - -function bill_now_changed (what) { - var form = what.form; - if ( what.checked ) { - form.start_date_text.disabled = true; - form.start_date.style.backgroundColor = '#dddddd'; - form.start_date_button.style.display = 'none'; - form.start_date_button_disabled.style.display = ''; - form.invoice_terms.disabled = false; - } else { - form.start_date_text.disabled = false; - form.start_date.style.backgroundColor = '#ffffff'; - form.start_date_button.style.display = ''; - form.start_date_button_disabled.style.display = 'none'; - form.invoice_terms.disabled = true; - } -} - -</SCRIPT> - -<FORM ACTION="process/quick-charge.cgi" NAME="QuickChargeForm" ID="QuickChargeForm" METHOD="POST" onsubmit="document.QuickChargeForm.submit.disabled=true;return validate_quick_charge();"> - -<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> - -<TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc"> - -<TR> - <TD ALIGN="right">Amount </TD> - <TD> - $<INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $amount %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()"> - </TD> -</TR> - -% if ( $conf->exists('invoice-unitprice') ) { - <TR> - <TD ALIGN="right">Quantity </TD> - <TD> - <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>"> - </TD> - </TR> -% } - -<% include('/elements/tr-select-pkg_class.html', 'curr_value' => $cgi->param('classnum') ) %> - -<TR> - <TD ALIGN="right">Invoice now</TD> - <TD> - <INPUT TYPE = "checkbox" - NAME = "bill_now" - VALUE = "1" - <% $cgi->param('bill_now') ? 'CHECKED' : '' %> - onChange = "bill_now_changed(this);" - > - with terms - <% include('/elements/select-terms.html', - 'curr_value' => scalar($cgi->param('invoice_terms')), - 'empty_value' => $default_terms, - 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ), - ) - %> - </TD> -</TR> - -%# false laziness w/misc/order_pkg.html -<TR> - <TD ALIGN="right">Charge date </TD> - <TD> - <INPUT TYPE = "text" - NAME = "start_date" - SIZE = 32 - ID = "start_date_text" - VALUE = "<% $start_date %>" - <% $cgi->param('bill_now') ? 'STYLE = "background-color:#dddddd" DISABLED' : '' %> - > - <IMG SRC = "<%$fsurl%>images/calendar.png" - ID = "start_date_button" - TITLE = "Select date" - STYLE = "cursor:pointer<% $cgi->param('bill_now') ? ';display:none' : '' %>" - > - <IMG SRC = "<%$fsurl%>images/calendar-disabled.png" - ID = "start_date_button_disabled" - <% $cgi->param('bill_now') ? '' : 'STYLE="display:none"' %> - > - <FONT SIZE=-1>(leave blank to charge immediately)</FONT> - </TD> -</TR> - -<SCRIPT TYPE="text/javascript"> - Calendar.setup({ - inputField: "start_date_text", - ifFormat: "<% $date_format %>", - button: "start_date_button", - align: "BR" - }); -</SCRIPT> - -% if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) { -% my $what = lc(FS::payby->shortname($cust_main->payby)); - <TR> - <TD ALIGN="right">Disable automatic <% $what %> charge </TD> - <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD> - </TR> -% } - -<TR> - <TD ALIGN="right">Tax exempt </TD> - <TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD> -</TR> - -<% include('/elements/tr-select-taxclass.html', 'curr_value' => $cgi->param('taxclass') ) %> - -<% include('/elements/tr-select-taxproduct.html', 'label' => 'Tax product', 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') ) %> - -<% include('/elements/tr-select-taxoverride.html', 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') ) %> - -<TR> - <TD ALIGN="right">Description </TD> - <TD> - <INPUT TYPE="text" NAME="pkg" SIZE="50" MAXLENGTH="50" VALUE="<% $pkg %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()"> - </TD> -</TR> - -<TR> - <TD></TD> - <TD><FONT SIZE="-1">Optional additional description (also printed on invoice): </FONT></TD> -</TR> - -% my $row = 0; -% if ( $cgi->param('error') || $cgi->param('magic') ) { -% my $param = $cgi->Vars; -% -% for ( $row = 0; exists($param->{"description$row"}); $row++ ) { - - <TR> - <TD></TD> - <TD> - <INPUT TYPE="text" NAME="description<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $param->{"description$row"} |h %>" rownum="<% $row %>" onkeyup = "possiblyAddRow;" > - </TD> - </TR> -% } -% } - - -</TABLE> - -<BR> -<INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="Add one-time charge" <% $cgi->param('error') ? '' :' DISABLED' %>> - -</FORM> - - -<SCRIPT TYPE="text/javascript"> - - var rownum = <% $row %>; - - function possiblyAddRow() { - if ( ( rownum - this.getAttribute('rownum') ) == 1 ) { - addRow(); - } - } - - function addRow() { - - var table = document.getElementById('QuickChargeTable'); - var tablebody = table.getElementsByTagName('tbody').item(0); - - var row = document.createElement('TR'); - - var empty_cell = document.createElement('TD'); - row.appendChild(empty_cell); - - var description_cell = document.createElement('TD'); - - var description_input = document.createElement('INPUT'); - description_input.setAttribute('name', 'description'+rownum); - description_input.setAttribute('id', 'description'+rownum); - description_input.setAttribute('size', 60); - description_input.setAttribute('maxLength', 65); - description_input.setAttribute('rownum', rownum); - description_input.onkeyup = possiblyAddRow; - description_cell.appendChild(description_input); - - row.appendChild(description_cell); - - tablebody.appendChild(row); - - rownum++; - - } - -</SCRIPT> - -</BODY> -</HTML> -<%init> - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('One-time charge'); - -my $conf = new FS::Conf; -my $date_format = $conf->config('date_format') || '%m/%d/%Y'; - -$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum'; -my $custnum = $1; -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); #XXX agent-virt - -my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi? -my $start_date = $cust_main->next_bill_date; -$start_date = $start_date ? time2str($format, $start_date) : ''; - -my $amount = ''; -if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) { - $amount = $1; -} - -my $quantity = 1; -if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) { - $quantity = $1; -} - -$cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ - or die 'illegal description'; -my $pkg = $1; - -my $default_terms; -if ( $cust_main->invoice_terms ) { - $default_terms = 'Customer default ('. $cust_main->invoice_terms. ')'; -} else { - $default_terms = - 'Default ('. - ($conf->config('invoice_default_terms') || 'Payable upon receipt'). - ')'; -} - -</%init> |