From 6156703325d68e052664aa6a460f1a317e31676f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 26 Feb 2020 14:59:40 -0500 Subject: [PATCH] Bug 24857: Add ability to manage item's volumes from detail.pl Signed-off-by: Andrew Fuerste-Henry --- Koha/Biblio.pm | 3 +- catalogue/detail.pl | 67 ++++++++--- .../prog/en/modules/catalogue/detail.tt | 109 +++++++++++++++++- 3 files changed, 163 insertions(+), 16 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index efaf604b8e..724ab9ebf1 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -37,13 +37,14 @@ use Koha::ArticleRequest::Status; use Koha::ArticleRequests; use Koha::Biblio::Metadatas; use Koha::Biblio::Volumes; +use Koha::Biblio::Volumes; use Koha::Biblioitems; use Koha::CirculationRules; use Koha::Item::Transfer::Limits; use Koha::Items; use Koha::Libraries; -use Koha::Suggestions; use Koha::Subscriptions; +use Koha::Suggestions; =head1 NAME diff --git a/catalogue/detail.pl b/catalogue/detail.pl index c968e33dc9..538726d108 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -21,33 +21,36 @@ use Modern::Perl; use CGI qw ( -utf8 ); use HTML::Entities; use Try::Tiny; + +use C4::Acquisition qw(GetOrdersByBiblionumber); use C4::Auth; +use C4::Biblio; +use C4::Circulation; use C4::Context; +use C4::CourseReserves qw(GetItemCourseReservesInfo); +use C4::External::Amazon; +use C4::HTML5Media; +use C4::Images; +use C4::Items; use C4::Koha; -use C4::Serials; #uses getsubscriptionfrom biblionumber use C4::Output; -use C4::Biblio; -use C4::Items; -use C4::Circulation; use C4::Reserves; -use C4::Serials; -use C4::XISBN qw(get_xisbns); -use C4::External::Amazon; use C4::Search; # enabled_staff_search_views +use C4::Serials; +use C4::Serials; #uses getsubscriptionfrom biblionumber use C4::Tags qw(get_tags); +use C4::XISBN qw(get_xisbns); use C4::XSLT; -use C4::Images; -use Koha::DateUtils; -use C4::HTML5Media; -use C4::CourseReserves qw(GetItemCourseReservesInfo); -use C4::Acquisition qw(GetOrdersByBiblionumber); + use Koha::AuthorisedValues; +use Koha::Biblio::Volume::Items; use Koha::Biblios; -use Koha::Items; +use Koha::DateUtils; use Koha::ItemTypes; +use Koha::Items; use Koha::Patrons; -use Koha::Virtualshelves; use Koha::Plugins; +use Koha::Virtualshelves; my $query = CGI->new(); @@ -114,6 +117,41 @@ if ( not defined $record ) { eval { $biblio->metadata->record }; $template->param( decoding_error => $@ ); +my $op = $query->param('op') || q{}; +if ( $op eq 'set_volume' ) { + my $volume_id = $query->param('volume_id'); + my @itemnumbers = $query->multi_param('itemnumber'); + + foreach my $itemnumber (@itemnumbers) { + my $volume_item = + Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } ); + + if ($volume_item) { + $volume_item->volume_id($volume_id); + } + else { + $volume_item = Koha::Biblio::Volume::Item->new( + { + itemnumber => $itemnumber, + volume_id => $volume_id, + } + ); + } + + $volume_item->store(); + } +} +elsif ( $op eq 'unset_volume' ) { + my $volume_id = $query->param('volume_id'); + my @itemnumbers = $query->multi_param('itemnumber'); + + foreach my $itemnumber (@itemnumbers) { + my $volume_item = + Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } ); + $volume_item->delete() if $volume_item; + } +} + if($query->cookie("holdfor")){ my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") ); $template->param( @@ -333,6 +371,7 @@ foreach my $item (@items) { # checking for holds my $item_object = Koha::Items->find( $item->{itemnumber} ); + $item->{object} = $item_object; my $holds = $item_object->current_holds; if ( my $first_hold = $holds->next ) { $item->{first_hold} = $first_hold; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 699e9e8f86..013bb63170 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -220,6 +220,10 @@ [% IF CAN_user_tools_items_batchmod %] Modify selected items [% END %] + [% IF biblio.volumes.count %] + Add/move to volume + Remove from volume + [% END %] [% END %] @@ -231,6 +235,7 @@ Current location Home library [% IF ( itemdata_ccode ) %]Collection[% END %] + [% IF Koha.Preference('EnableVolumes') %]Volume[% END %] Call number [% IF volinfo %] [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%] @@ -292,6 +297,7 @@ Note that permanent location is a code, and location may be an authval. [% IF ( itemdata_ccode ) %][% item.ccode | html %][% END %] + [% IF Koha.Preference('EnableVolumes') %][% item.object.volume.description | html %][% END %] [% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %] [% IF ( volinfo ) %] @@ -974,7 +980,7 @@ Note that permanent location is a code, and location may be an authval. -