From 458111f263aaa67b50cc101251cd637bf2bc1d2e Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 22 Oct 2007 14:43:16 -0500 Subject: [PATCH] Managing IndependantBranches when creating a new Biblio librarians can only add/edit/delete items on their own branches. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- cataloguing/addbiblio.pl | 21 ++++++++-------- cataloguing/additem.pl | 25 ++++++++++--------- .../prog/en/modules/cataloguing/additem.tmpl | 4 +-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 234b3e6852..5e6a224bb5 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -29,6 +29,7 @@ use C4::Context; 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; @@ -163,16 +164,16 @@ sub build_authorized_values_list ($$$$$$$) { #---- 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 diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 32c17f20d1..81b904dc98 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -25,6 +25,7 @@ use C4::Output; 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; @@ -256,7 +257,7 @@ foreach my $tag (sort keys %{$tagslib}) { 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; } @@ -308,18 +309,18 @@ foreach my $tag (sort keys %{$tagslib}) { #---- 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" ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl index 221353d8c4..e51ddd2227 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tmpl @@ -155,8 +155,8 @@ function CreateKey(){ - &itemnumber=">Edit - ,)">Delete +  &itemnumber=">Edit + ,)">Delete -- 2.39.5