From 550685eff557af23e242c545d6a9e27a7ef44f23 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 10 Oct 2005 12:20:57 +0000 Subject: updated quick payment entry --- httemplate/misc/batch-cust_pay.html | 414 ++++++++++++++++++++++----- httemplate/misc/process/batch-cust_pay.cgi | 40 +++ httemplate/misc/xmlhttp-cust_main-search.cgi | 21 ++ 3 files changed, 399 insertions(+), 76 deletions(-) create mode 100644 httemplate/misc/process/batch-cust_pay.cgi create mode 100644 httemplate/misc/xmlhttp-cust_main-search.cgi (limited to 'httemplate/misc') diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html index b09876b89..ac7f7ffa3 100644 --- a/httemplate/misc/batch-cust_pay.html +++ b/httemplate/misc/batch-cust_pay.html @@ -1,99 +1,234 @@ <%= header( 'Quick payment entry', menubar( - 'Main Menu' => popurl(1), + 'Main Menu' => $p, #popurl(1), + 'Old-style quick payment entry' => + $p. 'search/cust_main-quickpay.html', ), - 'onLoad="addRow()"', + ( $cgi->param('error') ? '' : 'onload="addRow()"' ), ) %> <% if ( $cgi->param('error') ) { %> - Error: <%= $cgi->param('error') %> + <%= $cgi->param('error') %>

<% } %> - + function select_customer() { -
+ var custnum = this.options[this.selectedIndex].value; + var customer = this.options[this.selectedIndex].text; -Batch

+ var searchrow = this.getAttribute('rownum'); + var custnum_obj = document.getElementById('custnum'+searchrow); + var customer_obj = document.getElementById('customer'+searchrow); + + if ( custnum == '' ) { + //this.style.color = '#ff0000'; + + } else if ( custnum == 'cancel' ) { + + custnum_obj.value = ''; + custnum_obj.style.color = '#000000'; + + this.style.display = 'none'; + customer_obj.style.display = ''; + customer_obj.focus(); + + } else { + + + custnum_obj.value = custnum; + custnum_obj.style.color = '#000000'; + + customer_obj.value = customer; + customer_obj.style.color = '#000000'; + + this.style.display = 'none'; + customer_obj.style.display = ''; + + } + + } + + function opt(what,value,text,color) { + var optionName = new Option(text, value, false, false); + optionName.style.color = color; + var length = what.length; + what.options[length] = optionName; + } + + @@ -102,33 +237,160 @@ + - +<% my $row = 0; + if ( $cgi->param('error') ) { + my $param = $cgi->Vars; +%> + + <% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { %> + + + + + + + + + + + + + + + + <% } %> + +<% } %>
Customer Amount Check #
+ " rownum="<%= $row %>"> + + + " rownum="<%= $row %>"> + + + + + $" > + + " > + + <% if ( $param->{"error$row"} ) { %> + Error: <%= $param->{"error$row"} %> + <% } %> +
-
- +
- + + + +<%= include('/elements/xmlhttp.html', + 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', + 'subs' => [qw( custnum_search smart_search )], + ) +%> + + + diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi new file mode 100644 index 000000000..1cc6c3bad --- /dev/null +++ b/httemplate/misc/process/batch-cust_pay.cgi @@ -0,0 +1,40 @@ +<% + my $param = $cgi->Vars; + + #my $paybatch = $param->{'paybatch'}; + my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); + + my @cust_pay = (); + #my $row = 0; + #while ( exists($param->{"custnum$row"}) ) { + for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) { + push @cust_pay, new FS::cust_pay { + 'custnum' => $param->{"custnum$row"}, + 'paid' => $param->{"paid$row"}, + 'payby' => 'BILL', + 'payinfo' => $param->{"payinfo$row"}, + 'paybatch' => $paybatch, + } + if $param->{"custnum$row"} + || $param->{"paid$row"} + || $param->{"payinfo$row"}; + #$row++; + } + + my @errors = FS::cust_pay->batch_insert(@cust_pay); + my $num_errors = scalar(grep $_, @errors); + + if ( $num_errors ) { + + $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : '') ); + + my $erow=0; + $cgi->param('error'. $erow++, shift @errors) while @errors; + + %><%= $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string) + + %><% } else { + + %><%= $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %> + + <% } %> diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi new file mode 100644 index 000000000..8dbd5a4f2 --- /dev/null +++ b/httemplate/misc/xmlhttp-cust_main-search.cgi @@ -0,0 +1,21 @@ +<% + my $sub = $cgi->param('sub'); + + if ( $sub eq 'custnum_search' ) { + + my $custnum = $cgi->param('arg'); + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); + + %>"<%= $cust_main ? $cust_main->name : '' %>" + +<% } elsif ( $sub eq 'smart_search' ) { + + my $string = $cgi->param('arg'); + my @cust_main = smart_search( 'search' => $string ); + my $return = [ map [ $_->custnum, $_->name ], @cust_main ]; + + %><%= objToJson($return) %> + +<% } %> + + -- cgit v1.2.1