Browse Source

Bug 14237: Add individual bibliographic records to course reserves

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 <christian.stelzenmueller@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
master
Aleisha Amohia 8 months ago
committed by Jonathan Druart
parent
commit
580c390bda
  1. 107
      C4/CourseReserves.pm
  2. 5
      catalogue/detail.pl
  3. 48
      course_reserves/add_items.pl
  4. 130
      course_reserves/batch_add_items.pl
  5. 9
      koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
  6. 28
      koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt
  7. 41
      koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt
  8. 101
      koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt
  9. 174
      koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt
  10. 8
      t/db_dependent/CourseReserves/CourseItems.t

107
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);

5
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;

48
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,

130
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' );

9
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt

@ -189,6 +189,15 @@
</span>
[% END %]
[% IF course_reserves %]
<span class="results_summary"><span class="label">Courses that have reserved this title: </span>
[% FOREACH c IN course_reserves %]
<a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% c.course_id | uri %]">[% c.course.course_name | html %]</a>
[% IF ( loop.last ) %][% ELSE %]|[% END %]
[% END %]
</span>
[% END %]
[% IF ( AmazonCoverImages || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
</div>
<div class="col-xs-3 bookcoverimg">

28
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' %]
<title>Add items &rsaquo; Course reserves &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
@ -30,8 +31,10 @@
[% IF ERROR_ITEM_NOT_FOUND %]
[% IF UNKNOWN_BARCODE %]
<div class="dialog alert">No item found with barcode [% UNKNOWN_BARCODE | html %]</div>
[% ELSIF UNKNOWN_BIBLIONUMBER %]
<div class="dialog alert">No bibliographic record found with biblionumber [% UNKNOWN_BIBLIONUMBER | html %]</div>
[% ELSE %]
<div class="dialog alert">No item found</div>
<div class="dialog alert">No item or bibliographic record found</div>
[% END %]
[% END %]
@ -49,6 +52,16 @@
</ol>
</fieldset>
<fieldset class="rows">
<legend>Or use biblionumber of a bibliographic record</legend>
<ol>
<li>
<label class="required" for="biblionumber">Biblionumber:</label>
<input id="biblionumber" name="biblionumber" type="text" />
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Submit" class="submit" />
@ -58,4 +71,17 @@
</div>
</div>
[% MACRO jsinclude BLOCK %]
<script>
$(document).ready(function(){
$("input[type='submit']").click(function(e){
if ( $("#biblionumber").val().length > 0 && $("#barcode").val().length > 0 ) {
e.preventDefault();
alert(__("Please enter only a barcode, or only a biblionumber."));
}
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

41
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt

@ -32,13 +32,21 @@
<div class="col-md-8 col-md-offset-2">
[% IF course_reserve && !is_edit%]<div class="dialog message" id="already_on_reserve_this">This course already has this item on reserve.</div>[% END %]
[% IF course_item %]<div class="dialog message" id="already_on_reserve">Number of courses reserving this item: [% course_item.course_reserves.count | html %]</div>[% END %]
[% IF course_item %]
[% IF item %]
<div class="dialog message" id="already_on_reserve">Number of courses reserving this item: [% course_item.course_reserves.count | html %]</div>
[% ELSE %]
<div class="dialog message" id="already_on_reserve">Number of courses reserving this bibliographic record: [% course_item.course_reserves.count | html %]</div>
[% END %]
[% END %]
<form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
<input type="hidden" name="course_id" value="[% course.course_id | html %]" />
<input type="hidden" name="return" value="[% return | html %]" />
<input type="hidden" name="action" value="add" />
[% IF item # adding an item to course items %]
<fieldset class="rows">
[% IF is_edit || course_reserve %]
<legend>Edit <em>[% biblio.title | html %]</em> in <em>[% course.course_name | html %]</em></legend>
@ -50,6 +58,7 @@
<span class="label">Barcode:</span>
<span id="barcode">[% item.barcode | html %]</span>
<input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
<input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" />
</li>
[% 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.<br>
Any items with existing course reserves will have their <em>on reserve</em> values updated.
</p>
[% ELSE # adding a biblio to course items %]
<fieldset class="rows">
[% IF is_edit || course_reserve %]
<legend>Edit <em>[% biblio.title | html %]</em> in <em>[% course.course_name | html %]</em></legend>
[% ELSE %]
<legend>Add <em>[% biblio.title | html %]</em> to <em>[% course.course_name | html %]</em></legend>
[% END %]
<ol>
<li>
<span class="label">Biblionumber:</span>
<span id="biblionumber">[% biblio.biblionumber | html %]</span>
<input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
</li>
<li>
<label for="staff_note">Staff note:</label>
<textarea name="staff_note" id="staff_note">[% course_reserve.staff_note | html %]</textarea>
</li>
<li>
<label for="public_note">Public note:</label>
<textarea name="public_note" id="public_note">[% course_reserve.public_note | html %]</textarea>
</li>
</ol>
</fieldset>
[% END %]
<fieldset class="action">
<input type="submit" id="submit" value="Save" class="submit focus" />

101
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt

@ -107,13 +107,13 @@
</li>
<li>
<label for="staff_note">Staff note:</label>
<textarea name="staff_note" id="staff_note">[% course_reserve.staff_note | html %]</textarea>
<label for="item_staff_note">Staff note:</label>
<textarea name="item_staff_note" id="item_staff_note">[% course_reserve.staff_note | html %]</textarea>
</li>
<li>
<label for="public_note">Public note:</label>
<textarea name="public_note" id="public_note">[% course_reserve.public_note | html %]</textarea>
<label for="item_public_note">Public note:</label>
<textarea name="item_public_note" id="item_public_note">[% course_reserve.public_note | html %]</textarea>
</li>
</ol>
</fieldset>
@ -123,6 +123,26 @@
Any items with existing course reserves will have their <em>on reserve</em> values updated.
</p>
<fieldset class="rows">
<legend>Or use biblionumbers of bibliographic records</legend>
<ol>
<li>
<label class="required" for="biblionumbers">Biblionumbers:</label>
<textarea rows="20" cols="50" id="biblionumbers" name="biblionumbers"></textarea>
</li>
<li>
<label for="biblio_staff_note">Staff note:</label>
<textarea name="biblio_staff_note" id="biblio_staff_note">[% course_reserve.staff_note | html %]</textarea>
</li>
<li>
<label for="biblio_public_note">Public note:</label>
<textarea name="biblio_public_note" id="biblio_public_note">[% course_reserve.public_note | html %]</textarea>
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Submit" class="submit" />
@ -134,27 +154,52 @@
[% IF action == 'display_results' %]
<h1>Results</h1>
<h3>Items added</h3>
[% IF items_added.size > 0 %]
<p>The following items were added or updated:</p>
<ul>
[% FOREACH i IN items_added %]
<li>[% i.biblio.title | html %] ( [% i.barcode | html %] )</li>
[% END %]
</ul>
[% ELSE %]
No valid item barcodes found.
[% END %]
[% IF invalid_barcodes.size > 0 %]
<h3>Invalid barcodes</h3>
<p>The following invalid barcodes were skipped:</p>
<ul>
[% FOREACH b IN invalid_barcodes %]
<li>[% b | html %]</li>
[% END %]
</ul>
[% IF barcodes %]
<h3>Items added</h3>
[% IF items_added.size > 0 %]
<p>The following items were added or updated:</p>
<ul>
[% FOREACH i IN items_added %]
<li>[% i.biblio.title | html %] ( [% i.barcode | html %] )</li>
[% END %]
</ul>
[% ELSE %]
No valid item barcodes found.
[% END %]
[% IF invalid_barcodes.size > 0 %]
<h3>Invalid barcodes</h3>
<p>The following invalid barcodes were skipped:</p>
<ul>
[% FOREACH b IN invalid_barcodes %]
<li>[% b | html %]</li>
[% END %]
</ul>
[% END %]
[% ELSIF biblionumbers %]
<h3>Bibliographic records added</h3>
[% IF biblios_added.size > 0 %]
<p>The following bibliographic records were added or updated:</p>
<ul>
[% FOREACH b IN biblios_added %]
<li>[% b.title | html %] ( [% b.biblionumber | html %] )</li>
[% END %]
</ul>
[% ELSE %]
No valid biblionumbers found.
[% END %]
[% IF invalid_biblionumbers.size > 0 %]
<h3>Invalid biblionumbers</h3>
<p>The following invalid biblionumbers were skipped:</p>
<ul>
[% FOREACH b IN invalid_biblionumbers %]
<li>[% b | html %]</li>
[% END %]
</ul>
[% END %]
[% END %]
<p>
@ -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."));
}
});
});
//]]>
</script>

174
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt

@ -116,106 +116,118 @@
<tr>
<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cr.biblio.biblionumber | uri %]">[% INCLUDE 'biblio-title.inc' biblio=cr.biblio %]</a></td>
<td>[% cr.biblio.author | html %]</td>
<td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% cr.item.itemnumber | uri %]&amp;biblionumber=[% cr.biblio.biblionumber | uri %]&amp;bi=[% cr.biblioitem.biblioitemnumber | uri %]">[% cr.item.barcode | html %]</a></td>
<td>[% cr.item.itemcallnumber | html %]</td>
[% IF item_level_itypes %]
<td>
[% IF cr.course_item.itype_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype ) | html %]</strong>
([% ItemTypes.GetDescription( cr.course_item.itype_storage ) | html %])
[% IF cr.item %]
<td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% cr.item.itemnumber | uri %]&amp;biblionumber=[% cr.biblio.biblionumber | uri %]&amp;bi=[% cr.biblioitem.biblioitemnumber | uri %]">[% cr.item.barcode | html %]</a></td>
<td>[% cr.item.itemcallnumber | html %]</td>
[% IF item_level_itypes %]
<td>
[% IF cr.course_item.itype_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype ) | html %]</strong>
([% ItemTypes.GetDescription( cr.course_item.itype_storage ) | html %])
[% ELSE %]
[% ItemTypes.GetDescription( cr.course_item.itype ) | html %]
(<strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype) | html %]</strong>)
[% END %]
[% ELSE %]
[% ItemTypes.GetDescription( cr.course_item.itype ) | html %]
(<strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype) | html %]</strong>)
<em>Unchanged</em>
[% IF cr.item.itype %]
([% ItemTypes.GetDescription( cr.item.itype ) | html %])
[% END %]
[% END %]
[% ELSE %]
<em>Unchanged</em>
[% IF cr.item.itype %]
([% ItemTypes.GetDescription( cr.item.itype ) | html %])
[% END %]
</td>
[% END %]
</td>
[% END %]
<td>
[% IF cr.course_item.ccode_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]</strong>
[% 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 %]
(<strong>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]</strong>)
[% END %]
[% END %]
[% ELSE %]
<em>Unchanged</em>
[% IF cr.item.ccode %]
([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %])
[% END %]
[% END %]
</td>
<td>
[% IF cr.course_item.location_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>
[% IF cr.item.permanent_location %]
([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location_storage ) | html %])
<td>
[% IF cr.course_item.ccode_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]</strong>
[% 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 %]
(<strong>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %]</strong>)
[% END %]
[% END %]
[% ELSE %]
<em>Unchanged</em>
[% IF cr.item.ccode %]
([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode ) | html %])
[% END %]
[% END %]
</td>
<td>
[% IF cr.course_item.location_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>
[% 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 %]
(<strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>)
[% END %]
[% END %]
[% ELSE %]
[% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %]
<em>Unchanged</em>
[% IF cr.item.permanent_location %]
(<strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>)
([% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %])
[% END %]
[% END %]
[% ELSE %]
<em>Unchanged</em>
[% IF cr.item.permanent_location %]
([% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %])
[% END %]
[% END %]
</td>
<td>
[% IF cr.course_item.homebranch_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% Branches.GetName( cr.item.homebranch ) | html %]</strong>
[% IF cr.item.homebranch %]
([% Branches.GetName( cr.course_item.homebranch_storage ) | html %])
</td>
<td>
[% IF cr.course_item.homebranch_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% Branches.GetName( cr.item.homebranch ) | html %]</strong>
[% 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 %]
(<strong>[% Branches.GetName( cr.item.homebranch ) | html %]</strong>)
[% END %]
[% END %]
[% ELSE %]
[% Branches.GetName( cr.course_item.homebranch ) | html %]
<em>Unchanged</em>
[% IF cr.item.homebranch %]
(<strong>[% Branches.GetName( cr.item.homebranch ) | html %]</strong>)
([% Branches.GetName( cr.item.homebranch ) | html %])
[% END %]
[% END %]
[% ELSE %]
<em>Unchanged</em>
[% IF cr.item.homebranch %]
([% Branches.GetName( cr.item.homebranch ) | html %])
[% END %]
[% END %]
</td>
<td>
[% IF cr.course_item.holdingbranch_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>
[% IF cr.item.holdingbranch %]
([% Branches.GetName( cr.course_item.holdingbranch_storage ) | html %])
</td>
<td>
[% IF cr.course_item.holdingbranch_enabled %]
[% IF cr.course_item.enabled == 'yes' %]
<strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>
[% 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 %]
(<strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>)
[% END %]
[% END %]
[% ELSE %]
[% Branches.GetName( cr.course_item.holdingbranch ) | html %]
<em>Unchanged</em>
[% IF cr.item.holdingbranch %]
(<strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>)
([% Branches.GetName( cr.item.holdingbranch ) | html %])
[% END %]
[% END %]
</td>
[% ELSE # record-level course reserve %]
[% IF ( item_level_itypes ) %]
<td colspan="7">
[% ELSE %]
<em>Unchanged</em>
[% IF cr.item.holdingbranch %]
([% Branches.GetName( cr.item.holdingbranch ) | html %])
[% END %]
<td colspan="6">
[% END %]
</td>
<em>Information not available for record-level course reserve</em>
</td>
[% END %]
<td>[% 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 %]
<td class="actions">
[% IF CAN_user_coursereserves_add_reserves %]
<a class="btn btn-default btn-xs" href="add_items.pl?course_id=[% course.course_id | html %]&amp;itemnumber=[% cr.item.itemnumber | html %]&amp;action=lookup&amp;return=[% course.course_id | html %]&amp;is_edit=1"><i class="fa fa-pencil"></i> Edit</a>
<a class="btn btn-default btn-xs" href="add_items.pl?course_id=[% course.course_id | html %]&amp;itemnumber=[% cr.item.itemnumber | html %]&amp;biblionumber=[% cr.biblio.biblionumber | html %]&amp;action=lookup&amp;return=[% course.course_id | html %]&amp;is_edit=1"><i class="fa fa-pencil"></i> Edit</a>
[% END %]
[% IF CAN_user_coursereserves_delete_reserves %]

8
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 => '',

Loading…
Cancel
Save