X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Finventory_item.html;h=681e5dbacab839df52516b559dcde59618d79312;hb=276c1e6f4efb7ba5568bee9189298bc1a757d34d;hp=cd37e267bfc9ae8d902ee1661d6021993b0196b4;hpb=40a7b3dc653e099f7bd0bd762b649b04c4432db2;p=freeside.git diff --git a/httemplate/search/inventory_item.html b/httemplate/search/inventory_item.html index cd37e267b..681e5dbac 100644 --- a/httemplate/search/inventory_item.html +++ b/httemplate/search/inventory_item.html @@ -1,14 +1,21 @@ <% include( 'elements/search.html', 'title' => $title, - #less lame to use Lingua:: something to pluralize - 'name' => $inventory_class->classname. 's', + 'menubar' => [ 'View inventory classes' => + $p.'browse/inventory_class.html', + 'Upload '. PL($inventory_class->classname)=> + $p.'misc/inventory_item-import.html?'. + "classnum=$classnum" + ], + + 'name' => PL($inventory_class->classname), 'query' => { 'table' => 'inventory_item', - 'hashref' => { 'classnum' => $classnum }, + 'hashref' => {}, 'select' => join(', ', 'inventory_item.*', + 'part_svc.svcdb', 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), @@ -18,6 +25,10 @@ 'count_query' => $count_query, + 'agent_virt' => 1, + 'agent_null' => 1, + 'agent_pos' => 2, + 'header' => [ '#', $inventory_class->classname, @@ -73,12 +84,17 @@ %> <%init> +my $curuser = $FS::CurrentUser::CurrentUser; + die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); my $classnum = $cgi->param('classnum'); $classnum =~ /^(\d+)$/ or errorpage("illegal classnum $classnum"); $classnum = $1; +my $extra_sql = "WHERE inventory_item.classnum = $classnum "; my $inventory_class = qsearchs( { 'table' => 'inventory_class', @@ -88,22 +104,30 @@ my $inventory_class = qsearchs( { my $title = $inventory_class->classname. ' Inventory'; #little false laziness with SQL fragments in inventory_class.pm -my $extra_sql = ''; if ( $cgi->param('avail') ) { - $extra_sql = 'AND ( svcnum IS NULL OR svcnum = 0 )'; + $extra_sql .= ' AND ( svcnum IS NULL OR svcnum = 0 )'; $title .= ' - Available'; } elsif ( $cgi->param('used') ) { - $extra_sql = 'AND svcnum IS NOT NULL AND svcnum > 0'; + $extra_sql .= ' AND svcnum IS NOT NULL AND svcnum > 0'; $title .= ' - In use'; } my $count_query = - "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql"; + "SELECT COUNT(*) FROM inventory_item $extra_sql"; my $link = sub { my $inventory_item = shift; if ( $inventory_item->svcnum ) { - [ "${p}view/svc_acct.cgi?", 'svcnum' ]; + + #[ "${p}view/svc_acct.cgi?", 'svcnum' ]; + my $url = svc_url( + 'm' => $m, + 'action' => 'view', + #'svcdb' => $inventory_item->cust_svc->part_svc->svcdb, + 'svcdb' => $inventory_item->svcdb, #we have it from the joined search + 'query' => '', + ); + [ $url, 'svcnum' ]; } else { ''; }