X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fquick-charge.html;h=ec1a58046219e1b270f8701e1a1ea9a8d33fee79;hb=2457752a82358108aa078f175a4e866f1786299a;hp=466091dfac97173e6faa0625d7cf32ff317943dc;hpb=54a357b171aa44f9399b4c146acd2afd3b686075;p=freeside.git diff --git a/httemplate/edit/quick-charge.html b/httemplate/edit/quick-charge.html index 466091dfa..ec1a58046 100644 --- a/httemplate/edit/quick-charge.html +++ b/httemplate/edit/quick-charge.html @@ -104,20 +104,97 @@ function bill_now_changed (what) { - - - +% if ( $cust_pkg ) { + + +% my $field = '/elements/tr-input-text.html'; +% # don't allow changing these after the fact +% $field = '/elements/tr-fixed.html' if $billed; +<& $field, + label => mt('Amount to charge'), + field => 'amount', + value => sprintf('%.2f',$part_pkg->option('setup_fee')), + size => 8, + prefix => $money_char, +&> + +% if ( $curuser->access_right('Edit package definition costs') ) { + <& $field, + label => mt('Cost'), + field => 'setup_cost', + value => sprintf('%.2f',$part_pkg->setup_cost), + size => 8, + prefix => $money_char, + &> +% } + +% if ( $conf->exists('invoice-unitprice') ) { +<& $field, + label => 'Quantity', + field => 'quantity', + value => $cust_pkg->quantity +&> +% } + +<& /elements/tr-select-pkg_class.html, 'curr_value' => $classnum &> + +% # crudely estimate whether any agent commission credits might exist +% my @events = grep { $_->part_event->action =~ /credit/ } +% $cust_pkg->cust_event; +% if ( scalar @events ) { + + +% } + +% #display the future or past charge date, but don't allow changes +% # XXX we probably _could_ let as-yet unbilled charges be rescheduled, but +% # there's no compelling need yet +% if ( $billed ) { + <& /elements/tr-fixed-date.html, + label => emt('Billed on'), + value => $cust_pkg->get('setup') + &> +% } else { + <& /elements/tr-input-date-field.html, + { + name => 'start_date', + label => emt('Will be billed'), + value => $cust_pkg->get('start_date'), + format => $date_format, + noinit => 1, + } + &> +% } + +% } else { # new one-time charge + + + + + + +% if ( $curuser->access_right('Edit package definition costs') ) { + <& /elements/tr-input-text.html, + label => mt('Cost'), + field => 'setup_cost', + value => $setup_cost, + size => 8, + prefix => $money_char, + &> +% } -% if ( $conf->exists('invoice-unitprice') ) { +% if ( $conf->exists('invoice-unitprice') ) { -% } +% } -<& /elements/tr-select-pkg_class.html, 'curr_value' => $cgi->param('classnum') &> +<& /elements/tr-select-pkg_class.html, 'curr_value' => $classnum &> @@ -144,8 +221,9 @@ function bill_now_changed (what) { > <% mt('with terms') |h %> <& /elements/select-terms.html, - 'curr_value' => scalar($cgi->param('invoice_terms')), - 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ), + 'curr_value' => scalar($cgi->param('invoice_terms')), + 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ), + 'agentnum' => $cust_main->agentnum, &> @@ -206,6 +284,8 @@ function bill_now_changed (what) { <& /elements/tr-select-taxoverride.html, 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') &> +% } # if !$cust_pkg + % my $row = 0; -% if ( $cgi->param('error') || $cgi->param('magic') ) { -% my $param = $cgi->Vars; -% -% for ( $row = 0; exists($param->{"description$row"}); $row++ ) { - +% foreach (@description) { -% } +% $row++; % }
<% mt('Amount') |h %> - <% $money_char %> -
+<% emt('Adjust commission credits if necessary') %> +
<% mt('Amount to charge') |h %> + <% $money_char %> +
<% mt('Quantity') |h %> @@ -128,9 +205,9 @@ function bill_now_changed (what) { onKeyPress = "return enable_quick_charge(event)">
<% mt('Invoice now') |h %>
<% mt('Description') |h %> @@ -226,11 +306,7 @@ function bill_now_changed (what) {
@@ -238,21 +314,25 @@ function bill_now_changed (what) { NAME = "description<% $row %>" SIZE = "60" MAXLENGTH = "65" - VALUE = "<% $param->{"description$row"} |h %>" + VALUE = "<% $_ |h %>" rownum = "<% $row %>" onKeyPress = "return enable_quick_charge(event)" onKeyUp = "return possiblyAddRow(event)" >

-param('error') ? '' :' DISABLED' %>> +% my $label = $cust_pkg +% ? emt('Modify one-time charge') +% : emt('Add one-time charge'); +param('error') || $cust_pkg) ? '' :' DISABLED' %>> @@ -329,9 +409,25 @@ 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); +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 { + $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum'; + $cust_main = FS::cust_main->by_key($1) or die "custnum $1 not found"; +} + +my $custnum = $cust_main->custnum; +# agent-virt +if (!exists($curuser->agentnums_href->{$cust_main->agentnum})) { + die "custnum $custnum 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; @@ -342,6 +438,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; @@ -355,9 +456,39 @@ my $default_terms; if ( $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_main->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; }