X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Finventory_class.html;h=2d85f1234cb8eadf981ccd7d265cabd14c5fcb9a;hp=8ce131ac293604d7e55bad8beb74aad666845dba;hb=833cfe5c9938d33c3e6b97ed610c25a7afa6eb04;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/httemplate/browse/inventory_class.html b/httemplate/browse/inventory_class.html index 8ce131ac2..2d85f1234 100644 --- a/httemplate/browse/inventory_class.html +++ b/httemplate/browse/inventory_class.html @@ -1,62 +1,15 @@ <% include( 'elements/browse.html', 'title' => 'Inventory Classes', 'name' => 'inventory classes', - 'menubar' => [ 'Add a new inventory class' => - $p.'edit/inventory_class.html', - ], + 'menubar' => $menubar, 'query' => { 'table' => 'inventory_class', }, 'count_query' => 'SELECT COUNT(*) FROM inventory_class', 'header' => [ '#', 'Inventory class', 'Inventory' ], 'fields' => [ 'classnum', 'classname', - sub { - #my $inventory_class = shift; - my $i_c = shift; - - my $link = - $p. 'search/inventory_item.html?'. - 'classnum='. $i_c->classnum; - - my %actioncol = (); - foreach ( keys %inv_action_link ) { - my($label, $baseurl, $method) = - @{ $inv_action_link{$_} }; - my $url = $baseurl. $i_c->$method(); - $actioncol{$_} = - ''. - '('. - ''. - $label. - ''. - ')'. - ''; - } - - my %num = map { - $_ => $i_c->$_(); - } keys %labels; - - [ map { - [ - { - 'data' => ''. $num{$_}. '', - 'align' => 'right', - }, - { - 'data' => $labels{$_}, - 'align' => 'left', - 'link' => ( $num{$_} - ? $link.$link{$_} - : '' - ), - }, - { 'data' => $actioncol{$_}, - 'align' => 'left', - }, - ] - } keys %labels - ]; - }, + FS::inventory_class->countcell_factory( + 'p'=>$p, + ), ], 'links' => [ $link, $link, @@ -66,28 +19,21 @@ %> <%init> -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); - -tie my %labels, 'Tie::IxHash', - 'num_avail' => 'Available', # (upload batch)', - 'num_used' => 'In use', #'Used', #'Allocated', - 'num_total' => 'Total', -; - -my %link = ( - 'num_avail' => ';avail=1', - 'num_used' => ';used=1', - 'num_total' => '', -); +my $curuser = $FS::CurrentUser::CurrentUser; -my %inv_action_link = ( - 'num_avail' => [ 'upload batch', - $p.'misc/inventory_item-import.html?classnum=', - 'classnum' - ], -); - -my $link = [ "${p}edit/inventory_class.html?", 'classnum' ]; +die "access denied" + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + +my $menubar = $curuser->access_right('Configuration') + ? [ 'Add a new inventory class' => + $p.'edit/inventory_class.html', + ] + : []; + +my $link = $curuser->access_right('Configuration') + ? [ "${p}edit/inventory_class.html?", 'classnum' ] + : '';