[freeside-commits] freeside/httemplate/search agent_inventory.html, NONE, 1.1 report_agent_inventory.html, NONE, 1.1 inventory_item.html, 1.11, 1.12

Ivan,,, ivan at wavetail.420.am
Fri May 21 16:35:26 PDT 2010


Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv4351/httemplate/search

Modified Files:
	inventory_item.html 
Added Files:
	agent_inventory.html report_agent_inventory.html 
Log Message:
reporting on agent inventory, RT#7010

Index: inventory_item.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/inventory_item.html,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -d -r1.11 -r1.12
--- inventory_item.html	21 May 2010 00:09:40 -0000	1.11
+++ inventory_item.html	21 May 2010 23:35:23 -0000	1.12
@@ -103,6 +103,12 @@
 
 my $title = $inventory_class->classname. ' Inventory';
 
+if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+  $extra_sql .= " AND inventory_item.agentnum = $1 ";
+  my $agent = qsearchs('agent', { 'agentnum' => $1 }) or die "unknown agentnum";
+  $title = $agent->agent. " $title";
+}
+
 #little false laziness with SQL fragments in inventory_class.pm
 if ( $cgi->param('avail') ) {
   $extra_sql .= ' AND ( svcnum IS NULL OR svcnum = 0 )';

--- NEW FILE: agent_inventory.html ---
<% include('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>

--- NEW FILE: report_agent_inventory.html ---
<% include('/elements/header.html', 'Inventory summary per agent' ) %>

<FORM ACTION="agent_inventory.html" METHOD="GET">

<TABLE BGCOLOR="#cccccc" CELLSPACING=0>

%# select agents

%# select inventory classes

</TABLE>

<BR>
<INPUT TYPE="submit" VALUE="Search">

</FORM>

<% include('/elements/footer.html') %>
<%init>

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

</%init>




More information about the freeside-commits mailing list