3 my $classnum = $cgi->param('classnum');
4 $classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum";
7 my $inventory_class = qsearchs( {
8 'table' => 'inventory_class',
9 'hashref' => { 'classnum' => $classnum },
12 my $title = $inventory_class->classname. ' Inventory';
14 #little false laziness with SQL fragments in inventory_class.pm
16 if ( $cgi->param('avail') ) {
17 $extra_sql = 'AND ( svcnum IS NULL OR svcnum = 0 )';
18 $title .= ' - Available';
19 } elsif ( $cgi->param('used') ) {
20 $extra_sql = 'AND svcnum IS NOT NULL AND svcnum > 0';
21 $title .= ' - In use';
25 "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql";
28 my $inventory_item = shift;
29 if ( $inventory_item->svcnum ) {
30 [ "${p}view/svc_acct.cgi?", 'svcnum' ];
36 my $inventory_item = shift;
37 if ( $inventory_item->custnum ) {
38 [ "${p}view/cust_main.cgi?", 'custnum' ];
44 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
45 ' LEFT JOIN part_svc USING ( svcpart ) '.
46 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
47 ' LEFT JOIN cust_main USING ( custnum ) ';
49 %><%= include( 'elements/search.html',
53 #less lame to use Lingua:: something to pluralize
54 'name' => $inventory_class->classname. 's',
57 'table' => 'inventory_item',
58 'hashref' => { 'classnum' => $classnum },
59 'select' => join(', ',
62 FS::UI::Web::cust_sql_fields(),
64 'extra_sql' => $extra_sql,
65 'addl_from' => $addl_from,
68 'count_query' => $count_query,
72 $inventory_class->classname,
74 FS::UI::Web::cust_header(),
80 #'svcnum', #XXX proper full service customer link ala svc_acct
81 # "unallocated" ? "available" ?
83 #this could be way more efficient with a mixin
84 # like cust_main_Mixin that let us all all the methods
85 # on data we already have...
86 my $inventory_item = shift;
87 my $cust_svc = $inventory_item->cust_svc;
89 my($label, $value) = $cust_svc->label;
96 \&FS::UI::Web::cust_fields,
104 ( map { $link_cust } FS::UI::Web::cust_header() ),