Bugzilla – Attachment 25060 Details for
Bug 11676
Loading shelving locations based on the item's homebranch instead of the user's logged-in branch.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11676 - Loading shelving locations based on the item's homebranch instead of the user's logged-in branch. For pageload.
Bug-11676---Loading-shelving-locations-based-on-th.patch (text/plain), 6.51 KB, created by
Olli-Antti Kivilahti
on 2014-02-05 16:32:52 UTC
(
hide
)
Description:
Bug 11676 - Loading shelving locations based on the item's homebranch instead of the user's logged-in branch. For pageload.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2014-02-05 16:32:52 UTC
Size:
6.51 KB
patch
obsolete
>From b98431b95a1d9b871c14a994871364186721e4a0 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 4 Feb 2014 18:00:33 +0200 >Subject: [PATCH] Bug 11676 - Loading shelving locations based on the item's > homebranch instead of the user's logged-in branch. For pageload. > >-Modifies the Koha::GetAuthorisedValues() to support passing a branchcode as a parameter >-Modifies cataloguing/additem.pl to find the items.homebranch and pass this to the > GetAuthorisedValues(). > >------------- >- TEST PLAN - >------------- > >1. Define shelving locations for a specific branch: > Go to Administration -> Authorised values -> category: LOC, > Add a new value X specific to branch A, > Add a new value Y specific to branch B. >2. Set your logged in library to branch C. >3. Edit an item. Set the Permanent location to branch A. Save the item. >4. Edit the item. Shelving locations has location X selectable in addition to the default > ones. Set the Permanent location to branch B. Save the item. >5. Edit the item. Shelving locations has location Y selectable in addition to the default > ones. Set the Permanent location to branch C. Save the item. >6. Edit the item. Shelving locations has neither Y or X selectable. Don't save. >7. Set your logged in branch to A. >8. Edit the item. Shelving locations has neither Y or X selectable. Don't save. > >This is how we do it! >--- > C4/Koha.pm | 11 ++++++++--- > cataloguing/additem.pl | 34 +++++++++++++++++++++++----------- > 2 files changed, 31 insertions(+), 14 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 4202957..f420ff3 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1018,7 +1018,7 @@ sub GetAuthValCodeFromField { > > =head2 GetAuthorisedValues > >- $authvalues = GetAuthorisedValues([$category], [$selected]); >+ $authvalues = GetAuthorisedValues([$category], [$selected], [$opac], [$branch_limit]); > > This function returns all authorised values from the'authorised_value' table in a reference to array of hashrefs. > >@@ -1026,11 +1026,16 @@ C<$category> returns authorised values for just one category (optional). > > C<$opac> If set to a true value, displays OPAC descriptions rather than normal ones when they exist. > >+C<$branch_limit> branchcode, returns authorised values for this branchcode and for authorised values for the default branch (optional). >+ > =cut > > sub GetAuthorisedValues { >- my ( $category, $selected, $opac ) = @_; >- my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; >+ my ( $category, $selected, $opac, $branch_limit ) = @_; >+ if (! $branch_limit) { >+ $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; >+ } >+ > my @results; > my $dbh = C4::Context->dbh; > my $query = qq{ >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 268ef66..9942b1c 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -104,9 +104,9 @@ sub _increment_barcode { > > > sub generate_subfield_form { >- my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_; >- >- my $frameworkcode = &GetFrameworkCode($biblionumber); >+ my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $itemrecord) = @_; >+ >+ my $frameworkcode = &GetFrameworkCode($biblionumber); > my %subfield_data; > my $dbh = C4::Context->dbh; > >@@ -204,12 +204,24 @@ sub generate_subfield_form { > #---- "true" authorised value > } > else { >- push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} ); >- my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} ); >- for my $r ( @$av ) { >- push @authorised_values, $r->{authorised_value}; >- $authorised_lib{$r->{authorised_value}} = $r->{lib}; >- } >+ push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} ); >+ my $av; >+ #Bug 11676 #Limit the available shelving locations based on the item's homebranch instead of the user's logged in branch >+ if ($subfieldlib->{authorised_value} eq 'LOC' && $itemrecord) { >+ #Get the homebranch of the item >+ my ( $homebranch_field, $homebranch_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.homebranch", $frameworkcode ); >+ my $homebranch = $itemrecord->subfield( $homebranch_field, $homebranch_subfield ); >+ #Get the shelving locations limited by the item's homebranch >+ $av = GetAuthorisedValues( $subfieldlib->{authorised_value}, undef, undef, $homebranch ); >+ } >+ else { >+ $av = GetAuthorisedValues( $subfieldlib->{authorised_value} ); >+ } >+ >+ for my $r ( @$av ) { >+ push @authorised_values, $r->{authorised_value}; >+ $authorised_lib{$r->{authorised_value}} = $r->{lib}; >+ } > } > > if ($subfieldlib->{'hidden'}) { >@@ -778,7 +790,7 @@ if($itemrecord){ > next if subfield_is_koha_internal_p($subfieldtag); > next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); > >- my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); >+ my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $itemrecord); > > push @fields, "$tag$subfieldtag"; > push (@loop_data, $subfield_data); >@@ -803,7 +815,7 @@ foreach my $tag ( keys %{$tagslib}){ > my @values = (undef); > @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag))); > for my $value (@values){ >- my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); >+ my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $itemrecord); > push (@loop_data, $subfield_data); > $i++; > } >-- >1.8.1.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11676
:
25034
|
25035
|
25036
| 25060 |
25061
|
25062
|
25064
|
25065
|
26796
|
26965