From 2eeadffb0d91eed49de16541f1882074f5d55785 Mon Sep 17 00:00:00 2001 From: Kris Sinnaeve Date: Tue, 14 Sep 2021 11:39:40 +0100 Subject: [PATCH] Bug 35972: Add thesis tables feature This patch adds a new 'Thesis tables' feature to Koha based on the existing 'Course reserves' system. --- C4/CourseReserves.pm | 18 ++- .../bootstrap/en/includes/masthead.inc | 3 + .../en/modules/opac-thesis-table-details.tt | 127 ++++++++++++++++++ .../en/modules/opac-thesis-tables.tt | 86 ++++++++++++ opac/opac-thesis-table-details.pl | 54 ++++++++ opac/opac-thesis-tables.pl | 44 ++++++ 6 files changed, 331 insertions(+), 1 deletion(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-table-details.tt create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-tables.tt create mode 100755 opac/opac-thesis-table-details.pl create mode 100755 opac/opac-thesis-tables.pl diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index ddc6b661441..ef71e4b3cf2 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -1017,7 +1017,7 @@ sub CountCourseReservesForItem { =head2 SearchCourses - my $courses = SearchCourses( term => $search_term, enabled => 'yes' ); + my $courses = SearchCourses( term => $search_term, enabled => 'yes', thesis_table => 'no' ); =cut @@ -1027,6 +1027,7 @@ sub SearchCourses { my $term = $params{'term'}; my $enabled = $params{'enabled'} || '%'; + my $thesis_table = $params{'thesis_table'} || 'no'; my @params; my $query = " @@ -1055,6 +1056,21 @@ sub SearchCourses { ) AND c.enabled LIKE ? + "; + + if ( $thesis_table eq 'no' ) { + $query .= " + AND + c.department != 'TT' + "; + } else { + $query .= " + AND + c.department = 'TT' + "; + } + + $query .= " GROUP BY c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp "; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 2b6d4478d6d..56e27586500 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -431,6 +431,9 @@ + [% END %] [% END %] [% IF ( Koha.Preference('OPACShowLibraries') && AllPublicBranches.size > 0 ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-table-details.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-table-details.tt new file mode 100644 index 00000000000..c8b84d1caca --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-table-details.tt @@ -0,0 +1,127 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% USE AuthorisedValues %] +[% USE ItemTypes %] +[% USE Branches %] +[% USE TablesSettings %] +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Reserves for [% course.course_name | html %][%- IF course.section -%] - [% course.section | html %][%- END -%] +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %] + [% Asset.css("css/datatables.css") | $raw %] +[% END %] + + +[% INCLUDE 'bodytag.inc' bodyid='opac-course-details' %] +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+
+
+ +

Reserves for [% course.course_name | html %][%- IF course.section -%] - [% course.section | html %][%- END -%]

+
+
    + [% IF ( course.instructors ) %] +
  1. Researcher: +
      + [% FOREACH i IN course.instructors %] +
    • [% i.firstname | html %] [% i.surname | html %]
    • + [% END %] +
    +
  2. + [% END %] + [% IF ( course.public_note ) %]
  3. Notes: [% course.public_note | $raw %]
  4. [% END %] +
+
+ + [% IF ( course_reserves ) %] + + + + + + + + + + + + + + + + + + + [% FOREACH cr IN course_reserves %] + + + + + + + + + + + + + + [% END %] + +
TitleAuthorItem typeLocationCollectionCall numberCopy numberStatusDate dueNotesLink
[% INCLUDE 'biblio-title-head.inc' biblio=cr.biblio %][% cr.biblio.author | html %][% ItemTypes.GetDescription( cr.item.itype ) | html %][% Branches.GetName( cr.item.holdingbranch ) | html %]
[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => cr.item.location, opac => 1 ) | html %]
[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode, opac => 1 ) | html %][% cr.item.itemcallnumber | html %][% cr.item.copynumber | html %][% INCLUDE 'item-status.inc' item=cr.item issue=cr.issue %][% cr.issue.date_due | $KohaDates as_due_date => 1 %][% IF ( cr.public_note ) %] + [% cr.public_note | $raw %] + [% ELSIF ( cr.item.itemnotes ) %] + [% cr.item.itemnotes | $raw %] + [% END %] + [% IF (cr.item.uri) %] + Item URI + [% ELSIF (cr.biblioitem.url) %] + Record URL + [% END %] +
+ [% ELSE %] +
+
+

No reserves have been selected for this research table.

+
+ [% END %] +
+
+
+
+
+[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-tables.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-tables.tt new file mode 100644 index 00000000000..a20e67612b8 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-thesis-tables.tt @@ -0,0 +1,86 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE AuthorisedValues %] +[% USE TablesSettings %] + +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Research tables +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %] + [% Asset.css("css/datatables.css") | $raw %] +[% END %] + + +[% INCLUDE 'bodytag.inc' bodyid='opac-thesis-tables' %] +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+
+
+

Research tables

+ + + + + + + + + + + + + [% FOREACH c IN courses %] + + + + + + [% END %] + +
NameTable #ResearcherTopic
[% c.course_name | html %][%- IF c.section -%] - [% c.section | html %][%- END -%][% c.course_number | html %] + [% FOREACH i IN c.instructors %] +
[% i.surname | html %][% IF i.firstname %], [% i.firstname | html %][% END %]
+ [% END %] +
[% c.public_note | $raw %]
+
+
+
+
+
+[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + +[% END %] diff --git a/opac/opac-thesis-table-details.pl b/opac/opac-thesis-table-details.pl new file mode 100755 index 00000000000..fd82176d1c7 --- /dev/null +++ b/opac/opac-thesis-table-details.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 3 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, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Koha; + +use C4::CourseReserves qw(GetCourse GetCourseReserves); + +my $cgi = CGI->new; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { template_name => "opac-thesis-table-details.tt", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } +); + +my $table_id = $cgi->param('table_id'); + +die("No table_id given") unless ($table_id); + +my $course = GetCourse($table_id); +my $course_reserves = GetCourseReserves( course_id => $table_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-thesis-tables.pl b/opac/opac-thesis-tables.pl new file mode 100755 index 00000000000..32321cd4c12 --- /dev/null +++ b/opac/opac-thesis-tables.pl @@ -0,0 +1,44 @@ +#!/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 3 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, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); + +use C4::CourseReserves qw(SearchCourses); + +my $cgi = CGI->new; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { template_name => "opac-thesis-tables.tt", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } +); + +my $courses = SearchCourses( enabled => 'yes', thesis_table => 'yes' ); + +$template->param( courses => $courses ); +output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.53.0