From 580c390bda0e694d901e892b579bef442d660b5e Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 3 Feb 2021 13:03:31 +1300 Subject: [PATCH] Bug 14237: Add individual bibliographic records to course reserves MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This feature allows a patron to add bibliographic records to course reserves. They can be added individually or in a batch. The courses that have reserved this record will also show on the record's detail page. To test: 1) Update database, refresh schema, and restart services 2) Enable the system preference UseCourseReserves 3) Set up a couple of biblios and a couple of items (attached to different biblios) 4) Go to Course Reserves and add a new course 5) Click Add reserves and put something in both the barcode field and biblionumber field. Click submit and confirm you get an error. 6) Add a barcode in the barcode field and submit. Confirm the item is reserved for the course as expected. 7) Add a biblionumber in the barcode field and submit. Add notes and Save. Confirm the record is reserved for the course as expected and the notes are saved correctly. 8) Edit the record-level course reserve that you just added. Confirm the correct record shows and any edits save as expected. 9) Go back to the course and try removing reserves. Use both the Remove action button for individual reserves and the Remove all reserves button. Confirm both work as expected. 10) Go to Batch add reserves and put something in both the barcodes field and biblionumbers field. Click submit and confirm you get an error. 11) Remove the barcodes and put some biblionumbers in the biblionumbers field. Add notes and Submit. Confirm the records are all added as expected. 12) Click on one of the biblios that has been reserved for the course. Confirm that the course shows under 'Courses that have reserved this title' on the biblio detail page. 13) Go back to the course and click Add reserves. Try and add a biblionumber that is already reserved. Confirm it detects that the biblio has already been reserved. Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ) Signed-off-by: Christian Stelzenmüller Signed-off-by: Kyle M Hall Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- C4/CourseReserves.pm | 107 ++++++----- catalogue/detail.pl | 5 + course_reserves/add_items.pl | 48 ++++- course_reserves/batch_add_items.pl | 130 +++++++++---- .../prog/en/modules/catalogue/detail.tt | 9 + .../course_reserves/add_items-step1.tt | 28 ++- .../course_reserves/add_items-step2.tt | 41 ++++- .../course_reserves/batch_add_items.tt | 101 +++++++--- .../modules/course_reserves/course-details.tt | 174 ++++++++++-------- t/db_dependent/CourseReserves/CourseItems.t | 8 + 10 files changed, 458 insertions(+), 193 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 2a6e5545d5..061c839925 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -292,7 +292,7 @@ sub EnableOrDisableCourseItem { my $course_item = GetCourseItem( ci_id => $ci_id ); - my $info = GetItemCourseReservesInfo( itemnumber => $course_item->{itemnumber} ); + my $info = $course_item->{itemnumber} ? GetItemCourseReservesInfo( itemnumber => $course_item->{itemnumber} ) : GetItemCourseReservesInfo( biblionumber => $course_item->{biblionumber} ); my $enabled = any { $_->{course}->{enabled} eq 'yes' } @$info; $enabled = $enabled ? 'yes' : 'no'; @@ -414,11 +414,21 @@ sub GetCourseItem { my $ci_id = $params{'ci_id'}; my $itemnumber = $params{'itemnumber'}; + my $biblionumber = $params{'biblionumber'}; - return unless ( $itemnumber || $ci_id ); + return unless ( $itemnumber || $biblionumber || $ci_id ); - my $field = ($itemnumber) ? 'itemnumber' : 'ci_id'; - my $value = ($itemnumber) ? $itemnumber : $ci_id; + my ( $field, $value ); + if ( $itemnumber ) { + $field = 'itemnumber'; + $value = $itemnumber; + } elsif ( $biblionumber ) { + $field = 'biblionumber'; + $value = $biblionumber; + } else { + $field = 'ci_id'; + $value = $ci_id; + } my $query = "SELECT * FROM course_items WHERE $field = ?"; my $dbh = C4::Context->dbh; @@ -451,10 +461,16 @@ sub ModCourseItem { my (%params) = @_; my $itemnumber = $params{'itemnumber'}; + my $biblionumber = $params{'biblionumber'}; - return unless ($itemnumber); + return unless ($itemnumber || $biblionumber); - my $course_item = GetCourseItem( itemnumber => $itemnumber ); + my $course_item = $itemnumber ? GetCourseItem( itemnumber => $itemnumber ) : GetCourseItem( biblionumber => $biblionumber ); + + if ( $itemnumber and !$biblionumber ) { + $biblionumber = Koha::Items->find( $itemnumber )->biblionumber; + $params{biblionumber} = $biblionumber; + } my $ci_id; @@ -492,6 +508,7 @@ sub _AddCourseItem { my $ci = Koha::Course::Item->new( { itemnumber => $params{itemnumber}, + biblionumber => $params{biblionumber}, %data, %enabled, } @@ -522,36 +539,39 @@ sub _UpdateCourseItem { my %data = map { $_ => $params{$_} } @FIELDS; my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS; - my $item = Koha::Items->find( $course_item->itemnumber ); - - # Handle updates to changed fields for a course item, both adding and removing - if ( $course_item->is_enabled ) { - my $item_fields = {}; - - for my $field ( @FIELDS ) { - - my $field_enabled = $field . '_enabled'; - my $field_storage = $field . '_storage'; - - # Find newly enabled field and add item value to storage - if ( $params{$field_enabled} && !$course_item->$field_enabled ) { - $enabled{$field_storage} = $item->$field; - $item_fields->{$field} = $params{$field}; - } - # Find newly disabled field and copy the storage value to the item, unset storage value - elsif ( !$params{$field_enabled} && $course_item->$field_enabled ) { - $item_fields->{$field} = $course_item->$field_storage; - $enabled{$field_storage} = undef; - } - # The field was already enabled, copy the incoming value to the item. - # The "original" ( when not on course reserve ) value is already in the storage field - elsif ( $course_item->$field_enabled) { - $item_fields->{$field} = $params{$field}; + if ( $course_item->itemnumber ) { + # biblio-level course items don't store any of these fields + my $item = Koha::Items->find( $course_item->itemnumber ); + + # Handle updates to changed fields for a course item, both adding and removing + if ( $course_item->is_enabled ) { + my $item_fields = {}; + + for my $field ( @FIELDS ) { + + my $field_enabled = $field . '_enabled'; + my $field_storage = $field . '_storage'; + + # Find newly enabled field and add item value to storage + if ( $params{$field_enabled} && !$course_item->$field_enabled ) { + $enabled{$field_storage} = $item->$field; + $item_fields->{$field} = $params{$field}; + } + # Find newly disabled field and copy the storage value to the item, unset storage value + elsif ( !$params{$field_enabled} && $course_item->$field_enabled ) { + $item_fields->{$field} = $course_item->$field_storage; + $enabled{$field_storage} = undef; + } + # The field was already enabled, copy the incoming value to the item. + # The "original" ( when not on course reserve ) value is already in the storage field + elsif ( $course_item->$field_enabled) { + $item_fields->{$field} = $params{$field}; + } } - } - $item->set( $item_fields )->store - if keys %$item_fields; + $item->set( $item_fields )->store + if keys %$item_fields; + } } $course_item->update( { %data, %enabled } ); @@ -830,7 +850,7 @@ sub GetCourseReserves { my $value = ($course_id) ? $course_id : $ci_id; my $query = " - SELECT cr.*, ci.itemnumber + SELECT cr.*, ci.itemnumber, ci.biblionumber FROM course_reserves cr, course_items ci WHERE cr.$field = ? AND cr.ci_id = ci.ci_id @@ -844,7 +864,7 @@ sub GetCourseReserves { if ($include_items) { foreach my $cr (@$course_reserves) { my $item = Koha::Items->find( $cr->{itemnumber} ); - my $biblio = $item->biblio; + my $biblio = $cr->{itemnumber} ? $item->biblio : Koha::Biblios->find( $cr->{biblionumber} ); my $biblioitem = $biblio->biblioitem; $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} ); $cr->{'item'} = $item; @@ -862,7 +882,7 @@ sub GetCourseReserves { if ($include_courses) { foreach my $cr (@$course_reserves) { - $cr->{'courses'} = GetCourses( itemnumber => $cr->{'itemnumber'} ); + $cr->{'courses'} = $cr->{itemnumber} ? GetCourses( itemnumber => $cr->{'itemnumber'} ) : GetCourses( biblionumber => $cr->{biblionumber} ); } } @@ -903,6 +923,7 @@ sub DelCourseReserve { =head2 GetItemCourseReservesInfo my $arrayref = GetItemCourseReservesInfo( itemnumber => $itemnumber ); + my $arrayref = GetItemCourseReservesInfo( biblionumber => $biblionumber ); For a given item, returns an arrayref of reserves hashrefs, with a course hashref under the key 'course' @@ -913,10 +934,11 @@ sub GetItemCourseReservesInfo { my (%params) = @_; my $itemnumber = $params{'itemnumber'}; + my $biblionumber = $params{'biblionumber'}; - return unless ($itemnumber); + return unless ($itemnumber || $biblionumber); - my $course_item = GetCourseItem( itemnumber => $itemnumber ); + my $course_item = $itemnumber ? GetCourseItem( itemnumber => $itemnumber ) : GetCourseItem( biblionumber => $biblionumber ); return unless ( keys %$course_item ); @@ -936,6 +958,8 @@ sub GetItemCourseReservesInfo { ci_id - course_item id OR itemnumber - course_item itemnumber + OR + biblionumber - course_item biblionumber enabled = 'yes' or 'no' Optional, if not supplied, counts reserves @@ -949,10 +973,11 @@ sub CountCourseReservesForItem { my $ci_id = $params{'ci_id'}; my $itemnumber = $params{'itemnumber'}; my $enabled = $params{'enabled'}; + my $biblionumber = $params{'biblionumber'}; - return unless ( $ci_id || $itemnumber ); + return unless ( $ci_id || ( $itemnumber || $biblionumber ) ); - my $course_item = GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber ); + my $course_item = $itemnumber ? GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber ) : GetCourseItem( ci_id => $ci_id, biblionumber => $biblionumber ); my @params = ( $course_item->{'ci_id'} ); push( @params, $enabled ) if ($enabled); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index c282ecf6b8..d4ab19edba 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -589,6 +589,11 @@ if($query->cookie("intranet_bib_list")){ } } +if ( C4::Context->preference('UseCourseReserves') ) { + my $course_reserves = GetItemCourseReservesInfo( biblionumber => $biblionumber ); + $template->param( course_reserves => $course_reserves ); +} + $template->param(biblio => $biblio); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/course_reserves/add_items.pl b/course_reserves/add_items.pl index 7c16a143f5..ec7906775c 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -41,15 +41,29 @@ my $barcode = $cgi->param('barcode') || ''; my $return = $cgi->param('return') || ''; my $itemnumber = $cgi->param('itemnumber') || ''; my $is_edit = $cgi->param('is_edit') || ''; +my $biblionumber = $cgi->param('biblionumber') || ''; $barcode =~ s/^\s*|\s*$//g; #remove leading/trailing whitespace +$biblionumber =~ s/^\s*|\s*$//g; #remove leading/trailing whitespace -my $item = Koha::Items->find( { ( $itemnumber ? ( itemnumber => $itemnumber ) : ( barcode => $barcode ) ) } ); -$itemnumber = $item->id if $item; +my ( $item, $biblio ); -my $title = ($item) ? $item->biblio->title : undef; +if ( $barcode || $itemnumber ) { + # adding an item to course items + $item = $itemnumber ? Koha::Items->find( $itemnumber ) : Koha::Items->find({ barcode => $barcode }); + if ( $item ) { + $itemnumber = $item->id; + $biblio = $item->biblio; + $biblionumber = $biblio->biblionumber; + } +} else { + # adding a biblio to course items + $biblio = Koha::Biblios->find( $biblionumber ); +} + +my $title = $biblio->title if $biblio; -my $step = ( $action eq 'lookup' && $item ) ? '2' : '1'; +my $step = ( $action eq 'lookup' && ( $item or $biblio ) ) ? '2' : '1'; my $tmpl = ($course_id) ? "add_items-step$step.tt" : "invalid-course.tt"; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -60,9 +74,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -if ( !$item && $action eq 'lookup' ){ +if ( !$item && !$biblio && $action eq 'lookup' ){ $template->param( ERROR_ITEM_NOT_FOUND => 1 ); $template->param( UNKNOWN_BARCODE => $barcode ) if $barcode; + $template->param( UNKNOWN_BIBLIONUMBER => $biblionumber ) if $biblionumber; } $template->param( course => GetCourse($course_id) ); @@ -80,7 +95,7 @@ if ( $action eq 'lookup' and $item ) { my $itemtypes = Koha::ItemTypes->search; $template->param( item => $item, - biblio => $item->biblio, + biblio => $biblio, course_item => $course_item, course_reserve => $course_reserve, is_edit => $is_edit, @@ -91,6 +106,26 @@ if ( $action eq 'lookup' and $item ) { return => $return, ); +} elsif ( $action eq 'lookup' and $biblio ) { + my $course_item = Koha::Course::Items->find({ biblionumber => $biblio->biblionumber }); + my $course_reserve = + ($course_item) + ? GetCourseReserve( + course_id => $course_id, + ci_id => $course_item->ci_id, + ) + : undef; + + my $itemtypes = Koha::ItemTypes->search; + $template->param( + biblio => $biblio, + course_item => $course_item, + course_reserve => $course_reserve, + is_edit => $is_edit, + + return => $return, + ); + } elsif ( $action eq 'add' ) { my $itype = scalar $cgi->param('itype'); my $ccode = scalar $cgi->param('ccode'); @@ -106,6 +141,7 @@ if ( $action eq 'lookup' and $item ) { my $ci_id = ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype => $itype, ccode => $ccode, homebranch => $homebranch, diff --git a/course_reserves/batch_add_items.pl b/course_reserves/batch_add_items.pl index 829709930d..4e454201c5 100755 --- a/course_reserves/batch_add_items.pl +++ b/course_reserves/batch_add_items.pl @@ -34,14 +34,13 @@ my $cgi = CGI->new; my $action = $cgi->param('action') || q{}; my $course_id = $cgi->param('course_id') || q{}; my $barcodes = $cgi->param('barcodes') || q{}; +my $biblionumbers = $cgi->param('biblionumbers') || q{}; my $itype = $cgi->param('itype'); my $ccode = $cgi->param('ccode'); my $homebranch = $cgi->param('homebranch'); my $holdingbranch = $cgi->param('holdingbranch'); my $location = $cgi->param('location'); -my $staff_note = $cgi->param('staff_note'); -my $public_note = $cgi->param('public_note'); my $itype_enabled = scalar $cgi->param('itype_enabled') ? 1 : 0; my $ccode_enabled = scalar $cgi->param('ccode_enabled') ? 1 : 0; @@ -68,49 +67,104 @@ if ( $course_id && $course ) { } elsif ( $action eq 'add' ) { my @barcodes = uniq( split( /\s\n/, $barcodes ) ); - - my @items; - my @invalid_barcodes; - for my $b (@barcodes) { - my $item = Koha::Items->find( { barcode => $b } ); - - if ($item) { - push( @items, $item ); + my @biblionumbers = uniq( split( /\s\n/, $biblionumbers ) ); + + if (@barcodes > 0) { + my @items; + my @invalid_barcodes; + for my $b (@barcodes) { + my $item = Koha::Items->find( { barcode => $b } ); + + if ($item) { + push( @items, $item ); + } + else { + push( @invalid_barcodes, $b ); + } } - else { - push( @invalid_barcodes, $b ); + + foreach my $item (@items) { + my $ci_id = ModCourseItem( + itemnumber => $item->id, + biblionumber => $item->biblionumber, + itype => $itype, + ccode => $ccode, + holdingbranch => $holdingbranch, + homebranch => $homebranch, + location => $location, + itype_enabled => $itype_enabled, + ccode_enabled => $ccode_enabled, + holdingbranch_enabled => $holdingbranch_enabled, + homebranch_enabled => $homebranch_enabled, + location_enabled => $location_enabled, + ); + + my $staff_note = $cgi->param('item_staff_note'); + my $public_note = $cgi->param('item_public_note'); + my $cr_id = ModCourseReserve( + course_id => $course_id, + ci_id => $ci_id, + staff_note => $staff_note, + public_note => $public_note, + ); } - } - foreach my $item (@items) { - my $ci_id = ModCourseItem( - itemnumber => $item->id, - itype => $itype, - ccode => $ccode, - holdingbranch => $holdingbranch, - homebranch => $homebranch, - location => $location, - itype_enabled => $itype_enabled, - ccode_enabled => $ccode_enabled, - holdingbranch_enabled => $holdingbranch_enabled, - homebranch_enabled => $homebranch_enabled, - location_enabled => $location_enabled, + $template->param( + action => 'display_results', + items_added => \@items, + invalid_barcodes => \@invalid_barcodes, + course_id => $course_id, + barcodes => 1, ); - my $cr_id = ModCourseReserve( - course_id => $course_id, - ci_id => $ci_id, - staff_note => $staff_note, - public_note => $public_note, + } elsif (@biblionumbers > 0) { + my @biblios; + my @invalid_biblionumbers; + for my $b (@biblionumbers) { + my $biblio = Koha::Biblios->find( $b ); + + if ($biblio) { + push( @biblios, $biblio ); + } + else { + push( @invalid_biblionumbers, $b ); + } + } + + foreach my $biblio (@biblios) { + my $ci_id = ModCourseItem( + itemnumber => undef, + biblionumber => $biblio->id, + itype => $itype, + ccode => $ccode, + holdingbranch => $holdingbranch, + homebranch => $homebranch, + location => $location, + itype_enabled => $itype_enabled, + ccode_enabled => $ccode_enabled, + holdingbranch_enabled => $holdingbranch_enabled, + homebranch_enabled => $homebranch_enabled, + location_enabled => $location_enabled, + ); + + my $staff_note = $cgi->param('biblio_staff_note'); + my $public_note = $cgi->param('biblio_public_note'); + my $cr_id = ModCourseReserve( + course_id => $course_id, + ci_id => $ci_id, + staff_note => $staff_note, + public_note => $public_note, + ); + } + + $template->param( + action => 'display_results', + biblios_added => \@biblios, + invalid_biblionumbers => \@invalid_biblionumbers, + course_id => $course_id, + biblionumbers => 1, ); } - - $template->param( - action => 'display_results', - items_added => \@items, - invalid_barcodes => \@invalid_barcodes, - course_id => $course_id, - ); } } else { $template->param( action => 'invalid_course' ); 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 c7183df68a..494e836e26 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -189,6 +189,15 @@ [% END %] + [% IF course_reserves %] + Courses that have reserved this title: + [% FOREACH c IN course_reserves %] + [% c.course.course_name | html %] + [% IF ( loop.last ) %][% ELSE %]|[% END %] + [% END %] + + [% END %] + [% IF ( AmazonCoverImages || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt index 8b39393b19..67deabc403 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt @@ -1,3 +1,4 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Add items › Course reserves › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -30,8 +31,10 @@ [% IF ERROR_ITEM_NOT_FOUND %] [% IF UNKNOWN_BARCODE %]
No item found with barcode [% UNKNOWN_BARCODE | html %]
+ [% ELSIF UNKNOWN_BIBLIONUMBER %] +
No bibliographic record found with biblionumber [% UNKNOWN_BIBLIONUMBER | html %]
[% ELSE %] -
No item found
+
No item or bibliographic record found
[% END %] [% END %] @@ -49,6 +52,16 @@ +
+ Or use biblionumber of a bibliographic record +
    +
  1. + + +
  2. +
+
+
@@ -58,4 +71,17 @@
+[% MACRO jsinclude BLOCK %] + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] 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 15da092deb..6098b397c1 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 @@ -32,13 +32,21 @@
[% IF course_reserve && !is_edit%]
This course already has this item on reserve.
[% END %] - [% IF course_item %]
Number of courses reserving this item: [% course_item.course_reserves.count | html %]
[% END %] + [% IF course_item %] + [% IF item %] +
Number of courses reserving this item: [% course_item.course_reserves.count | html %]
+ [% ELSE %] +
Number of courses reserving this bibliographic record: [% course_item.course_reserves.count | html %]
+ [% END %] + [% END %]
+ [% IF item # adding an item to course items %] +
[% IF is_edit || course_reserve %] Edit [% biblio.title | html %] in [% course.course_name | html %] @@ -50,6 +58,7 @@ Barcode: [% item.barcode | html %] + [% IF item_level_itypes %] @@ -200,6 +209,36 @@ Checking the box next to the field label will enable changes to that field. Leave boxes unchecked to make no change.
Any items with existing course reserves will have their on reserve values updated.

+ + [% ELSE # adding a biblio to course items %] + +
+ [% IF is_edit || course_reserve %] + Edit [% biblio.title | html %] in [% course.course_name | html %] + [% ELSE %] + Add [% biblio.title | html %] to [% course.course_name | html %] + [% END %] +
    +
  1. + Biblionumber: + [% biblio.biblionumber | html %] + +
  2. + +
  3. + + +
  4. + +
  5. + + +
  6. + +
+
+ + [% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt index 270a9e53b4..153f51c6ef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt @@ -107,13 +107,13 @@
  • - - + +
  • - - + +
  • @@ -123,6 +123,26 @@ Any items with existing course reserves will have their on reserve values updated.

    +
    + Or use biblionumbers of bibliographic records +
      +
    1. + + +
    2. + +
    3. + + +
    4. + +
    5. + + +
    6. +
    +
    +
    @@ -134,27 +154,52 @@ [% IF action == 'display_results' %]

    Results

    -

    Items added

    - [% IF items_added.size > 0 %] -

    The following items were added or updated:

    -
      - [% FOREACH i IN items_added %] -
    • [% i.biblio.title | html %] ( [% i.barcode | html %] )
    • - [% END %] -
    - [% ELSE %] - No valid item barcodes found. - [% END %] - - - [% IF invalid_barcodes.size > 0 %] -

    Invalid barcodes

    -

    The following invalid barcodes were skipped:

    -
      - [% FOREACH b IN invalid_barcodes %] -
    • [% b | html %]
    • - [% END %] -
    + [% IF barcodes %] +

    Items added

    + [% IF items_added.size > 0 %] +

    The following items were added or updated:

    +
      + [% FOREACH i IN items_added %] +
    • [% i.biblio.title | html %] ( [% i.barcode | html %] )
    • + [% END %] +
    + [% ELSE %] + No valid item barcodes found. + [% END %] + + + [% IF invalid_barcodes.size > 0 %] +

    Invalid barcodes

    +

    The following invalid barcodes were skipped:

    +
      + [% FOREACH b IN invalid_barcodes %] +
    • [% b | html %]
    • + [% END %] +
    + [% END %] + [% ELSIF biblionumbers %] +

    Bibliographic records added

    + [% IF biblios_added.size > 0 %] +

    The following bibliographic records were added or updated:

    +
      + [% FOREACH b IN biblios_added %] +
    • [% b.title | html %] ( [% b.biblionumber | html %] )
    • + [% END %] +
    + [% ELSE %] + No valid biblionumbers found. + [% END %] + + + [% IF invalid_biblionumbers.size > 0 %] +

    Invalid biblionumbers

    +

    The following invalid biblionumbers were skipped:

    +
      + [% FOREACH b IN invalid_biblionumbers %] +
    • [% b | html %]
    • + [% END %] +
    + [% END %] [% END %]

    @@ -176,6 +221,12 @@ $('#' + $(this).data('pulldown') ).attr('disabled', 'disabled'); } }); + $("input[type='submit']").click(function(e){ + if ( $("#biblionumbers").val().length > 0 && $("#barcodes").val().length > 0 ) { + e.preventDefault(); + alert(__("Please enter only barcodes, or only biblionumbers.")); + } + }); }); //]]> 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 1e36e2015d..12efce92bb 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 @@ -116,106 +116,118 @@ [% INCLUDE 'biblio-title.inc' biblio=cr.biblio %] [% cr.biblio.author | html %] - [% cr.item.barcode | html %] - [% cr.item.itemcallnumber | html %] - [% IF item_level_itypes %] - - [% IF cr.course_item.itype_enabled %] - [% IF cr.course_item.enabled == 'yes' %] - [% ItemTypes.GetDescription( cr.item.effective_itemtype ) | html %] - ([% ItemTypes.GetDescription( cr.course_item.itype_storage ) | html %]) + + [% IF cr.item %] + [% cr.item.barcode | html %] + [% cr.item.itemcallnumber | html %] + [% IF item_level_itypes %] + + [% IF cr.course_item.itype_enabled %] + [% IF cr.course_item.enabled == 'yes' %] + [% ItemTypes.GetDescription( cr.item.effective_itemtype ) | html %] + ([% ItemTypes.GetDescription( cr.course_item.itype_storage ) | html %]) + [% ELSE %] + [% ItemTypes.GetDescription( cr.course_item.itype ) | html %] + ([% ItemTypes.GetDescription( cr.item.effective_itemtype) | html %]) + [% END %] [% ELSE %] - [% ItemTypes.GetDescription( cr.course_item.itype ) | html %] - ([% ItemTypes.GetDescription( cr.item.effective_itemtype) | html %]) + Unchanged + [% IF cr.item.itype %] + ([% ItemTypes.GetDescription( cr.item.itype ) | html %]) + [% END %] [% END %] - [% ELSE %] - Unchanged - [% IF cr.item.itype %] - ([% ItemTypes.GetDescription( cr.item.itype ) | html %]) - [% END %] + [% END %] - - [% END %] - - [% IF cr.course_item.ccode_enabled %] - [% IF cr.course_item.enabled == 'yes' %] - [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %] - [% IF cr.item.ccode %] - ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.course_item.ccode_storage ) | html %]) - [% END %] - [% ELSE %] - [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.course_item.ccode ) | html %] - [% IF cr.item.ccode %] - ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]) - [% END %] - [% END %] - [% ELSE %] - Unchanged - [% IF cr.item.ccode %] - ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]) - [% END %] - [% END %] - - - [% IF cr.course_item.location_enabled %] - [% IF cr.course_item.enabled == 'yes' %] - [% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %] - [% IF cr.item.permanent_location %] - ([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location_storage ) | html %]) + + [% IF cr.course_item.ccode_enabled %] + [% IF cr.course_item.enabled == 'yes' %] + [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %] + [% IF cr.item.ccode %] + ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.course_item.ccode_storage ) | html %]) + [% END %] + [% ELSE %] + [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.course_item.ccode ) | html %] + [% IF cr.item.ccode %] + ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]) + [% END %] + [% END %] + [% ELSE %] + Unchanged + [% IF cr.item.ccode %] + ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]) + [% END %] + [% END %] + + + [% IF cr.course_item.location_enabled %] + [% IF cr.course_item.enabled == 'yes' %] + [% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %] + [% IF cr.item.permanent_location %] + ([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location_storage ) | html %]) + [% END %] + [% ELSE %] + [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %] + [% IF cr.item.permanent_location %] + ([% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]) + [% END %] [% END %] [% ELSE %] - [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %] + Unchanged [% IF cr.item.permanent_location %] - ([% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]) + ([% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]) [% END %] [% END %] - [% ELSE %] - Unchanged - [% IF cr.item.permanent_location %] - ([% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]) - [% END %] - [% END %] - - - [% IF cr.course_item.homebranch_enabled %] - [% IF cr.course_item.enabled == 'yes' %] - [% Branches.GetName( cr.item.homebranch ) | html %] - [% IF cr.item.homebranch %] - ([% Branches.GetName( cr.course_item.homebranch_storage ) | html %]) + + + [% IF cr.course_item.homebranch_enabled %] + [% IF cr.course_item.enabled == 'yes' %] + [% Branches.GetName( cr.item.homebranch ) | html %] + [% IF cr.item.homebranch %] + ([% Branches.GetName( cr.course_item.homebranch_storage ) | html %]) + [% END %] + [% ELSE %] + [% Branches.GetName( cr.course_item.homebranch ) | html %] + [% IF cr.item.homebranch %] + ([% Branches.GetName( cr.item.homebranch ) | html %]) + [% END %] [% END %] [% ELSE %] - [% Branches.GetName( cr.course_item.homebranch ) | html %] + Unchanged [% IF cr.item.homebranch %] - ([% Branches.GetName( cr.item.homebranch ) | html %]) + ([% Branches.GetName( cr.item.homebranch ) | html %]) [% END %] [% END %] - [% ELSE %] - Unchanged - [% IF cr.item.homebranch %] - ([% Branches.GetName( cr.item.homebranch ) | html %]) - [% END %] - [% END %] - - - [% IF cr.course_item.holdingbranch_enabled %] - [% IF cr.course_item.enabled == 'yes' %] - [% Branches.GetName( cr.item.holdingbranch ) | html %] - [% IF cr.item.holdingbranch %] - ([% Branches.GetName( cr.course_item.holdingbranch_storage ) | html %]) + + + [% IF cr.course_item.holdingbranch_enabled %] + [% IF cr.course_item.enabled == 'yes' %] + [% Branches.GetName( cr.item.holdingbranch ) | html %] + [% IF cr.item.holdingbranch %] + ([% Branches.GetName( cr.course_item.holdingbranch_storage ) | html %]) + [% END %] + [% ELSE %] + [% Branches.GetName( cr.course_item.holdingbranch ) | html %] + [% IF cr.item.holdingbranch %] + ([% Branches.GetName( cr.item.holdingbranch ) | html %]) + [% END %] [% END %] [% ELSE %] - [% Branches.GetName( cr.course_item.holdingbranch ) | html %] + Unchanged [% IF cr.item.holdingbranch %] - ([% Branches.GetName( cr.item.holdingbranch ) | html %]) + ([% Branches.GetName( cr.item.holdingbranch ) | html %]) [% END %] [% END %] + + [% ELSE # record-level course reserve %] + [% IF ( item_level_itypes ) %] + [% ELSE %] - Unchanged - [% IF cr.item.holdingbranch %] - ([% Branches.GetName( cr.item.holdingbranch ) | html %]) - [% END %] + [% END %] - + Information not available for record-level course reserve + + [% END %] + [% IF (cr.staff_note) %] [% cr.staff_note | html %] [% ELSIF (cr.item.itemnotes_nonpublic) %] @@ -264,7 +276,7 @@ [% IF CAN_user_coursereserves_add_reserves || CAN_user_coursereserves_delete_reserves %] [% IF CAN_user_coursereserves_add_reserves %] - Edit + Edit [% END %] [% IF CAN_user_coursereserves_delete_reserves %] diff --git a/t/db_dependent/CourseReserves/CourseItems.t b/t/db_dependent/CourseReserves/CourseItems.t index b34da74a7d..6cf0fcdbc9 100755 --- a/t/db_dependent/CourseReserves/CourseItems.t +++ b/t/db_dependent/CourseReserves/CourseItems.t @@ -39,6 +39,7 @@ my ($biblionumber, $itemnumber) = create_bib_and_item(); my $ci_id = ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype_enabled => 1, ccode_enabled => 1, homebranch_enabled => 1, @@ -82,6 +83,7 @@ is($item->location, 'TH', 'Item location in course should be TH'); ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype_enabled => 1, ccode_enabled => 1, homebranch_enabled => 1, @@ -158,6 +160,7 @@ is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empt ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype_enabled => 1, ccode_enabled => 1, homebranch_enabled => 1, @@ -182,6 +185,7 @@ is($item->ccode, 'DVD', 'Item ccode should be DVD'); ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype_enabled => 1, ccode_enabled => 1, homebranch_enabled => 0, # LEAVE UNCHANGED @@ -208,6 +212,7 @@ subtest 'Ensure modifying fields on existing course items updates the item and c my ($biblionumber, $itemnumber) = create_bib_and_item(); my $ci_id = ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype_enabled => 0, ccode_enabled => 0, homebranch_enabled => 0, @@ -299,6 +304,7 @@ subtest 'Ensure modifying fields on existing course items updates the item and c # Test removing fields from an active course item ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype_enabled => 0, ccode_enabled => 0, homebranch_enabled => 0, @@ -346,6 +352,7 @@ subtest 'Ensure item info is preserved' => sub { #Add course item but change nothing my $course_item_id = ModCourseItem( itemnumber => $item->itemnumber, + biblionumber => $biblionumber, itype => '', ccode => '', holdingbranch => '', @@ -376,6 +383,7 @@ subtest 'Ensure item info is preserved' => sub { #Add course item but change nothing $course_item_id = ModCourseItem( itemnumber => $item->itemnumber, + biblionumber => $biblionumber, itype => '', ccode => '', holdingbranch => '', -- 2.39.5