Bugzilla – Attachment 25034 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), 5.89 KB, created by
Olli-Antti Kivilahti
on 2014-02-04 17:41:19 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-04 17:41:19 UTC
Size:
5.89 KB
patch
obsolete
>From 5a20725e6e1e581950eb553e4201362c3bf7c266 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 | 25 +++++++++++++++++++++---- > 2 files changed, 29 insertions(+), 7 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..afcc742 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -104,7 +104,12 @@ sub _increment_barcode { > > > sub generate_subfield_form { >- my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_; >+ my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $itemrecord) = @_; >+ >+ if ($tag == 952 && $subfieldtag eq 'c') { >+ my $break = 1; >+ } >+ > > my $frameworkcode = &GetFrameworkCode($biblionumber); > my %subfield_data; >@@ -205,7 +210,19 @@ sub generate_subfield_form { > } > else { > push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} ); >- my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} ); >+ 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}; >@@ -778,7 +795,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 +820,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