1 <% include("/elements/header-popup.html", 'One-time charge', '',
2 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
6 <LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2">
7 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT>
8 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT>
9 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT>
11 <% include('/elements/error.html') %>
13 <SCRIPT TYPE="text/javascript">
15 function enable_quick_charge () {
16 if ( document.QuickChargeForm.amount.value
17 && document.QuickChargeForm.pkg.value ) {
18 document.QuickChargeForm.submit.disabled = false;
20 document.QuickChargeForm.submit.disabled = true;
24 function validate_quick_charge () {
25 var pkg = document.QuickChargeForm.pkg.value;
26 var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ ;
27 var amount = document.QuickChargeForm.amount.value;
28 var amount_regex = /^\s*\$?\s*(\d*(\.?\d{1,2}))\s*$/ ;
31 if ( ! amount_regex.test(amount) ) {
32 alert('Illegal amount - enter an amount to charge, for example, "5" or "43" or "21.46".');
35 if ( String(pkg).length < 1 ) {
38 if ( ! pkg_regex.test(pkg) ) {
42 for (i=0; i < rownum; i++) {
43 if (! eval('pkg_regex.test(document.QuickChargeForm.description' + i + '.value)')){
53 alert('Enter a description for the one-time charge');
57 alert('Illegal description - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' );
61 function bill_now_changed (what) {
64 form.start_date_text.disabled = true;
65 form.start_date.style.backgroundColor = '#dddddd';
66 form.start_date_button.style.display = 'none';
67 form.start_date_button_disabled.style.display = '';
68 form.invoice_terms.disabled = false;
70 form.start_date_text.disabled = false;
71 form.start_date.style.backgroundColor = '#ffffff';
72 form.start_date_button.style.display = '';
73 form.start_date_button_disabled.style.display = 'none';
74 form.invoice_terms.disabled = true;
80 <FORM ACTION="process/quick-charge.cgi" NAME="QuickChargeForm" ID="QuickChargeForm" METHOD="POST" onsubmit="document.QuickChargeForm.submit.disabled=true;return validate_quick_charge();">
82 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
84 <TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc">
87 <TD ALIGN="right">Amount </TD>
89 $<INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $amount %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()">
93 % if ( $conf->exists('invoice-unitprice') ) {
95 <TD ALIGN="right">Quantity </TD>
97 <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
102 <% include('/elements/tr-select-pkg_class.html', 'curr_value' => $cgi->param('classnum') ) %>
105 <TD ALIGN="right">Invoice now</TD>
107 <INPUT TYPE = "checkbox"
110 <% $cgi->param('bill_now') ? 'CHECKED' : '' %>
111 onChange = "bill_now_changed(this);"
114 <% include('/elements/select-terms.html',
115 'curr_value' => scalar($cgi->param('invoice_terms')),
116 'empty_value' => $default_terms,
117 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ),
123 %# false laziness w/misc/order_pkg.html
125 <TD ALIGN="right">Charge date </TD>
130 ID = "start_date_text"
131 VALUE = "<% $start_date %>"
132 <% $cgi->param('bill_now') ? 'STYLE = "background-color:#dddddd" DISABLED' : '' %>
134 <IMG SRC = "<%$fsurl%>images/calendar.png"
135 ID = "start_date_button"
136 TITLE = "Select date"
137 STYLE = "cursor:pointer<% $cgi->param('bill_now') ? ';display:none' : '' %>"
139 <IMG SRC = "<%$fsurl%>images/calendar-disabled.png"
140 ID = "start_date_button_disabled"
141 <% $cgi->param('bill_now') ? '' : 'STYLE="display:none"' %>
143 <FONT SIZE=-1>(leave blank to charge immediately)</FONT>
147 <SCRIPT TYPE="text/javascript">
149 inputField: "start_date_text",
150 ifFormat: "<% $date_format %>",
151 button: "start_date_button",
156 % if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
157 % my $what = lc(FS::payby->shortname($cust_main->payby));
159 <TD ALIGN="right">Disable automatic <% $what %> charge </TD>
160 <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
165 <TD ALIGN="right">Tax exempt </TD>
166 <TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD>
169 <% include('/elements/tr-select-taxclass.html', 'curr_value' => $cgi->param('taxclass') ) %>
171 <% include('/elements/tr-select-taxproduct.html', 'label' => 'Tax product', 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') ) %>
173 <% include('/elements/tr-select-taxoverride.html', 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') ) %>
176 <TD ALIGN="right">Description </TD>
178 <INPUT TYPE="text" NAME="pkg" SIZE="50" MAXLENGTH="50" VALUE="<% $pkg %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()">
184 <TD><FONT SIZE="-1">Optional additional description (also printed on invoice): </FONT></TD>
188 % if ( $cgi->param('error') || $cgi->param('magic') ) {
189 % my $param = $cgi->Vars;
191 % for ( $row = 0; exists($param->{"description$row"}); $row++ ) {
196 <INPUT TYPE="text" NAME="description<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $param->{"description$row"} |h %>" rownum="<% $row %>" onkeyup = "possiblyAddRow;" >
206 <INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="Add one-time charge" <% $cgi->param('error') ? '' :' DISABLED' %>>
211 <SCRIPT TYPE="text/javascript">
213 var rownum = <% $row %>;
215 function possiblyAddRow() {
216 if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
223 var table = document.getElementById('QuickChargeTable');
224 var tablebody = table.getElementsByTagName('tbody').item(0);
226 var row = document.createElement('TR');
228 var empty_cell = document.createElement('TD');
229 row.appendChild(empty_cell);
231 var description_cell = document.createElement('TD');
233 var description_input = document.createElement('INPUT');
234 description_input.setAttribute('name', 'description'+rownum);
235 description_input.setAttribute('id', 'description'+rownum);
236 description_input.setAttribute('size', 60);
237 description_input.setAttribute('maxLength', 65);
238 description_input.setAttribute('rownum', rownum);
239 description_input.onkeyup = possiblyAddRow;
240 description_cell.appendChild(description_input);
242 row.appendChild(description_cell);
244 tablebody.appendChild(row);
257 unless $FS::CurrentUser::CurrentUser->access_right('One-time charge');
259 my $conf = new FS::Conf;
260 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
262 $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
264 my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); #XXX agent-virt
266 my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi?
267 my $start_date = $cust_main->next_bill_date;
268 $start_date = $start_date ? time2str($format, $start_date) : '';
271 if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) {
276 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
280 $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/
281 or die 'illegal description';
285 if ( $cust_main->invoice_terms ) {
286 $default_terms = 'Customer default ('. $cust_main->invoice_terms. ')';
290 ($conf->config('invoice_default_terms') || 'Payable upon receipt').