2 % $cgi->param('error', $error );
3 <% $cgi->redirect($p.'quick-charge.html?'. $cgi->query_string) %>
5 <% header(emt("One-time charge added")) %>
6 <SCRIPT TYPE="text/javascript">
7 window.top.location.reload();
14 unless $FS::CurrentUser::CurrentUser->access_right('One-time charge');
17 my $conf = new FS::conf;
18 my $param = $cgi->Vars;
21 for ( my $row = 0; exists($param->{"description$row"}); $row++ ) {
22 push @description, $param->{"description$row"}
23 if ($param->{"description$row"} =~ /\S/);
26 $param->{"custnum"} =~ /^(\d+)$/
27 or $error .= "Illegal customer number " . $param->{"custnum"} . " ";
30 $param->{"amount"} =~ /^\s*(\d*(?:\.?\d{1,2}))\s*$/
31 or $error .= "Illegal amount " . $param->{"amount"} . " ";
35 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
39 $param->{'tax_override'} =~ /^\s*([,\d]*)\s*$/
40 or $error .= "Illegal tax override " . $param->{"tax_override"} . " ";
43 if ( $param->{'taxclass'} eq '(select)' ) {
44 $error .= "Must select a tax class. "
45 unless ($conf->exists('enable_taxproducts') &&
46 ( $override || $param->{taxproductnum} )
48 $cgi->param('taxclass', '');
52 my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
53 or $error .= "Unknown customer number $custnum. ";
55 $error ||= $cust_main->charge( {
57 'quantity' => $quantity,
58 'bill_now' => scalar($cgi->param('bill_now')),
59 'invoice_terms' => scalar($cgi->param('invoice_terms')),
60 'start_date' => ( scalar($cgi->param('start_date'))
61 ? parse_datetime($cgi->param('start_date'))
64 'no_auto' => scalar($cgi->param('no_auto')),
65 'pkg' => scalar($cgi->param('pkg')),
66 'setuptax' => scalar($cgi->param('setuptax')),
67 'taxclass' => scalar($cgi->param('taxclass')),
68 'taxproductnum' => scalar($cgi->param('taxproductnum')),
69 'tax_override' => $override,
70 'classnum' => scalar($cgi->param('classnum')),
71 'additional' => \@description,