From: ivan Date: Sun, 15 Aug 2010 06:21:06 +0000 (+0000) Subject: fix payment and refund searches by otaker (now usernum), RT#9555 X-Git-Tag: TORRUS_1_0_9~393 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=80f722b82cb92fa49ee172230be3c61f72e56f41 fix payment and refund searches by otaker (now usernum), RT#9555 --- diff --git a/httemplate/elements/select-user.html b/httemplate/elements/select-user.html index bdb92e70f..6264398e2 100644 --- a/httemplate/elements/select-user.html +++ b/httemplate/elements/select-user.html @@ -4,8 +4,8 @@ % } -% foreach my $otaker ( @{ $opt{'otakers'} } ) { - +% foreach my $usernum ( keys %{ $opt{'access_user'} } ) { + % } @@ -14,15 +14,18 @@ my %opt = @_; -unless ( $opt{'otakers'} ) { +unless ( $opt{'access_user'} ) { - my $sth = dbh->prepare("SELECT username,usernum FROM access_user". - " WHERE disabled = '' or disabled IS NULL") - or die dbh->errstr; + tie %{ $opt{'access_user'} }, 'Tie::IxHash'; + + my $sth = dbh->prepare(" + SELECT usernum, username FROM access_user + WHERE disabled = '' or disabled IS NULL + ORDER BY username + ") or die dbh->errstr; $sth->execute or die $sth->errstr; - for($sth->fetchall_arrayref) { - $opt{'otakers'} = [ map { $_->[0] } @$_ ]; - $opt{'usernums'} = [ map { $_->[1] } @$_ ]; + while ( my $row = $sth->fetchrow_arrayref ) { + $opt{'access_user'}->{$row->[0]} = $row->[1]; } } diff --git a/httemplate/graph/money_time.cgi b/httemplate/graph/money_time.cgi index 4e4157ea1..cde71be76 100644 --- a/httemplate/graph/money_time.cgi +++ b/httemplate/graph/money_time.cgi @@ -88,7 +88,7 @@ my %link = ( 'netsales' => "${p}search/cust_bill.html?agentnum=$agentnum;net=1;", 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;", 'netcredits' => "${p}search/cust_credit_bill.html?agentnum=$agentnum;", - 'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;", + 'payments' => "${p}search/cust_pay.html?magic=_date;agentnum=$agentnum;", 'receipts' => "${p}search/cust_bill_pay.html?agentnum=$agentnum;", 'refunds' => "${p}search/cust_refund.html?magic=_date;agentnum=$agentnum;", 'netrefunds' => "${p}search/cust_credit_refund.html?agentnum=$agentnum;", diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi index 058a2251a..4da00c63d 100644 --- a/httemplate/misc/process/batch-cust_pay.cgi +++ b/httemplate/misc/process/batch-cust_pay.cgi @@ -42,6 +42,6 @@ % } else { % % -<% $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %> +<% $cgi->redirect(popurl(3). "search/cust_pay.html?magic=paybatch;paybatch=$paybatch") %> % } diff --git a/httemplate/misc/process/cust_pay-import.cgi b/httemplate/misc/process/cust_pay-import.cgi index d4ff226ec..92b6e5a36 100644 --- a/httemplate/misc/process/cust_pay-import.cgi +++ b/httemplate/misc/process/cust_pay-import.cgi @@ -1,4 +1,4 @@ -<% $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %> +<% $cgi->redirect(popurl(3). "search/cust_pay.html?magic=paybatch;paybatch=$paybatch") %> <%init> my $fh = $cgi->upload('csvfile'); diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi deleted file mode 100755 index 65bd39e19..000000000 --- a/httemplate/search/cust_pay.cgi +++ /dev/null @@ -1,7 +0,0 @@ -<% include( 'elements/cust_pay_or_refund.html', - 'thing' => 'pay', - 'amount_field' => 'paid', - 'name_singular' => 'payment', - 'name_verb' => 'paid', - ) -%> diff --git a/httemplate/search/cust_pay.html b/httemplate/search/cust_pay.html new file mode 100755 index 000000000..65bd39e19 --- /dev/null +++ b/httemplate/search/cust_pay.html @@ -0,0 +1,7 @@ +<% include( 'elements/cust_pay_or_refund.html', + 'thing' => 'pay', + 'amount_field' => 'paid', + 'name_singular' => 'payment', + 'name_verb' => 'paid', + ) +%> diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 4f83d0ab6..114f24549 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -245,8 +245,8 @@ if ( $cgi->param('magic') ) { push @search, "$table.payinfo = '$1'"; } - if ( $cgi->param('otaker') =~ /^(\w+)$/ ) { - push @search, "$table.otaker = '$1'"; + if ( $cgi->param('usernum') =~ /^(\d+)$/ ) { + push @search, "$table.usernum = $1"; } #for cust_pay_pending... statusNOT=done diff --git a/httemplate/search/elements/report_cust_pay_or_refund.html b/httemplate/search/elements/report_cust_pay_or_refund.html new file mode 100644 index 000000000..dff831e5c --- /dev/null +++ b/httemplate/search/elements/report_cust_pay_or_refund.html @@ -0,0 +1,136 @@ +<%doc> + +Examples: + + include( 'elements/report_cust_pay_or_refund.html', + 'thing' => 'pay', + 'name_singular' => 'payment', + ) + + include( 'elements/report_cust_pay_or_refund.html', + 'thing' => 'refund', + 'name_singular' => 'refund', + ) + + +<% include('/elements/header.html', $title ) %> + +
+ + + + + + + + + + + + + + + + + + + + + <% include( '/elements/tr-select-agent.html', + 'curr_value' => scalar($cgi->param('agentnum')), + 'label' => 'for agent: ', + 'disable_empty' => 0, + ) + %> + + <% include( '/elements/tr-select-user.html' ) %> + + + + + + +% if ( $void ) { + + + + +% } + + <% include( '/elements/tr-input-lessthan_greaterthan.html', + 'label' => 'Amount', + 'field' => 'paid', + ) + %> + +
+ Search options +
<% ucfirst(PL($name_singular)) %> of type: + +
Check #: + +
Payment + + <% include( '/elements/tr-input-beginning_ending.html', + layout => 'horiz', + ) + %> +
+
Voided + + <% include( '/elements/tr-input-beginning_ending.html', + prefix => 'void', + layout => 'horiz', + ) + %> +
+
+ +
+ + +
+ +<% include('/elements/footer.html') %> +<%init> + +my %opt = @_; +my $table = 'cust_'.$opt{'thing'}; +my $name_singular = $opt{'name_singular'}; + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); + +my $void = $cgi->param('void') ? 1 : 0; + +my $title = $void ? "Voided $name_singular report" : "\u$name_singular report"; +$table .= '_void' if $void; + + diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 6c10a2e4d..ea7a215fa 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -1,116 +1,5 @@ -<% include('/elements/header.html', $title ) %> - -
- - - - - - - - - - - - - - - - - - - - - <% include( '/elements/tr-select-agent.html', - 'curr_value' => scalar($cgi->param('agentnum')), - 'label' => 'for agent: ', - 'disable_empty' => 0, - ) - %> - - <% include( '/elements/tr-select-otaker.html' ) %> - - - - - - -% if ( $void ) { - - - - -% } - - <% include( '/elements/tr-input-lessthan_greaterthan.html', - 'label' => 'Amount', - 'field' => 'paid', - ) - %> - -
- Search options -
Payments of type: - -
Check #: - -
Payment - - <% include( '/elements/tr-input-beginning_ending.html', - layout => 'horiz', - ) - %> -
-
Voided - - <% include( '/elements/tr-input-beginning_ending.html', - prefix => 'void', - layout => 'horiz', - ) - %> -
-
- -
- - -
- -<% include('/elements/footer.html') %> -<%init> - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); - -my $void = $cgi->param('void') ? 1 : 0; - -my $title = $void ? 'Voided payment report' : 'Payment report'; - - +<% include( 'elements/report_cust_pay_or_refund.html', + 'thing' => 'pay', + 'name_singular' => 'payment', + ) +%> diff --git a/httemplate/search/report_cust_refund.html b/httemplate/search/report_cust_refund.html index 4d311001e..b886f2e19 100644 --- a/httemplate/search/report_cust_refund.html +++ b/httemplate/search/report_cust_refund.html @@ -1,116 +1,5 @@ -<% include('/elements/header.html', $title ) %> - -
- - - - - - - - - - - - - - - - - - - - - <% include( '/elements/tr-select-agent.html', - 'curr_value' => scalar($cgi->param('agentnum')), - 'label' => 'for agent: ', - 'disable_empty' => 0, - ) - %> - - <% include( '/elements/tr-select-otaker.html' ) %> - - - - - - -% if ( $void ) { - - - - -% } - - <% include( '/elements/tr-input-lessthan_greaterthan.html', - 'label' => 'Amount', - 'field' => 'paid', - ) - %> - -
- Search options -
Refunds of type: - -
Check #: - -
Refund - - <% include( '/elements/tr-input-beginning_ending.html', - layout => 'horiz', - ) - %> -
-
Voided - - <% include( '/elements/tr-input-beginning_ending.html', - prefix => 'void', - layout => 'horiz', - ) - %> -
-
- -
- - -
- -<% include('/elements/footer.html') %> -<%init> - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); - -my $void = $cgi->param('void') ? 1 : 0; - -my $title = $void ? 'Voided refund report' : 'Refund report'; - - +<% include( 'elements/report_cust_pay_or_refund.html', + 'thing' => 'refund', + 'name_singular' => 'refund', + ) +%>