From 9dde31ca4be9bb6b488b04cad5f412ed6889cd4c 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 Signed-off-by: Rebecca Coert Signed-off-by: Tomas Cohen Arazi --- Koha/Biblio.pm | 3 +- catalogue/detail.pl | 42 ++++++- .../prog/en/modules/catalogue/detail.tt | 109 +++++++++++++++++- 3 files changed, 150 insertions(+), 4 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 6b3d04f81a..d415269ca9 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -35,13 +35,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 0cb204ced9..c5c9792a24 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -46,15 +46,17 @@ use Koha::DateUtils qw( format_sqldatetime ); use C4::HTML5Media; use C4::CourseReserves qw( GetItemCourseReservesInfo ); use Koha::AuthorisedValues; +use Koha::Biblio::Volume::Items; use Koha::Biblios; use Koha::CoverImages; +use Koha::DateUtils; use Koha::Illrequests; -use Koha::Items; use Koha::ItemTypes; +use Koha::Items; use Koha::Patrons; -use Koha::Virtualshelves; use Koha::Plugins; use Koha::SearchEngine::Search; +use Koha::Virtualshelves; my $query = CGI->new(); @@ -97,6 +99,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") ); if ( $holdfor_patron ) { @@ -329,6 +366,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 10596b14e7..ca3777524c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -310,6 +310,10 @@ [% IF CAN_user_tools_items_batchmod %] Modify selected items [% END %] + [% IF biblio.volumes.count %] + Add/move to volume + Remove from volume + [% END %] [% END %] @@ -324,6 +328,7 @@ Current library Home library [% IF ( itemdata_ccode ) %]Collection[% END %] + [% IF Koha.Preference('EnableVolumes') %]Volume[% END %] Call number [% IF volinfo %] Serial enumeration / chronology @@ -398,6 +403,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 ) %] [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %] @@ -1102,7 +1108,7 @@ Note that permanent location is a code, and location may be an authval. -