From 87e5c306a8c0c82e3030430aeb77e91f50325353 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. --- C4/CourseReserves.pm | 8 ++++++-- course_reserves/add_items.pl | 9 ++++++--- .../prog/en/modules/course_reserves/add_items-step2.tt | 4 ++-- .../prog/en/modules/course_reserves/course-details.tt | 10 +++++----- .../opac-tmpl/bootstrap/en/modules/opac-course-details.tt | 8 ++++---- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 4215422..3a3f422 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 bcfadc7..0f9af5a 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -29,6 +29,8 @@ use C4::Biblio; use C4::CourseReserves qw(GetCourse GetCourseItem GetCourseReserve ModCourseItem ModCourseReserve); +use Koha::Items; + my $cgi = new CGI; my $action = $cgi->param('action') || ''; @@ -36,7 +38,7 @@ my $course_id = $cgi->param('course_id') || ''; my $barcode = $cgi->param('barcode') || ''; my $return = $cgi->param('return') || ''; -my $item = GetBiblioFromItemNumber( undef, $barcode ); +my $item = Koha::Items->find({ barcode => $barcode }); my $step = ( $action eq 'lookup' && $item ) ? '2' : '1'; @@ -54,8 +56,8 @@ $template->param( ERROR_BARCODE_NOT_FOUND => $barcode ) $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( @@ -66,6 +68,7 @@ if ( $action eq 'lookup' ) { $template->param( item => $item, + 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 3286640..7ab45a2 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 [% item.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 9360706..6839033 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 fd2e739..3cab2f9 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.9.3