X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fquick-charge.html;h=466091dfac97173e6faa0625d7cf32ff317943dc;hb=924fbbe678936174dd7d49a123d227e884a2dd37;hp=95ec70c54c9dd5f3d59031e4f9e6142482551888;hpb=ba5deb42e573673383c8e9dac0dfe3e4296c4b6d;p=freeside.git diff --git a/httemplate/edit/quick-charge.html b/httemplate/edit/quick-charge.html index 95ec70c54..466091dfa 100644 --- a/httemplate/edit/quick-charge.html +++ b/httemplate/edit/quick-charge.html @@ -1,42 +1,47 @@ -<% include("/elements/header-popup.html", 'One-time charge entry', '', +<& /elements/header-popup.html, mt('One-time charge'), '', ( $cgi->param('error') ? '' : 'onload="addRow()"' ), - ) -%> +&> -<% include('/elements/error.html') %> + + + + + +<& /elements/error.html &> -
+ - + -<% include('/elements/tr-select-pkg_class.html', '') %> -<% include('/elements/tr-select-taxclass.html') %> - + +% if ( $conf->exists('invoice-unitprice') ) { + + + + +% } + +<& /elements/tr-select-pkg_class.html, 'curr_value' => $cgi->param('classnum') &> + + + + +%# false laziness w/misc/order_pkg.html + + + + + + + +% if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) { +% my $what = lc(FS::payby->shortname($cust_main->payby)); + + + + +% } + + + + + + +<& /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') &> + + + + + + - + % my $row = 0; -% if ( $cgi->param('error') ) { +% if ( $cgi->param('error') || $cgi->param('magic') ) { % my $param = $cgi->Vars; % % for ( $row = 0; exists($param->{"description$row"}); $row++ ) { @@ -104,7 +234,15 @@ function validate_quick_charge () { % } @@ -114,7 +252,7 @@ function validate_quick_charge () {
Amount:<% mt('Amount') |h %> - $ + <% $money_char %>
Description:
<% mt('Quantity') |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 ), + &>
<% 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 %> param('setuptax') ? 'CHECKED' : '' %>>
<% mt('Description') |h %> + +
Optional additional description: <% mt('Optional additional description (also printed on invoice):') |h %>
- " rownum="<% $row %>" onkeyup = "possiblyAddRow;" > + " + rownum = "<% $row %>" + onKeyPress = "return enable_quick_charge(event)" + onKeyUp = "return possiblyAddRow(event)" + >

-param('error') ? '' :' DISABLED' %>> +param('error') ? '' :' DISABLED' %>>
@@ -123,10 +261,26 @@ function validate_quick_charge () { 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() { @@ -141,14 +295,16 @@ function validate_quick_charge () { 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); @@ -164,19 +320,44 @@ function validate_quick_charge () { <%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') || '$'; $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum'; my $custnum = $1; +my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); #XXX agent-virt + +my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi? +my $start_date = $cust_main->next_bill_date; +$start_date = $start_date ? time2str($format, $start_date) : ''; my $amount = ''; if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) { $amount = $1; } +my $quantity = 1; +if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) { + $quantity = $1; +} + $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ or die 'illegal description'; my $pkg = $1; +my $default_terms; +if ( $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') || emt('Payable upon receipt')) + ); +} +