From dadfeabc379ffeb417aad28e544fbdcc292d2755 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Mar 2017 10:15:30 -0300 Subject: [PATCH] Bug 18276: Remove GetBiblioFromItemNumber - Course reserves Values from the items, biblio and biblioitems tables are used in the template, so we need to pass all of them to the template, but separately. That way we easily see which field from which table we are displaying. Test plan: Create a course reserve and add items. Correct information must be displayed on the detail page of the course reserve, on staff and OPAC interface. Signed-off-by: Josef Moravec Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/CourseReserves.pm | 8 ++++++-- course_reserves/add_items.pl | 7 ++++--- .../prog/en/modules/course_reserves/add_items-step2.tt | 4 ++-- .../prog/en/modules/course_reserves/course-details.tt | 10 +++++----- .../bootstrap/en/modules/opac-course-details.tt | 8 ++++---- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 42154225b7..3a3f422a96 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -21,7 +21,6 @@ use List::MoreUtils qw(any); use C4::Context; use C4::Items qw(GetItem ModItem); -use C4::Biblio qw(GetBiblioFromItemNumber); use C4::Circulation qw(GetOpenIssue); use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS); @@ -877,8 +876,13 @@ sub GetCourseReserves { if ($include_items) { foreach my $cr (@$course_reserves) { + my $item = Koha::Items->find( $cr->{itemnumber} ); + my $biblio = $item->biblio; + my $biblioitem = $biblio->biblioitem; $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} ); - $cr->{'item'} = GetBiblioFromItemNumber( $cr->{'itemnumber'} ); + $cr->{'item'} = $item; + $cr->{'biblio'} = $biblio; + $cr->{'biblioitem'} = $biblioitem; $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} ); } } diff --git a/course_reserves/add_items.pl b/course_reserves/add_items.pl index 89cbb47eb7..f48c113a37 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -30,6 +30,7 @@ use Koha::Items; use C4::CourseReserves qw(GetCourse GetCourseItem GetCourseReserve ModCourseItem ModCourseReserve); +use Koha::Items; use Koha::ItemTypes; my $cgi = new CGI; @@ -60,8 +61,8 @@ $template->param( ERROR_BARCODE_NOT_FOUND => $barcode . $inumber ) $template->param( course => GetCourse($course_id) ); -if ( $action eq 'lookup' ) { - my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} ); +if ( $action eq 'lookup' and $item ) { + my $course_item = GetCourseItem( itemnumber => $item->itemnumber ); my $course_reserve = ($course_item) ? GetCourseReserve( @@ -73,7 +74,7 @@ if ( $action eq 'lookup' ) { my $itemtypes = Koha::ItemTypes->search; $template->param( item => $item, - title => $title, + biblio => $item->biblio, course_item => $course_item, course_reserve => $course_reserve, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt index bc5831a7ec..7ab45a2b4b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt @@ -9,7 +9,7 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] - +
@@ -23,7 +23,7 @@
- Add [% title %] to [% course.course_name %] + Add [% biblio.title %] to [% course.course_name %]
  1. Barcode: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt index 7ab27d8a6c..3e6f8c3a4b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt @@ -102,9 +102,9 @@ [% FOREACH cr IN course_reserves %] - [% cr.item.title %] - [% cr.item.author %] - [% cr.item.barcode %] + [% cr.biblio.title %] + [% cr.biblio.author %] + [% cr.item.barcode %] [% cr.item.itemcallnumber %] [% IF item_level_itypes %] @@ -180,8 +180,8 @@ [% IF (cr.item.uri) %] Item URI - [% ELSIF (cr.item.url) %] - Record URL + [% ELSIF (cr.biblioitem.url) %] + Record URL [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt index fd2e739731..3cab2f9239 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt @@ -66,8 +66,8 @@ [% FOREACH cr IN course_reserves %] - [% cr.item.title %] - [% cr.item.author %] + [% cr.biblio.title %] + [% cr.biblio.author %] [% ItemTypes.GetDescription( cr.item.itype ) %] [% Branches.GetName( cr.item.holdingbranch ) %]
    [% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %] [% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %] @@ -83,8 +83,8 @@ [% IF (cr.item.uri) %] Item URI - [% ELSIF (cr.item.url) %] - Record URL + [% ELSIF (cr.biblioitem.url) %] + Record URL [% END %] -- 2.39.5