@@ -, +, @@
---
C4/Circulation.pm | 5 +
C4/Courses.pm | 65 ++++++++
C4/Items.pm | 167 ++++++++++----------
C4/XSLT.pm | 3 +
cataloguing/additem.pl | 40 +++--
circ/returns.pl | 10 ++
.../prog/en/modules/cataloguing/additem.tt | 37 +++++
.../intranet-tmpl/prog/en/modules/circ/returns.tt | 7 +
.../prog/en/modules/tools/batchMod-edit.tt | 38 +++++
koha-tmpl/opac-tmpl/prog/en/css/datatables.css | 42 +++---
koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 1 +
.../lib/jquery/plugins/jquery.tablesorter.min.js | 4 +-
.../prog/en/modules/opac-coursereserves.tt | 48 ++++++
.../prog/en/xslt/MARC21slim2OPACResults.xsl | 6 +
lbo_sql/lbo_RM1738_reserve_profs.sql | 23 +++
opac/opac-coursereserves.pl | 33 ++++
t/db_dependent/Courses.t | 41 +++++
tools/batchMod.pl | 24 ++--
21 files changed, 524 insertions(+), 132 deletions(-)
create mode 100644 C4/Courses.pm
create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-coursereserves.tt
create mode 100644 lbo_sql/lbo_RM1738_reserve_profs.sql
create mode 100644 opac/opac-coursereserves.pl
create mode 100644 t/db_dependent/Courses.t
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -1597,6 +1597,11 @@ sub AddReturn {
$messages->{'wthdrawn'} = 1;
$doreturn = 0;
}
+
+ # book is reserved to a teacher
+ if ( $doreturn && ($item->{'notforloan'} == 101 || $item->{'notforloan'} == -101 )) {
+ $messages->{'coursereserve'} = 1;
+ }
# case of a return of document (deal with issues and holdingbranch)
if ($doreturn) {
--- a/C4/Courses.pm
+++ a/C4/Courses.pm
@@ -0,0 +1,65 @@
+package C4::Courses;
+
+use strict;
+use warnings;
+use vars qw($VERSION);
+use Data::Dumper;
+use C4::Context;
+
+BEGIN {
+ $VERSION = 1.00; # set the version for version checking
+}
+
+sub GetReserveFromItemNumber {
+ my ($itemnumber) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("SELECT * FROM reserve_courses WHERE itemnumber = ?");
+
+ $sth->execute($itemnumber);
+ my $data = $sth->fetchrow_hashref;
+ $sth->finish;
+ return ($data);
+}
+
+sub GetAllReserves {
+ my @results;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('SELECT *,
+ ExtractValue(biblioitems.marcxml,"//record/datafield[@tag=\"245\"]/subfield[@code=\"h\"]") AS typedocument,
+ ExtractValue(biblioitems.marcxml,"//record/datafield[@tag=\"245\"]/subfield[@code=\"b\"]") AS subtitle
+ FROM items
+ JOIN reserve_courses USING (itemnumber)
+ JOIN biblio USING (biblionumber)
+ JOIN biblioitems USING (biblionumber)
+ JOIN branches b ON (b.branchcode = holdingbranch)
+ LEFT OUTER JOIN authorised_values av ON (av.authorised_value = items.location)
+ WHERE notforloan = 101 OR notforloan = -101');
+ $sth->execute();
+ while ( my $data = $sth->fetchrow_hashref ) {
+ push @results, $data;
+ }
+
+ $sth->finish;
+ return @results;
+}
+
+sub DeleteReserveFromItemNumber {
+ my ($itemnumber) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("DELETE FROM reserve_courses WHERE itemnumber = ?");
+ $sth->execute($itemnumber);
+ return;
+}
+
+sub SaveReserve {
+ my ($itemnumber, $teacher_name, $course_name) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("DELETE FROM reserve_courses WHERE itemnumber = ?");
+ $sth->execute($itemnumber);
+ $sth = $dbh->prepare("INSERT INTO reserve_courses(teacher_name, course_name, itemnumber)
+ VALUES (?, ?, ?)");
+ $sth->execute($teacher_name, $course_name, $itemnumber);
+ return;
+}
+
+1;
--- a/C4/Items.pm
+++ a/C4/Items.pm
@@ -32,6 +32,7 @@ use C4::Log;
use List::MoreUtils qw/any/;
use Data::Dumper; # used as part of logging item record changes, not just for
# debugging; so please don't remove this
+use C4::Courses; #DeleteReserveFromItemNumber
use vars qw($VERSION @ISA @EXPORT);
@@ -2246,6 +2247,9 @@ Internal function to delete an item record from the koha tables
sub _koha_delete_item {
my ( $dbh, $itemnum ) = @_;
+
+ # delete the course reservations
+ C4::Courses::DeleteReserveFromItemNumber($itemnum);
# save the deleted item to deleteditems table
my $sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?");
--- a/C4/XSLT.pm
+++ a/C4/XSLT.pm
@@ -249,6 +249,9 @@ sub buildKohaItemsNamespace {
if ( $item->{itemnotforloan} > 0 || $item->{notforloan} > 0 || $itemtypes->{ $item->{itype} }->{notforloan} == 1 ) {
$status = "reference";
}
+ if ( $item->{itemnotforloan} == 101 || $item->{notforloan} == -101 ) {
+ $status = "reserveprofs";
+ }
if ($item->{onloan}) {
$status = "Checked out";
}
--- a/cataloguing/additem.pl
+++ a/cataloguing/additem.pl
@@ -33,6 +33,7 @@ use C4::ClassSource;
use C4::Dates;
use List::MoreUtils qw/any/;
use C4::Search;
+use C4::Courses;
use MARC::File::XML;
use URI::Escape;
@@ -348,6 +349,7 @@ if ($op eq "additem") {
# if barcode exists, don't create, but report The problem.
unless ($exist_itemnumber) {
my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
+ C4::Courses::SaveReserve($oldbibitemnum, $input->param('teacher_name'), $input->param('course_name'));
set_item_default_location($oldbibitemnum);
}
$nextop = "additem";
@@ -517,6 +519,7 @@ if ($op eq "additem") {
push @errors,"barcode_not_unique";
} else {
ModItemFromMarc($itemtosave,$biblionumber,$itemnumber);
+ C4::Courses::SaveReserve($itemnumber, $input->param('teacher_name'), $input->param('course_name'));
$itemnumber="";
}
$nextop="additem";
@@ -710,6 +712,8 @@ foreach my $tag ( keys %{$tagslib}){
}
@loop_data = sort {$a->{subfield} cmp $b->{subfield} } @loop_data;
+my $reserve = C4::Courses::GetReserveFromItemNumber($itemnumber);
+
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
$template->param( title => $record->title() ) if ($record ne "-1");
$template->param(
@@ -725,6 +729,8 @@ $template->param(
op => $nextop,
opisadd => ($nextop eq "saveitem") ? 0 : 1,
C4::Search::enabled_staff_search_views,
+ teacher_name => $reserve->{teacher_name},
+ course_name => $reserve->{course_name},
);
if ($frameworkcode eq 'FA'){
--- a/circ/returns.pl
+++ a/circ/returns.pl
@@ -334,6 +334,13 @@ if ( $messages->{'Wrongbranch'} ){
);
}
+if ( $messages->{'coursereserve'} ){
+ $template->param(
+ found => 1,
+ coursereserve => 1
+ );
+}
+
# case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
@@ -470,6 +477,9 @@ foreach my $code ( keys %$messages ) {
$err{debarborrowernumber} = $borrower->{borrowernumber};
$err{debarname} = "$borrower->{firstname} $borrower->{surname}";
}
+ elsif ( $code eq 'coursereserve' ) {
+ }
+
else {
die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die.
# This forces the issue of staying in sync w/ Circulation.pm
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
@@ -16,6 +16,31 @@ $(document).ready(function(){
$(this).append("Edit Item Delete Item");
}
});
+
+ lstNotLoad = $('[id^="tag_952_subfield_7"]');
+ divNotLoan = lstNotLoad.parent().parent();
+ //Move the course and teacher fields below the not_for_load field
+ $("#course_name").insertAfter(divNotLoan);
+ $("#teacher_name").insertAfter(divNotLoan);
+ //Hide the course and teacher fields if not_for_loan isn't "Réservé par professeur"
+ if (lstNotLoad.val() != 101 && lstNotLoad.val() != -101)
+ {
+ $("#course_name").hide();
+ $("#teacher_name").hide();
+ }
+ lstNotLoad.bind('change', function() {
+ //If not_for_loan changes to "Réservé par professeur" show the course and teacher fields
+ if ($(this).val() == 101 || $(this).val() == -101)
+ {
+ $("#course_name").show();
+ $("#teacher_name").show();
+ }
+ else //Else, hide them
+ {
+ $("#course_name").hide();
+ $("#teacher_name").hide();
+ }
+ });
});
function active(numlayer)
{
@@ -244,6 +269,18 @@ $(document).ready(function() {
[% IF ( ite.mandatory ) %] Required[% END %]
[% END %]
+
+
+
+
+
+
+
+
+
+
+
+
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
@@ -208,6 +208,13 @@ $(document).ready(function () {
[% END %]
[% END %]
+
+ [% IF ( coursereserve ) %]
+
+
+ [% END %]
[% IF ( needstransfer ) %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
@@ -37,6 +37,32 @@ $("input[name='disable_input']").click(function() {
}
});
+$(document).ready(function() {
+ lstNotLoad = $('[id^="tag_952_subfield_7"]');
+ divNotLoan = lstNotLoad.parent().parent();
+ //Move the course and teacher fields below the not_for_load field
+ $("#course_name").insertAfter(divNotLoan);
+ $("#teacher_name").insertAfter(divNotLoan);
+ //Hide the course and teacher fields if not_for_loan isn't "Réservé par professeur"
+ if (lstNotLoad.val() != 101 && lstNotLoad.val() != -101)
+ {
+ $("#course_name").hide();
+ $("#teacher_name").hide();
+ }
+ lstNotLoad.bind('change', function() {
+ //If not_for_loan changes to "Réservé par professeur" show the course and teacher fields
+ if ($(this).val() == 101 || $(this).val() == -101)
+ {
+ $("#course_name").show();
+ $("#teacher_name").show();
+ }
+ else //Else, hide them
+ {
+ $("#course_name").hide();
+ $("#teacher_name").hide();
+ }
+ });
+});
//]]>
@@ -160,6 +186,18 @@ $("input[name='disable_input']").click(function() {
[% END %]
+
+
+
+
+
+
+
+
+
+
+
+