From f99fa0f7c5185992fc38444a63174be6950466e7 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 --- C4/CourseReserves.pm | 107 ++++++++----- course_reserves/add_items.pl | 48 +++++- .../en/modules/course_reserves/add_items-step1.tt | 14 +- .../en/modules/course_reserves/add_items-step2.tt | 41 ++++- .../en/modules/course_reserves/course-details.tt | 174 +++++++++++---------- t/db_dependent/CourseReserves/CourseItems.t | 8 + 6 files changed, 261 insertions(+), 131 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 1c08ad4d5e..c944886471 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -298,7 +298,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'; @@ -424,11 +424,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; @@ -462,10 +472,16 @@ sub ModCourseItem { warn identify_myself(%params) if $DEBUG; 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; @@ -504,6 +520,7 @@ sub _AddCourseItem { my $ci = Koha::Course::Item->new( { itemnumber => $params{itemnumber}, + biblionumber => $params{biblionumber}, %data, %enabled, } @@ -535,36 +552,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 } ); @@ -850,7 +870,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 @@ -864,7 +884,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; @@ -882,7 +902,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} ); } } @@ -924,6 +944,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' @@ -935,10 +956,11 @@ sub GetItemCourseReservesInfo { warn identify_myself(%params) if $DEBUG; 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 ); @@ -958,6 +980,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 @@ -972,10 +996,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/course_reserves/add_items.pl b/course_reserves/add_items.pl index 7c16a143f5..8fc8553b4a 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -41,15 +41,27 @@ 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, $biblio ); + +if ( $barcode || $itemnumber ) { + # adding an item to course items + $item = $itemnumber ? Koha::Items->find( $itemnumber ) : Koha::Items->find({ barcode => $barcode }); + $itemnumber = $item->id; + $biblio = $item->biblio; + $biblionumber = $biblio->biblionumber; +} else { + # adding a biblio to course items + $biblio = Koha::Biblios->find( $biblionumber ); +} -my $item = Koha::Items->find( { ( $itemnumber ? ( itemnumber => $itemnumber ) : ( barcode => $barcode ) ) } ); -$itemnumber = $item->id if $item; - -my $title = ($item) ? $item->biblio->title : undef; +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 +72,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 +93,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 +104,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 +139,7 @@ if ( $action eq 'lookup' and $item ) { my $ci_id = ModCourseItem( itemnumber => $itemnumber, + biblionumber => $biblionumber, itype => $itype, ccode => $ccode, homebranch => $homebranch, 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 428e293713..9426067738 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 @@ -16,8 +16,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 %] @@ -35,6 +37,16 @@ +
+ Or use biblionumber of a bibliographic record +
    +
  1. + + +
  2. +
+
+
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 9c12bc05db..e1ed6363e3 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 @@ -17,13 +17,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 %] @@ -35,6 +43,7 @@ Barcode: [% item.barcode | html %] + [% IF item_level_itypes %] @@ -185,6 +194,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/course-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt index 2ea511a363..3d7db4abba 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,106 +102,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) %] @@ -250,7 +262,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.11.0