'Edit billing events',
{ rightname=>'Edit global billing events', global=>1 },
+
+ 'Edit inventory',
+ { rightname=>'Edit global inventory', global=>1 },
{ rightname=>'Dialup configuration' },
{ rightname=>'Dialup global configuration', global=>1 },
'columns' => [
'itemnum', 'serial', '', '', '', '',
'classnum', 'int', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
'item', 'varchar', '', $char_d, '', '',
'svcnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'itemnum',
'unique' => [ [ 'classnum', 'item' ] ],
- 'index' => [ [ 'classnum' ], [ 'svcnum' ] ],
+ 'index' => [ [ 'classnum' ], [ 'agentnum' ], [ 'svcnum' ] ],
},
'inventory_class' => {
my $error =
$self->ut_numbern('itemnum')
|| $self->ut_foreign_key('classnum', 'inventory_class', 'classnum' )
+ #|| $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum' )
+ || $self->ut_agentnum_acl('agentnum', ['Configuration',
+ 'Edit global inventory'] )
|| $self->ut_text('item')
|| $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum' )
;
qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
}
+=item agent
+
+Returns the associated agent for this event, if any, as an FS::agent object.
+
+=cut
+
+sub agent {
+ my $self = shift;
+ qsearchs('agent', { 'agentnum' => $self->agentnum } );
+}
+
=back
=head1 SUBROUTINES
my $opt = { 'table' => 'inventory_item',
#'params' => [ 'itembatch', 'classnum', ],
- 'params' => [ 'classnum', ],
+ 'params' => [ 'classnum', 'agentnum', ],
'formats' => { 'default' => [ 'item' ] },
'default_csv' => 1,
};
<% 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' ],
%>
<%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');
tie my %labels, 'Tie::IxHash',
'num_avail' => 'Available', # <FONT SIZE="-1"><A HREF="eventually">(upload batch)</A></FONT>',
],
);
-my $link = [ "${p}edit/inventory_class.html?", 'classnum' ];
+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' ]
+ : '';
</%init>
if ( $curuser->access_right('Configuration') ) {
$config_misc{'Virtual fields'} = [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ];
$config_misc{'Message catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ];
- $config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ];
}
+$config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ]
+ if $curuser->access_right('Edit inventory')
+ || $curuser->access_right('Edit global inventory')
+ || $curuser->access_right('Configuration');
tie my %config_menu, 'Tie::IxHash';
if ( $curuser->access_right('Configuration' ) ) {
'name' => 'InventoryItemImportForm',
'action' => 'process/inventory_item-import.html',
'num_files' => 1,
- #'fields' => [ 'format', 'itembatch', 'classnum', ],
- 'fields' => [ 'format', 'classnum', ],
+ #'fields' => [ 'format', 'itembatch', 'classnum', 'agentnum' ],
+ 'fields' => [ 'format', 'classnum', 'agentnum', ],
'message' => 'Inventory import successful',
#XXX redirect via $itembatch? or just back to class browse?
#'url' => $p."search/phone_avail.html?availbatch=$availbatch",
%# <INPUT TYPE="hidden" NAME="itembatch" VALUE="<% $itembatch %>">
+ <% include('/elements/tr-select-agent.html') %>
+
<% include( '/elements/file-upload.html',
'field' => 'file',
'label' => 'Filename',
#handling agent virtualization
'agent_virt' => 1, # set true if this search should be
# agent-virtualized
+ 'agent_null' => 1, # set true to view global records always
'agent_null_right' => 'Access Right', # optional right to view global
# records
'agent_null_right_link' => 'Access Right' # optional right to link to
|| $opt{'agent_null_right'} );
my $agentnums_sql = $curuser->agentnums_sql(
- 'null_right' => $opt{'agent_null_right'}
+ 'null' => $opt{'agent_null'},
+ 'null_right' => $opt{'agent_null_right'},
+ 'table' => $opt{'query'}{'table'},
);
$opt{'query'}{'extra_sql'} .=
<% 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',
+ ],
+
+ 'name' => PL($inventory_class->classname),
'query' => {
'table' => 'inventory_item',
'count_query' => $count_query,
+ 'agent_virt' => 1,
+ 'agent_null' => 1,
+ 'agent_pos' => 2,
+
'header' => [
'#',
$inventory_class->classname,
%>
<%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");