-<& /elements/header-popup.html, mt('One-time charge'), '',
- ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
+% 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()"',
&>
+<h2><% $quotationnum
+ ? emt('Quotation #[_1]: add one-time charge', $quotationnum)
+ : mt('One-time charge')
+ %></h2>
+% }
-<LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2">
-<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT>
+<& /elements/init_calendar.html &>
+<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/xregexp-all.js"></SCRIPT>
<& /elements/error.html &>
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;
</SCRIPT>
+<P>
+% if ( $prospect_main ) {
+<& /elements/small_prospect_view.html, $prospect_main &>
+% }
+</P>
+
<FORM ACTION = "process/quick-charge.cgi"
NAME = "QuickChargeForm"
ID = "QuickChargeForm"
onSubmit = "document.QuickChargeForm.submit.disabled=true; return validate_quick_charge();"
>
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main ? $cust_main->custnum : '' %>">
+<INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospect_main ? $prospect_main->prospectnum : '' %>">
+<INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
-<TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc">
+<TABLE><TR><TD>
-% if ( $cust_pkg ) {
+<FONT CLASS="fsinnerbox-title"><% mt('Charge') |h %>
+<TABLE ID="QuickChargeTable" CLASS="fsinnerbox">
+
+% if ( $cust_pkg ) { #modify one-time charge
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $cust_pkg->pkgnum %>">
% my $field = '/elements/tr-input-text.html';
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 ( $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,
noinit => 1,
}
&>
+
+ <& /elements/tr-checkbox.html,
+ label => emt('Invoice this charge separately'),
+ field => 'separate_bill',
+ value => 'Y',
+ curr_value => $cust_pkg->get('separate_bill'),
+ &>
+ <TR>
+ <TH ALIGN="right"><% mt('Tax exempt') |h %> </TH>
+ <TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD>
+ </TR>
+
+ <& /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')
+ &>
% }
+ </TABLE>
+ </TD></TR></TABLE>
+
% } else { # new one-time charge
<TR>
- <TD ALIGN="right"><% mt('Amount to charge') |h %> </TD>
+ <TH ALIGN="right"><% mt('Amount to charge') |h %> </TH>
<TD>
<% $money_char %><INPUT TYPE = "text"
NAME = "amount"
</TD>
</TR>
-% 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') ) {
<TR>
- <TD ALIGN="right"><% mt('Quantity') |h %> </TD>
+ <TH ALIGN="right"><% mt('Quantity') |h %> </TH>
<TD>
<INPUT TYPE = "text"
NAME = "quantity"
<& /elements/tr-select-pkg_class.html, 'curr_value' => $classnum &>
<TR>
- <TD ALIGN="right"><% mt('Invoice now') |h %></TD>
- <TD>
- <INPUT TYPE = "checkbox"
- NAME = "bill_now"
- VALUE = "1"
- <% $cgi->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,
- &>
- </TD>
-</TR>
-
-%# false laziness w/misc/order_pkg.html
-<TR>
- <TD ALIGN="right"><% mt('Charge date') |h %> </TD>
- <TD>
- <INPUT TYPE = "text"
- NAME = "start_date"
- SIZE = 32
- ID = "start_date_text"
- VALUE = "<% $start_date %>"
- onKeyPress="return enable_quick_charge(event)"
- <% $cgi->param('bill_now')
- ? 'STYLE = "background-color:#dddddd" DISABLED'
- : ''
- %>
- >
- <IMG SRC = "<%$fsurl%>images/calendar.png"
- ID = "start_date_button"
- TITLE = "<% mt('Select date') |h %>"
- STYLE = "cursor:pointer<% $cgi->param('bill_now') ? ';display:none' : '' %>"
- >
- <IMG SRC = "<%$fsurl%>images/calendar-disabled.png"
- ID = "start_date_button_disabled"
- <% $cgi->param('bill_now') ? '' : 'STYLE="display:none"' %>
- >
- <FONT SIZE=-1>(<% mt('leave blank to charge immediately') |h %>)</FONT>
- </TD>
-</TR>
-
-<SCRIPT TYPE="text/javascript">
- Calendar.setup({
- inputField: "start_date_text",
- ifFormat: "<% $date_format %>",
- button: "start_date_button",
- align: "BR"
- });
-</SCRIPT>
-
-% if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
-% my $what = lc(FS::payby->shortname($cust_main->payby));
- <TR>
- <TD ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TD>
- <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
- </TR>
-% }
-
-<TR>
- <TD ALIGN="right"><% mt('Tax exempt') |h %> </TD>
- <TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD>
-</TR>
-
-<& /elements/tr-select-taxclass.html, 'curr_value' => $cgi->param('taxclass') &>
-
-<& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') &>
-
-<& /elements/tr-select-taxoverride.html, 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') &>
-
-% } # if !$cust_pkg
-
-<TR>
- <TD ALIGN="right"><% mt('Description') |h %> </TD>
+ <TH ALIGN="right"><% mt('Description') |h %> </TH>
<TD>
<INPUT TYPE = "text"
NAME = "pkg"
</TD>
</TR>
+% 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) {
<TR>
<TD></TD>
- <TD><FONT SIZE="-1"><% mt('Optional additional description (also printed on invoice):') |h %> </FONT></TD>
+ <TH ALIGN="left"><% mt('Optional additional description (also printed on invoice):') |h %></TH>
</TR>
-% my $row = 0;
-% foreach (@description) {
+% foreach (@description) {
<TR>
<TD></TD>
<TD>
>
</TD>
</TR>
-% $row++;
-% }
-
+% $row++;
+% }
+% }
</TABLE>
-<BR>
-% my $label = $cust_pkg
-% ? emt('Modify one-time charge')
-% : emt('Add one-time charge');
-<INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="<% $label %>" \
-<% ($cgi->param('error') || $cust_pkg) ? '' :' DISABLED' %>>
-
-</FORM>
+</TD>
<SCRIPT TYPE="text/javascript">
</SCRIPT>
-</BODY>
-</HTML>
+
+<TD>
+
+ <FONT CLASS="fsinnerbox-title">Taxation</FONT>
+ <TABLE CLASS="fsinnerbox">
+
+ <TR>
+ <TH ALIGN="right"><% mt('Tax exempt') |h %> </TH>
+ <TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD>
+ </TR>
+
+ <& /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')),
+ &>
+
+ </TABLE>
+
+% if ( $curuser->access_right('Edit package definition costs') ) {
+
+ <BR>
+ <FONT CLASS="fsinnerbox-title"><% mt('Cost Accounting') |h %>
+ <TABLE ID="QuickChargeTable" CLASS="fsinnerbox">
+
+ <& /elements/tr-input-text.html,
+ label => mt('Cost'),
+ field => 'setup_cost',
+ value => $setup_cost,
+ size => 8,
+ prefix => $money_char,
+ &>
+
+ </TABLE>
+
+% }
+
+</TD>
+
+
+</TR></TABLE>
+
+
+% if ( $curuser->access_right('Discount customer package') ) {
+ <BR>
+ <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
+ <TABLE CLASS="fsinnerbox">
+ <& /elements/tr-select-pkg-discount.html,
+ 'setup_label' => emt('Discount'),
+ 'disable_recur' => 1,
+ 'disable_waive_setup' => 1,
+ &>
+ </TABLE>
+% }
+
+
+% unless ( $quotationnum ) {
+
+ <BR>
+ <FONT CLASS="fsinnerbox-title"><% mt('Invoicing') |h %></FONT>
+ <TABLE CLASS="fsinnerbox">
+
+ <TR>
+ <TH ALIGN="right"><% mt('Invoice now') |h %></TH>
+ <TD>
+ <INPUT TYPE = "checkbox"
+ NAME = "bill_now"
+ VALUE = "1"
+ <% $cgi->param('bill_now') ? 'CHECKED' : '' %>
+ onClick = "bill_now_changed(this);"
+ onChange = "bill_now_changed(this);"
+ >
+ <FONT SIZE=-1><% mt('with terms') |h %></FONT>
+ <& /elements/select-terms.html,
+ 'curr_value' => scalar($cgi->param('invoice_terms')),
+ 'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ),
+ 'agentnum' => $cust_or_prospect->agentnum,
+ &>
+ </TD>
+ </TR>
+
+% # false laziness w/misc/order_pkg.html
+ <TR>
+ <TH ALIGN="right"><% mt('Charge date') |h %> </TH>
+ <TD>
+ <INPUT TYPE = "text"
+ NAME = "start_date"
+ SIZE = 32
+ ID = "start_date_text"
+ VALUE = "<% $start_date %>"
+ onKeyPress="return enable_quick_charge(event)"
+ <% $cgi->param('bill_now')
+ ? 'STYLE = "background-color:#dddddd" DISABLED'
+ : ''
+ %>
+ >
+ <IMG SRC = "<%$fsurl%>images/calendar.png"
+ ID = "start_date_button"
+ TITLE = "<% mt('Select date') |h %>"
+ STYLE = "cursor:pointer<% $cgi->param('bill_now') ? ';display:none' : '' %>"
+ >
+ <IMG SRC = "<%$fsurl%>images/calendar-disabled.png"
+ ID = "start_date_button_disabled"
+ <% $cgi->param('bill_now') ? '' : 'STYLE="display:none"' %>
+ >
+ <FONT SIZE=-1>(<% mt('leave blank to charge immediately') |h %>)</FONT>
+ </TD>
+ </TR>
+
+ <SCRIPT TYPE="text/javascript">
+ Calendar.setup({
+ inputField: "start_date_text",
+ ifFormat: "<% $date_format %>",
+ button: "start_date_button",
+ align: "BR"
+ });
+ </SCRIPT>
+
+ <& /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));
+ <TR>
+ <TD ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TD>
+ <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
+ </TR>
+% }
+
+ </TABLE>
+
+% }
+
+% } # if !$cust_pkg
+
+<BR>
+% my $label = $cust_pkg
+% ? emt('Modify one-time charge')
+% : emt('Add one-time charge');
+<INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="<% $label %>" \
+<% ($cgi->param('error') || $cust_pkg) ? '' :' DISABLED' %>>
+
+</FORM>
+
+%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;
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"
$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 = '';
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')
)
);