1 <% include( 'elements/search.html',
4 'menubar' => [ 'View inventory classes' =>
5 $p.'browse/inventory_class.html',
8 'name' => PL($inventory_class->classname),
11 'table' => 'inventory_item',
13 'select' => join(', ',
17 FS::UI::Web::cust_sql_fields(),
19 'extra_sql' => $extra_sql,
20 'addl_from' => $addl_from,
23 'count_query' => $count_query,
31 $inventory_class->classname,
33 FS::UI::Web::cust_header(),
39 #'svcnum', #XXX proper full service customer link ala svc_acct
40 # "unallocated" ? "available" ?
42 #this could be way more efficient with a mixin
43 # like cust_main_Mixin that let us all all the methods
44 # on data we already have...
45 my $inventory_item = shift;
46 my $cust_svc = $inventory_item->cust_svc;
48 my($label, $value) = $cust_svc->label;
55 \&FS::UI::Web::cust_fields,
58 'align' => 'rll'.FS::UI::Web::cust_aligns(),
63 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
64 FS::UI::Web::cust_header()
71 FS::UI::Web::cust_colors(),
77 FS::UI::Web::cust_styles(),
84 my $curuser = $FS::CurrentUser::CurrentUser;
87 unless $curuser->access_right('Edit inventory')
88 || $curuser->access_right('Edit global inventory')
89 || $curuser->access_right('Configuration');
91 my $classnum = $cgi->param('classnum');
92 $classnum =~ /^(\d+)$/ or errorpage("illegal classnum $classnum");
94 my $extra_sql = "WHERE inventory_item.classnum = $classnum ";
96 my $inventory_class = qsearchs( {
97 'table' => 'inventory_class',
98 'hashref' => { 'classnum' => $classnum },
101 my $title = $inventory_class->classname. ' Inventory';
103 #little false laziness with SQL fragments in inventory_class.pm
104 if ( $cgi->param('avail') ) {
105 $extra_sql .= ' AND ( svcnum IS NULL OR svcnum = 0 )';
106 $title .= ' - Available';
107 } elsif ( $cgi->param('used') ) {
108 $extra_sql .= ' AND svcnum IS NOT NULL AND svcnum > 0';
109 $title .= ' - In use';
113 "SELECT COUNT(*) FROM inventory_item $extra_sql";
116 my $inventory_item = shift;
117 if ( $inventory_item->svcnum ) {
119 #[ "${p}view/svc_acct.cgi?", 'svcnum' ];
123 #'svcdb' => $inventory_item->cust_svc->part_svc->svcdb,
124 'svcdb' => $inventory_item->svcdb, #we have it from the joined search
132 my $link_cust = sub {
133 my $inventory_item = shift;
134 if ( $inventory_item->custnum ) {
135 [ "${p}view/cust_main.cgi?", 'custnum' ];
141 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
142 ' LEFT JOIN part_svc USING ( svcpart ) '.
143 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
144 ' LEFT JOIN cust_main USING ( custnum ) ';