summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-cust_bill-search.html
blob: 459c5db3e2c25cdde29108ea942968f58d663c4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<% encode_json(\@return) %>
<%init>

my $curuser = $FS::CurrentUser::CurrentUser;
die 'access denied' unless $curuser->access_right('View invoices');
my @return;
if ( $cgi->param('sub') eq 'custnum_search_open' ) { 
  my $custnum = $cgi->param('arg');
  if ( $custnum =~ /^(\d+)$/ ) {
#warn "searching invoices for $custnum\n";
    my $cust_main = FS::cust_main->by_key($custnum);
    @return = map { 
      +{ $_->hash, 
        'owed' => $_->owed }
    } $cust_main->open_cust_bill
      if $curuser->agentnums_href->{ $cust_main->agentnum };
  }
}

</%init>