-<% include("/elements/header-popup.html", 'One-time charge', '',
+<& /elements/header-popup.html, mt('One-time charge'), '',
( $cgi->param('error') ? '' : 'onload="addRow()"' ),
- )
-%>
+&>
<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>
-<% include('/elements/error.html') %>
+<& /elements/error.html &>
<SCRIPT TYPE="text/javascript">
-function enable_quick_charge () {
+function enable_quick_charge (e) {
+
if ( document.QuickChargeForm.amount.value
&& document.QuickChargeForm.pkg.value ) {
document.QuickChargeForm.submit.disabled = false;
} else {
document.QuickChargeForm.submit.disabled = true;
}
+
+% if ( $curuser->option('disable_enter_submit_onetimecharge') ) {
+
+ var key;
+ if (window.event)
+ key = window.event.keyCode; //IE
+ else
+
+ key = e.which; //firefox, others
+
+ return (key != 13);
+
+% } else {
+ return true;
+% }
+
}
function validate_quick_charge () {
</SCRIPT>
-<FORM ACTION="process/quick-charge.cgi" NAME="QuickChargeForm" ID="QuickChargeForm" METHOD="POST" onsubmit="document.QuickChargeForm.submit.disabled=true;return validate_quick_charge();">
+<FORM ACTION = "process/quick-charge.cgi"
+ NAME = "QuickChargeForm"
+ ID = "QuickChargeForm"
+ METHOD = "POST"
+ onSubmit = "document.QuickChargeForm.submit.disabled=true; return validate_quick_charge();"
+>
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc">
+% if ( $cust_pkg ) {
+
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $cust_pkg->pkgnum %>">
+% 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,
+&>
+
+% 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 ) {
+<TR><TD></TD>
+ <TD><INPUT TYPE="checkbox" NAME="adjust_commission" VALUE="Y" CHECKED>
+<% emt('Adjust commission credits if necessary') %>
+</TD>
+</TR>
+% }
+
+% #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
+
<TR>
- <TD ALIGN="right">Amount </TD>
+ <TD ALIGN="right"><% mt('Amount') |h %> </TD>
<TD>
- $<INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $amount %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()">
+ <% $money_char %><INPUT TYPE = "text"
+ NAME = "amount"
+ SIZE = 6
+ VALUE = "<% $amount %>"
+ onChange = "return enable_quick_charge(event)"
+ onKeyPress = "return enable_quick_charge(event)"
+ >
</TD>
</TR>
-% if ( $conf->exists('invoice-unitprice') ) {
+% if ( $conf->exists('invoice-unitprice') ) {
<TR>
- <TD ALIGN="right">Quantity </TD>
+ <TD ALIGN="right"><% mt('Quantity') |h %> </TD>
<TD>
- <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
+ <INPUT TYPE = "text"
+ NAME = "quantity"
+ SIZE = 4
+ VALUE = "<% $quantity %>"
+ onKeyPress = "return enable_quick_charge(event)">
</TD>
</TR>
-% }
+% }
-<% include('/elements/tr-select-pkg_class.html', 'curr_value' => $cgi->param('classnum') ) %>
+<& /elements/tr-select-pkg_class.html, 'curr_value' => $classnum &>
<TR>
- <TD ALIGN="right">Invoice now</TD>
+ <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);"
>
- with terms
- <% include('/elements/select-terms.html',
+ <% mt('with terms') |h %>
+ <& /elements/select-terms.html,
'curr_value' => scalar($cgi->param('invoice_terms')),
- 'empty_value' => $default_terms,
'disabled' => ( $cgi->param('bill_now') ? 0 : 1 ),
- )
- %>
+ &>
</TD>
</TR>
%# false laziness w/misc/order_pkg.html
<TR>
- <TD ALIGN="right">Charge date </TD>
+ <TD ALIGN="right"><% mt('Charge date') |h %> </TD>
<TD>
<INPUT TYPE = "text"
NAME = "start_date"
SIZE = 32
ID = "start_date_text"
VALUE = "<% $start_date %>"
- <% $cgi->param('bill_now') ? 'STYLE = "background-color:#dddddd" DISABLED' : '' %>
+ 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 = "Select date"
+ 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>(leave blank to charge immediately)</FONT>
+ <FONT SIZE=-1>(<% mt('leave blank to charge immediately') |h %>)</FONT>
</TD>
</TR>
<SCRIPT TYPE="text/javascript">
Calendar.setup({
inputField: "start_date_text",
- ifFormat: "%m/%d/%Y",
+ 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">Tax exempt </TD>
+ <TD ALIGN="right"><% mt('Tax exempt') |h %> </TD>
<TD><INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $cgi->param('setuptax') ? 'CHECKED' : '' %>></TD>
</TR>
-<% include('/elements/tr-select-taxclass.html', 'curr_value' => $cgi->param('taxclass') ) %>
+<& /elements/tr-select-taxclass.html, 'curr_value' => $cgi->param('taxclass') &>
-<% include('/elements/tr-select-taxproduct.html', 'label' => 'Tax product', 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') ) %>
+<& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $cgi->param('taxproductnum') &>
-<% include('/elements/tr-select-taxoverride.html', 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') ) %>
+<& /elements/tr-select-taxoverride.html, 'onclick' => 'parent.taxoverridemagic(this);', 'curr_value' => $cgi->param('tax_override') &>
+
+% } # if !$cust_pkg
<TR>
- <TD ALIGN="right">Description </TD>
+ <TD ALIGN="right"><% mt('Description') |h %> </TD>
<TD>
- <INPUT TYPE="text" NAME="pkg" SIZE="50" MAXLENGTH="50" VALUE="<% $pkg %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge()">
+ <INPUT TYPE = "text"
+ NAME = "pkg"
+ SIZE = "50"
+ MAXLENGTH = "50"
+ VALUE = "<% $pkg %>"
+ onChange = "return enable_quick_charge(event)"
+ onKeyPress = "return enable_quick_charge(event)"
+ >
</TD>
</TR>
<TR>
<TD></TD>
- <TD><FONT SIZE="-1">Optional additional description (also printed on invoice): </FONT></TD>
+ <TD><FONT SIZE="-1"><% mt('Optional additional description (also printed on invoice):') |h %> </FONT></TD>
</TR>
% my $row = 0;
-% if ( $cgi->param('error') || $cgi->param('magic') ) {
-% my $param = $cgi->Vars;
-%
-% for ( $row = 0; exists($param->{"description$row"}); $row++ ) {
-
+% foreach (@description) {
<TR>
<TD></TD>
<TD>
- <INPUT TYPE="text" NAME="description<% $row %>" SIZE="60" MAXLENGTH="65" VALUE="<% $param->{"description$row"} |h %>" rownum="<% $row %>" onkeyup = "possiblyAddRow;" >
+ <INPUT TYPE = "text"
+ NAME = "description<% $row %>"
+ SIZE = "60"
+ MAXLENGTH = "65"
+ VALUE = "<% $_ |h %>"
+ rownum = "<% $row %>"
+ onKeyPress = "return enable_quick_charge(event)"
+ onKeyUp = "return possiblyAddRow(event)"
+ >
</TD>
</TR>
-% }
+% $row++;
% }
</TABLE>
<BR>
-<INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="Add one-time charge" <% $cgi->param('error') ? '' :' DISABLED' %>>
+% 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>
var rownum = <% $row %>;
- function possiblyAddRow() {
+ function possiblyAddRow(e) {
+
if ( ( rownum - this.getAttribute('rownum') ) == 1 ) {
addRow();
}
+
+% if ( $curuser->option('disable_enter_submit_onetimecharge') ) {
+
+ var key;
+ if (window.event)
+ key = window.event.keyCode; //IE
+ else
+ key = e.which; //firefox, others
+
+ return (key != 13);
+
+% } else {
+ return true;
+% }
+
}
function addRow() {
var description_cell = document.createElement('TD');
- var description_input = document.createElement('INPUT');
- description_input.setAttribute('name', 'description'+rownum);
- description_input.setAttribute('id', 'description'+rownum);
- description_input.setAttribute('size', 60);
- description_input.setAttribute('maxLength', 65);
- description_input.setAttribute('rownum', rownum);
- description_input.onkeyup = possiblyAddRow;
- description_cell.appendChild(description_input);
+ //var description_input = document.createElement('INPUT');
+ var di = document.createElement('INPUT');
+ di.setAttribute('name', 'description'+rownum);
+ di.setAttribute('id', 'description'+rownum);
+ di.setAttribute('size', 60);
+ di.setAttribute('maxLength', 65);
+ di.setAttribute('rownum', rownum);
+ di.onkeyup = possiblyAddRow;
+ di.onkeypress = enable_quick_charge;
+ description_cell.appendChild(di);
row.appendChild(description_cell);
</HTML>
<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('One-time charge');
+ 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);
+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";
+}
-$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
-my $custnum = $1;
-my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); #XXX agent-virt
+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;
my $default_terms;
if ( $cust_main->invoice_terms ) {
- $default_terms = 'Customer default ('. $cust_main->invoice_terms. ')';
+ $default_terms = emt("Customer default ([_1])", $cust_main->invoice_terms);
} else {
- $default_terms =
- 'Default ('.
- ($conf->config('invoice_default_terms') || 'Payable upon receipt').
- ')';
+ $default_terms = emt("Default ([_1])",
+ ($conf->config('invoice_default_terms') || 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;
+
+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);
+ }
+ }
+}
+
+my $billed = ($cust_pkg and $cust_pkg->get('setup')) ? 1 : 0;
+
</%init>