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' ];
35 %my $link_cust = sub {
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 ) ';
50 <% include( 'elements/search.html',
54 #less lame to use Lingua:: something to pluralize
55 'name' => $inventory_class->classname. 's',
58 'table' => 'inventory_item',
59 'hashref' => { 'classnum' => $classnum },
60 'select' => join(', ',
63 FS::UI::Web::cust_sql_fields(),
65 'extra_sql' => $extra_sql,
66 'addl_from' => $addl_from,
69 'count_query' => $count_query,
73 $inventory_class->classname,
75 FS::UI::Web::cust_header(),
81 #'svcnum', #XXX proper full service customer link ala svc_acct
82 # "unallocated" ? "available" ?
84 #this could be way more efficient with a mixin
85 # like cust_main_Mixin that let us all all the methods
86 # on data we already have...
87 my $inventory_item = shift;
88 my $cust_svc = $inventory_item->cust_svc;
90 my($label, $value) = $cust_svc->label;
97 \&FS::UI::Web::cust_fields,
105 ( map { $link_cust } FS::UI::Web::cust_header() ),