Bugzilla – Attachment 16587 Details for
Bug 8215
Add Course Reserves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8215 - Course Reserves
Bug-8215---Course-Reserves.patch (text/plain), 143.78 KB, created by
Kyle M Hall (khall)
on 2013-03-21 09:43:46 UTC
(
hide
)
Description:
Bug 8215 - Course Reserves
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-03-21 09:43:46 UTC
Size:
143.78 KB
patch
obsolete
>From 0e05160400b60899dce6bead6ce84b6a0aee7da5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 17 Apr 2012 08:07:32 -0400 >Subject: [PATCH] Bug 8215 - Course Reserves > >Adds a course reserves system for academic libraries. > >The course reserves system allows libraries to create courses >and put items on reserves for those courses. > >Each item with at least one reserve can have some of its attributes >modified while it is on reserve for at least one active course. >These attributes include item type, collection code, shelving location, >and holding library. If there are no active courses with this item >on reserve, it's attributes will revert to the original attributes >it had before going on reserve. > >Test Plan: > 1) Create new authorised value categories DEPARTMENT and TERM > 2) Create a new course, add instructors to that course. > 3) Reserve items for that course, verify item attributes have changed. > 4) Disable course, verify item attributes have reverted. > 5) Enable course again, verify item attributes again. > 6) Delete course, verify item attributes again. > 7) Create two new courses, add the same item(s) to both courses. > 8) Disable one course, verify item attributes have not reverted. > 9) Disable both courses, verify item attributes have reverted. > 10) Enable one course, verify item attributes are again set to the > new values. > 11) Edit reserve item attributes, verify. > 12) Disable all courses, edit reserve item attributes, verify > the item itself still has its original attributes, verify > the reserve item attributes have been updated. > 13) Verify the ability to remove instructors from a course. > 14) Verify new permissions, top level coursereserves, with > subpermissions add_reserves and delete_reserves. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Corinne Bulac <corinne.hayet@bulac.fr> >--- > C4/Auth.pm | 2 + > C4/CourseReserves.pm | 1122 ++++++++++++++++++++ > C4/Koha.pm | 22 +- > Koha/Template/Plugin/AuthorisedValues.pm | 34 + > Koha/Template/Plugin/Branches.pm | 37 + > Koha/Template/Plugin/ItemTypes.pm | 38 + > Makefile.PL | 1 + > admin/authorised_values.pl | 2 +- > catalogue/detail.pl | 5 + > course_reserves/add_items.pl | 97 ++ > course_reserves/course-details.pl | 67 ++ > course_reserves/course-reserves.pl | 54 + > course_reserves/course.pl | 55 + > course_reserves/mod_course.pl | 72 ++ > installer/data/mysql/de-DE/mandatory/userflags.sql | 1 + > .../data/mysql/de-DE/mandatory/userpermissions.sql | 3 + > installer/data/mysql/en/mandatory/userflags.sql | 3 +- > .../data/mysql/en/mandatory/userpermissions.sql | 3 + > installer/data/mysql/es-ES/mandatory/userflags.sql | 1 + > .../data/mysql/es-ES/mandatory/userpermissions.sql | 3 + > .../data/mysql/fr-FR/1-Obligatoire/userflags.sql | 1 + > .../mysql/fr-FR/1-Obligatoire/userpermissions.sql | 4 +- > installer/data/mysql/it-IT/necessari/userflags.sql | 3 +- > .../data/mysql/it-IT/necessari/userpermissions.sql | 3 + > installer/data/mysql/kohastructure.sql | 102 ++ > .../data/mysql/nb-NO/1-Obligatorisk/userflags.sql | 1 + > .../mysql/nb-NO/1-Obligatorisk/userpermissions.sql | 3 + > installer/data/mysql/pl-PL/mandatory/userflags.sql | 1 + > .../data/mysql/pl-PL/mandatory/userpermissions.sql | 3 + > .../ru-RU/mandatory/permissions_and_user_flags.sql | 4 + > installer/data/mysql/sysprefs.sql | 1 + > .../uk-UA/mandatory/permissions_and_user_flags.sql | 4 + > installer/data/mysql/updatedatabase.pl | 93 ++- > .../intranet-tmpl/prog/en/css/staff-global.css | 4 +- > .../intranet-tmpl/prog/en/includes/header.inc | 3 + > koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 6 +- > .../en/modules/admin/preferences/circulation.pref | 7 + > .../prog/en/modules/catalogue/detail.tt | 34 + > .../prog/en/modules/cataloguing/additem.tt | 2 +- > .../en/modules/course_reserves/add_items-step1.tt | 63 ++ > .../en/modules/course_reserves/add_items-step2.tt | 133 +++ > .../en/modules/course_reserves/course-details.tt | 185 ++++ > .../en/modules/course_reserves/course-reserves.tt | 119 +++ > .../prog/en/modules/course_reserves/course.tt | 205 ++++ > .../prog/en/modules/members/mancredit.tt | 2 +- > .../prog/en/modules/members/maninvoice.tt | 2 +- > .../prog/en/modules/members/memberentrygen.tt | 2 +- > koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc | 1 + > koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 1 + > .../prog/en/modules/opac-course-details.tt | 63 ++ > .../prog/en/modules/opac-course-reserves.tt | 62 ++ > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 31 + > opac/opac-course-details.pl | 60 ++ > opac/opac-course-reserves.pl | 51 + > opac/opac-detail.pl | 7 + > t/db_dependent/CourseReserves.t | 88 ++ > 56 files changed, 2956 insertions(+), 20 deletions(-) > create mode 100644 C4/CourseReserves.pm > create mode 100644 Koha/Template/Plugin/AuthorisedValues.pm > create mode 100644 Koha/Template/Plugin/Branches.pm > create mode 100644 Koha/Template/Plugin/ItemTypes.pm > create mode 100755 course_reserves/add_items.pl > create mode 100755 course_reserves/course-details.pl > create mode 100755 course_reserves/course-reserves.pl > create mode 100755 course_reserves/course.pl > create mode 100755 course_reserves/mod_course.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt > create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-course-details.tt > create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-course-reserves.tt > create mode 100755 opac/opac-course-details.pl > create mode 100755 opac/opac-course-reserves.pl > create mode 100755 t/db_dependent/CourseReserves.t > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 2984570..0df1383 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -203,6 +203,7 @@ sub get_template_and_user { > $template->param( CAN_user_reports => 1 ); > $template->param( CAN_user_staffaccess => 1 ); > $template->param( CAN_user_plugins => 1 ); >+ $template->param( CAN_user_coursereserves => 1 ); > foreach my $module (keys %$all_perms) { > foreach my $subperm (keys %{ $all_perms->{$module} }) { > $template->param( "CAN_user_${module}_${subperm}" => 1 ); >@@ -336,6 +337,7 @@ sub get_template_and_user { > noItemTypeImages => C4::Context->preference("noItemTypeImages"), > marcflavour => C4::Context->preference("marcflavour"), > persona => C4::Context->preference("persona"), >+ UseCourseReserves => C4::Context->preference("UseCourseReserves"), > ); > if ( $in->{'type'} eq "intranet" ) { > $template->param( >diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm >new file mode 100644 >index 0000000..f8ebb26 >--- /dev/null >+++ b/C4/CourseReserves.pm >@@ -0,0 +1,1122 @@ >+package C4::CourseReserves; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along with >+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, >+# Suite 330, Boston, MA 02111-1307 USA >+ >+use Modern::Perl; >+ >+require Exporter; >+ >+use C4::Context; >+use C4::Items qw(GetItem ModItem); >+use C4::Biblio qw(GetBiblioFromItemNumber); >+use C4::Circulation qw(GetOpenIssue); >+ >+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS); >+ >+BEGIN { >+ @ISA = qw(Exporter); >+ @EXPORT = qw( >+ &GetCourse >+ &ModCourse >+ &GetCourses >+ &DelCourse >+ >+ &GetCourseInstructors >+ &ModCourseInstructors >+ >+ &GetCourseItem >+ &ModCourseItem >+ >+ &GetCourseReserve >+ &ModCourseReserve >+ &GetCourseReserves >+ &DelCourseReserve >+ >+ &SearchCourses >+ >+ &GetItemReservesInfo >+ ); >+ >+ $DEBUG = 0; >+ @FIELDS = ( 'itype', 'ccode', 'holdingbranch', 'location' ); >+} >+ >+=head1 NAME >+ >+C4::CourseReserves - Koha course reserves module >+ >+=head1 SYNOPSIS >+ >+use C4::CourseReserves; >+ >+=head1 DESCRIPTION >+ >+This module deals with course reserves. >+ >+=head1 FUNCTIONS >+ >+=head2 GetCourse >+ >+ $course = GetCourse( $course_id ); >+ >+=cut >+ >+sub GetCourse { >+ my ($course_id) = @_; >+ warn whoami() . "( $course_id )" if $DEBUG; >+ >+ my $query = "SELECT * FROM courses WHERE course_id = ?"; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($course_id); >+ >+ my $course = $sth->fetchrow_hashref(); >+ >+ $query = " >+ SELECT b.* FROM course_instructors ci >+ LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber ) >+ WHERE course_id = ? >+ "; >+ $sth = $dbh->prepare($query); >+ $sth->execute($course_id); >+ $course->{'instructors'} = $sth->fetchall_arrayref( {} ); >+ >+ return $course; >+} >+ >+=head2 ModCourse >+ >+ ModCourse( [ course_id => $id ] [, course_name => $course_name ] [etc...] ); >+ >+=cut >+ >+sub ModCourse { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $course_id; >+ if ( defined $params{'course_id'} ) { >+ $course_id = $params{'course_id'}; >+ delete $params{'course_id'}; >+ } >+ >+ my @query_keys; >+ my @query_values; >+ >+ my $query; >+ >+ $query .= ($course_id) ? ' UPDATE ' : ' INSERT '; >+ $query .= ' courses SET '; >+ >+ foreach my $key ( keys %params ) { >+ push( @query_keys, "$key=?" ); >+ push( @query_values, $params{$key} ); >+ } >+ $query .= join( ',', @query_keys ); >+ >+ if ($course_id) { >+ $query .= " WHERE course_id = ?"; >+ push( @query_values, $course_id ); >+ } >+ >+ $dbh->do( $query, undef, @query_values ); >+ >+ $course_id = $course_id >+ || $dbh->last_insert_id( undef, undef, 'courses', 'course_id' ); >+ >+ EnableOrDisableCourseItems( >+ course_id => $course_id, >+ enabled => $params{'enabled'} >+ ); >+ >+ return $course_id; >+} >+ >+=head2 GetCourses >+ >+ @courses = GetCourses( [ fieldname => $value ] [, fieldname2 => $value2 ] [etc...] ); >+ >+=cut >+ >+sub GetCourses { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my @query_keys; >+ my @query_values; >+ >+ my $query = " >+ SELECT courses.* >+ FROM courses >+ LEFT JOIN course_reserves ON course_reserves.course_id = courses.course_id >+ LEFT JOIN course_items ON course_items.ci_id = course_reserves.ci_id >+ "; >+ >+ if ( keys %params ) { >+ >+ $query .= " WHERE "; >+ >+ foreach my $key ( keys %params ) { >+ push( @query_keys, " $key LIKE ? " ); >+ push( @query_values, $params{$key} ); >+ } >+ >+ $query .= join( ' AND ', @query_keys ); >+ } >+ >+ $query .= " GROUP BY courses.course_id "; >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(@query_values); >+ >+ my $courses = $sth->fetchall_arrayref( {} ); >+ >+ foreach my $c (@$courses) { >+ $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} ); >+ } >+ >+ return $courses; >+} >+ >+=head2 DelCourse >+ >+ DelCourse( $course_id ); >+ >+=cut >+ >+sub DelCourse { >+ my ($course_id) = @_; >+ >+ my $course_reserves = GetCourseReserves( course_id => $course_id ); >+ >+ foreach my $res (@$course_reserves) { >+ DelCourseReserve( cr_id => $res->{'cr_id'} ); >+ } >+ >+ my $query = " >+ DELETE FROM course_instructors >+ WHERE course_id = ? >+ "; >+ C4::Context->dbh->do( $query, undef, $course_id ); >+ >+ $query = " >+ DELETE FROM courses >+ WHERE course_id = ? >+ "; >+ C4::Context->dbh->do( $query, undef, $course_id ); >+} >+ >+=head2 EnableOrDisableCourseItems >+ >+ EnableOrDisableCourseItems( course_id => $course_id, enabled => $enabled ); >+ >+ For each item on reserve for this course, >+ if the course item has no active course reserves, >+ swap the fields for the item to make it 'normal' >+ again. >+ >+ enabled => 'yes' to enable course items >+ enabled => 'no' to disable course items >+ >+=cut >+ >+sub EnableOrDisableCourseItems { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $course_id = $params{'course_id'}; >+ my $enabled = $params{'enabled'} || 0; >+ >+ my $lookfor = ( $enabled eq 'yes' ) ? 'no' : 'yes'; >+ >+ return unless ( $course_id && $enabled ); >+ return unless ( $enabled eq 'yes' || $enabled eq 'no' ); >+ >+ my $course_reserves = GetCourseReserves( course_id => $course_id ); >+ >+ if ( $enabled eq 'yes' ) { >+ foreach my $course_reserve (@$course_reserves) { >+ if ( >+ CountCourseReservesForItem( >+ ci_id => $course_reserve->{'ci_id'}, >+ enabled => 'yes' >+ ) >+ ) >+ { >+ EnableOrDisableCourseItem( >+ ci_id => $course_reserve->{'ci_id'}, >+ enabled => 'yes', >+ ); >+ } >+ } >+ } >+ if ( $enabled eq 'no' ) { >+ foreach my $course_reserve (@$course_reserves) { >+ unless ( >+ CountCourseReservesForItem( >+ ci_id => $course_reserve->{'ci_id'}, >+ enabled => 'yes' >+ ) >+ ) >+ { >+ EnableOrDisableCourseItem( >+ ci_id => $course_reserve->{'ci_id'}, >+ enabled => 'no', >+ ); >+ } >+ } >+ } >+} >+ >+=head2 EnableOrDisableCourseItem >+ >+ EnableOrDisableCourseItem( ci_id => $ci_id, enabled => $enabled ); >+ >+ enabled => 'yes' to enable course items >+ enabled => 'no' to disable course items >+ >+=cut >+ >+sub EnableOrDisableCourseItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $ci_id = $params{'ci_id'}; >+ my $enabled = $params{'enabled'}; >+ >+ return unless ( $ci_id && $enabled ); >+ return unless ( $enabled eq 'yes' || $enabled eq 'no' ); >+ >+ my $course_item = GetCourseItem( ci_id => $ci_id ); >+ >+ ## We don't want to 'enable' an already enabled item, >+ ## or disable and already disabled item, >+ ## as that would cause the fields to swap >+ if ( $course_item->{'enabled'} ne $enabled ) { >+ _SwapAllFields($ci_id); >+ >+ my $query = " >+ UPDATE course_items >+ SET enabled = ? >+ WHERE ci_id = ? >+ "; >+ >+ C4::Context->dbh->do( $query, undef, $enabled, $ci_id ); >+ >+ } >+ >+} >+ >+=head2 GetCourseInstructors >+ >+ @$borrowers = GetCourseInstructors( $course_id ); >+ >+=cut >+ >+sub GetCourseInstructors { >+ my ($course_id) = @_; >+ warn "C4::CourseReserves::GetCourseInstructors( $course_id )" >+ if $DEBUG; >+ >+ my $query = " >+ SELECT * FROM borrowers >+ RIGHT JOIN course_instructors ON ( course_instructors.borrowernumber = borrowers.borrowernumber ) >+ WHERE course_instructors.course_id = ? >+ "; >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($course_id); >+ >+ return $sth->fetchall_arrayref( {} ); >+} >+ >+=head2 ModCourseInstructors >+ >+ ModCourseInstructors( mode => $mode, course_id => $course_id, [ cardnumbers => $cardnumbers ] OR [ borrowernumbers => $borrowernumbers ); >+ >+ $mode can be 'replace', 'add', or 'delete' >+ >+ $cardnumbers and $borrowernumbers are both references to arrays >+ >+ Use either cardnumbers or borrowernumber, but not both. >+ >+=cut >+ >+sub ModCourseInstructors { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $course_id = $params{'course_id'}; >+ my $mode = $params{'mode'}; >+ my $cardnumbers = $params{'cardnumbers'}; >+ my $borrowernumbers = $params{'borrowernumbers'}; >+ >+ return unless ($course_id); >+ return >+ unless ( $mode eq 'replace' >+ || $mode eq 'add' >+ || $mode eq 'delete' ); >+ return unless ( $cardnumbers || $borrowernumbers ); >+ return if ( $cardnumbers && $borrowernumbers ); >+ >+ my @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' ); >+ my @borrowernumbers = @$borrowernumbers >+ if ( ref($borrowernumbers) eq 'ARRAY' ); >+ >+ my $field = (@cardnumbers) ? 'cardnumber' : 'borrowernumber'; >+ my @fields = (@cardnumbers) ? @cardnumbers : @borrowernumbers; >+ my $placeholders = join( ',', ('?') x scalar @fields ); >+ >+ my $dbh = C4::Context->dbh; >+ >+ $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?", >+ undef, $course_id ) >+ if ( $mode eq 'replace' ); >+ >+ my $query; >+ >+ if ( $mode eq 'add' || $mode eq 'replace' ) { >+ $query = " >+ INSERT INTO course_instructors ( course_id, borrowernumber ) >+ SELECT ?, borrowernumber >+ FROM borrowers >+ WHERE $field IN ( $placeholders ) >+ "; >+ } >+ else { >+ $query = " >+ DELETE FROM course_instructors >+ WHERE course_id = ? >+ AND borrowernumber IN ( >+ SELECT borrowernumber FROM borrowers WHERE $field IN ( $placeholders ) >+ ) >+ "; >+ } >+ >+ my $sth = $dbh->prepare($query); >+ >+ $sth->execute( $course_id, @fields ) if (@fields); >+} >+ >+=head2 GetCourseItem { >+ >+ $course_item = GetCourseItem( itemnumber => $itemnumber [, ci_id => $ci_id ); >+ >+=cut >+ >+sub GetCourseItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $ci_id = $params{'ci_id'}; >+ my $itemnumber = $params{'itemnumber'}; >+ >+ return unless ( $itemnumber || $ci_id ); >+ >+ my $field = ($itemnumber) ? 'itemnumber' : 'ci_id'; >+ my $value = ($itemnumber) ? $itemnumber : $ci_id; >+ >+ my $query = "SELECT * FROM course_items WHERE $field = ?"; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($value); >+ >+ my $course_item = $sth->fetchrow_hashref(); >+ >+ if ($course_item) { >+ $query = "SELECT * FROM course_reserves WHERE ci_id = ?"; >+ $sth = $dbh->prepare($query); >+ $sth->execute( $course_item->{'ci_id'} ); >+ my $course_reserves = $sth->fetchall_arrayref( {} ); >+ >+ $course_item->{'course_reserves'} = $course_reserves >+ if ($course_reserves); >+ } >+ return $course_item; >+} >+ >+=head2 ModCourseItem { >+ >+ ModCourseItem( %params ); >+ >+ Creates or modifies an existing course item. >+ >+=cut >+ >+sub ModCourseItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $itemnumber = $params{'itemnumber'}; >+ my $itype = $params{'itype'}; >+ my $ccode = $params{'ccode'}; >+ my $holdingbranch = $params{'holdingbranch'}; >+ my $location = $params{'location'}; >+ >+ return unless ($itemnumber); >+ >+ my $course_item = GetCourseItem( itemnumber => $itemnumber ); >+ >+ my $ci_id; >+ >+ if ($course_item) { >+ $ci_id = $course_item->{'ci_id'}; >+ >+ _UpdateCourseItem( >+ ci_id => $ci_id, >+ course_item => $course_item, >+ %params >+ ); >+ } >+ else { >+ $ci_id = _AddCourseItem(%params); >+ } >+ >+ return $ci_id; >+ >+} >+ >+=head2 _AddCourseItem >+ >+ my $ci_id = _AddCourseItem( %params ); >+ >+=cut >+ >+sub _AddCourseItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my ( @fields, @values ); >+ >+ push( @fields, 'itemnumber = ?' ); >+ push( @values, $params{'itemnumber'} ); >+ >+ foreach (@FIELDS) { >+ if ( $params{$_} ) { >+ push( @fields, "$_ = ?" ); >+ push( @values, $params{$_} ); >+ } >+ } >+ >+ my $query = "INSERT INTO course_items SET " . join( ',', @fields ); >+ my $dbh = C4::Context->dbh; >+ $dbh->do( $query, undef, @values ); >+ >+ my $ci_id = $dbh->last_insert_id( undef, undef, 'course_items', 'ci_id' ); >+ >+ return $ci_id; >+} >+ >+=head2 _UpdateCourseItem >+ >+ _UpdateCourseItem( %params ); >+ >+=cut >+ >+sub _UpdateCourseItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $ci_id = $params{'ci_id'}; >+ my $course_item = $params{'course_item'}; >+ my $itype = $params{'itype'}; >+ my $ccode = $params{'ccode'}; >+ my $holdingbranch = $params{'holdingbranch'}; >+ my $location = $params{'location'}; >+ >+ return unless ( $ci_id || $course_item ); >+ >+ $course_item = GetCourseItem( ci_id => $ci_id ) >+ unless ($course_item); >+ $ci_id = $course_item->{'ci_id'} unless ($ci_id); >+ >+ ## Revert fields that had an 'original' value, but now don't >+ ## Update the item fields to the stored values from course_items >+ ## and then set those fields in course_items to NULL >+ my @fields_to_revert; >+ foreach (@FIELDS) { >+ if ( !$params{$_} && $course_item->{$_} ) { >+ push( @fields_to_revert, $_ ); >+ } >+ } >+ _RevertFields( >+ ci_id => $ci_id, >+ fields => \@fields_to_revert, >+ course_item => $course_item >+ ) if (@fields_to_revert); >+ >+ ## Update fields that still have an original value, but it has changed >+ ## This necessitates only changing the current item values, as we still >+ ## have the original values stored in course_items >+ my %mod_params; >+ foreach (@FIELDS) { >+ if ( $params{$_} >+ && $course_item->{$_} >+ && $params{$_} ne $course_item->{$_} ) >+ { >+ $mod_params{$_} = $params{$_}; >+ } >+ } >+ ModItem( \%mod_params, undef, $course_item->{'itemnumber'} ); >+ >+ ## Update fields that didn't have an original value, but now do >+ ## We must save the original value in course_items, and also >+ ## update the item fields to the new value >+ my $item = GetItem( $course_item->{'itemnumber'} ); >+ my %mod_params_new; >+ my %mod_params_old; >+ foreach (@FIELDS) { >+ if ( $params{$_} && !$course_item->{$_} ) { >+ $mod_params_new{$_} = $params{$_}; >+ $mod_params_old{$_} = $item->{$_}; >+ } >+ } >+ _ModStoredFields( 'ci_id' => $params{'ci_id'}, %mod_params_old ); >+ ModItem( \%mod_params_new, undef, $course_item->{'itemnumber'} ); >+ >+} >+ >+=head2 _ModStoredFields >+ >+ _ModStoredFields( %params ); >+ >+ Updates the values for the 'original' fields in course_items >+ for a given ci_id >+ >+=cut >+ >+sub _ModStoredFields { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ return unless ( $params{'ci_id'} ); >+ >+ my ( @fields_to_update, @values_to_update ); >+ >+ foreach (@FIELDS) { >+ if ( $params{$_} ) { >+ push( @fields_to_update, $_ ); >+ push( @values_to_update, $params{$_} ); >+ } >+ } >+ >+ my $query = >+ "UPDATE course_items SET " >+ . join( ',', map { "$_=?" } @fields_to_update ) >+ . " WHERE ci_id = ?"; >+ >+ C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} ) >+ if (@values_to_update); >+ >+} >+ >+=head2 _RevertFields >+ >+ _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert ); >+ >+=cut >+ >+sub _RevertFields { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $ci_id = $params{'ci_id'}; >+ my $course_item = $params{'course_item'}; >+ my $fields = $params{'fields'}; >+ my @fields = @$fields; >+ >+ return unless ($ci_id); >+ >+ $course_item = GetCourseItem( ci_id => $params{'ci_id'} ) >+ unless ($course_item); >+ >+ my $mod_item_params; >+ my @fields_to_null; >+ foreach my $field (@fields) { >+ foreach (@FIELDS) { >+ if ( $field eq $_ && $course_item->{$_} ) { >+ $mod_item_params->{$_} = $course_item->{$_}; >+ push( @fields_to_null, $_ ); >+ } >+ } >+ } >+ ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} ); >+ >+ my $query = >+ "UPDATE course_items SET " >+ . join( ',', map { "$_=NULL" } @fields_to_null ) >+ . " WHERE ci_id = ?"; >+ >+ C4::Context->dbh->do( $query, undef, $ci_id ) if (@fields_to_null); >+} >+ >+=head2 _SwapAllFields >+ >+ _SwapAllFields( $ci_id ); >+ >+=cut >+ >+sub _SwapAllFields { >+ my ($ci_id) = @_; >+ warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG; >+ >+ my $course_item = GetCourseItem( ci_id => $ci_id ); >+ my $item = GetItem( $course_item->{'itemnumber'} ); >+ >+ my %course_item_fields; >+ my %item_fields; >+ foreach (@FIELDS) { >+ if ( $course_item->{$_} ) { >+ $course_item_fields{$_} = $course_item->{$_}; >+ $item_fields{$_} = $item->{$_}; >+ } >+ } >+ >+ ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} ); >+ _ModStoredFields( %item_fields, ci_id => $ci_id ); >+} >+ >+=head2 GetCourseItems { >+ >+ $course_items = GetCourseItems( >+ [course_id => $course_id] >+ [, itemnumber => $itemnumber ] >+ ); >+ >+=cut >+ >+sub GetCourseItems { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $course_id = $params{'course_id'}; >+ my $itemnumber = $params{'itemnumber'}; >+ >+ return unless ($course_id); >+ >+ my @query_keys; >+ my @query_values; >+ >+ my $query = "SELECT * FROM course_items"; >+ >+ if ( keys %params ) { >+ >+ $query .= " WHERE "; >+ >+ foreach my $key ( keys %params ) { >+ push( @query_keys, " $key LIKE ? " ); >+ push( @query_values, $params{$key} ); >+ } >+ >+ $query .= join( ' AND ', @query_keys ); >+ } >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(@query_values); >+ >+ return $sth->fetchall_arrayref( {} ); >+} >+ >+=head2 DelCourseItem { >+ >+ DelCourseItem( ci_id => $cr_id ); >+ >+=cut >+ >+sub DelCourseItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $ci_id = $params{'ci_id'}; >+ >+ return unless ($ci_id); >+ >+ _RevertFields( ci_id => $ci_id, fields => \@FIELDS ); >+ >+ my $query = " >+ DELETE FROM course_items >+ WHERE ci_id = ? >+ "; >+ C4::Context->dbh->do( $query, undef, $ci_id ); >+} >+ >+=head2 GetCourseReserve { >+ >+ $course_item = GetCourseReserve( %params ); >+ >+=cut >+ >+sub GetCourseReserve { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $cr_id = $params{'cr_id'}; >+ my $course_id = $params{'course_id'}; >+ my $ci_id = $params{'ci_id'}; >+ >+ return unless ( $cr_id || ( $course_id && $ci_id ) ); >+ >+ my $dbh = C4::Context->dbh; >+ my $sth; >+ >+ if ($cr_id) { >+ my $query = " >+ SELECT * FROM course_reserves >+ WHERE cr_id = ? >+ "; >+ $sth = $dbh->prepare($query); >+ $sth->execute($cr_id); >+ } >+ else { >+ my $query = " >+ SELECT * FROM course_reserves >+ WHERE course_id = ? AND ci_id = ? >+ "; >+ $sth = $dbh->prepare($query); >+ $sth->execute( $course_id, $ci_id ); >+ } >+ >+ my $course_reserve = $sth->fetchrow_hashref(); >+ return $course_reserve; >+} >+ >+=head2 ModCourseReserve >+ >+ $id = ModCourseReserve( %params ); >+ >+=cut >+ >+sub ModCourseReserve { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $course_id = $params{'course_id'}; >+ my $ci_id = $params{'ci_id'}; >+ my $staff_note = $params{'staff_note'}; >+ my $public_note = $params{'public_note'}; >+ >+ return unless ( $course_id && $ci_id ); >+ >+ my $course_reserve = >+ GetCourseReserve( course_id => $course_id, ci_id => $ci_id ); >+ my $cr_id; >+ >+ my $dbh = C4::Context->dbh; >+ >+ if ($course_reserve) { >+ $cr_id = $course_reserve->{'cr_id'}; >+ >+ my $query = " >+ UPDATE course_reserves >+ SET staff_note = ?, public_note = ? >+ WHERE cr_id = ? >+ "; >+ $dbh->do( $query, undef, $staff_note, $public_note, $cr_id ); >+ } >+ else { >+ my $query = " >+ INSERT INTO course_reserves SET >+ course_id = ?, >+ ci_id = ?, >+ staff_note = ?, >+ public_note = ? >+ "; >+ $dbh->do( $query, undef, $course_id, $ci_id, $staff_note, >+ $public_note ); >+ $cr_id = >+ $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' ); >+ } >+ >+ my $course = GetCourse($course_id); >+ EnableOrDisableCourseItem( >+ ci_id => $params{'ci_id'}, >+ enabled => $course->{'enabled'} >+ ); >+ >+ return $cr_id; >+} >+ >+=head2 GetCourseReserves { >+ >+ $course_reserves = GetCourseReserves( %params ); >+ >+ Required: >+ course_id OR ci_id >+ Optional: >+ include_items => 1, >+ include_count => 1, >+ include_courses => 1, >+ >+=cut >+ >+sub GetCourseReserves { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $course_id = $params{'course_id'}; >+ my $ci_id = $params{'ci_id'}; >+ my $include_items = $params{'include_items'}; >+ my $include_count = $params{'include_count'}; >+ my $include_courses = $params{'include_courses'}; >+ >+ return unless ( $course_id || $ci_id ); >+ >+ my $field = ($course_id) ? 'course_id' : 'ci_id'; >+ my $value = ($course_id) ? $course_id : $ci_id; >+ >+ my $query = " >+ SELECT cr.*, ci.itemnumber >+ FROM course_reserves cr, course_items ci >+ WHERE cr.$field = ? >+ AND cr.ci_id = ci.ci_id >+ "; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($value); >+ >+ my $course_reserves = $sth->fetchall_arrayref( {} ); >+ >+ if ($include_items) { >+ foreach my $cr (@$course_reserves) { >+ $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} ); >+ $cr->{'item'} = GetBiblioFromItemNumber( $cr->{'itemnumber'} ); >+ $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} ); >+ } >+ } >+ >+ if ($include_count) { >+ foreach my $cr (@$course_reserves) { >+ $cr->{'reserves_count'} = >+ CountCourseReservesForItem( ci_id => $cr->{'ci_id'} ); >+ } >+ } >+ >+ if ($include_courses) { >+ foreach my $cr (@$course_reserves) { >+ $cr->{'courses'} = >+ GetCourses( itemnumber => $cr->{'itemnumber'} ); >+ } >+ } >+ >+ return $course_reserves; >+} >+ >+=head2 DelCourseReserve { >+ >+ DelCourseReserve( cr_id => $cr_id ); >+ >+=cut >+ >+sub DelCourseReserve { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $cr_id = $params{'cr_id'}; >+ >+ return unless ($cr_id); >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $course_reserve = GetCourseReserve( cr_id => $cr_id ); >+ >+ my $query = " >+ DELETE FROM course_reserves >+ WHERE cr_id = ? >+ "; >+ $dbh->do( $query, undef, $cr_id ); >+ >+ ## If there are no other course reserves for this item >+ ## delete the course_item as well >+ unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) ) >+ { >+ DelCourseItem( ci_id => $course_reserve->{'ci_id'} ); >+ } >+ >+} >+ >+=head2 GetReservesInfo >+ >+ my $arrayref = GetItemReservesInfo( itemnumber => $itemnumber ); >+ >+ For a given item, returns an arrayref of reserves hashrefs, >+ with a course hashref under the key 'course' >+ >+=cut >+ >+sub GetItemReservesInfo { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $itemnumber = $params{'itemnumber'}; >+ >+ return unless ($itemnumber); >+ >+ my $course_item = GetCourseItem( itemnumber => $itemnumber ); >+ >+ return unless ( keys %$course_item ); >+ >+ my $course_reserves = GetCourseReserves( ci_id => $course_item->{'ci_id'} ); >+ >+ foreach my $cr (@$course_reserves) { >+ $cr->{'course'} = GetCourse( $cr->{'course_id'} ); >+ } >+ >+ return $course_reserves; >+} >+ >+=head2 CountCourseReservesForItem >+ >+ $bool = CountCourseReservesForItem( %params ); >+ >+ ci_id - course_item id >+ OR >+ itemnumber - course_item itemnumber >+ >+ enabled = 'yes' or 'no' >+ Optional, if not supplied, counts reserves >+ for both enabled and disabled courses >+ >+=cut >+ >+sub CountCourseReservesForItem { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $ci_id = $params{'ci_id'}; >+ my $itemnumber = $params{'itemnumber'}; >+ my $enabled = $params{'enabled'}; >+ >+ return unless ( $ci_id || $itemnumber ); >+ >+ my $course_item = >+ GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber ); >+ >+ my @params = ( $course_item->{'ci_id'} ); >+ push( @params, $enabled ) if ($enabled); >+ >+ my $query = " >+ SELECT COUNT(*) AS count >+ FROM course_reserves cr >+ LEFT JOIN courses c ON ( c.course_id = cr.course_id ) >+ WHERE ci_id = ? >+ "; >+ $query .= "AND c.enabled = ?" if ($enabled); >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(@params); >+ >+ my $row = $sth->fetchrow_hashref(); >+ >+ return $row->{'count'}; >+} >+ >+=head2 SearchCourses >+ >+ my $courses = SearchCourses( term => $search_term, enabled => 'yes' ); >+ >+=cut >+ >+sub SearchCourses { >+ my (%params) = @_; >+ warn identify_myself(%params) if $DEBUG; >+ >+ my $term = $params{'term'}; >+ >+ my $enabled = $params{'enabled'} || '%'; >+ >+ my @params; >+ my $query = "SELECT c.* FROM courses c"; >+ >+ $query .= " >+ LEFT JOIN course_instructors ci >+ ON ( c.course_id = ci.course_id ) >+ LEFT JOIN borrowers b >+ ON ( ci.borrowernumber = b.borrowernumber ) >+ LEFT JOIN authorised_values av >+ ON ( c.department = av.authorised_value ) >+ WHERE >+ ( av.category = 'DEPARTMENT' OR av.category = 'TERM' ) >+ AND >+ ( >+ department LIKE ? OR >+ course_number LIKE ? OR >+ section LIKE ? OR >+ course_name LIKE ? OR >+ term LIKE ? OR >+ public_note LIKE ? OR >+ CONCAT(surname,' ',firstname) LIKE ? OR >+ CONCAT(firstname,' ',surname) LIKE ? OR >+ lib LIKE ? OR >+ lib_opac LIKE ? >+ ) >+ AND >+ c.enabled LIKE ? >+ GROUP BY c.course_id >+ "; >+ >+ $term = "%$term%"; >+ @params = ($term) x 10; >+ >+ $query .= " ORDER BY department, course_number, section, term, course_name "; >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ >+ $sth->execute(@params, $enabled); >+ >+ my $courses = $sth->fetchall_arrayref( {} ); >+ >+ foreach my $c (@$courses) { >+ $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} ); >+ } >+ >+ return $courses; >+} >+ >+sub whoami { ( caller(1) )[3] } >+sub whowasi { ( caller(2) )[3] } >+ >+sub stringify_params { >+ my (%params) = @_; >+ >+ my $string = "\n"; >+ >+ foreach my $key ( keys %params ) { >+ $string .= " $key => " . $params{$key} . "\n"; >+ } >+ >+ return "( $string )"; >+} >+ >+sub identify_myself { >+ my (%params) = @_; >+ >+ return whowasi() . stringify_params(%params); >+} >+ >+1; >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 4c01309..42b5438 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -204,10 +204,15 @@ sub GetSupportList{ > } > =head2 GetItemTypes > >- $itemtypes = &GetItemTypes(); >+ $itemtypes = &GetItemTypes( style => $style ); > > Returns information about existing itemtypes. > >+Params: >+ style: either 'array' or 'hash', defaults to 'hash'. >+ 'array' returns an arrayref, >+ 'hash' return a hashref with the itemtype value as the key >+ > build a HTML select with the following code : > > =head3 in PERL SCRIPT >@@ -240,6 +245,8 @@ build a HTML select with the following code : > =cut > > sub GetItemTypes { >+ my ( %params ) = @_; >+ my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash'; > > # returns a reference to a hash of references to itemtypes... > my %itemtypes; >@@ -250,10 +257,15 @@ sub GetItemTypes { > |; > my $sth = $dbh->prepare($query); > $sth->execute; >- while ( my $IT = $sth->fetchrow_hashref ) { >- $itemtypes{ $IT->{'itemtype'} } = $IT; >+ >+ if ( $style eq 'hash' ) { >+ while ( my $IT = $sth->fetchrow_hashref ) { >+ $itemtypes{ $IT->{'itemtype'} } = $IT; >+ } >+ return ( \%itemtypes ); >+ } else { >+ return $sth->fetchall_arrayref({}); > } >- return ( \%itemtypes ); > } > > sub get_itemtypeinfos_of { >@@ -1106,7 +1118,7 @@ sub GetAuthorisedValueCategories { > > =head2 GetAuthorisedValueByCode > >-$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode ); >+$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac ); > > Return the lib attribute from authorised_values from the row identified > by the passed category and code >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >new file mode 100644 >index 0000000..9df3f2e >--- /dev/null >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -0,0 +1,34 @@ >+package Koha::Template::Plugin::AuthorisedValues; >+ >+# Copyright ByWater Solutions 2012 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use Encode qw{encode decode}; >+ >+use C4::Koha; >+ >+sub GetByCode { >+ my ( $self, $category, $code, $opac ) = @_; >+ return encode('UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); >+} >+ >+1; >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >new file mode 100644 >index 0000000..ad768a5 >--- /dev/null >+++ b/Koha/Template/Plugin/Branches.pm >@@ -0,0 +1,37 @@ >+package Koha::Template::Plugin::Branches; >+ >+# Copyright ByWater Solutions 2012 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Koha; >+ >+sub GetName { >+ my ( $self, $branchcode ) = @_; >+ >+ my $query = "SELECT branchname FROM branches WHERE branchcode = ?"; >+ my $sth = C4::Context->dbh->prepare($query); >+ $sth->execute($branchcode); >+ my $b = $sth->fetchrow_hashref(); >+ return $b->{'branchname'}; >+} >+ >+1; >diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm >new file mode 100644 >index 0000000..60ca979 >--- /dev/null >+++ b/Koha/Template/Plugin/ItemTypes.pm >@@ -0,0 +1,38 @@ >+package Koha::Template::Plugin::ItemTypes; >+ >+# Copyright ByWater Solutions 2012 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Koha; >+ >+sub GetDescription { >+ my ( $self, $itemtype ) = @_; >+ >+ my $query = "SELECT description FROM itemtypes WHERE itemtype = ?"; >+ my $sth = C4::Context->dbh->prepare($query); >+ $sth->execute($itemtype); >+ my $d = $sth->fetchrow_hashref(); >+ return $d->{'description'}; >+ >+} >+ >+1; >diff --git a/Makefile.PL b/Makefile.PL >index b69dfad..4228d89 100644 >--- a/Makefile.PL >+++ b/Makefile.PL >@@ -265,6 +265,7 @@ my $target_map = { > './changelanguage.pl' => 'INTRANET_CGI_DIR', > './check_sysprefs.pl' => 'NONE', > './circ' => 'INTRANET_CGI_DIR', >+ './course_reserves' => 'INTRANET_CGI_DIR', > './offline_circ' => 'INTRANET_CGI_DIR', > './edithelp.pl' => 'INTRANET_CGI_DIR', > './etc' => { target => 'KOHA_CONF_DIR', trimdir => -1 }, >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index c00bb64..d344438 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -247,7 +247,7 @@ sub default_form { > } > > # push koha system categories >- foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP)) { >+ foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM)) { > push @category_list, $_ unless $categories{$_}; > } > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index a5b32c6..6f005d8 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -41,6 +41,7 @@ use C4::XSLT; > use C4::Images; > use Koha::DateUtils; > use C4::HTML5Media; >+use C4::CourseReserves; > > # use Smart::Comments; > >@@ -269,6 +270,10 @@ foreach my $item (@items) { > $materials_flag = 1; > } > >+ if ( C4::Context->preference('UseCourseReserves') ) { >+ $item->{'course_reserves'} = GetItemReservesInfo( itemnumber => $item->{'itemnumber'} ); >+ } >+ > if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET" > and C4::Context->preference('SeparateHoldings')) { > if ($itembranchcode and $itembranchcode eq $currentbranch) { >diff --git a/course_reserves/add_items.pl b/course_reserves/add_items.pl >new file mode 100755 >index 0000000..bbf67d5 >--- /dev/null >+++ b/course_reserves/add_items.pl >@@ -0,0 +1,97 @@ >+#!/usr/bin/perl >+ >+# >+# Copyright 2012 Bywater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use C4::Koha; >+use C4::Biblio; >+use C4::Branch; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+ >+my $action = $cgi->param('action') || ''; >+my $course_id = $cgi->param('course_id') || ''; >+my $barcode = $cgi->param('barcode') || ''; >+ >+die('No course_id provided') unless ($course_id); >+ >+my $item = GetBiblioFromItemNumber( undef, $barcode ); >+ >+my $step = ( $action eq 'lookup' && $item ) ? '2' : '1'; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "course_reserves/add_items-step$step.tmpl", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { coursereserves => 'add_reserves' }, >+ } >+); >+$template->param( ERROR_BARCODE_NOT_FOUND => $barcode ) >+ unless ( $barcode && $item && $action eq 'lookup' ); >+ >+$template->param( course => GetCourse($course_id) ); >+ >+if ( $action eq 'lookup' ) { >+ my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} ); >+ my $course_reserve = ($course_item) >+ ? GetCourseReserve( >+ course_id => $course_id, >+ ci_id => $course_item->{'ci_id'} >+ ) >+ : undef; >+ >+ $template->param( >+ item => $item, >+ course_item => $course_item, >+ course_reserve => $course_reserve, >+ >+ ccodes => GetAuthorisedValues('CCODE'), >+ locations => GetAuthorisedValues('LOC'), >+ itypes => GetItemTypes( style => 'array' ), >+ branches => GetBranchesLoop(), >+ ); >+ >+} >+elsif ( $action eq 'add' ) { >+ my $ci_id = ModCourseItem( >+ itemnumber => $cgi->param('itemnumber'), >+ itype => $cgi->param('itype'), >+ ccode => $cgi->param('ccode'), >+ holdingbranch => $cgi->param('holdingbranch'), >+ location => $cgi->param('location'), >+ ); >+ >+ my $cr_id = ModCourseReserve( >+ course_id => $course_id, >+ ci_id => $ci_id, >+ staff_note => $cgi->param('staff_note'), >+ public_note => $cgi->param('public_note'), >+ ); >+} >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/course_reserves/course-details.pl b/course_reserves/course-details.pl >new file mode 100755 >index 0000000..a0b03e9 >--- /dev/null >+++ b/course_reserves/course-details.pl >@@ -0,0 +1,67 @@ >+#!/usr/bin/perl >+ >+# >+# Copyright 2012 Bywater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use C4::Koha; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+ >+my $action = $cgi->param('action') || ''; >+my $course_id = $cgi->param('course_id'); >+ >+my $flagsrequired; >+$flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' ); >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "course_reserves/course-details.tmpl", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => $flagsrequired, >+ } >+); >+ >+die("No course_id given") unless ($course_id); >+ >+if ( $action eq 'del_reserve' ) { >+ DelCourseReserve( cr_id => $cgi->param('cr_id') ); >+} >+ >+my $course = GetCourse($course_id); >+my $course_reserves = GetCourseReserves( >+ course_id => $course_id, >+ include_items => 1, >+ include_courses => 1 >+); >+ >+$template->param( >+ course => $course, >+ course_reserves => $course_reserves, >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/course_reserves/course-reserves.pl b/course_reserves/course-reserves.pl >new file mode 100755 >index 0000000..ebffed4 >--- /dev/null >+++ b/course_reserves/course-reserves.pl >@@ -0,0 +1,54 @@ >+#!/usr/bin/perl >+ >+# >+# Copyright 2012 Bywater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "course_reserves/course-reserves.tmpl", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => {}, >+ } >+); >+ >+my $search_on = $cgi->param('search_on'); >+my %params; >+if ($search_on) { >+ $params{'course_name'} = "%$search_on%"; >+} >+ >+my $courses = GetCourses(%params); >+if ( $search_on && @$courses == 1 ) { >+ print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=" . $courses->[0]->{'course_id'}); >+} else { >+ $template->param( courses => $courses ); >+ output_html_with_http_headers $cgi, $cookie, $template->output; >+} >diff --git a/course_reserves/course.pl b/course_reserves/course.pl >new file mode 100755 >index 0000000..e2af77f >--- /dev/null >+++ b/course_reserves/course.pl >@@ -0,0 +1,55 @@ >+#!/usr/bin/perl >+ >+# >+# Copyright 2012 Bywater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use C4::Koha; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "course_reserves/course.tmpl", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { coursereserves => 'manage_courses' }, >+ } >+); >+ >+my $course_id = $cgi->param('course_id'); >+ >+if ($course_id) { >+ my $course = GetCourse($course_id); >+ $template->param(%$course); >+} >+ >+$template->param( >+ departments => GetAuthorisedValues('DEPARTMENT'), >+ terms => GetAuthorisedValues('TERM'), >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/course_reserves/mod_course.pl b/course_reserves/mod_course.pl >new file mode 100755 >index 0000000..0df85f3 >--- /dev/null >+++ b/course_reserves/mod_course.pl >@@ -0,0 +1,72 @@ >+#!/usr/bin/perl >+ >+# Copyright 2012 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Output; >+use C4::Reserves; >+use C4::Auth; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "about.tmpl", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { coursereserves => 'manage_courses' }, >+ } >+); >+ >+my $action = $cgi->param('action'); >+ >+if ( $action eq 'del' ) { >+ DelCourse( $cgi->param('course_id') ); >+ print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl"); >+} >+else { >+ my %params; >+ >+ $params{'course_id'} = $cgi->param('course_id') >+ if ( $cgi->param('course_id') ); >+ $params{'department'} = $cgi->param('department'); >+ $params{'course_number'} = $cgi->param('course_number'); >+ $params{'section'} = $cgi->param('section'); >+ $params{'course_name'} = $cgi->param('course_name'); >+ $params{'term'} = $cgi->param('term'); >+ $params{'staff_note'} = $cgi->param('staff_note'); >+ $params{'public_note'} = $cgi->param('public_note'); >+ $params{'students_count'} = $cgi->param('students_count'); >+ $params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no'; >+ >+ my $course_id = ModCourse(%params); >+ >+ my @instructors = $cgi->param('instructors'); >+ ModCourseInstructors( >+ mode => 'replace', >+ cardnumbers => \@instructors, >+ course_id => $course_id >+ ); >+ print $cgi->redirect( >+ "/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id"); >+} >diff --git a/installer/data/mysql/de-DE/mandatory/userflags.sql b/installer/data/mysql/de-DE/mandatory/userflags.sql >index 50b567e..7d34e40 100644 >--- a/installer/data/mysql/de-DE/mandatory/userflags.sql >+++ b/installer/data/mysql/de-DE/mandatory/userflags.sql >@@ -15,4 +15,5 @@ INSERT INTO `userflags` VALUES(14,'editauthorities','Normdaten ändern',0); > INSERT INTO `userflags` VALUES(15,'serials','Zugang auf Abonnementverwaltung/Zeitschriftenmodul',0); > INSERT INTO `userflags` VALUES(16,'reports','Zugang auf Reportmodul',0); > INSERT INTO `userflags` VALUES(17,'staffaccess','Berechtigungen für Bibliotheksmitarbeiter vergeben',0); >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); > INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >diff --git a/installer/data/mysql/de-DE/mandatory/userpermissions.sql b/installer/data/mysql/de-DE/mandatory/userpermissions.sql >index dc281a9..3acc525 100644 >--- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql >+++ b/installer/data/mysql/de-DE/mandatory/userpermissions.sql >@@ -53,6 +53,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Umlauflisten verwalten'), > (16, 'execute_reports', 'SQL-Reports ausführen'), > (16, 'create_reports', 'SQL-Reports erstellen'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/en/mandatory/userflags.sql b/installer/data/mysql/en/mandatory/userflags.sql >index c098dd1..0714ea4 100644 >--- a/installer/data/mysql/en/mandatory/userflags.sql >+++ b/installer/data/mysql/en/mandatory/userflags.sql >@@ -15,4 +15,5 @@ INSERT INTO `userflags` VALUES(14,'editauthorities','Edit Authorities',0); > INSERT INTO `userflags` VALUES(15,'serials','Manage serial subscriptions',0); > INSERT INTO `userflags` VALUES(16,'reports','Allow access to the reports module',0); > INSERT INTO `userflags` VALUES(17,'staffaccess','Allow staff members to modify permissions for other staff members',0); >-INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >\ No newline at end of file >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); >+INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql >index 124e030..4fa2a7a 100644 >--- a/installer/data/mysql/en/mandatory/userpermissions.sql >+++ b/installer/data/mysql/en/mandatory/userpermissions.sql >@@ -53,6 +53,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Routing'), > (16, 'execute_reports', 'Execute SQL reports'), > (16, 'create_reports', 'Create SQL Reports'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'manage', 'Manage plugins ( install / uninstall )'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), >diff --git a/installer/data/mysql/es-ES/mandatory/userflags.sql b/installer/data/mysql/es-ES/mandatory/userflags.sql >index 85b977a..55fa157 100644 >--- a/installer/data/mysql/es-ES/mandatory/userflags.sql >+++ b/installer/data/mysql/es-ES/mandatory/userflags.sql >@@ -15,4 +15,5 @@ INSERT INTO `userflags` VALUES(14,'editauthorities','Allow to edit authorities', > INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0); > INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0); > INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0); >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); > INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >diff --git a/installer/data/mysql/es-ES/mandatory/userpermissions.sql b/installer/data/mysql/es-ES/mandatory/userpermissions.sql >index f731eab..543175b 100644 >--- a/installer/data/mysql/es-ES/mandatory/userpermissions.sql >+++ b/installer/data/mysql/es-ES/mandatory/userpermissions.sql >@@ -53,6 +53,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Routing'), > (16, 'execute_reports', 'Execute SQL reports'), > (16, 'create_reports', 'Create SQL Reports'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql b/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql >index 7c3c233..1eb167a 100644 >--- a/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql >+++ b/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql >@@ -16,4 +16,5 @@ INSERT INTO `userflags` VALUES(13,'tools','Outils (export, import, impression de > INSERT INTO `userflags` VALUES(14,'editauthorities','Gestion des autorités',0); > INSERT INTO `userflags` VALUES(15,'serials','Gestion du module périodique',0); > INSERT INTO `userflags` VALUES(16,'reports','Accès aux statistiques',0); >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); > INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >index 8edc356..4452e4c 100644 >--- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >+++ b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >@@ -53,8 +53,10 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Mettre en circulation'), > (16, 'execute_reports', 'Lancer les rapports SQL'), > (16, 'create_reports', 'Créer les rapports SQL Reports'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >- > ; >diff --git a/installer/data/mysql/it-IT/necessari/userflags.sql b/installer/data/mysql/it-IT/necessari/userflags.sql >index 6f551ad..d1c3a57 100644 >--- a/installer/data/mysql/it-IT/necessari/userflags.sql >+++ b/installer/data/mysql/it-IT/necessari/userflags.sql >@@ -17,6 +17,7 @@ INSERT INTO `userflags` VALUES(14,'editauthorities','autorizza la modifica delle > INSERT INTO `userflags` VALUES(15,'serials','autorizza la gestione degli abbonamenti ai periodici',0); > INSERT INTO `userflags` VALUES(16,'reports','autorizza accesso al modulo dei reports',0); > INSERT INTO `userflags` VALUES(17,'staffaccess','modifica la login o i permessi degli staff users',0); >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); > INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); > >-SET FOREIGN_KEY_CHECKS=1; >\ No newline at end of file >+SET FOREIGN_KEY_CHECKS=1; >diff --git a/installer/data/mysql/it-IT/necessari/userpermissions.sql b/installer/data/mysql/it-IT/necessari/userpermissions.sql >index 96746cc..fe173d1 100644 >--- a/installer/data/mysql/it-IT/necessari/userpermissions.sql >+++ b/installer/data/mysql/it-IT/necessari/userpermissions.sql >@@ -55,6 +55,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'), > (16, 'execute_reports', 'Esegui reports SQL'), > (16, 'create_reports', 'Crea reports SQL'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index c74c39b..d7b215f 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -466,6 +466,108 @@ CREATE TABLE collections_tracking ( > ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8; > > -- >+-- Table structure for table `courses` >+-- >+ >+-- The courses table stores the courses created for the >+-- course reserves feature. >+ >+DROP TABLE IF EXISTS courses; >+CREATE TABLE `courses` ( >+ `course_id` int(11) NOT NULL AUTO_INCREMENT, >+ `department` varchar(20) DEFAULT NULL, -- Stores the authorised value DEPT >+ `course_number` varchar(255) DEFAULT NULL, -- An arbitrary field meant to store the "course number" assigned to a course >+ `section` varchar(255) DEFAULT NULL, -- Also arbitrary, but for the 'section' of a course. >+ `course_name` varchar(255) DEFAULT NULL, >+ `term` varchar(20) DEFAULT NULL, -- Stores the authorised value TERM >+ `staff_note` mediumtext, >+ `public_note` mediumtext, >+ `students_count` varchar(20) DEFAULT NULL, -- Meant to be just an estimate of how many students will be taking this course/section >+ `enabled` enum('yes','no') NOT NULL DEFAULT 'yes', -- Determines whether the course is active >+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >+ PRIMARY KEY (`course_id`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Table structure for table `course_instructors` >+-- >+ >+-- The course instructors table links Koha borrowers to the >+-- courses they are teaching. Many instructors can teach many >+-- courses. course_instructors is just a many-to-many join table. >+ >+DROP TABLE IF EXISTS course_instructors; >+CREATE TABLE `course_instructors` ( >+ `course_id` int(11) NOT NULL, >+ `borrowernumber` int(11) NOT NULL, >+ PRIMARY KEY (`course_id`,`borrowernumber`), >+ KEY `borrowernumber` (`borrowernumber`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Constraints for table `course_instructors` >+-- >+ALTER TABLE `course_instructors` >+ ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`), >+ ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE; >+ >+-- >+-- Table structure for table `course_items` >+-- >+ >+-- If an item is placed on course reserve for one or more courses >+-- it will have an entry in this table. No matter how many courses an item >+-- is part of, it will only have one row in this table. >+ >+DROP TABLE IF EXISTS course_items; >+CREATE TABLE `course_items` ( >+ `ci_id` int(11) NOT NULL AUTO_INCREMENT, >+ `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve >+ `itype` varchar(10) DEFAULT NULL, -- an optional new itemtype for the item to have while on reserve >+ `ccode` varchar(10) DEFAULT NULL, -- an optional new category code for the item to have while on reserve >+ `holdingbranch` varchar(10) DEFAULT NULL, -- an optional new holding branch for the item to have while on reserve >+ `location` varchar(80) DEFAULT NULL, -- an optional new shelving location for the item to have while on reseve >+ `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- If at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no' >+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >+ PRIMARY KEY (`ci_id`), >+ UNIQUE KEY `itemnumber` (`itemnumber`), >+ KEY `holdingbranch` (`holdingbranch`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Constraints for table `course_items` >+-- >+ALTER TABLE `course_items` >+ ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE; >+ >+-- >+-- Table structure for table `course_reserves` >+-- >+ >+-- This table connects an item placed on course reserve to a course it is on reserve for. >+-- There will be a row in this table for each course an item is on reserve for. >+ >+DROP TABLE IF EXISTS course_reserves; >+CREATE TABLE `course_reserves` ( >+ `cr_id` int(11) NOT NULL AUTO_INCREMENT, >+ `course_id` int(11) NOT NULL, -- Foreign key to the courses table >+ `ci_id` int(11) NOT NULL, -- Foreign key to the course_items table >+ `staff_note` mediumtext, -- Staff only note >+ `public_note` mediumtext, -- Public, OPAC visible note >+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >+ PRIMARY KEY (`cr_id`), >+ UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`), >+ KEY `course_id` (`course_id`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Constraints for table `course_reserves` >+-- >+ALTER TABLE `course_reserves` >+ ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`); >+ >+-- > -- Table structure for table `borrower_branch_circ_rules` > -- > >diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql >index c9062fa..6323b36 100644 >--- a/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql >+++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql >@@ -36,4 +36,5 @@ INSERT INTO `userflags` VALUES(14,'editauthorities','Tilgang til Ã¥ endre autori > INSERT INTO `userflags` VALUES(15,'serials','Tilgang til Ã¥ endre abonnementer',0); > INSERT INTO `userflags` VALUES(16,'reports','Tilgang til rapportmodulen',0); > INSERT INTO `userflags` VALUES(17,'staffaccess','Endre innlogging og rettigheter for bibliotekansatte',0); >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); > INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >index ba56e3a..4708341 100644 >--- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >+++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >@@ -73,6 +73,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Sirkulasjon'), > (16, 'execute_reports', 'Kjøre SQL-rapporter'), > (16, 'create_reports', 'Opprette SQL-rapporter'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/pl-PL/mandatory/userflags.sql b/installer/data/mysql/pl-PL/mandatory/userflags.sql >index 85b977a..55fa157 100644 >--- a/installer/data/mysql/pl-PL/mandatory/userflags.sql >+++ b/installer/data/mysql/pl-PL/mandatory/userflags.sql >@@ -15,4 +15,5 @@ INSERT INTO `userflags` VALUES(14,'editauthorities','Allow to edit authorities', > INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0); > INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0); > INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0); >+INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0); > INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0'); >diff --git a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >index 5659aba..a6fba02 100644 >--- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >+++ b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >@@ -54,6 +54,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Routing'), > (16, 'execute_reports', 'Execute SQL reports'), > (16, 'create_reports', 'Create SQL Reports'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql b/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql >index a7123ba..4a952e4 100644 >--- a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql >+++ b/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql >@@ -18,6 +18,7 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES > (15,'serials', 'РазÑеÑение на ÑпÑавление подпиÑкой пеÑиодиÑеÑÐºÐ¸Ñ Ð¸Ð·Ð´Ð°Ð½Ð¸Ð¹',0), > (16,'reports', 'РазÑеÑение на доÑÑÑп к модÑÐ»Ñ Ð¾ÑÑеÑов',0), > (17,'staffaccess', 'Смена имени(логина)/пÑивилегий Ð´Ð»Ñ ÑабоÑников библиоÑеки',0), >+ (18,'coursereserves', 'Course Reserves',0), > (19,'plugins', 'Koha plugins', '0') > ; > >@@ -78,6 +79,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Routing'), > (16, 'execute_reports', 'Execute SQL reports'), > (16, 'create_reports', 'Create SQL Reports'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index df821c0..13bc7c3 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -419,3 +419,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','1','Enable or disable the ability to use Koha Plugins.','','YesNo'); >+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo'); >diff --git a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql b/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql >index 366764c..9f0f0d8 100644 >--- a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql >+++ b/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql >@@ -18,6 +18,7 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES > (15,'serials', 'ÐозвÑл на кеÑÑÐ²Ð°Ð½Ð½Ñ Ð¿ÑдпиÑÐºÐ¾Ñ Ð¿ÐµÑÑодиÑÐ½Ð¸Ñ Ð²Ð¸Ð´Ð°Ð½Ñ',0), > (16,'reports', 'ÐозвÑл на доÑÑÑп до модÑÐ»Ñ Ð·Ð²ÑÑÑв',0), > (17,'staffaccess', 'ÐмÑна ÑменÑ(логÑнÑ)/пÑивÑлеÑв Ð´Ð»Ñ Ð¿ÑаÑÑвникÑв бÑблÑоÑеки',0), >+ (18,'coursereserves', 'Course Reserves',0), > (19,'plugins', 'Koha plugins', '0') > ; > >@@ -78,6 +79,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (15, 'routing', 'Routing'), > (16, 'execute_reports', 'Execute SQL reports'), > (16, 'create_reports', 'Create SQL Reports'), >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves'), > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 222428d..901fc47 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5797,7 +5797,6 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >- > $DBversion = "3.09.00.047"; > if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not >@@ -5828,8 +5827,6 @@ if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >- >- > $DBversion = "3.09.00.050"; > if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > $dbh->do("ALTER TABLE authorised_values MODIFY category varchar(16) NOT NULL DEFAULT '';"); >@@ -6655,6 +6652,96 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.11.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')"); >+ $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')"); >+ $dbh->do(" >+CREATE TABLE `courses` ( >+ `course_id` int(11) NOT NULL AUTO_INCREMENT, >+ `department` varchar(20) DEFAULT NULL, >+ `course_number` varchar(255) DEFAULT NULL, >+ `section` varchar(255) DEFAULT NULL, >+ `course_name` varchar(255) DEFAULT NULL, >+ `term` varchar(20) DEFAULT NULL, >+ `staff_note` mediumtext, >+ `public_note` mediumtext, >+ `students_count` varchar(20) DEFAULT NULL, >+ `enabled` enum('yes','no') NOT NULL DEFAULT 'yes', >+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >+ PRIMARY KEY (`course_id`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+CREATE TABLE `course_instructors` ( >+ `course_id` int(11) NOT NULL, >+ `borrowernumber` int(11) NOT NULL, >+ PRIMARY KEY (`course_id`,`borrowernumber`), >+ KEY `borrowernumber` (`borrowernumber`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ALTER TABLE `course_instructors` >+ ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`), >+ ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE; >+ "); >+ >+ $dbh->do(" >+CREATE TABLE `course_items` ( >+ `ci_id` int(11) NOT NULL AUTO_INCREMENT, >+ `itemnumber` int(11) NOT NULL, >+ `itype` varchar(10) DEFAULT NULL, >+ `ccode` varchar(10) DEFAULT NULL, >+ `holdingbranch` varchar(10) DEFAULT NULL, >+ `location` varchar(80) DEFAULT NULL, >+ `enabled` enum('yes','no') NOT NULL DEFAULT 'no', >+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >+ PRIMARY KEY (`ci_id`), >+ UNIQUE KEY `itemnumber` (`itemnumber`), >+ KEY `holdingbranch` (`holdingbranch`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+$dbh->do(" >+ALTER TABLE `course_items` >+ ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE; >+"); >+ >+$dbh->do(" >+CREATE TABLE `course_reserves` ( >+ `cr_id` int(11) NOT NULL AUTO_INCREMENT, >+ `course_id` int(11) NOT NULL, >+ `ci_id` int(11) NOT NULL, >+ `staff_note` mediumtext, >+ `public_note` mediumtext, >+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, >+ PRIMARY KEY (`cr_id`), >+ UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`), >+ KEY `course_id` (`course_id`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+"); >+ >+ $dbh->do(" >+ALTER TABLE `course_reserves` >+ ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`); >+ "); >+ >+ $dbh->do(" >+INSERT INTO permissions (module_bit, code, description) VALUES >+ (18, 'manage_courses', 'Add, edit and delete courses'), >+ (18, 'add_reserves', 'Add course reserves'), >+ (18, 'delete_reserves', 'Remove course reserves') >+; >+ "); >+ >+ >+ print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index 91d0431..8e7f15a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -744,7 +744,7 @@ fieldset.rows .inputnote { > visibility:visible; /* you propably don't need to change this one */ > display:block; > } >-#newbiblio a, #addchild a, #newentry a, #newshelf a, #newmenuc .first-child, #newsupplier .first-child, #newlabel a, #newtemplate a, #newlabelbatch a, #newpatroncardbatch a, #newprofile a, #newsubscription a, #newdictionary a, #newbasket a, #newrootbudget-button, #budgets_menuc .first-child { >+#new_course a, #newbiblio a, #addchild a, #newentry a, #newshelf a, #newmenuc .first-child, #newsupplier .first-child, #newlabel a, #newtemplate a, #newlabelbatch a, #newpatroncardbatch a, #newprofile a, #newsubscription a, #newdictionary a, #newbasket a, #newrootbudget-button, #budgets_menuc .first-child { > padding-left : 34px; > background-image: url("../../img/toolbar-new.gif"); > background-position : center left; >@@ -2550,4 +2550,4 @@ button.closebtn{padding:0;cursor:pointer;background:transparent;border:0;-webkit > .btn-group label, > .btn-group select { > font-size: 13px; >-} >\ No newline at end of file >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index d75b36e..b1618ed 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -24,6 +24,9 @@ > [% IF ( CAN_user_serials ) %] > <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li> > [% END %] >+ [% IF ( CAN_user_coursereserves ) %] >+ <li><a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a></li> >+ [% END %] > [% IF ( CAN_user_reports ) %] > <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js >index f21b122..53fc249 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js >@@ -5,14 +5,16 @@ function _(s) { return s; } // dummy function for gettext > > $(document).ready(function() { > $('#header_search').tabs().bind('tabsshow', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); }); >- $(".close").click(function(){ window.close(); }); >+ >+ $(".close").click(function(){ window.close(); }); >+ > if($("#header_search #checkin_search").length > 0){ $(document).bind('keydown','Alt+r',function (){ $("#header_search").tabs("select","#checkin_search"); $("#ret_barcode").focus(); }); } else { $(document).bind('keydown','Alt+r',function (){ location.href="/cgi-bin/koha/circ/returns.pl"; }); } > if($("#header_search #circ_search").length > 0){ $(document).bind('keydown','Alt+u',function (){ $("#header_search").tabs("select","#circ_search"); $("#findborrower").focus(); }); } else { $(document).bind('keydown','Alt+u',function(){ location.href="/cgi-bin/koha/circ/circulation.pl"; }); } > if($("#header_search #catalog_search").length > 0){ $(document).bind('keydown','Alt+q',function (){ $("#header_search").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { $(document).bind('keydown','Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); } >+ > $(".focus").focus(); > }); > >- > // http://jennifermadden.com/javascript/stringEnterKeyDetector.html > function checkEnter(e){ //e is event object passed from function invocation > var characterCode; // literal character code will be stored in this variable >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index f88d964..243b8e4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -543,3 +543,10 @@ Circulation: > - and this password > - pref: AutoSelfCheckPass > - . >+ Course Reserves: >+ - >+ - pref: UseCourseReserves >+ choices: >+ yes: Use >+ no: "Don't use" >+ - course reserves >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 8f40e31..b136052 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1,3 +1,18 @@ >+[% USE AuthorisedValues %] >+ >+[% ShowCourseReserves = 0 %] >+[% IF UseCourseReserves %] >+ [% FOREACH item IN itemloop %] >+ [% IF item.course_reserves %] >+ [% FOREACH r IN item.course_reserves %] >+ [% IF r.course.enabled == 'yes' %] >+ [% ShowCourseReserves = 1 %] >+ [% END %] >+ [% END %] >+ [% END %] >+ [% END %] >+[% END %] >+ > [% INCLUDE 'doc-head-open.inc' %] > [% INCLUDE 'greybox.inc' %] > <title>Koha › Catalog › >@@ -370,6 +385,7 @@ function verify_images() { > [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %] > [% IF ( hostrecords ) %]<th>Host records</th>[% END %] > [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %] >+ [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %] > </tr> > </thead> > <tbody> >@@ -522,6 +538,24 @@ function verify_images() { > <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% item.biblionumber %]&hostitemnumber=[% item.itemnumber %]">Create analytics</a></td> > [% END %] > >+ [% IF ShowCourseReserves %] >+ <td> >+ [% IF item.course_reserves %] >+ [% FOREACH r IN item.course_reserves %] >+ [% IF r.course.enabled == 'yes' %] >+ <p> >+ <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id %]"> >+ [% r.course.course_name %] >+ <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]--> >+ [% IF r.course.section %] [% r.course.section %] [% END %] >+ [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %] >+ </a> >+ </p> >+ [% END %] >+ [% END %] >+ [% END %] >+ </td> >+ [% END %] > </tr> > [% END %] > </tbody> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index f01c682..d7e3536 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -10,7 +10,7 @@ $(document).ready(function(){ > window.close(); > [% END %] > [% END %] >- $("fieldset.rows input").keydown(function(e){ return checkEnter(e); }); >+ $("fieldset.rows input").addClass("noEnterSubmit"); > /* Inline edit/delete links */ > var biblionumber = $("input[name='biblionumber']").attr("value"); > $("td").click(function(event){ >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 >new file mode 100644 >index 0000000..ab1b6ce >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt >@@ -0,0 +1,63 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Course reserves › Add items</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ >+$(document).ready(function() { >+ $('#barcode').focus(); >+}); >+ >+//]]> >+</script> >+ >+<body> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> › Add reserves for <i><a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]">[% course.course_name %]</a></i></div> >+ >+<div id="doc2" class="yui-t7"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <div class="yui-g"> >+ <div class="yui-u first"> >+ [% IF ERROR_BARCODE_NOT_FOUND %] >+ <div class="error">No item found for barcode [% ERROR_BARCODE_NOT_FOUND %]</div> >+ [% END %] >+ >+ <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl"> >+ <input type="hidden" name="course_id" value="[% course.course_id %]" /> >+ <input type="hidden" name="action" value="lookup" /> >+ >+ <fieldset class="rows"> >+ <legend>Add items: scan barcode</legend> >+ >+ <p> >+ >+ <li> >+ <label class="required" for="barcode">Item barcode:</label> >+ <input id="barcode" name="barcode" type="text" /> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="submit" value="Submit" class="submit" /> >+ >+ <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a> >+ </fieldset> >+ </form> >+ </div> >+ </div> >+ </div> >+ </div> >+ </div> >+</div> >+ >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt >new file mode 100644 >index 0000000..2326e3f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt >@@ -0,0 +1,133 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Course reserves › Add items</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+$(document).ready(function() { >+ $('#submit').focus(); >+}); >+//]]> >+</script> >+ >+</head> >+ >+<body> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> › Reserve <i><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.biblionumber %]">[% item.title %]</a></i> for <i><a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]">[% course.course_name %]</a></i></div> >+ >+<div id="doc2" class="yui-t7"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <div class="yui-g"> >+ <div class="yui-u first"> >+ [% IF course_reserve %]<div class="warn" id="already_on_reserve_this">This course already has this item on reserve.<div>[% END %] >+ [% IF course_item %]<div class="warn" id="already_on_reserve">Number of courses reserving this item: [% course_item.course_reserves.size %]<div>[% END %] >+ >+ <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl"> >+ <input type="hidden" name="course_id" value="[% course.course_id %]" /> >+ <input type="hidden" name="action" value="add" /> >+ >+ <fieldset class="rows"> >+ <legend>Add <i>[% item.title %]</i> to <i>[% course.course_name %]</i></legend> >+ <ol> >+ <li> >+ <label for="barcode">Barcode:</label> >+ <span id="barcode">[% item.barcode %]</span> >+ <input type="hidden" name="itemnumber" value="[% item.itemnumber %]" /> >+ </li> >+ >+ [% IF item_level_itypes %] >+ <li> >+ <label class="required" for="itype">Item Type:</label> >+ <select id="itype" name="itype"> >+ <option value="">LEAVE UNCHANGED</option> >+ >+ [% FOREACH it IN itypes %] >+ [% IF course_item.itype && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %] >+ <option value="[% it.itemtype %]" selected="selected">[% it.description %]</option> >+ [% ELSE %] >+ <option value="[% it.itemtype %]">[% it.description %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ [% END %] >+ >+ <li> >+ <label class="required" for="ccode">Collection Code:</label> >+ <select id="ccode" name="ccode"> >+ <option value="">LEAVE UNCHANGED</option> >+ >+ [% FOREACH c IN ccodes %] >+ [% IF course_item.ccode && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %] >+ <option value="[% c.authorised_value %]" selected="selected">[% c.lib %]</option> >+ [% ELSE %] >+ <option value="[% c.authorised_value %]">[% c.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ <li> >+ <label class="required" for="location">Shelving Location:</label> >+ <select id="location" name="location"> >+ <option value="">LEAVE UNCHANGED</option> >+ >+ [% FOREACH s IN locations %] >+ [% IF course_item.location && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %] >+ <option value="[% s.authorised_value %]" selected="selected">[% s.lib %]</option> >+ [% ELSE %] >+ <option value="[% s.authorised_value %]">[% s.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ <li> >+ <label class="required" for="holdingbranch">Holding Library:</label> >+ <select id="holdingbranch" name="holdingbranch"> >+ <option value="">LEAVE UNCHANGED</option> >+ >+ [% FOREACH b IN branches %] >+ [% IF course_item.holdingbranch && ( ( course.enabled == 'yes' && b.value == item.holdingbranch ) || ( course.enabled == 'no' && b.value == course_item.holdingbranch ) ) %] >+ <option value="[% b.value %]" selected="selected">[% b.branchname %]</option> >+ [% ELSE %] >+ <option value="[% b.value %]">[% b.branchname %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ <li> >+ <label for="staff_note">Staff note:</label> >+ <textarea name="staff_note" id="staff_note">[% course_reserve.staff_note %]</textarea> >+ </li> >+ >+ <li> >+ <label for="public_note">Public note:</label> >+ <textarea name="public_note" id="public_note">[% course_reserve.public_note %]</textarea> >+ </li> >+ >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="submit" id="submit" value="Save" class="submit" /> >+ >+ <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a> >+ </fieldset> >+ >+ </div> >+ </div> >+ </div> >+ </div> >+ </div> >+</div> >+ >+ >+[% INCLUDE 'intranet-bottom.inc' %] >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 >new file mode 100644 >index 0000000..3c91065 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt >@@ -0,0 +1,185 @@ >+[% USE AuthorisedValues %] >+[% USE ItemTypes %] >+[% USE Branches %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Course reserves › New course</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ >+ function confirmItemDelete(){ >+ return confirm( _('Are you sure you want to delete this item?'); >+ } >+ >+//]]> >+</script> >+ >+</head> >+ >+<body> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> › Course details for <i>[% course.course_name %]</i></div> >+ >+<div id="doc2" class="yui-t7"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div id="toolbar"> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ $(document).ready(function(){ >+ addItemsButton = new YAHOO.widget.Button("add_items"); >+ editCourseButton = new YAHOO.widget.Button("edit_course"); >+ deleteCourseButton = new YAHOO.widget.Button("delete_course"); >+ >+ deleteCourseButton.on("click", confirmDelete ); >+ }); >+ >+ function confirmDelete(p_oEvent){ >+ if ( ! confirm( _('Are you sure you want to delete this course?') ) ) { >+ YAHOO.util.Event.stopEvent( p_oEvent ); >+ } >+ } >+ >+ //]]> >+ </script> >+ <ul class="toolbar"> >+ [% IF CAN_user_coursereserves_add_reserves %]<li><a id="add_items" href="/cgi-bin/koha/course_reserves/add_items.pl?course_id=[% course.course_id %]">Add reserves</a></li>[% END %] >+ [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]">Edit course</a></li>[% END %] >+ [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a id="delete_course" href="/cgi-bin/koha/course_reserves/mod_course.pl?course_id=[% course.course_id %]&action=del">Delete course</a></li>[% END %] >+ </ul> >+ </div><!-- /toolbar --> >+ >+ <table> >+ <tr><th>Course name</th><td>[% course.course_name %]</td></tr> >+ <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr> >+ <tr><th>Department</th><td>_[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr> >+ <tr><th>Course number</th><td>[% course.course_number %]</td></tr> >+ <tr><th>Section</th><td>[% course.section %]</td></tr> >+ <tr><th>Instructors</th><td>[% FOREACH i IN course.instructors %]<div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>[% END %]</td></tr> >+ <tr><th>Staff note</th><td>[% course.staff_note %]</td></tr> >+ <tr><th>Public note</th><td>[% course.public_note %]</td></tr> >+ <tr><th>Students count</th><td>[% course.students_count %]</td></tr> >+ <tr><th>Status</th><td>[% IF course.enabled == 'yes' %]Active[% ELSE %]Inactive[% END %]</td></tr> >+ </table> >+ >+ <table> >+ <thead> >+ <tr> >+ <th>Title</th> >+ <th>Barcode</th> >+ <th>Call number</th> >+ [% IF item_level_itypes %]<th>Item type</th>[% END %] >+ <th>Collection</th> >+ <th>Location</th> >+ <th>Library</th> >+ <th>Staff note</th> >+ <th>Public note</th> >+ [% IF CAN_user_coursereserves_add_reserves %]<th> <!-- Edit --></th>[% END %] >+ [% IF CAN_user_coursereserves_delete_reserves %]<th> <!-- Remove --></th>[% END %] >+ <th>Other course reserves</th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH cr IN course_reserves %] >+ <tr> >+ <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td> >+ <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% cr.item.itemnumber %]&biblionumber=[% cr.item.biblionumber %]&bi=[% cr.item.biblioitemnumber %]">[% cr.item.barcode %]</a></td> >+ <td>[% cr.item.itemcallnumber %]</td> >+ [% IF item_level_itypes %] >+ <td> >+ [% IF cr.course_item.itype %] >+ [% IF cr.course_item.enabled == 'yes' %] >+ [% ItemTypes.GetDescription( cr.item.itype ) %] >+ [% ELSE %] >+ [% ItemTypes.GetDescription( cr.course_item.itype ) %] >+ [% END %] >+ [% ELSE %] >+ <i>Unchanged</i> >+ ([% ItemTypes.GetDescription( cr.item.itype ) %]) >+ [% END %] >+ </td> >+ [% END %] >+ <td> >+ [% IF cr.course_item.ccode %] >+ [% IF cr.course_item.enabled == 'yes' %] >+ [% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %] >+ [% ELSE %] >+ [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) %] >+ [% END %] >+ [% ELSE %] >+ <i>Unchanged</i> >+ ([% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]) >+ [% END %] >+ </td> >+ <td> >+ [% IF cr.course_item.location %] >+ [% IF cr.course_item.enabled == 'yes' %] >+ [% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %] >+ [% ELSE %] >+ [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) %] >+ [% END %] >+ [% ELSE %] >+ <i>Unchanged</i> >+ ([% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]) >+ [% END %] >+ </td> >+ <td> >+ [% IF cr.course_item.holdingbranch %] >+ [% IF cr.course_item.enabled == 'yes' %] >+ [% Branches.GetName( cr.item.holdingbranch ) %] >+ [% ELSE %] >+ [% Branches.GetName( cr.course_item.holdingbranch ) %] >+ [% END %] >+ [% ELSE %] >+ <i>Unchanged</i> >+ ([% Branches.GetName( cr.item.holdingbranch ) %]) >+ [% END %] >+ </td> >+ <td>[% cr.staff_note %]</td> >+ <td>[% cr.public_note %]</td> >+ >+ [% IF CAN_user_coursereserves_add_reserves %] >+ <td><a href="add_items.pl?course_id=[% course.course_id %]&barcode=[% cr.item.barcode %]&action=lookup">Edit</a></td> >+ [% END %] >+ >+ [% IF CAN_user_coursereserves_delete_reserves %] >+ <td> >+ [% IF cr.item.onloan %] >+ On Loan >+ [% ELSIF cr.item.itemlost %] >+ Item Lost >+ [% ELSE %] >+ <a href="course-details.pl?course_id=[% course.course_id %]&action=del_reserve&cr_id=[% cr.cr_id %]" onclick="return confirmItemDelete()" >Remove</a> >+ [% END %] >+ >+ </td> >+ [% END %] >+ >+ <td> >+ [% FOREACH course IN cr.courses %] >+ [% UNLESS cr.course_id == course.course_id %] >+ <p> >+ <a href="course-details.pl?course_id=[% course.course_id %]"> >+ [% course.course_name %] >+ [% IF course.section %] [% course.section %] [% END %] >+ [% IF course.term %] [% AuthorisedValues.GetByCode( 'TERM', course.term ) %] [% END %] >+ </a> >+ </p> >+ [% END %] >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ </div> >+</div> >+ >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt >new file mode 100644 >index 0000000..dfae703 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt >@@ -0,0 +1,119 @@ >+[% USE AuthorisedValues %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Course reserves</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<link rel="stylesheet" type="text/css" href="/intranet-tmpl/prog/en/css/datatables.css" /> >+<script type="text/javascript" src="/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="/intranet-tmpl/prog/en/js/datatables.js"></script> >+<script type="text/javascript" id="js">$(document).ready(function() { >+ $(document).ready(function() { >+ $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sPaginationType": "four_button", >+ })); >+ }); >+}); >+</script> >+ >+</head> >+<body id="lists_shelves" class="lists"> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a></div> >+ >+<div id="doc2" class="yui-t7"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <div class="yui-g"> >+ >+ <div id="toolbar"> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ $(document).ready(function(){ >+ newCourseButton = new YAHOO.widget.Button("new_course"); >+ }); >+ //]]> >+ </script> >+ <ul class="toolbar"> >+ [% IF ( CAN_user_coursereserves_manage_courses ) %] >+ <li><a id="new_course" href="/cgi-bin/koha/course_reserves/course.pl">New course</a></li> >+ [% END %] >+ </ul> >+ </div><!-- /toolbar --> >+ >+ <!-- >+ <div id="search-toolbar"> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function submitSearchForm(p_oEvent){ >+ $('#search_courses_form').submit(); >+ } >+ >+ $(document).ready(function(){ >+ newCourseButton = new YAHOO.widget.Button("search_courses"); >+ newCourseButton.on("click", submitSearchForm ); >+ }); >+ //]]> >+ </script> >+ <ul class="toolbar"> >+ <li><form id="search_courses_form"><input type="text" name="search_on" id="search_on"></form></li> >+ <li><a id="search_courses">Search courses</a></li> >+ </ul> >+ </div> >+ --> >+ >+ <h1>Courses</h1> >+ <table id="course_reserves_table"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Dept.</th> >+ <th>Course #</th> >+ <th>Section</th> >+ <th>Term</th> >+ <th>Instructors</th> >+ <th>Staff note</th> >+ <th>Public note</th> >+ <th># of Students</th> >+ <th>Enabled</th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH c IN courses %] >+ <tr> >+ <td><a href="course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td> >+ <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department ) %]</td> >+ <td>[% c.course_number %]</td> >+ <td>[% c.section %]</td> >+ <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td> >+ <td> >+ [% FOREACH i IN c.instructors %] >+ <div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div> >+ [% END %] >+ </td> >+ <td>[% c.staff_note %]</td> >+ <td>[% c.public_note %]</td> >+ <td>[% c.students_count %]</td> >+ <td> >+ [% IF c.enabled == 'yes' %] >+ <img src="/intranet-tmpl/prog/img/approve.gif" /> >+ [% ELSE %] >+ <img src="http://kohadev:8080/intranet-tmpl/prog/img/deny.gif" /> >+ [% END %] >+ </td> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ </div> >+ </div> >+ </div> >+</div> >+ >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt >new file mode 100644 >index 0000000..14498fa >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt >@@ -0,0 +1,205 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Course reserves › [% IF course_name %] Edit [% course_name %] [% ELSE %] New course [% END %]</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ >+ function Check(f) { >+ var _alertString = ""; >+ >+ if( ! $("#department").val() ) { >+ _alertString += _("- You must choose a department") + "\n"; >+ } >+ >+ if( ! $("#course_number").val() ) { >+ _alertString += _("- You must choose a course number") + "\n"; >+ } >+ >+ if( ! $("#course_name").val() ) { >+ _alertString += _("- You must add a course name") + "\n"; >+ } >+ >+ if ( _alertString.length ) { >+ var alertHeader; >+ alertHeader = _("Form not submitted because of the following problem(s)"); >+ alertHeader += "\n------------------------------------------------------------------------------------\n\n"; >+ >+ alert( alertHeader + _alertString ); >+ } else { >+ f.submit(); >+ } >+ } >+ >+//]]> >+</script> >+ >+<script type="text/javascript"> >+//<![CDATA[ >+$(document).ready(function(){ >+ $( "#find_instructor" ).autocomplete({ >+ source: "/cgi-bin/koha/circ/ysearch.pl", >+ minLength: 3, >+ select: function( event, ui ) { >+ AddInstructor( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber ); >+ return false; >+ } >+ }) >+ .data( "autocomplete" )._renderItem = function( ul, item ) { >+ return $( "<li></li>" ) >+ .data( "item.autocomplete", item ) >+ .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >+ .appendTo( ul ); >+ }; >+ >+}); >+ >+function AddInstructor( name, cardnumber ) { >+ div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>"; >+ $('#instructors').append( div ); >+ >+ $('#find_instructor').val('').focus(); >+} >+ >+function RemoveInstructor( cardnumber ) { >+ $( '#borrower_' + cardnumber ).remove(); >+} >+ >+//]]> >+</script> >+ >+</head> >+ >+<body> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> › [% IF course_name %] Edit <i>[% course_name %]</i> [% ELSE %] New course [% END %]</div> >+ >+<div id="doc2" class="yui-t7"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <div class="yui-g"> >+ <div class="yui-u first"> >+ <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl"> >+ [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %] >+ <fieldset class="rows"> >+ <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend> >+ <ol> >+ <li> >+ <label class="required" for="department">Department:</label> >+ [% IF departments %] >+ <select id="department" name="department"> >+ <option value="">Select A Department</option> >+ >+ [% FOREACH d IN departments %] >+ [% IF d.authorised_value == department %] >+ <option value="[% d.authorised_value %]" selected="selected">[% d.lib %]</option> >+ [% ELSE %] >+ <option value="[% d.authorised_value %]">[% d.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ [% ELSE %] >+ <span id="department">No DEPARTMENT authorised values found! Please create one or more authorised values with the category DEPARTMENT.</span> >+ [% END %] >+ </li> >+ >+ <li> >+ <label class="required" for="course_number">Course number:</label> >+ <input id="course_number" name="course_number" type="text" value="[% course_number %]" /> >+ </li> >+ >+ <li> >+ <label for="section">Section:</label> >+ <input id="section" name="section" type="text" value="[% section %]"/> >+ </li> >+ >+ <li> >+ <label class="required" for="course_name">Course name:</label> >+ <input id="course_name" name="course_name" type="text" value="[% course_name %]" /> >+ </li> >+ >+ <li> >+ <label for="term">Term:</label> >+ [% IF terms %] >+ <select id="term" name="term"> >+ <option value=""></option> >+ >+ [% FOREACH t IN terms %] >+ [% IF t.authorised_value == term %] >+ <option value="[% t.authorised_value %]" selected="selected">[% t.lib %]</option> >+ [% ELSE %] >+ <option value="[% t.authorised_value %]">[% t.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ [% ELSE %] >+ <span id="term">No TERM authorised values found! Please create one or more authorised values with the category TERM.</span> >+ [% END %] >+ </li> >+ >+ <!-- TODO: Add Instructors --> >+ <li> >+ <label for="instructors">Instructors:</label> >+ >+ <fieldset> >+ <div id="instructors"> >+ [% FOREACH i IN instructors %] >+ <div id="borrower_[% i.cardnumber %]"> >+ [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> ) >+ <input type='hidden' name='instructors' value='[% i.cardnumber %]' /> >+ </div> >+ [% END %] >+ </div> >+ >+ </fieldset> >+ >+ <fieldset> >+ <label for="find_instructor">Instructor search:</label> >+ <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/> >+ <div id="find_instructor_container"></div> >+ </fieldset> >+ <li> >+ <label for="staff_note">Staff note:</label> >+ <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea> >+ </li> >+ >+ <li> >+ <label for="public_note">Public note:</label> >+ <textarea name="public_note" id="public_note">[% public_note %]</textarea> >+ </li> >+ >+ <li> >+ <label for="students_count">Number of students:</label> >+ <input id="students_count" name="students_count" type="text" value="[% students_count %]" /> >+ </li> >+ >+ <li> >+ <label for="enabled">Enabled?</label> >+ [% IF enabled == 'no' %] >+ <input type="checkbox" name="enabled" id="enabled" /> >+ [% ELSE %] >+ <input type="checkbox" name="enabled" id="enabled" checked="checked" /> >+ [% END %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" /> >+ >+ <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a> >+ </fieldset> >+ >+ </div> >+ </div> >+ </div> >+ </div> >+ </div> >+</div> >+ >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >index 52264ee..ff2b6b6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >@@ -4,8 +4,8 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function(){ >- $("fieldset.rows input").keydown(function(e){ return checkEnter(e); }); > $('#mancredit').preventDoubleFormSubmit(); >+ $("fieldset.rows input").addClass("noEnterSubmit"); > }); > //]]> > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >index dc9aac4..30a4e20 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >@@ -4,8 +4,8 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function(){ >- $("fieldset.rows input").keydown(function(e){ return checkEnter(e); }); > $('#maninvoice').preventDoubleFormSubmit(); >+ $("fieldset.rows input").addClass("noEnterSubmit"); > }); > //]]> > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 2fdb387..3254aa9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -6,7 +6,7 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { >- $("fieldset.rows input").keydown(function(e){ return checkEnter(e); }); >+ $("fieldset.rows input").addClass("noEnterSubmit"); > $("#guarantordelete").click(function() { > $("#contact-details").hide().find('a').remove(); > $("#guarantorid, #contactname, #contactfirstname").each(function () { this.value = "" }); >diff --git a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >index 1d8538e..e57e2d6 100644 >--- a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >@@ -247,6 +247,7 @@ > > <div id="moresearches"> > <a href="/cgi-bin/koha/opac-search.pl">Advanced search</a> >+[% IF ( UseCourseReserves ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course Reserves</a>[% END %] > [% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %] > [% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Browse by author or subject</a>[% END %] > [% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >index aa8c281..4ae6e22 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >@@ -118,6 +118,7 @@ > > <div id="moresearches"> > <a href="/cgi-bin/koha/opac-search.pl">Advanced search</a> >+[% IF ( UseCourseReserves ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course Reserves</a>[% END %] > [% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %] > [% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Browse by author or subject</a>[% END %] > [% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-details.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-details.tt >new file mode 100644 >index 0000000..70ed2d1 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-details.tt >@@ -0,0 +1,63 @@ >+[% USE KohaDates %] >+[% USE AuthorisedValues %] >+[% USE ItemTypes %] >+[% USE Branches %] >+[% INCLUDE 'doc-head-open.inc' %] >+[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="opac-main"> >+[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %] >+ <div id="bd"> >+[% INCLUDE 'masthead.inc' %] >+ >+<div id="doc2" class="yui-t7"> >+ <div id="yui-main"> >+ >+ <table> >+ <tr><th>Course Name</th><td>[% course.course_name %]</td></tr> >+ <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr> >+ <tr><th>Department</th><td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr> >+ <tr><th>Course Number</th><td>[% course.course_number %]</td></tr> >+ <tr><th>Section</th><td>[% course.section %]</td></tr> >+ <tr><th>Instructors</th><td>[% FOREACH i IN course.instructors %]<div class="instructor">[% i.firstname %] [% i.surname %]</div>[% END %]</td></tr> >+ <tr><th>Notes</th><td>[% course.public_note %]</td></tr> >+ </table> >+ >+ <table> >+ <thead> >+ <tr> >+ <th>Title</th> >+ <th>Item type</th> >+ <th>Location</th> >+ <th>Collection</th> >+ <th>Call number</th> >+ <th>Copy</th> >+ <th>Status</td> >+ <th>Date due</td> >+ <th>Notes</th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH cr IN course_reserves %] >+ <tr> >+ <td><a href="opac-detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td> >+ <td>[% ItemTypes.GetDescription( cr.item.itype ) %]</td> >+ <td>[% Branches.GetName( cr.item.holdingbranch ) %] <br/> <i>[% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]</i></td> >+ <td>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]</td> >+ <td>[% cr.item.itemcallnumber %]</td> >+ <td>[% cr.item.copynumber %]</td> >+ <td>[% INCLUDE 'item-status.inc' item = cr.item %]</td> >+ <td>[% cr.issue.date_due | $KohaDates %]</td> >+ <td>[% cr.public_note %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ >+ </div> >+</div> >+ >+ >+[% INCLUDE 'opac-bottom.inc' %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-reserves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-reserves.tt >new file mode 100644 >index 0000000..98965c9 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-reserves.tt >@@ -0,0 +1,62 @@ >+[% USE AuthorisedValues %] >+ >+[% INCLUDE 'doc-head-open.inc' %] >+[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="opac-main"> >+[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %] >+ <div id="bd"> >+[% INCLUDE 'masthead.inc' %] >+ >+ >+<div id="doc2" class="yui-t7"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <div class="yui-g"> >+ >+ <div id="search-toolbar"> >+ <form id="search_courses_form"> >+ <input type="text" name="search_on" id="search_on" /> >+ <input type="submit" value="Search" /> >+ </form> >+ </div><!-- /toolbar --> >+ >+ <h1>Courses</h1> >+ <table id="course_reserves_table"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Dept.</th> >+ <th>Course #</th> >+ <th>Section</th> >+ <th>Term</th> >+ <th>Instructors</th> >+ <th>Notes</th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH c IN courses %] >+ <tr> >+ <td><a href="opac-course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td> >+ <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department, 1 ) %]</td> >+ <td>[% c.course_number %]</td> >+ <td>[% c.section %]</td> >+ <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td> >+ <td> >+ [% FOREACH i IN c.instructors %] >+ <div class="instructor">[% i.firstname %] [% i.surname %]</div> >+ [% END %] >+ </td> >+ <td>[% c.public_note %]</td> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ </div> >+ </div> >+</div> >+ >+ >+[% INCLUDE 'opac-bottom.inc' %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index 6321efd..bf7f91b 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -1,7 +1,21 @@ > [% USE KohaDates %] >+[% USE AuthorisedValues %] > [% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnDetail ) %] > [% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnDetail ) %] > >+[% ShowCourseReservesHeader = 0 %] >+[% IF UseCourseReserves %] >+ [% FOREACH ITEM_RESULT IN itemloop %] >+ [% IF ITEM_RESULT.course_reserves %] >+ [% FOREACH r IN ITEM_RESULT.course_reserves %] >+ [% IF r.course.enabled == 'yes' %] >+ [% ShowCourseReservesHeader = 1 %] >+ [% END %] >+ [% END %] >+ [% END %] >+ [% END %] >+[% END %] >+ > [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Details for: [% title |html %][% FOREACH subtitl IN subtitle %], [% subtitl.subfield |html %][% END %] > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >@@ -1469,6 +1483,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% ELSIF show_priority %] > <th>Item hold queue priority</th> > [% END %] >+ [% IF ( ShowCourseReservesHeader ) %]<th id="item_coursereserves">Course Reserves</th>[% END %] > </tr></thead> > <tbody>[% FOREACH ITEM_RESULT IN items %] > <tr>[% IF ( item_level_itypes ) %]<td class="itype">[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %]<img src="[% ITEM_RESULT.imageurl %]" title="[% ITEM_RESULT.description %]" alt="[% ITEM_RESULT.description %]" />[% END %][% END %] [% ITEM_RESULT.description %]</td>[% END %] >@@ -1515,6 +1530,22 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% END %] > </td> > [% END %] >+ [% IF ShowCourseReservesHeader %] >+ <td> >+ [% IF ITEM_RESULT.course_reserves %] >+ [% FOREACH r IN ITEM_RESULT.course_reserves %] >+ <p> >+ <a href="opac-course-details.pl?course_id=[% r.course.course_id %]"> >+ [% r.course.course_name %] >+ <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]--> >+ [% IF r.course.section %] [% r.course.section %] [% END %] >+ [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %] >+ </a> >+ </p> >+ [% END %] >+ [% END %] >+ </td> >+ [% END %] > </tr> > [% END %]</tbody> > </table> >diff --git a/opac/opac-course-details.pl b/opac/opac-course-details.pl >new file mode 100755 >index 0000000..ee505c9 >--- /dev/null >+++ b/opac/opac-course-details.pl >@@ -0,0 +1,60 @@ >+#!/usr/bin/perl >+ >+# >+# Copyright 2012 Bywater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use C4::Koha; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+ >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-course-details.tmpl", >+ query => $cgi, >+ type => "opac", >+ authnotrequired => 1, >+ debug => 1, >+ } >+); >+ >+my $action = $cgi->param('action') || ''; >+my $course_id = $cgi->param('course_id'); >+ >+die( "No course_id given" ) unless ( $course_id ); >+ >+if ( $action eq 'del_reserve' ) { >+ DelCourseReserve( cr_id => $cgi->param('cr_id') ); >+} >+ >+my $course = GetCourse( $course_id ); >+my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, include_count => 1 ); >+ >+$template->param( >+ course => $course, >+ course_reserves => $course_reserves, >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/opac/opac-course-reserves.pl b/opac/opac-course-reserves.pl >new file mode 100755 >index 0000000..60f8f15 >--- /dev/null >+++ b/opac/opac-course-reserves.pl >@@ -0,0 +1,51 @@ >+#!/usr/bin/perl >+ >+# >+# Copyright 2012 Bywater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+ >+use C4::CourseReserves; >+ >+my $cgi = new CGI; >+ >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-course-reserves.tmpl", >+ query => $cgi, >+ type => "opac", >+ authnotrequired => 1, >+ debug => 1, >+ } >+); >+ >+my $search_on = $cgi->param('search_on'); >+ >+my $courses = SearchCourses( term => $search_on, enabled => 'yes' ); >+ >+if ( @$courses == 1 ) { >+ print $cgi->redirect("/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'}); >+} else { >+ $template->param( courses => $courses ); >+ output_html_with_http_headers $cgi, $cookie, $template->output; >+} >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 4371f65..a0beb50 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -50,6 +50,7 @@ use List::MoreUtils qw/any none/; > use C4::Images; > use Koha::DateUtils; > use C4::HTML5Media; >+use C4::CourseReserves; > > BEGIN { > if (C4::Context->preference('BakerTaylorEnabled')) { >@@ -1021,4 +1022,10 @@ if (C4::Context->preference('OpacHighlightedWords')) { > } > $template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); > >+if ( C4::Context->preference('UseCourseReserves') ) { >+ foreach my $i ( @items ) { >+ $i->{'course_reserves'} = GetItemReservesInfo( itemnumber => $i->{'itemnumber'} ); >+ } >+} >+ > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t >new file mode 100755 >index 0000000..4b8fe41 >--- /dev/null >+++ b/t/db_dependent/CourseReserves.t >@@ -0,0 +1,88 @@ >+#!/usr/bin/perl >+# >+# This is to test C4/Members >+# It requires a working Koha database with the sample data >+ >+use strict; >+use warnings; >+ >+use Test::More tests => 16; >+use Data::Dumper; >+ >+BEGIN { >+ use_ok('C4::Context'); >+ use_ok('C4::CourseReserves'); >+} >+ >+my $dbh = C4::Context->dbh; >+$dbh->do("TRUNCATE TABLE course_instructors"); >+$dbh->do("TRUNCATE TABLE courses"); >+$dbh->do("TRUNCATE TABLE course_reserves"); >+ >+my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10"); >+$sth->execute(); >+my @borrowers = @{$sth->fetchall_arrayref({})}; >+ >+$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10"); >+$sth->execute(); >+my @items = @{$sth->fetchall_arrayref({})}; >+ >+my $course_id = ModCourse( >+ course_name => "Test Course", >+ staff_note => "Test staff note", >+ public_note => "Test public note", >+); >+ >+ok( $course_id, "ModCourse created course successfully" ); >+ >+$course_id = ModCourse( >+ course_id => $course_id, >+ staff_note => "Test staff note 2", >+); >+ >+my $course = GetCourse( $course_id ); >+ >+ok( $course->{'course_name'} eq "Test Course", "GetCourse returned correct course" ); >+ok( $course->{'staff_note'} eq "Test staff note 2", "ModCourse updated course succesfully" ); >+ >+my $courses = GetCourses(); >+ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" ); >+ >+ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] ); >+$course = GetCourse( $course_id ); >+ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrowernumber'}, "ModCourseInstructors added instructors correctly"); >+ >+my $course_instructors = GetCourseInstructors( $course_id ); >+ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" ); >+ >+my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} ); >+ok( $ci_id, "ModCourseItem returned valid data" ); >+ >+my $course_item = GetCourseItem( 'ci_id' => $ci_id ); >+ok( $course_item->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetCourseItem returns valid data" ); >+ >+my $cr_id = ModCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id ); >+ok( $cr_id, "ModCourseReserve returns valid data" ); >+ >+my $course_reserve = GetCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id ); >+ok( $course_reserve->{'cr_id'} eq $cr_id, "GetCourseReserve returns valid data" ); >+ >+my $course_reserves = GetCourseReserves( 'course_id' => $course_id ); >+ok( $course_reserves->[0]->{'ci_id'} eq $ci_id, "GetCourseReserves returns valid data." ); >+ >+my $info = GetItemReservesInfo( itemnumber => $items[0]->{'itemnumber'} ); >+ok( $info->[0]->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetItemReservesInfo returns valid data." ); >+ >+DelCourseReserve( 'cr_id' => $cr_id ); >+$course_reserve = GetCourseReserve( 'cr_id' => $cr_id ); >+ok( !defined( $course_reserve->{'cr_id'} ), "DelCourseReserve functions correctly" ); >+ >+DelCourse( $course_id ); >+$course = GetCourse( $course_id ); >+ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" ); >+ >+$dbh->do("TRUNCATE TABLE course_instructors"); >+$dbh->do("TRUNCATE TABLE courses"); >+$dbh->do("TRUNCATE TABLE course_reserves"); >+ >+exit; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8215
:
9990
|
10181
|
10224
|
11131
|
11612
|
11657
|
11677
|
11678
|
11679
|
11680
|
11681
|
11682
|
11683
|
11860
|
11861
|
11862
|
11865
|
11875
|
11881
|
11882
|
11980
|
12039
|
12120
|
12128
|
12188
|
12189
|
12192
|
12246
|
12361
|
12400
|
12413
|
12414
|
12593
|
12627
|
13496
|
13497
|
13498
|
13499
|
15195
|
15196
|
15197
|
15198
|
15199
|
16228
|
16229
|
16251
|
16252
|
16532
|
16533
|
16534
|
16536
|
16537
|
16545
|
16567
|
16568
|
16587
|
16588
|
16599
|
16621
|
16623
|
16634
|
17333
|
17334
|
17335
|
17336
|
17337
|
17377
|
17378
|
17379
|
17894
|
17895
|
17896
|
17897
|
17898
|
17899
|
18274
|
18275
|
18276
|
18277
|
18278
|
18279
|
18282
|
18283
|
18284
|
18285
|
18286
|
18287
|
18288
|
18289
|
18290
|
18291
|
18292
|
18293
|
21885
|
23264