+% if ( $cust_pkg ) { #modify one-time charge
+
+<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 => 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 ) {
+<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,
+ }
+ &>
+
+ <& /elements/tr-checkbox.html,
+ label => emt('Invoice this charge separately'),
+ field => 'separate_bill',
+ value => 'Y',
+ curr_value => $cust_pkg->get('separate_bill'),
+ &>
+ <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' => $part_pkg->get('taxclass') &>
+
+ <& /elements/tr-select-taxproduct.html, 'label' => emt('Tax product'), 'onclick' => 'parent.taxproductmagic(this);', 'curr_value' => $part_pkg->get('taxproductnum') &>
+% }
+
+% } else { # new one-time charge
+
+ <TR>
+ <TD ALIGN="right"><% mt('Amount to charge') |h %> </TD>
+ <TD>
+ <% $money_char %><INPUT TYPE = "text"
+ NAME = "amount"
+ SIZE = 8
+ VALUE = "<% $amount %>"
+ onChange = "return enable_quick_charge(event)"
+ onKeyPress = "return enable_quick_charge(event)"
+ >
+ </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>
+ <TD>
+ <INPUT TYPE = "text"
+ NAME = "quantity"
+ SIZE = 4
+ VALUE = "<% $quantity %>"
+ onKeyPress = "return enable_quick_charge(event)">
+ </TD>
+ </TR>
+% }
+
+<& /elements/tr-select-pkg_class.html, 'curr_value' => $classnum &>
+
+% unless ( $quotationnum ) {
+
+ <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_or_prospect->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>
+
+<& /elements/tr-checkbox.html,
+ label => emt('Invoice this charge separately'),
+ field => 'separate_bill',
+ value => 'Y'
+&>
+
+% }
+
+% if ( ! $quotationnum && $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>
+% }
+