X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fquick-charge.html;h=51cd854ca436a3c919d9c891de31b211810da6e4;hp=da9ac6e66f9ae4bf7c2285071677390e83626848;hb=24a7dd6d18a1413ec34b906274365e4b2fef28e8;hpb=c7c96355331687b6fd44bfe541b402bd0664481d diff --git a/httemplate/edit/quick-charge.html b/httemplate/edit/quick-charge.html index da9ac6e66..51cd854ca 100644 --- a/httemplate/edit/quick-charge.html +++ b/httemplate/edit/quick-charge.html @@ -1,11 +1,16 @@ -<& /elements/header-popup.html, mt('One-time charge'), '', - ( $cgi->param('error') ? '' : 'onload="addRow()"' ), +% if ( $quotationnum ) { +<& /elements/header.html, mt('One-time charge') &> +% } else { +<& /elements/header-cust_main.html, + view => 'packages', + cust_main => $cust_main, + etc => $cgi->param('error') ? '' : 'onload="addRow()"', &> +

One-time charge

+% } - - - - +<& /elements/init_calendar.html &> + <& /elements/error.html &> @@ -39,7 +44,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 +98,12 @@ function bill_now_changed (what) { +

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

+
- + + + - +
-% if ( $cust_pkg ) { +% 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 => 'Amount', - field => 'amount', - value => sprintf('%.2f',$part_pkg->option('setup_fee')), - size => 8, - prefix => $money_char, + 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', @@ -157,25 +180,54 @@ function bill_now_changed (what) { 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') + &> +% } + % } 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') ) { - + - - - +% unless ( $quotationnum ) { -%# false laziness w/misc/order_pkg.html - - - - + + + + - +% # 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->payby =~ /^(CARD|CHEK)$/ ) { +% if ( ! $quotationnum && $cust_main->payby =~ /^(CARD|CHEK)$/ ) { % my $what = lc(FS::payby->shortname($cust_main->payby)); @@ -253,20 +315,25 @@ function bill_now_changed (what) { % } - + -<& /elements/tr-select-taxclass.html, 'curr_value' => $cgi->param('taxclass') &> +<& /elements/tr-select-taxclass.html, 'curr_value' => scalar($cgi->param('taxclass')) &> -<& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') &> +<& /elements/tr-select-taxproduct.html, + 'label' => emt('Tax product'), + 'curr_value' => scalar($cgi->param('taxproductnum')), +&> -<& /elements/tr-select-taxoverride.html, 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') &> +<& /elements/tr-select-taxoverride.html, + 'curr_value' => scalar($cgi->param('tax_override')), +&> % } # if !$cust_pkg - + +% 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) { -% my $row = 0; -% foreach (@description) { +% foreach (@description) { -% $row++; -% } +% $row++; +% } +% }
<% mt('Tax exempt') |h %> param('setuptax') ? 'CHECKED' : '' %>>
<% mt('Amount') |h %> - <% $money_char %> -
<% mt('Amount to charge') |h %> + <% $money_char %> +
<% mt('Quantity') |h %> <% mt('Quantity') |h %> $classnum &> -
<% 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_main->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('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 %>
<% mt('Tax exempt') |h %> <% mt('Tax exempt') |h %> param('setuptax') ? 'CHECKED' : '' %>>
<% mt('Description') |h %> <% mt('Description') |h %>
<% mt('Optional additional description (also printed on invoice):') |h %>
@@ -300,8 +370,9 @@ function bill_now_changed (what) { >
@@ -388,7 +459,7 @@ 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); +my( $cust_main, $cust_pkg, $prospect_main, $quotationnum ) = ( '', '', '', '' ); if ( $cgi->param('change_pkgnum') ) { # change an existing one-time charge die "access denied" @@ -398,18 +469,37 @@ if ( $cgi->param('change_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"; + 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 $custnum = $cust_main->custnum; -# agent-virt -if (!exists($curuser->agentnums_href->{$cust_main->agentnum})) { - die "custnum $custnum not found"; +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 = ''; @@ -417,6 +507,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; @@ -427,12 +522,12 @@ $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', $cust_main->agentnum) + ( $conf->config('invoice_default_terms', $cust_or_prospect->agentnum) || emt('Payable upon receipt') ) );