@@ -, +, @@ reserves different biblios) --- 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 ++ .../en/modules/course_reserves/add_items-step1.tt | 28 +++- .../en/modules/course_reserves/add_items-step2.tt | 41 ++++- .../en/modules/course_reserves/batch_add_items.tt | 101 +++++++++--- .../en/modules/course_reserves/course-details.tt | 174 +++++++++++---------- t/db_dependent/CourseReserves/CourseItems.t | 8 + 10 files changed, 458 insertions(+), 193 deletions(-) --- a/C4/CourseReserves.pm +++ a/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); --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -612,6 +612,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; --- a/course_reserves/add_items.pl +++ a/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, --- a/course_reserves/batch_add_items.pl +++ a/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' ); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -165,6 +165,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')) ) %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt +++ a/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' %] Koha › Course reserves › Add items [% INCLUDE 'doc-head-close.inc' %] @@ -16,8 +17,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 +38,16 @@ +
+ Or use biblionumber of a bibliographic record +
    +
  1. + + +
  2. +
+
+
@@ -44,4 +57,17 @@
+[% MACRO jsinclude BLOCK %] + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt +++ a/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 %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt @@ -93,13 +93,13 @@
  • - - + +
  • - - + +
  • @@ -109,6 +109,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. +
    +
    +
    @@ -120,27 +140,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 %]

    @@ -162,6 +207,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.")); + } + }); }); //]]> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt +++ a/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 %] --- a/t/db_dependent/CourseReserves/CourseItems.t +++ a/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 => '', --