merge NG auth, RT#21563
[freeside.git] / httemplate / misc / xmlhttp-cust_bill-search.html
1 <% encode_json(\@return) %>\
2 <%init>
3
4 my $curuser = $FS::CurrentUser::CurrentUser;
5 die 'access denied' unless $curuser->access_right('View invoices');
6 my @return;
7 if ( $cgi->param('sub') eq 'custnum_search_open' ) { 
8   my $custnum = $cgi->param('arg');
9   if ( $custnum =~ /^(\d+)$/ ) {
10 #warn "searching invoices for $custnum\n";
11     my $cust_main = FS::cust_main->by_key($custnum);
12     @return = map { 
13       +{ $_->hash, 
14         'owed' => $_->owed }
15     } $cust_main->open_cust_bill
16       if $curuser->agentnums_href->{ $cust_main->agentnum };
17   }
18 }
19
20 </%init>