1 <% include( 'elements/search.html',
4 'menubar' => [ 'View inventory classes' =>
5 $p.'browse/inventory_class.html',
6 'Upload '. PL($inventory_class->classname)=>
7 $p.'misc/inventory_item-import.html?'.
11 'name' => PL($inventory_class->classname),
14 'table' => 'inventory_item',
16 'select' => join(', ',
20 FS::UI::Web::cust_sql_fields(),
22 'extra_sql' => $extra_sql,
23 'addl_from' => $addl_from,
26 'count_query' => $count_query,
34 $inventory_class->classname,
36 FS::UI::Web::cust_header(),
42 #'svcnum', #XXX proper full service customer link ala svc_acct
43 # "unallocated" ? "available" ?
45 #this could be way more efficient with a mixin
46 # like cust_main_Mixin that let us all all the methods
47 # on data we already have...
48 my $inventory_item = shift;
49 my $cust_svc = $inventory_item->cust_svc;
51 my($label, $value) = $cust_svc->label;
58 \&FS::UI::Web::cust_fields,
61 'align' => 'rll'.FS::UI::Web::cust_aligns(),
66 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
67 FS::UI::Web::cust_header()
74 FS::UI::Web::cust_colors(),
80 FS::UI::Web::cust_styles(),
87 my $curuser = $FS::CurrentUser::CurrentUser;
90 unless $curuser->access_right('Edit inventory')
91 || $curuser->access_right('Edit global inventory')
92 || $curuser->access_right('Configuration');
94 my $classnum = $cgi->param('classnum');
95 $classnum =~ /^(\d+)$/ or errorpage("illegal classnum $classnum");
97 my $extra_sql = "WHERE inventory_item.classnum = $classnum ";
99 my $inventory_class = qsearchs( {
100 'table' => 'inventory_class',
101 'hashref' => { 'classnum' => $classnum },
104 my $title = $inventory_class->classname. ' Inventory';
106 #little false laziness with SQL fragments in inventory_class.pm
107 if ( $cgi->param('avail') ) {
108 $extra_sql .= ' AND ( svcnum IS NULL OR svcnum = 0 )';
109 $title .= ' - Available';
110 } elsif ( $cgi->param('used') ) {
111 $extra_sql .= ' AND svcnum IS NOT NULL AND svcnum > 0';
112 $title .= ' - In use';
116 "SELECT COUNT(*) FROM inventory_item $extra_sql";
119 my $inventory_item = shift;
120 if ( $inventory_item->svcnum ) {
122 #[ "${p}view/svc_acct.cgi?", 'svcnum' ];
126 #'svcdb' => $inventory_item->cust_svc->part_svc->svcdb,
127 'svcdb' => $inventory_item->svcdb, #we have it from the joined search
135 my $link_cust = sub {
136 my $inventory_item = shift;
137 if ( $inventory_item->custnum ) {
138 [ "${p}view/cust_main.cgi?", 'custnum' ];
144 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
145 ' LEFT JOIN part_svc USING ( svcpart ) '.
146 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
147 ' LEFT JOIN cust_main USING ( custnum ) ';