% if ( $quotationnum && ! $cust_main ) { <& /elements/header.html, mt('Quotation #[_1]: add one-time charge', $quotationnum) &> % } else { <& /elements/header-cust_main.html, view => $quotationnum ? 'quotations' : 'packages', cust_main => $cust_main, etc => $cgi->param('error') ? '' : 'onload="addRow()"', &>

<% $quotationnum ? emt('Quotation #[_1]: add one-time charge', $quotationnum) : mt('One-time charge') %>

% } <& /elements/init_calendar.html &> <& /elements/error.html &>

% if ( $prospect_main ) { <& /elements/small_prospect_view.html, $prospect_main &> % }

<% mt('Charge') |h %> % if ( $cust_pkg ) { #modify one-time charge % 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, } &> <& /elements/tr-checkbox.html, label => emt('Invoice this charge separately'), field => 'separate_bill', value => 'Y', curr_value => $cust_pkg->get('separate_bill'), &> <& /elements/tr-select-taxclass.html, 'curr_value' => $part_pkg->get('taxclass') &> <& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'curr_value' => $part_pkg->get('taxproductnum') &> % }
<% emt('Adjust commission credits if necessary') %>
<% mt('Tax exempt') |h %> param('setuptax') ? 'CHECKED' : '' %>>
% } else { # new one-time charge <% mt('Amount to charge') |h %> <% $money_char %> % if ( $conf->exists('invoice-unitprice') ) { <% mt('Quantity') |h %> % } <& /elements/tr-select-pkg_class.html, 'curr_value' => $classnum &> <% mt('Description') |h %> % my $row = 0; % # quotation details are handled by quotation_pkg_detail records, added via link from view/quotation.html % # the details below get attached to the part_pkg record, and there's no way to edit that from quotations % unless ($quotationnum) { <% mt('Optional additional description (also printed on invoice):') |h %> % foreach (@description) { % $row++; % } % } Taxation <& /elements/tr-select-taxclass.html, 'curr_value' => scalar($cgi->param('taxclass')) &> <& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'curr_value' => scalar($cgi->param('taxproductnum')), &> <& /elements/tr-select-taxoverride.html, 'curr_value' => scalar($cgi->param('tax_override')), &>
<% mt('Tax exempt') |h %> param('setuptax') ? 'CHECKED' : '' %>>
% if ( $curuser->access_right('Edit package definition costs') ) {
<% mt('Cost Accounting') |h %> <& /elements/tr-input-text.html, label => mt('Cost'), field => 'setup_cost', value => $setup_cost, size => 8, prefix => $money_char, &>
% } % if ( $curuser->access_right('Discount customer package') ) {
<% mt('Discounting') |h %> <& /elements/tr-select-pkg-discount.html, 'setup_label' => emt('Discount'), 'disable_recur' => 1, 'disable_waive_setup' => 1, &>
% } % unless ( $quotationnum ) {
<% mt('Invoicing') |h %> % # false laziness w/misc/order_pkg.html <& /elements/tr-checkbox.html, label => emt('Invoice this charge separately'), field => 'separate_bill', value => 'Y' &> % if ( $cust_main->has_cust_payby_auto ) { % my $what = lc(FS::payby->shortname($cust_main->payby)); % }
<% mt('Invoice now') |h %> param('bill_now') ? 'CHECKED' : '' %> onClick = "bill_now_changed(this);" onChange = "bill_now_changed(this);" > <% mt('with terms') |h %> <& /elements/select-terms.html, 'curr_value' => scalar($cgi->param('invoice_terms')), 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ), 'agentnum' => $cust_or_prospect->agentnum, &>
<% mt('Charge date') |h %> param('bill_now') ? 'STYLE = "background-color:#dddddd" DISABLED' : '' %> > param('bill_now') ? '' : 'STYLE="display:none"' %> > (<% mt('leave blank to charge immediately') |h %>)
<% mt("Disable automatic $what charge") |h %>
% } % } # if !$cust_pkg
% my $label = $cust_pkg % ? emt('Modify one-time charge') % : emt('Add one-time charge'); param('error') || $cust_pkg) ? '' :' DISABLED' %>> %my %footer_args = ( % formvalidation => { % QuickChargeForm => { % validate_fields => { % quantity => 'digits: true, min: 1, required: true', % }, % }, % }, %); % if ( $quotationnum ) { <& /elements/footer.html, %footer_args &> % } else { <& /elements/footer-cust_main.html, %footer_args &> % } <%init> my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('One-time charge'); my $conf = new FS::Conf; my $date_format = $conf->config('date_format') || '%m/%d/%Y'; my $money_char = $conf->config('money_char') || '$'; 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 ? $cust_main->next_bill_date : ''; $start_date = $start_date ? time2str($format, $start_date) : ''; my $amount = ''; 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; } $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ or die 'illegal description'; my $pkg = $1; my $default_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', $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; }