1 <% include( 'elements/search.html',
4 #less lame to use Lingua:: something to pluralize
5 'name' => $inventory_class->classname. 's',
8 'table' => 'inventory_item',
9 'hashref' => { 'classnum' => $classnum },
10 'select' => join(', ',
13 FS::UI::Web::cust_sql_fields(),
15 'extra_sql' => $extra_sql,
16 'addl_from' => $addl_from,
19 'count_query' => $count_query,
23 $inventory_class->classname,
25 FS::UI::Web::cust_header(),
31 #'svcnum', #XXX proper full service customer link ala svc_acct
32 # "unallocated" ? "available" ?
34 #this could be way more efficient with a mixin
35 # like cust_main_Mixin that let us all all the methods
36 # on data we already have...
37 my $inventory_item = shift;
38 my $cust_svc = $inventory_item->cust_svc;
40 my($label, $value) = $cust_svc->label;
47 \&FS::UI::Web::cust_fields,
50 'align' => 'rll'.FS::UI::Web::cust_aligns(),
55 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
56 FS::UI::Web::cust_header()
63 FS::UI::Web::cust_colors(),
69 FS::UI::Web::cust_styles(),
77 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
79 my $classnum = $cgi->param('classnum');
80 $classnum =~ /^(\d+)$/ or errorpage("illegal classnum $classnum");
83 my $inventory_class = qsearchs( {
84 'table' => 'inventory_class',
85 'hashref' => { 'classnum' => $classnum },
88 my $title = $inventory_class->classname. ' Inventory';
90 #little false laziness with SQL fragments in inventory_class.pm
92 if ( $cgi->param('avail') ) {
93 $extra_sql = 'AND ( svcnum IS NULL OR svcnum = 0 )';
94 $title .= ' - Available';
95 } elsif ( $cgi->param('used') ) {
96 $extra_sql = 'AND svcnum IS NOT NULL AND svcnum > 0';
97 $title .= ' - In use';
101 "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql";
104 my $inventory_item = shift;
105 if ( $inventory_item->svcnum ) {
106 [ "${p}view/svc_acct.cgi?", 'svcnum' ];
111 my $link_cust = sub {
112 my $inventory_item = shift;
113 if ( $inventory_item->custnum ) {
114 [ "${p}view/cust_main.cgi?", 'custnum' ];
120 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
121 ' LEFT JOIN part_svc USING ( svcpart ) '.
122 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
123 ' LEFT JOIN cust_main USING ( custnum ) ';