X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fquick-charge.html;h=a9e57b6a5ea606639f5599972bc111a062b60696;hb=6df492990ea195513430f3a56d537e57e50b6913;hp=466091dfac97173e6faa0625d7cf32ff317943dc;hpb=54a357b171aa44f9399b4c146acd2afd3b686075;p=freeside.git diff --git a/httemplate/edit/quick-charge.html b/httemplate/edit/quick-charge.html index 466091dfa..a9e57b6a5 100644 --- a/httemplate/edit/quick-charge.html +++ b/httemplate/edit/quick-charge.html @@ -1,11 +1,12 @@ -<& /elements/header-popup.html, mt('One-time charge'), '', - ( $cgi->param('error') ? '' : 'onload="addRow()"' ), +<& /elements/header.html, mt('One-time charge'), '', + ( ($quotationnum || $cgi->param('error')) ? '' : 'onload="addRow()"' ), &> + <& /elements/error.html &> @@ -39,7 +40,7 @@ function enable_quick_charge (e) { function validate_quick_charge () { var pkg = document.QuickChargeForm.pkg.value; - var pkg_regex = /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ ; + var pkg_regex = XRegExp('^([\\p{L}\\p{N} \_\!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\\[\\]]*)$'); var amount = document.QuickChargeForm.amount.value; var amount_regex = /^\s*\$?\s*(\d*(\.?\d{1,2}))\s*$/ ; var rval = true; @@ -93,6 +94,18 @@ function bill_now_changed (what) { +
+% if ( $cust_main ) { +<& /elements/small_custview.html, + $cust_main->custnum, + scalar($conf->config('countrydefault')), + 1, #no balance +&> +% } else { +<& /elements/small_prospect_view.html, $prospect_main &> +% } +
+ @@ -329,12 +461,47 @@ my $conf = new FS::Conf; my $date_format = $conf->config('date_format') || '%m/%d/%Y'; my $money_char = $conf->config('money_char') || '$'; -$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum'; -my $custnum = $1; -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); #XXX agent-virt +my( $cust_main, $cust_pkg, $prospect_main, $quotationnum ) = ( '', '', '', '' ); +if ( $cgi->param('change_pkgnum') ) { + # change an existing one-time charge + die "access denied" + unless $curuser->access_right('Modify one-time charge'); + + $cgi->param('change_pkgnum') =~ /^(\d+)$/ or die "illegal pkgnum"; + $cust_pkg = FS::cust_pkg->by_key($1) or die "pkgnum $1 not found"; + $cust_main = $cust_pkg->cust_main; +} else { + if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) { + $quotationnum = $1; + } + if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { + $cust_main = FS::cust_main->by_key($1) or die "custnum $1 not found"; + } + if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) { + $prospect_main = FS::prospect_main->by_key($1) or die "prospectnum $1 not found"; + } + die "custnum or prospectnum must be specified" + unless $cust_main || $prospect_main; +} + +my $cust_or_prospect = $cust_main || $prospect_main; + +if ( $cust_main ) { + my $custnum = $cust_main->custnum; + # agent-virt + if (!exists($curuser->agentnums_href->{$cust_main->agentnum})) { + die "custnum $custnum not found"; + } +} elsif ( $prospect_main ) { + my $prospectnum = $prospect_main->prospectnum; + # agent-virt + if (!exists($curuser->agentnums_href->{$prospect_main->agentnum})) { + die "prospectnum $prospectnum not found"; + } +} my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi? -my $start_date = $cust_main->next_bill_date; +my $start_date = $cust_main ? $cust_main->next_bill_date : ''; $start_date = $start_date ? time2str($format, $start_date) : ''; my $amount = ''; @@ -342,6 +509,11 @@ if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) { $amount = $1; } +my $setup_cost = ''; +if ( $cgi->param('setup_cost') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) { + $setup_cost = $1; +} + my $quantity = 1; if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) { $quantity = $1; @@ -352,12 +524,42 @@ $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ my $pkg = $1; my $default_terms; -if ( $cust_main->invoice_terms ) { +if ( $cust_main && $cust_main->invoice_terms ) { $default_terms = emt("Customer default ([_1])", $cust_main->invoice_terms); } else { - $default_terms = emt("Default ([_1])", - ($conf->config('invoice_default_terms') || emt('Payable upon receipt')) - ); + $default_terms = + emt( "Default ([_1])", + ( $conf->config('invoice_default_terms', $cust_or_prospect->agentnum) + || emt('Payable upon receipt') + ) + ); +} + +my @description; +my %param = $cgi->Vars; +for (my $i = 0; exists($param{"description$i"}); $i++) { + push @description, $param{"description$i"}; +} + +my $classnum; +if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { + $classnum = $1; +} + +my $part_pkg; +my $billed = 0; + +if ( $cust_pkg ) { # set defaults + $part_pkg = $cust_pkg->part_pkg; + $pkg ||= $part_pkg->pkg; + $classnum ||= $part_pkg->classnum; + if (!@description) { + for (my $i = 0; $i < ($part_pkg->option('additional_count',1) || 0); $i++) + { + push @description, $part_pkg->option("additional_info$i",1); + } + } + $billed = $cust_pkg->get('setup') ? 1 : 0; } %init>