librarians can only add/edit/delete items on their own branches.
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
use MARC::Record;
use C4::Log;
use C4::Koha; # XXX subfield_is_koha_internal_p
+use C4::Branch; # XXX subfield_is_koha_internal_p
use Date::Calc qw(Today);
use MARC::File::USMARC;
use MARC::File::XML;
#---- branch
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
- my $sth =
- $dbh->prepare(
- "select branchcode,branchname from branches order by branchname");
- $sth->execute;
- push @authorised_values, ""
- unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
-
- while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
- push @authorised_values, $branchcode;
- $authorised_lib{$branchcode} = $branchname;
+ #Use GetBranches($onlymine)
+ my $onlymine=C4::Context->preference('IndependantBranches') &&
+ C4::Context->userenv &&
+ C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{branch};
+ my $branches = GetBranches($onlymine);
+ my @branchloop;
+ foreach my $thisbranch ( sort keys %$branches ) {
+ push @authorised_values, $thisbranch;
+ $authorised_lib{$thisbranch} = $branches->{$thisbranch}->{'branchname'};
}
#----- itemtypes
use C4::Biblio;
use C4::Context;
use C4::Koha; # XXX subfield_is_koha_internal_p
+use C4::Branch; # XXX subfield_is_koha_internal_p
use Date::Calc qw(Today);
use MARC::File::XML;
my $index_subfield= int(rand(1000000));
if($subfield eq '@'){
- $subfield_data{id} = "tag_".$tag."_subfield_0_".$index_subfield;
+ $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield;
} else {
$subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield;
}
#---- branch
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
- my $sth =
- $dbh->prepare(
- "select branchcode,branchname from branches order by branchname");
- $sth->execute;
- push @authorised_values, ""
- unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
-
- while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
- push @authorised_values, $branchcode;
- $authorised_lib{$branchcode} = $branchname;
+ #Use GetBranches($onlymine)
+ my $onlymine=C4::Context->preference('IndependantBranches') &&
+ C4::Context->userenv &&
+ C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{branch};
+ my $branches = GetBranches($onlymine);
+ my @branchloop;
+ foreach my $thisbranch ( sort keys %$branches ) {
+ push @authorised_values, $thisbranch;
+ $authorised_lib{$thisbranch} = $branches->{$thisbranch}->{'branchname'};
}
-
+
#----- itemtypes
}
elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
<!-- TMPL_LOOP NAME="item_loop" -->
<tr>
<!-- TMPL_VAR NAME="item_value" -->
- <td><a href="additem.pl?op=edititem&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">Edit</a></td>
- <td><a href="javascript:confirm_deletion(<!-- TMPL_VAR NAME="biblionumber" -->,<!-- TMPL_VAR NAME="itemnumber" -->)">Delete</a></td>
+ <!-- TMPL_IF Name="nomod"--> <td colspan="2"> </td><!--TMPL_ELSE--><td><a href="additem.pl?op=edititem&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">Edit</a></td>
+ <td><a href="javascript:confirm_deletion(<!-- TMPL_VAR NAME="biblionumber" -->,<!-- TMPL_VAR NAME="itemnumber" -->)">Delete</a></td><!--/TMPL_IF-->
</tr>
<!-- /TMPL_LOOP -->
</table>