1 <& /elements/header-popup.html, mt('One-time charge'), '',
2 ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
5 <LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2">
6 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT>
7 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT>
8 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT>
10 <& /elements/error.html &>
12 <SCRIPT TYPE="text/javascript">
14 function enable_quick_charge () {
15 if ( document.QuickChargeForm.amount.value
16 && document.QuickChargeForm.pkg.value ) {
17 document.QuickChargeForm.submit.disabled = false;
19 document.QuickChargeForm.submit.disabled = true;
23 function validate_quick_charge () {
24 var pkg = document.QuickChargeForm.pkg.value;
25 var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ ;
26 var amount = document.QuickChargeForm.amount.value;
27 var amount_regex = /^\s*\$?\s*(\d*(\.?\d{1,2}))\s*$/ ;
30 if ( ! amount_regex.test(amount) ) {
31 alert('Illegal amount - enter an amount to charge, for example, "5" or "43" or "21.46".');
34 if ( String(pkg).length < 1 ) {
37 if ( ! pkg_regex.test(pkg) ) {
41 for (i=0; i < rownum; i++) {
42 if (! eval('pkg_regex.test(document.QuickChargeForm.description' + i + '.value)')){
52 alert('Enter a description for the one-time charge');
56 alert('Illegal description - spaces, letters, numbers, and the following punctuation characters are allowed: . , ! ? @ # $ % & ( ) - + ; : ' + "'" + ' " = [ ]' );
60 function bill_now_changed (what) {
63 form.start_date_text.disabled = true;
64 form.start_date.style.backgroundColor = '#dddddd';
65 form.start_date_button.style.display = 'none';
66 form.start_date_button_disabled.style.display = '';
67 form.invoice_terms.disabled = false;
69 form.start_date_text.disabled = false;
70 form.start_date.style.backgroundColor = '#ffffff';
71 form.start_date_button.style.display = '';
72 form.start_date_button_disabled.style.display = 'none';
73 form.invoice_terms.disabled = true;
79 <FORM ACTION="process/quick-charge.cgi" NAME="QuickChargeForm" ID="QuickChargeForm" METHOD="POST" onsubmit="document.QuickChargeForm.submit.disabled=true;return validate_quick_charge();">
81 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
83 <TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc">
86 <TD ALIGN="right"><% mt('Amount') |h %> </TD>
88 <% $money_char %><INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $amount %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()">
92 % if ( $conf->exists('invoice-unitprice') ) {
94 <TD ALIGN="right"><% mt('Quantity') |h %> </TD>
96 <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
101 <& /elements/tr-select-pkg_class.html, 'curr_value' => $cgi->param('classnum') &>
104 <TD ALIGN="right"><% mt('Invoice now') |h %></TD>
106 <INPUT TYPE = "checkbox"
109 <% $cgi->param('bill_now') ? 'CHECKED' : '' %>
110 onChange = "bill_now_changed(this);"
112 <% mt('with terms') |h %>
113 <& /elements/select-terms.html,
114 'curr_value' => scalar($cgi->param('invoice_terms')),
115 'empty_value' => $default_terms,
116 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ),
121 %# false laziness w/misc/order_pkg.html
123 <TD ALIGN="right"><% mt('Charge date') |h %> </TD>
128 ID = "start_date_text"
129 VALUE = "<% $start_date %>"
130 <% $cgi->param('bill_now') ? 'STYLE = "background-color:#dddddd" DISABLED' : '' %>
132 <IMG SRC = "<%$fsurl%>images/calendar.png"
133 ID = "start_date_button"
134 TITLE = "<% mt('Select date') |h %>"
135 STYLE = "cursor:pointer<% $cgi->param('bill_now') ? ';display:none' : '' %>"
137 <IMG SRC = "<%$fsurl%>images/calendar-disabled.png"
138 ID = "start_date_button_disabled"
139 <% $cgi->param('bill_now') ? '' : 'STYLE="display:none"' %>
141 <FONT SIZE=-1>(<% mt('leave blank to charge immediately') |h %>)</FONT>
145 <SCRIPT TYPE="text/javascript">
147 inputField: "start_date_text",
148 ifFormat: "<% $date_format %>",
149 button: "start_date_button",
154 % if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
155 % my $what = lc(FS::payby->shortname($cust_main->payby));
157 <TD ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TD>
158 <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
163 <TD ALIGN="right"><% mt('Tax exempt') |h %> </TD>
164 <TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD>
167 <& /elements/tr-select-taxclass.html, 'curr_value' => $cgi->param('taxclass') &>
169 <& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') &>
171 <& /elements/tr-select-taxoverride.html, 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') &>
174 <TD ALIGN="right"><% mt('Description') |h %> </TD>
176 <INPUT TYPE="text" NAME="pkg" SIZE="50" MAXLENGTH="50" VALUE="<% $pkg %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()">
182 <TD><FONT SIZE="-1"><% mt('Optional additional description (also printed on invoice):') |h %> </FONT></TD>
186 % if ( $cgi->param('error') || $cgi->param('magic') ) {
187 % my $param = $cgi->Vars;
189 % for ( $row = 0; exists($param->{"description$row"}); $row++ ) {
194 <INPUT TYPE="text" NAME="description<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $param->{"description$row"} |h %>" rownum="<% $row %>" onkeyup = "possiblyAddRow;" >
204 <INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="<% mt('Add one-time charge') |h %>" <% $cgi->param('error') ? '' :' DISABLED' %>>
209 <SCRIPT TYPE="text/javascript">
211 var rownum = <% $row %>;
213 function possiblyAddRow() {
214 if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
221 var table = document.getElementById('QuickChargeTable');
222 var tablebody = table.getElementsByTagName('tbody').item(0);
224 var row = document.createElement('TR');
226 var empty_cell = document.createElement('TD');
227 row.appendChild(empty_cell);
229 var description_cell = document.createElement('TD');
231 var description_input = document.createElement('INPUT');
232 description_input.setAttribute('name', 'description'+rownum);
233 description_input.setAttribute('id', 'description'+rownum);
234 description_input.setAttribute('size', 60);
235 description_input.setAttribute('maxLength', 65);
236 description_input.setAttribute('rownum', rownum);
237 description_input.onkeyup = possiblyAddRow;
238 description_cell.appendChild(description_input);
240 row.appendChild(description_cell);
242 tablebody.appendChild(row);
255 unless $FS::CurrentUser::CurrentUser->access_right('One-time charge');
257 my $conf = new FS::Conf;
258 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
259 my $money_char = $conf->config('money_char') || '$';
261 $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
263 my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); #XXX agent-virt
265 my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi?
266 my $start_date = $cust_main->next_bill_date;
267 $start_date = $start_date ? time2str($format, $start_date) : '';
270 if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) {
275 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
279 $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/
280 or die 'illegal description';
284 if ( $cust_main->invoice_terms ) {
285 $default_terms = emt("Customer default ([_1])", $cust_main->invoice_terms);
287 $default_terms = emt("Default ([_1])",
288 ($conf->config('invoice_default_terms') || emt('Payable upon receipt'))