summaryrefslogtreecommitdiff
path: root/httemplate/search/agent_inventory.html
blob: 015aca46b1836b364fff2a05aca458fc0f0979f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<& elements/search.html,
     'title'         => 'Inventory summary per agent',
     'name_singular' => 'agent',
     'query'         => { 'table'     => 'agent',
                          'hashref'   => { 'disabled' => '' },
                          'extra_sql' => "AND $agentnums_sql",
                        },
     'count_query'   => "SELECT COUNT(*) FROM agent".
                        " WHERE disabled = '' OR disabled IS NULL".
                        " AND $agentnums_sql",
     'header'        => \@header,
     'fields'        => \@fields,
&>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
#XXX List inventory

my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql;

my @header = ('Agent');
my @fields = ('agent');

                                                        #{ 'disabled' => '' }
foreach my $inventory_class ( qsearch('inventory_class', {}) ) {
  push @header, $inventory_class->classname;
  push @fields, sub {
    my $agent = shift;
    my $sub = FS::inventory_class->countcell_factory(
      'p' => $p, 'agentnum' => $agent->agentnum,
    );
    &{$sub}($inventory_class);
  };
}

#XXX show global inventory too

</%init>