diff options
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/edit/cust_main/billing.html | 12 | ||||
-rw-r--r-- | httemplate/edit/process/quick-charge.cgi | 2 | ||||
-rw-r--r-- | httemplate/edit/quick-charge.html | 63 | ||||
-rw-r--r-- | httemplate/elements/select-terms.html | 26 |
4 files changed, 89 insertions, 14 deletions
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 363dd0419..ad83778ca 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -411,14 +411,10 @@ <TR> <TD ALIGN="right" WIDTH="200">Invoice terms </TD> <TD WIDTH="408"> - <SELECT NAME="invoice_terms"> - <OPTION VALUE="">Default (<% $conf->config('invoice_default_terms') || 'Payable upon receipt' %>) -% foreach my $term ( 'Payable upon receipt', -% ( map "Net $_", 0, 10, 15, 20, 30, 45, 60 ), -% ) { - <OPTION VALUE="<% $term %>" <% $cust_main->invoice_terms eq $term ? ' SELECTED' : '' %>><% $term %> -% } - </SELECT> + <% include('/elements/select-terms.html', + 'curr_value' => $cust_main->invoice_terms, + ) + %> </TD> </TR> diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 8f0e42471..827530e50 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -55,6 +55,8 @@ unless ( $error ) { $error ||= $cust_main->charge( { 'amount' => $amount, 'quantity' => $quantity, + 'bill_now' => scalar($cgi->param('bill_now')), + 'invoice_terms' => scalar($cgi->param('invoice_terms')), 'start_date' => ( scalar($cgi->param('start_date')) ? str2time($cgi->param('start_date')) : '' diff --git a/httemplate/edit/quick-charge.html b/httemplate/edit/quick-charge.html index 75e3fee14..c96fa6c81 100644 --- a/httemplate/edit/quick-charge.html +++ b/httemplate/edit/quick-charge.html @@ -3,10 +3,10 @@ ) %> -<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> +<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') %> @@ -58,6 +58,23 @@ function validate_quick_charge () { return false; } +function bill_now_changed (what) { + var form = what.form; + if ( what.checked ) { + form.start_date_text.disabled = true; + form.start_date.style.backgroundColor = '#dddddd'; + form.start_date_button.style.display = 'none'; + form.start_date_button_disabled.style.display = ''; + form.invoice_terms.disabled = false; + } else { + form.start_date_text.disabled = false; + form.start_date.style.backgroundColor = '#ffffff'; + form.start_date_button.style.display = ''; + form.start_date_button_disabled.style.display = 'none'; + form.invoice_terms.disabled = true; + } +} + </SCRIPT> <FORM ACTION="process/quick-charge.cgi" NAME="QuickChargeForm" ID="QuickChargeForm" METHOD="POST" onsubmit="document.QuickChargeForm.submit.disabled=true;return validate_quick_charge();"> @@ -84,6 +101,25 @@ function validate_quick_charge () { <% include('/elements/tr-select-pkg_class.html', 'curr_value' => $cgi->param('classnum') ) %> +<TR> + <TD ALIGN="right">Invoice now</TD> + <TD> + <INPUT TYPE = "checkbox" + NAME = "bill_now" + VALUE = "1" + <% $cgi->param('bill_now') ? 'CHECKED' : '' %> + onChange = "bill_now_changed(this);" + > + with terms + <% include('/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> @@ -93,11 +129,16 @@ function validate_quick_charge () { SIZE = 32 ID = "start_date_text" VALUE = "<% $start_date %>" + <% $cgi->param('bill_now') ? 'STYLE = "background-color:#dddddd" DISABLED' : '' %> > - <IMG SRC = "../images/calendar.png" + <IMG SRC = "<%$fsurl%>images/calendar.png" ID = "start_date_button" - STYLE = "cursor: pointer" TITLE = "Select date" + 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> </TD> @@ -232,4 +273,14 @@ $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ or die 'illegal description'; my $pkg = $1; +my $default_terms; +if ( $cust_main->invoice_terms ) { + $default_terms = 'Customer default ('. $cust_main->invoice_terms. ')'; +} else { + $default_terms = + 'Default ('. + ($conf->config('invoice_default_terms') || 'Payable upon receipt'). + ')'; +} + </%init> diff --git a/httemplate/elements/select-terms.html b/httemplate/elements/select-terms.html new file mode 100644 index 000000000..629d1e464 --- /dev/null +++ b/httemplate/elements/select-terms.html @@ -0,0 +1,26 @@ +<SELECT NAME = "invoice_terms" + ID = "invoice_terms" + <% $opt{'disabled'} ? 'DISABLED' : ''%> +> + <OPTION VALUE=""><% $empty_label %> +% foreach my $term ( @terms ) { + <OPTION VALUE="<% $term %>" <% $curr_value eq $term ? ' SELECTED' : '' %>><% $term %> +% } +</SELECT> +<%init> + +my %opt = @_; +my $curr_value = $opt{'curr_value'}; +my $conf = new FS::Conf; + +my $empty_label = + $opt{'empty_label'} + || 'Default ('. + ($conf->config('invoice_default_terms') || 'Payable upon receipt'). + ')'; + +my @terms = ( 'Payable upon receipt', + ( map "Net $_", 0, 10, 15, 20, 30, 45, 60 ), + ); + +</%init> |