From 985a87de2e53274c5976642cdd596acd465d8e15 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 17 Feb 2012 15:07:22 -0500 Subject: [PATCH] Bug 7572 - Add Clubs & Services Feature This features adds the ability to create clubs and services which patrons may be enrolled in. It is particularly useful for tracking summer reading programs, book clubs and other such clubs. It includes 2 built-in service archetypes: Bestsellers Club : Batch generate a holds list which shuffles the holds queue when new items matching a given title or author are catalogued. New Items Weekly Mailing Lists : Create custom mailing lists to alert subscribers to new items in your library. This code has been in production for a number of years at the Crawford County Federated Library System. Test Plan: 1) Add clubs & services permissions for a librarian account. 2) Create a new archetype 3) Create a new club or service based on the archetype 4) Enroll a borrower in the club or service 5) Cancel the enrollment in the club or service 6) Verify the permissions work correctly by turning off each one in turn and attempt to perform the action that should be denied. --- C4/Auth.pm | 1 + C4/ClubsAndServices.pm | 1272 ++++++++++++++++++++ cataloguing/addbiblio.pl | 2 + circ/circulation.pl | 4 + clubs_services/clubs_services.pl | 55 + clubs_services/clubs_services_enrollments.pl | 51 + clubs_services/edit_archetypes.pl | 194 +++ clubs_services/edit_clubs_services.pl | 195 +++ clubs_services/enroll_clubs_services.pl | 111 ++ .../mandatory/clubs_and_services_archetypes.sql | 3 + .../mandatory/clubs_and_services_archetypes.txt | 2 + installer/data/mysql/de-DE/mandatory/userflags.sql | 1 + .../data/mysql/de-DE/mandatory/userpermissions.sql | 5 +- .../en/mandatory/clubs_and_services_archetypes.sql | 3 + .../en/mandatory/clubs_and_services_archetypes.txt | 2 + installer/data/mysql/en/mandatory/userflags.sql | 3 +- .../data/mysql/en/mandatory/userpermissions.sql | 5 +- .../mandatory/clubs_and_services_archetypes.sql | 3 + .../mandatory/clubs_and_services_archetypes.txt | 2 + installer/data/mysql/es-ES/mandatory/userflags.sql | 1 + .../data/mysql/es-ES/mandatory/userpermissions.sql | 5 +- .../clubs_and_services_archetypes.sql | 3 + .../clubs_and_services_archetypes.txt | 2 + .../data/mysql/fr-FR/1-Obligatoire/userflags.sql | 1 + .../mysql/fr-FR/1-Obligatoire/userpermissions.sql | 5 +- .../necessari/clubs_and_services_archetypes.sql | 3 + .../necessari/clubs_and_services_archetypes.txt | 2 + installer/data/mysql/it-IT/necessari/userflags.sql | 1 + .../data/mysql/it-IT/necessari/userpermissions.sql | 5 +- installer/data/mysql/kohastructure.sql | 100 ++ .../clubs_and_services_archetypes.sql | 3 + .../clubs_and_services_archetypes.txt | 2 + .../data/mysql/nb-NO/1-Obligatorisk/userflags.sql | 1 + .../mysql/nb-NO/1-Obligatorisk/userpermissions.sql | 5 +- .../mandatory/clubs_and_services_archetypes.sql | 3 + .../mandatory/clubs_and_services_archetypes.txt | 2 + installer/data/mysql/pl-PL/mandatory/userflags.sql | 1 + .../data/mysql/pl-PL/mandatory/userpermissions.sql | 5 +- .../mandatory/clubs_and_services_archetypes.sql | 3 + .../mandatory/clubs_and_services_archetypes.txt | 2 + .../ru-RU/mandatory/permissions_and_user_flags.sql | 6 +- .../mandatory/clubs_and_services_archetypes.sql | 3 + .../mandatory/clubs_and_services_archetypes.txt | 2 + .../uk-UA/mandatory/permissions_and_user_flags.sql | 4 + installer/data/mysql/updatedatabase.pl | 104 ++ .../intranet-tmpl/prog/en/includes/circ-menu.inc | 1 + .../prog/en/includes/members-menu.inc | 1 + .../prog/en/modules/circ/circulation.tt | 9 +- .../en/modules/clubs_services/clubs_services.tt | 93 ++ .../clubs_services/clubs_services_enrollments.tt | 67 + .../en/modules/clubs_services/edit_archetypes.tt | 270 +++++ .../modules/clubs_services/edit_clubs_services.tt | 258 ++++ .../clubs_services/enroll_clubs_services.tt | 95 ++ .../prog/en/modules/members/clubs_services.tt | 85 ++ .../en/modules/members/clubs_services_enroll.tt | 73 ++ .../prog/en/modules/tools/tools-home.tt | 4 + koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc | 2 +- .../en/modules/opac-clubsAndServices-enroll.tt | 72 ++ .../prog/en/modules/opac-clubsAndServices.tt | 84 ++ members/clubs_services.pl | 57 + members/clubs_services_enroll.pl | 126 ++ misc/cronjobs/mailinglist/mailinglist.pl | 200 +++ misc/cronjobs/mailinglist/mailinglist.tt | 34 + opac/opac-clubsAndServices-enroll.pl | 145 +++ opac/opac-clubsAndServices.pl | 68 ++ 65 files changed, 3921 insertions(+), 11 deletions(-) create mode 100644 C4/ClubsAndServices.pm create mode 100755 clubs_services/clubs_services.pl create mode 100755 clubs_services/clubs_services_enrollments.pl create mode 100755 clubs_services/edit_archetypes.pl create mode 100755 clubs_services/edit_clubs_services.pl create mode 100755 clubs_services/enroll_clubs_services.pl create mode 100644 installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/en/mandatory/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/en/mandatory/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.txt create mode 100644 installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.sql create mode 100644 installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.txt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services_enrollments.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tt create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices-enroll.tt create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices.tt create mode 100755 members/clubs_services.pl create mode 100755 members/clubs_services_enroll.pl create mode 100644 misc/cronjobs/mailinglist/mailinglist.pl create mode 100644 misc/cronjobs/mailinglist/mailinglist.tt create mode 100755 opac/opac-clubsAndServices-enroll.pl create mode 100755 opac/opac-clubsAndServices.pl diff --git a/C4/Auth.pm b/C4/Auth.pm index 44edf67..fa6dfb2 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -215,6 +215,7 @@ sub get_template_and_user { $template->param( CAN_user_staffaccess => 1 ); $template->param( CAN_user_plugins => 1 ); $template->param( CAN_user_coursereserves => 1 ); + $template->param( CAN_user_clubs_services => 1 ); foreach my $module (keys %$all_perms) { foreach my $subperm (keys %{ $all_perms->{$module} }) { $template->param( "CAN_user_${module}_${subperm}" => 1 ); diff --git a/C4/ClubsAndServices.pm b/C4/ClubsAndServices.pm new file mode 100644 index 0000000..a804e1a --- /dev/null +++ b/C4/ClubsAndServices.pm @@ -0,0 +1,1272 @@ +package C4::ClubsAndServices; + +# $Id: ClubsAndServices.pm,v 0.1 2007/04/10 kylemhall + +# This package is intended for dealing with clubs and services +# and enrollments in such, such as summer reading clubs, and +# library newsletters + +# Copyright 2012 Kyle Hall +# +# 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 vars qw($VERSION @ISA @EXPORT); + +# set the version for version checking +$VERSION = 0.01; + +=head1 NAME + +C4::ClubsAndServices - Functions for managing clubs and services + +=head1 FUNCTIONS + +=over 2 + +=cut + +@ISA = qw( Exporter ); +@EXPORT = qw( + AddClubOrServiceArchetype + UpdateClubOrServiceArchetype + DeleteClubOrServiceArchetype + + AddClubOrService + UpdateClubOrService + DeleteClubOrService + + EnrollInClubOrService + GetEnrollments + GetClubsAndServices + GetClubOrService + GetClubsAndServicesArchetypes + GetClubOrServiceArchetype + DoesEnrollmentRequireData + CancelClubOrServiceEnrollment + GetEnrolledClubsAndServices + GetPubliclyEnrollableClubsAndServices + GetAllEnrollableClubsAndServices + GetCasEnrollments + + ReserveForBestSellersClub + + getTodayMysqlDateFormat +); + +=head2 AddClubOrServiceArchetype + +Creates a new archetype for a club or service +An archetype is something after which other things a patterned, +For example, you could create a 'Summer Reading Club' club archtype +which is then used to create an individual 'Summer Reading Club' +*for each library* in your system. + +Input: + $type : 'club' or 'service', could be extended to add more types + $title: short description of the club or service + $description: long description of the club or service + $publicEnrollment: If true, any borrower should be able + to enroll in club or service from opac. If false, + Only a librarian should be able to enroll a borrower + in the club or service. + $casData1Title: explanation of what is stored in + clubsAndServices.casData1Title + $casData2Title: same but for casData2Title + $casData3Title: same but for casData3Title + $caseData1Title: explanation of what is stored in + clubsAndServicesEnrollment.data1 + $caseData2Title: Same but for data2 + $caseData3Title: Same but for data3 + $casData1Desc: Long explanation of what is stored in + clubsAndServices.casData1Title + $casData2Desc: same but for casData2Title + $casData3Desc: same but for casData3Title + $caseData1Desc: Long explanation of what is stored in + clubsAndServicesEnrollment.data1 + $caseData2Desc: Same but for data2 + $caseData3Desc: Same but for data3 + $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower + record as specified in the syspref AutoEmailPrimaryAddress + $branchcode: The branchcode for the branch where this Archetype was created + + Output: + $success: 1 if all database operations were successful, 0 otherwise + $errorCode: Code for reason of failure, good for translating errors in templates + $errorMessage: English description of error + +=cut + +sub AddClubOrServiceArchetype { + my ($type, $title, $description, $publicEnrollment, $casData1Title, $casData2Title, + $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, $casData2Desc, + $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $caseRequireEmail, $branchcode + ) = @_; + + ## Check for all neccessary parameters + if ( !$type ) { + return ( 0, "NO_TYPE" ); + } + if ( !$title ) { + return ( 0, "NO_TITLE" ); + } + if ( !$description ) { + return ( 0, "NO_DESCRIPTION" ); + } + + my $success = 1; + + my $dbh = C4::Context->dbh; + + my $sth; + $sth = $dbh->prepare( + "INSERT INTO clubsAndServicesArchetypes ( casaId, type, title, description, publicEnrollment, caseRequireEmail, branchcode, last_updated ) + VALUES ( NULL, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)" + ); + $sth->execute( $type, $title, $description, $publicEnrollment, $caseRequireEmail, $branchcode ) or $success = 0; + my $casaId = $dbh->{'mysql_insertid'}; + $sth->finish; + + if ($casData1Title) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Title = ? WHERE casaId = ?"); + $sth->execute( $casData1Title, $casaId ) or $success = 0; + $sth->finish; + } + if ($casData2Title) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Title = ? WHERE casaId = ?"); + $sth->execute( $casData2Title, $casaId ) or $success = 0; + $sth->finish; + } + if ($casData3Title) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Title = ? WHERE casaId = ?"); + $sth->execute( $casData3Title, $casaId ) or $success = 0; + $sth->finish; + } + + if ($caseData1Title) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Title = ? WHERE casaId = ?"); + $sth->execute( $caseData1Title, $casaId ) or $success = 0; + $sth->finish; + } + if ($caseData2Title) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Title = ? WHERE casaId = ?"); + $sth->execute( $caseData2Title, $casaId ) or $success = 0; + $sth->finish; + } + if ($caseData3Title) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Title = ? WHERE casaId = ?"); + $sth->execute( $caseData3Title, $casaId ) or $success = 0; + $sth->finish; + } + + if ($casData1Desc) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Desc = ? WHERE casaId = ?"); + $sth->execute( $casData1Desc, $casaId ) or $success = 0; + $sth->finish; + } + if ($casData2Desc) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Desc = ? WHERE casaId = ?"); + $sth->execute( $casData2Desc, $casaId ) or $success = 0; + $sth->finish; + } + if ($casData3Desc) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Desc = ? WHERE casaId = ?"); + $sth->execute( $casData3Desc, $casaId ) or $success = 0; + $sth->finish; + } + + if ($caseData1Desc) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Desc = ? WHERE casaId = ?"); + $sth->execute( $caseData1Desc, $casaId ) or $success = 0; + $sth->finish; + } + if ($caseData2Desc) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Desc = ? WHERE casaId = ?"); + $sth->execute( $caseData2Desc, $casaId ) or $success = 0; + $sth->finish; + } + if ($caseData3Desc) { + $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Desc = ? WHERE casaId = ?"); + $sth->execute( $caseData3Desc, $casaId ) or $success = 0; + $sth->finish; + } + + my ( $errorCode, $errorMessage ); + if ( !$success ) { + $errorMessage = "DB_ERROR"; + } + + return ( $success, $errorMessage ); + +} + +=head2 UpdateClubOrServiceArchetype + + Updates an archetype for a club or service + + Input: + $casaId: id of the archetype to be updated + $type : 'club' or 'service', could be extended to add more types + $title: short description of the club or service + $description: long description of the club or service + $publicEnrollment: If true, any borrower should be able + to enroll in club or service from opac. If false, + Only a librarian should be able to enroll a borrower + in the club or service. + $casData1Title: explanation of what is stored in + clubsAndServices.casData1Title + $casData2Title: same but for casData2Title + $casData3Title: same but for casData3Title + $caseData1Title: explanation of what is stored in + clubsAndServicesEnrollment.data1 + $caseData2Title: Same but for data2 + $caseData3Title: Same but for data3 + $casData1Desc: Long explanation of what is stored in + clubsAndServices.casData1Title + $casData2Desc: same but for casData2Title + $casData3Desc: same but for casData3Title + $caseData1Desc: Long explanation of what is stored in + clubsAndServicesEnrollment.data1 + $caseData2Desc: Same but for data2 + $caseData3Desc: Same but for data3 + $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower + record as specified in the syspref AutoEmailPrimaryAddress + + Output: + $success: 1 if all database operations were successful, 0 otherwise + $errorCode: Code for reason of failure, good for translating errors in templates + $errorMessage: English description of error + +=cut + +sub UpdateClubOrServiceArchetype { + my ($casaId, $type, $title, $description, $publicEnrollment, $casData1Title, + $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, + $casData2Desc, $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $caseRequireEmail, + ) = @_; + + ## Check for all neccessary parameters + if ( !$casaId ) { + return ( 0, "NO_ID" ); + } + if ( !$type ) { + return ( 0, "NO_TYPE" ); + } + if ( !$title ) { + return ( 0, "NO_TITLE" ); + } + if ( !$description ) { + return ( 0, "NO_DESCRIPTION" ); + } + + my $success = 1; + + my $dbh = C4::Context->dbh; + + my $sth; + $sth = $dbh->prepare( + "UPDATE clubsAndServicesArchetypes + SET + type = ?, title = ?, description = ?, publicEnrollment = ?, + casData1Title = ?, casData2Title = ?, casData3Title = ?, + caseData1Title = ?, caseData2Title = ?, caseData3Title = ?, + casData1Desc = ?, casData2Desc = ?, casData3Desc = ?, + caseData1Desc = ?, caseData2Desc = ?, caseData3Desc = ?, caseRequireEmail = ?, + last_updated = NOW() WHERE casaId = ?" + ); + + $sth->execute( + $type, $title, $description, $publicEnrollment, $casData1Title, $casData2Title, + $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, $casData2Desc, + $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $caseRequireEmail, $casaId + ) or return ( $success = 0, my $errorMessage = "DB_ERROR" ); + $sth->finish; + + return $success; + +} + +=head2 DeleteClubOrServiceArchetype + + Deletes an Archetype of the given id + and all Clubs or Services based on it, + and all Enrollments based on those clubs + or services. + + Input: + $casaId : id of the Archtype to be deleted + + Output: + $success : 1 on successful deletion, 0 otherwise + +=cut + +sub DeleteClubOrServiceArchetype { + my ($casaId) = @_; + + ## Paramter check + if ( !$casaId ) { + return 0; + } + + my $success = 1; + + my $dbh = C4::Context->dbh; + + my $sth; + + $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casaId = ?"); + $sth->execute($casaId) or $success = 0; + $sth->finish; + + $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casaId = ?"); + $sth->execute($casaId) or $success = 0; + $sth->finish; + + $sth = $dbh->prepare("DELETE FROM clubsAndServicesArchetypes WHERE casaId = ?"); + $sth->execute($casaId) or $success = 0; + $sth->finish; + + return 1; +} + +=head2 AddClubOrService + + Creates a new club or service in the database + + Input: + $type: 'club' or 'service', other types may be added as necessary. + $title: Short description of the club or service + $description: Long description of the club or service + $casData1: The data described in case.casData1Title + $casData2: The data described in case.casData2Title + $casData3: The data described in case.casData3Title + $startDate: The date the club or service begins ( Optional: Defaults to TODAY() ) + $endDate: The date the club or service ends ( Optional ) + $branchcode: Branch that created this club or service ( Optional: NULL is system-wide ) + + Output: + $success: 1 on successful add, 0 on failure + $errorCode: Code for reason of failure, good for translating errors in templates + $errorMessage: English description of error + +=cut + +sub AddClubOrService { + my ( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) = @_; + + ## Check for all neccessary parameters + if ( !$casaId ) { + return ( 0, "NO_ARCHETYPE" ); + } + if ( !$title ) { + return ( 0, "NO_TITLE" ); + } + if ( !$description ) { + return ( 0, "NO_DESCRIPTION" ); + } + + my $success = 1; + + if ( !$startDate ) { + $startDate = getTodayMysqlDateFormat(); + } + + my $dbh = C4::Context->dbh; + + my $sth; + if ($endDate) { + $sth = $dbh->prepare( + "INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, endDate, branchcode, last_updated ) + VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)" + ); + $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) or $success = 0; + } else { + $sth = $dbh->prepare( + "INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, branchcode, last_updated ) + VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)" + ); + $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $branchcode ) or $success = 0; + } + $sth->finish; + + my ( $errorCode, $errorMessage ); + if ( !$success ) { + $errorMessage = "DB_ERROR"; + } + + return ( $success, $errorCode, $errorMessage ); +} + +=head UpdateClubOrService + + Updates club or service in the database + + Input: + $casId: id of the club or service to be updated + $type: 'club' or 'service', other types may be added as necessary. + $title: Short description of the club or service + $description: Long description of the club or service + $casData1: The data described in case.casData1Title + $casData2: The data described in case.casData2Title + $casData3: The data described in case.casData3Title + $startDate: The date the club or service begins ( Optional: Defaults to TODAY() ) + $endDate: The date the club or service ends ( Optional ) + + Output: + $success: 1 on successful add, 0 on failure + $errorCode: Code for reason of failure, good for translating errors in templates + $errorMessage: English description of error + +=cut + +sub UpdateClubOrService { + my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate ) = @_; + + ## Check for all neccessary parameters + if ( !$casId ) { + return ( 0, "NO_CAS_ID" ); + } + if ( !$casaId ) { + return ( 0, "NO_CASA_ID" ); + } + if ( !$title ) { + return ( 0, "NO_TITLE" ); + } + if ( !$description ) { + return ( 0, "NO_DESCRIPTION" ); + } + + my $success = 1; + + if ( !$startDate ) { + $startDate = getTodayMysqlDateFormat(); + } + + my $dbh = C4::Context->dbh; + + my $sth; + if ($endDate) { + $sth = $dbh->prepare( +"UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = ?, last_updated = NOW() WHERE casId = ?" + ); + $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $casId ) + or return ( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() ); + } else { + $sth = $dbh->prepare( +"UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = NULL, last_updated = NOW() WHERE casId = ?" + ); + $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $casId ) + or return ( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() ); + } + $sth->finish; + + my ( $errorCode, $errorMessage ); + if ( !$success ) { + $errorMessage = "DB_ERROR"; + } + + return ( $success, $errorMessage ); +} + +=head2 DeleteClubOrService + + Deletes a club or service of the given id and all enrollments based on it. + + Input: + $casId : id of the club or service to be deleted + + Output: + $success : 1 on successful deletion, 0 otherwise + +=cut + +sub DeleteClubOrService { + my ($casId) = @_; + + if ( !$casId ) { + return 0; + } + + my $success = 1; + + my $dbh = C4::Context->dbh; + + my $sth; + $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casId = ?"); + $sth->execute($casId) or $success = 0; + $sth->finish; + + $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casId = ?"); + $sth->execute($casId) or $success = 0; + $sth->finish; + + return 1; +} + +=head EnrollInClubOrService + + Enrolls a borrower in a given club or service + + Input: + $casId: The unique id of the club or service being enrolled in + $borrowerCardnumber: The card number of the enrolling borrower + $dateEnrolled: Date the enrollment begins ( Optional: Defauls to TODAY() ) + $data1: The data described in ClubsAndServicesArchetypes.caseData1Title + $data2: The data described in ClubsAndServicesArchetypes.caseData2Title + $data3: The data described in ClubsAndServicesArchetypes.caseData3Title + $branchcode: The branch where this club or service enrollment is, + $borrowernumber: ( Optional: Alternative to using $borrowerCardnumber ) + + Output: + $success: 1 on successful enrollment, 0 on failure + $errorCode: Code for reason of failure, good for translating errors in templates + $errorMessage: English description of error + +=cut + +sub EnrollInClubOrService { + my ( $casaId, $casId, $borrowerCardnumber, $dateEnrolled, $data1, $data2, $data3, $branchcode, $borrowernumber ) = @_; + + ## Check for all neccessary parameters + unless ($casaId) { + return ( 0, "NO_CASA_ID" ); + } + unless ($casId) { + return ( 0, "NO_CAS_ID" ); + } + unless ( $borrowerCardnumber || $borrowernumber ) { + return ( 0, "NO_BORROWER" ); + } + + my $member; + if ($borrowerCardnumber) { + $member = C4::Members::GetMember( cardnumber => $borrowerCardnumber ); + } elsif ($borrowernumber) { + $member = C4::Members::GetMember( borrowernumber => $borrowernumber ); + } + + unless ($member) { + return ( 0, "NO_BORROWER_FOUND" ); + } + + my $casa = GetClubOrServiceArchetype( $casaId, 1 ); + if ( $casa->{'caseRequireEmail'} ) { + my $AutoEmailPrimaryAddress = C4::Context->preference('AutoEmailPrimaryAddress'); + unless ( $member->{$AutoEmailPrimaryAddress} ) { + return ( 0, "NO_EMAIL" ); + } + } + + $borrowernumber = $member->{'borrowernumber'}; + + if ( isEnrolled( $casId, $borrowernumber ) ) { return ( 0, "ENROLLED" ); } + + if ( !$dateEnrolled ) { + $dateEnrolled = getTodayMysqlDateFormat(); + } + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( + "INSERT INTO clubsAndServicesEnrollments ( caseId, casaId, casId, borrowernumber, data1, data2, data3, dateEnrolled, dateCanceled, last_updated, branchcode) + VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, NULL, NOW(), ? )" + ); + $sth->execute( $casaId, $casId, $borrowernumber, $data1, $data2, $data3, $dateEnrolled, $branchcode ) + or return ( my $success = 0, my $errorCode = 4, my $errorMessage = $sth->errstr() ); + $sth->finish; + + return $success = 1; +} + +=head2 GetEnrollments + + Returns information about the clubs and services the given borrower is enrolled in. + + Input: + $borrowernumber: The borrowernumber of the borrower + + Output: + $results: Reference to an array of associated arrays + +=cut + +sub GetEnrollments { + my ($borrowernumber) = @_; + + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare( + "SELECT * FROM clubsAndServices, clubsAndServicesEnrollments + WHERE clubsAndServices.casId = clubsAndServicesEnrollments.casId + AND clubsAndServicesEnrollments.borrowernumber = ?" + ); + $sth->execute($borrowernumber) or return 0; + + my @results; + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; +} + +=head2 GetCasEnrollments + + Returns information about the clubs and services borrowers that are enrolled + + Input: + $casId: The id of the club or service to look up enrollments for + + Output: + $results: Reference to an array of associated arrays + +=cut + +sub GetCasEnrollments { + my ($casId) = @_; + + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare( + "SELECT * FROM clubsAndServicesEnrollments, borrowers + WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber + AND clubsAndServicesEnrollments.casId = ? AND dateCanceled IS NULL + ORDER BY surname, firstname" + ); + $sth->execute($casId) or return 0; + + my @results; + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; +} + +=head2 GetClubsAndServices + + Returns information about clubs and services + + Input: + $type: ( Optional: 'club' or 'service' ) + $branchcode: ( Optional: Get clubs and services only created by this branch ) + $orderby: ( Optional: name of column to sort by ) + + Output: + $results: Reference to an array of associated arrays + +=cut + +sub GetClubsAndServices { + my ( $type, $branchcode, $orderby ) = @_; + $orderby = 'startDate DESC' unless ($orderby); + + my $dbh = C4::Context->dbh; + + my ( $sth, @results ); + if ( $type && $branchcode ) { + $sth = $dbh->prepare( + "SELECT clubsAndServices.casId, + clubsAndServices.casaId, + clubsAndServices.title, + clubsAndServices.description, + clubsAndServices.casData1, + clubsAndServices.casData2, + clubsAndServices.casData3, + clubsAndServices.startDate, + clubsAndServices.endDate, + clubsAndServices.last_updated, + clubsAndServices.branchcode + FROM clubsAndServices, clubsAndServicesArchetypes + WHERE + clubsAndServices.casaId = clubsAndServicesArchetypes.casaId + AND clubsAndServices.branchcode = ? + AND clubsAndServicesArchetypes.type = ? + ORDER BY $orderby + " + ); + $sth->execute( $branchcode, $type ) or return 0; + + } elsif ($type) { + $sth = $dbh->prepare( + "SELECT clubsAndServices.casId, + clubsAndServices.casaId, + clubsAndServices.title, + clubsAndServices.description, + clubsAndServices.casData1, + clubsAndServices.casData2, + clubsAndServices.casData3, + clubsAndServices.startDate, + clubsAndServices.endDate, + clubsAndServices.last_updated, + clubsAndServices.branchcode + FROM clubsAndServices, clubsAndServicesArchetypes + WHERE + clubsAndServices.casaId = clubsAndServicesArchetypes.casaId + AND clubsAndServicesArchetypes.type = ? + ORDER BY $orderby + " + ); + $sth->execute($type) or return 0; + + } elsif ($branchcode) { + $sth = $dbh->prepare( + "SELECT clubsAndServices.casId, + clubsAndServices.casaId, + clubsAndServices.title, + clubsAndServices.description, + clubsAndServices.casData1, + clubsAndServices.casData2, + clubsAndServices.casData3, + clubsAndServices.startDate, + clubsAndServices.endDate, + clubsAndServices.last_updated, + clubsAndServices.branchcode + FROM clubsAndServices, clubsAndServicesArchetypes + WHERE + clubsAndServices.casaId = clubsAndServicesArchetypes.casaId + AND clubsAndServices.branchcode = ? + ORDER BY $orderby + " + ); + $sth->execute($branchcode) or return 0; + + } else { ## Get all clubs and services + $sth = $dbh->prepare("SELECT * FROM clubsAndServices ORDER BY $orderby"); + $sth->execute() or return 0; + } + + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; + +} + +=head2 GetClubOrService + + Returns information about a club or service + + Input: + $casId: Id of club or service to get + + Output: $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode + +=cut + +sub GetClubOrService { + my ($casId) = @_; + + my $dbh = C4::Context->dbh; + + my ( $sth, @results ); + $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casId = ?"); + $sth->execute($casId) or return 0; + + my $row = $sth->fetchrow_hashref; + + $sth->finish; + + return ( + $$row{'casId'}, $$row{'casaId'}, $$row{'title'}, $$row{'description'}, $$row{'casData1'}, $$row{'casData2'}, + $$row{'casData3'}, $$row{'startDate'}, $$row{'endDate'}, $$row{'last_updated'}, $$row{'branchcode'} + ); + +} + +=head2 GetClubsAndServicesArchetypes + + Returns information about clubs and services archetypes + + Input: + $type: 'club' or 'service' ( Optional: Defaults to all types ) + $branchcode: Get clubs or services created by this branch ( Optional ) + + Output: + $results: + Otherwise: Reference to an array of associated arrays + Except: 0 on failure + +=cut + +sub GetClubsAndServicesArchetypes { + my ( $type, $branchcode ) = @_; + my $dbh = C4::Context->dbh; + + my $sth; + if ( $type && $branchcode ) { + $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ? AND branchcode = ?"); + $sth->execute( $type, $branchcode ) or return 0; + } elsif ($type) { + $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ?"); + $sth->execute($type) or return 0; + } elsif ($branchcode) { + $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE branchcode = ?"); + $sth->execute($branchcode) or return 0; + } else { + $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes"); + $sth->execute() or return 0; + } + + my @results; + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; +} + +=head2 GetClubOrServiceArchetype + + Returns information about a club or services archetype + + Input: + $casaId: Id of Archetype to get + $asHashref: Optional, if true, will return hashref instead of array + + Output: + ( $casaId, $type, $title, $description, $publicEnrollment, + $casData1Title, $casData2Title, $casData3Title, + $caseData1Title, $caseData2Title, $caseData3Title, + $casData1Desc, $casData2Desc, $casData3Desc, + $caseData1Desc, $caseData2Desc, $caseData3Desc, + $caseRequireEmail, $last_updated, $branchcode ) + Except: 0 on failure + +=cut + +sub GetClubOrServiceArchetype { + my ( $casaId, $asHashref ) = @_; + + my $dbh = C4::Context->dbh; + + my $sth; + $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE casaId = ?"); + $sth->execute($casaId) or return 0; + + my $row = $sth->fetchrow_hashref; + + $sth->finish; + + if ($asHashref) { return $row; } + + return ( + $$row{'casaId'}, $$row{'type'}, $$row{'title'}, $$row{'description'}, $$row{'publicEnrollment'}, + $$row{'casData1Title'}, $$row{'casData2Title'}, $$row{'casData3Title'}, $$row{'caseData1Title'}, $$row{'caseData2Title'}, + $$row{'caseData3Title'}, $$row{'casData1Desc'}, $$row{'casData2Desc'}, $$row{'casData3Desc'}, $$row{'caseData1Desc'}, + $$row{'caseData2Desc'}, $$row{'caseData3Desc'}, $$row{'caseRequireEmail'}, $$row{'last_updated'}, $$row{'branchcode'} + ); +} + +=head2 DoesEnrollmentRequireData + + Returns 1 if the given Archetype has + data fields that need to be filled in + at the time of enrollment. + + Input: + $casaId: Id of Archetype to get + + Output: + 1: Enrollment will require extra data + 0: Enrollment will not require extra data + +=cut + +sub DoesEnrollmentRequireData { + my ($casaId) = @_; + + my $dbh = C4::Context->dbh; + + my $sth; + $sth = $dbh->prepare("SELECT caseData1Title FROM clubsAndServicesArchetypes WHERE casaId = ?"); + $sth->execute($casaId) or return 0; + + my $row = $sth->fetchrow_hashref; + + $sth->finish; + + if ( $$row{'caseData1Title'} ) { + return 1; + } else { + return 0; + } +} + +=head2 CancelClubOrServiceEnrollment + + Cancels the given enrollment in a club or service + + Input: + $caseId: The id of the enrollment to be canceled + + Output: + $success: 1 on successful cancelation, 0 otherwise + +=cut + +sub CancelClubOrServiceEnrollment { + my ($caseId) = @_; + + my $success = 1; + + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare("UPDATE clubsAndServicesEnrollments SET dateCanceled = CURDATE(), last_updated = NOW() WHERE caseId = ?"); + $sth->execute($caseId) or $success = 0; + $sth->finish; + + return $success; +} + +=head2 GetEnrolledClubsAndServices + + Returns information about clubs and services + the given borrower is enrolled in. + + Input: + $borrowernumber + + Output: + $results: Reference to an array of associated arrays + +=cut + +sub GetEnrolledClubsAndServices { + my ($borrowernumber) = @_; + my $dbh = C4::Context->dbh; + + my ( $sth, @results ); + $sth = $dbh->prepare( + "SELECT + clubsAndServicesEnrollments.caseId, + clubsAndServices.casId, + clubsAndServices.casaId, + clubsAndServices.title, + clubsAndServices.description, + clubsAndServices.branchcode, + clubsAndServicesArchetypes.type, + clubsAndServicesArchetypes.publicEnrollment + FROM clubsAndServices, clubsAndServicesArchetypes, clubsAndServicesEnrollments + WHERE ( + clubsAndServices.casaId = clubsAndServicesArchetypes.casaId + AND clubsAndServices.casId = clubsAndServicesEnrollments.casId + AND ( clubsAndServices.endDate >= CURRENT_DATE() OR clubsAndServices.endDate IS NULL ) + AND clubsAndServicesEnrollments.dateCanceled IS NULL + AND clubsAndServicesEnrollments.borrowernumber = ? + ) + ORDER BY type, title + " + ); + $sth->execute($borrowernumber) or return 0; + + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; + +} + +=head2 GetPubliclyEnrollableClubsAndServices + + Returns information about clubs and services + the given borrower can enroll in. + + Input: + $borrowernumber + + Output: + $results: Reference to an array of associated arrays + +=cut + +sub GetPubliclyEnrollableClubsAndServices { + my ($borrowernumber) = @_; + + my $dbh = C4::Context->dbh; + + my ( $sth, @results ); + $sth = $dbh->prepare( " +SELECT +DISTINCT ( clubsAndServices.casId ), + clubsAndServices.title, + clubsAndServices.description, + clubsAndServices.branchcode, + clubsAndServicesArchetypes.type, + clubsAndServices.casaId +FROM clubsAndServices, clubsAndServicesArchetypes +WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId +AND clubsAndServicesArchetypes.publicEnrollment =1 +AND clubsAndServices.casId NOT +IN ( + SELECT clubsAndServices.casId + FROM clubsAndServices, clubsAndServicesEnrollments + WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId + AND clubsAndServicesEnrollments.dateCanceled IS NULL + AND clubsAndServicesEnrollments.borrowernumber = ? +) + ORDER BY type, title" ); + $sth->execute($borrowernumber) or return 0; + + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; + +} + +=head2 GetAllEnrollableClubsAndServices + + Returns information about clubs and services + the given borrower can enroll in. + + Input: + $borrowernumber + + Output: + $results: Reference to an array of associated arrays + +=cut + +sub GetAllEnrollableClubsAndServices { + my ( $borrowernumber, $branchcode ) = @_; + + if ( $branchcode eq '' ) { + $branchcode = '%'; + } + + my $dbh = C4::Context->dbh; + + my ( $sth, @results ); + $sth = $dbh->prepare( " +SELECT +DISTINCT ( clubsAndServices.casId ), + clubsAndServices.title, + clubsAndServices.description, + clubsAndServices.branchcode, + clubsAndServicesArchetypes.type, + clubsAndServices.casaId +FROM clubsAndServices, clubsAndServicesArchetypes +WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId +AND ( + DATE(clubsAndServices.endDate) >= CURDATE() + OR + clubsAndServices.endDate IS NULL +) +AND clubsAndServices.branchcode LIKE ? +AND clubsAndServices.casId NOT +IN ( + SELECT clubsAndServices.casId + FROM clubsAndServices, clubsAndServicesEnrollments + WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId + AND clubsAndServicesEnrollments.dateCanceled IS NULL + AND clubsAndServicesEnrollments.borrowernumber = ? +) + ORDER BY type, title" ); + $sth->execute( $branchcode, $borrowernumber ) or return 0; + + while ( my $row = $sth->fetchrow_hashref ) { + push( @results, $row ); + } + + $sth->finish; + + return \@results; + +} + +sub getBorrowernumberByCardnumber { + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE cardnumber = ?"); + $sth->execute(@_) or return (0); + + my $row = $sth->fetchrow_hashref; + + my $borrowernumber = $$row{'borrowernumber'}; + $sth->finish; + + return ($borrowernumber); +} + +sub isEnrolled { + my ( $casId, $borrowernumber ) = @_; + + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare("SELECT COUNT(*) as isEnrolled FROM clubsAndServicesEnrollments WHERE casId = ? AND borrowernumber = ? AND dateCanceled IS NULL"); + $sth->execute( $casId, $borrowernumber ) or return (0); + + my $row = $sth->fetchrow_hashref; + + my $isEnrolled = $$row{'isEnrolled'}; + $sth->finish; + + return ($isEnrolled); +} + +sub getTodayMysqlDateFormat { + my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ]; + my $today = sprintf( "%04d-%02d-%02d", $year + 1900, $month + 1, $day ); + return $today; +} + +sub ReserveForBestSellersClub { + my ($biblionumber) = @_; + + unless ($biblionumber) { return; } + + my $dbh = C4::Context->dbh; + my $sth; + + ## Grab the bib for this biblionumber, we will need the author and title to find the relevent clubs + my $biblio_data = C4::Biblio::GetBiblioData($biblionumber); + my $author = $biblio_data->{'author'}; + my $title = $biblio_data->{'title'}; + my $itemtype = $biblio_data->{'itemtype'}; + + ## Find the casaId for the Bestsellers Club archetype + $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE code LIKE 'BESTSELLERS_CLUB' "); + $sth->execute(); + my $casa = $sth->fetchrow_hashref(); + my $casaId = $casa->{'casaId'}; + $sth->finish(); + + unless ($casaId) { return; } + + ## Find all the relevent bestsellers clubs + ## casData1 is title, casData2 is author + $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casaId = ?"); + $sth->execute($casaId); + my @clubs; + while ( my $club = $sth->fetchrow_hashref() ) { + + #warn "Author/casData2 : '$author'/ " . $club->{'casData2'} . "'"; + #warn "Title/casData1 : '$title'/" . $club->{'casData1'} . "'"; + + ## If the author, title or both match, keep it. + if ( ( $club->{'casData1'} eq $title ) || ( $club->{'casData2'} eq $author ) ) { + push( @clubs, $club ); + + #warn "casId" . $club->{'casId'}; + } elsif ( $club->{'casData1'} =~ m/%/ ) { # Title is using % as a wildcard + my @substrings = split( /%/, $club->{'casData1'} ); + my $all_match = 1; + foreach my $sub (@substrings) { + unless ( $title =~ m/\Q$sub/ ) { + $all_match = 0; + } + } + if ($all_match) { push( @clubs, $club ); } + } elsif ( $club->{'casData2'} =~ m/%/ ) { # Author is using % as a wildcard + my @substrings = split( /%/, $club->{'casData2'} ); + my $all_match = 1; + foreach my $sub (@substrings) { + unless ( $author =~ m/\Q$sub/ ) { + $all_match = 0; + } + } + + ## Make sure the bib is in the list of itemtypes to use + my @itemtypes = split( / /, $club->{'casData3'} ); + my $found_itemtype_match = 0; + if (@itemtypes) { ## If no itemtypes are listed, all itemtypes are valid, skip test. + foreach my $it (@itemtypes) { + if ( $it eq $itemtype ) { + $found_itemtype_match = 1; + last; ## Short circuit for speed. + } + } + $all_match = 0 unless ($found_itemtype_match); + } + + if ($all_match) { push( @clubs, $club ); } + } + } + $sth->finish(); + + unless ( scalar(@clubs) ) { return; } + + ## Get all the members of the relevant clubs, but only get each borrower once, even if they are in multiple relevant clubs + ## Randomize the order of the borrowers + my @casIds; + my $sql = "SELECT DISTINCT(borrowers.borrowernumber) FROM borrowers, clubsAndServicesEnrollments + WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber + AND ("; + my $clubsCount = scalar(@clubs); + foreach my $club (@clubs) { + $sql .= " casId = ?"; + if ( --$clubsCount ) { + $sql .= " OR"; + } + push( @casIds, $club->{'casId'} ); + } + $sql .= " ) ORDER BY RAND()"; + + $sth = $dbh->prepare($sql); + $sth->execute(@casIds); + my @borrowers; + while ( my $borrower = $sth->fetchrow_hashref() ) { + push( @borrowers, $borrower ); + } + + unless ( scalar(@borrowers) ) { return; } + + my $priority = 1; + foreach my $borrower (@borrowers) { + C4::Reserves::AddReserve( + my $branch = $borrower->{'branchcode'}, + my $borrowernumber = $borrower->{'borrowernumber'}, + $biblionumber, my $constraint = 'a', + my $bibitems, $priority, my $notes = $casa->{'title'}, + $title, my $checkitem, + my $found, my $expire_date + ); + $priority++; + } +} + +1; + +__END__ + +=back + +=head1 AUTHOR + +Kyle M Hall + +=cut diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 118bfc2..fec025c 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -35,6 +35,7 @@ use C4::Branch; # XXX subfield_is_koha_internal_p use C4::ClassSource; use C4::ImportBatch; use C4::Charset; +use C4::ClubsAndServices; use Date::Calc qw(Today); use MARC::File::USMARC; @@ -877,6 +878,7 @@ if ( $op eq "addbiblio" ) { } else { ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); + ReserveForBestSellersClub( $biblionumber ); } if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){ if ($frameworkcode eq 'FA'){ diff --git a/circ/circulation.pl b/circ/circulation.pl index 7d214ea..7660808 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -38,6 +38,7 @@ use C4::Search; use MARC::Record; use C4::Reserves; use C4::Context; +use C4::ClubsAndServices; use CGI::Session; use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Borrower::Debarments qw(GetDebarments); @@ -108,6 +109,7 @@ my $findborrower = $query->param('findborrower') || q{}; $findborrower =~ s|,| |g; my $borrowernumber = $query->param('borrowernumber'); + $branch = C4::Context->userenv->{'branch'}; $printer = C4::Context->userenv->{'branchprinter'}; @@ -772,6 +774,8 @@ $template->param( picture => 1 ) if $picture; my $canned_notes = GetAuthorisedValues("BOR_NOTES"); +$template->param( ClubsAndServicesLoop => GetEnrolledClubsAndServices( $borrowernumber ) ); + $template->param( debt_confirmed => $debt_confirmed, SpecifyDueDate => $duedatespec_allow, diff --git a/clubs_services/clubs_services.pl b/clubs_services/clubs_services.pl new file mode 100755 index 0000000..60edb35 --- /dev/null +++ b/clubs_services/clubs_services.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl + +# Author: Kyle M Hall +# +# 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::Auth; +use C4::Context; +use C4::ClubsAndServices; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "clubs_services/clubs_services.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + + # flagsrequired => { clubs_services => 'create_clubs_service' }, + } +); + +my $branchcode = C4::Context->userenv->{branch}; + +my $clubs = GetClubsAndServices( 'club', $branchcode ); +my $services = GetClubsAndServices( 'service', $branchcode ); + +$template->param( + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + + clubs_services => 1, + + clubsLoop => $clubs, + servicesLoop => $services, +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/clubs_services/clubs_services_enrollments.pl b/clubs_services/clubs_services_enrollments.pl new file mode 100755 index 0000000..05c52ec --- /dev/null +++ b/clubs_services/clubs_services_enrollments.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +# Author: Kyle M Hall +# +# 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::Auth; +use C4::Context; +use C4::ClubsAndServices; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "clubs_services/clubs_services_enrollments.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { clubs_services => 'enroll_borrower' }, + } +); + +my $casId = $query->param('casId'); +my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode ) = GetClubOrService($casId); +$template->param( casTitle => $title ); + +my $enrollments = GetCasEnrollments($casId); +$template->param( enrollments_loop => $enrollments ); + +$template->param( + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/clubs_services/edit_archetypes.pl b/clubs_services/edit_archetypes.pl new file mode 100755 index 0000000..1b5f4dd --- /dev/null +++ b/clubs_services/edit_archetypes.pl @@ -0,0 +1,194 @@ +#!/usr/bin/perl + +# Author: Kyle M Hall +# +# 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::Auth; +use C4::Context; +use C4::ClubsAndServices; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "clubs_services/edit_archetypes.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { clubs_services => 'create_archetype' }, + } +); + +my $branchcode = C4::Context->userenv->{branch}; + +## Create new Archetype +if ( $query->param('action') eq 'create' ) { + my $type = $query->param('type'); + my $title = $query->param('title'); + my $description = $query->param('description'); + my $publicEnrollment = ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0; + + my $casData1Title = $query->param('casData1Title'); + my $casData2Title = $query->param('casData2Title'); + my $casData3Title = $query->param('casData3Title'); + + my $caseData1Title = $query->param('caseData1Title'); + my $caseData2Title = $query->param('caseData2Title'); + my $caseData3Title = $query->param('caseData3Title'); + + my $casData1Desc = $query->param('casData1Desc'); + my $casData2Desc = $query->param('casData2Desc'); + my $casData3Desc = $query->param('casData3Desc'); + + my $caseData1Desc = $query->param('caseData1Desc'); + my $caseData2Desc = $query->param('caseData2Desc'); + my $caseData3Desc = $query->param('caseData3Desc'); + + my $caseRequireEmail = $query->param('caseRequireEmail') ? '1' : '0'; + + my ( $createdSuccessfully, $errorMessage ) = AddClubOrServiceArchetype( + $type, $title, $description, $publicEnrollment, $casData1Title, $casData2Title, + $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, $casData2Desc, + $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $caseRequireEmail, $branchcode + ); + + $template->param( + previousActionCreate => 1, + createdTitle => $title, + ); + + if ($createdSuccessfully) { + $template->param( createSuccess => 1 ); + } else { + $template->param( createFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + +} + +## Delete an Archtype +elsif ( $query->param('action') eq 'delete' ) { + my $casaId = $query->param('casaId'); + my $success = DeleteClubOrServiceArchetype($casaId); + + $template->param( previousActionDelete => 1 ); + if ($success) { + $template->param( deleteSuccess => 1 ); + } else { + $template->param( deleteFailure => 1 ); + } +} + +## Edit a club or service: grab data, put in form. +elsif ( $query->param('action') eq 'edit' ) { + my $casaId = $query->param('casaId'); + my ($casaId, $type, $title, $description, $publicEnrollment, $casData1Title, $casData2Title, + $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, $casData2Desc, $casData3Desc, + $caseData1Desc, $caseData2Desc, $caseData3Desc, $caseRequireEmail, $casaTimestamp, $casaBranchcode + ) = GetClubOrServiceArchetype($casaId); + + $template->param( + previousActionEdit => 1, + editCasaId => $casaId, + editType => $type, + editTitle => $title, + editDescription => $description, + editCasData1Title => $casData1Title, + editCasData2Title => $casData2Title, + editCasData3Title => $casData3Title, + editCaseData1Title => $caseData1Title, + editCaseData2Title => $caseData2Title, + editCaseData3Title => $caseData3Title, + editCasData1Desc => $casData1Desc, + editCasData2Desc => $casData2Desc, + editCasData3Desc => $casData3Desc, + editCaseData1Desc => $caseData1Desc, + editCaseData2Desc => $caseData2Desc, + editCaseData3Desc => $caseData3Desc, + editCaseRequireEmail => $caseRequireEmail, + editCasaTimestamp => $casaTimestamp, + editCasaBranchcode => $casaBranchcode + ); + + if ($publicEnrollment) { + $template->param( editPublicEnrollment => 1 ); + } +} + +# Update an Archetype +elsif ( $query->param('action') eq 'update' ) { + my $casaId = $query->param('casaId'); + my $type = $query->param('type'); + my $title = $query->param('title'); + my $description = $query->param('description'); + my $publicEnrollment = ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0; + + my $casData1Title = $query->param('casData1Title'); + my $casData2Title = $query->param('casData2Title'); + my $casData3Title = $query->param('casData3Title'); + + my $caseData1Title = $query->param('caseData1Title'); + my $caseData2Title = $query->param('caseData2Title'); + my $caseData3Title = $query->param('caseData3Title'); + + my $casData1Desc = $query->param('casData1Desc'); + my $casData2Desc = $query->param('casData2Desc'); + my $casData3Desc = $query->param('casData3Desc'); + + my $caseData1Desc = $query->param('caseData1Desc'); + my $caseData2Desc = $query->param('caseData2Desc'); + my $caseData3Desc = $query->param('caseData3Desc'); + + my $caseRequireEmail = $query->param('caseRequireEmail'); + + my ( $createdSuccessfully, $errorMessage ) = UpdateClubOrServiceArchetype( + $casaId, $type, $title, $description, $publicEnrollment, $casData1Title, + $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, + $casData2Desc, $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $caseRequireEmail + ); + + $template->param( + previousActionUpdate => 1, + updatedTitle => $title, + ); + + if ($createdSuccessfully) { + $template->param( updateSuccess => 1 ); + } else { + $template->param( updateFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + +} + +my $clubArchetypes = GetClubsAndServicesArchetypes('club'); +my $serviceArchetypes = GetClubsAndServicesArchetypes('service'); + +$template->param( + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + + edit_archetypes => 1, + + clubArchetypesLoop => $clubArchetypes, + serviceArchetypesLoop => $serviceArchetypes, +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/clubs_services/edit_clubs_services.pl b/clubs_services/edit_clubs_services.pl new file mode 100755 index 0000000..8862f4a --- /dev/null +++ b/clubs_services/edit_clubs_services.pl @@ -0,0 +1,195 @@ +#!/usr/bin/perl + +# Author: Kyle M Hall +# +# 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::Auth; +use C4::Context; +use C4::ClubsAndServices; +use Koha::DateUtils; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "clubs_services/edit_clubs_services.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { clubs_services => 'create_club_service' }, + } +); + +my $branchcode = C4::Context->userenv->{branch}; + +# Archetype selected for Club or Service creation +if ( $query->param('action') eq 'selectArchetype' ) { + my $casaId = $query->param('casaId'); + + my ($casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment, $casData1Title, + $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, + $casData2Desc, $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $casaTimestamp + ) = GetClubOrServiceArchetype($casaId); + + $template->param( + previousActionSelectArchetype => 1, + + casaId => $casaId, + casaType => $casaType, + casaTitle => $casaTitle, + casaDescription => $casaDescription, + casaPublicEnrollment => $casaPublicEnrollment, + casData1Title => $casData1Title, + casData2Title => $casData2Title, + casData3Title => $casData3Title, + caseData1Title => $caseData1Title, + caseData2Title => $caseData2Title, + caseData3Title => $caseData3Title, + casData1Desc => $casData1Desc, + casData2Desc => $casData2Desc, + casData3Desc => $casData3Desc, + caseData1Desc => $caseData1Desc, + caseData2Desc => $caseData2Desc, + caseData3Desc => $caseData3Desc, + caseTimestamp => $casaTimestamp + ); +} + +# Create new Club or Service +elsif ( $query->param('action') eq 'create' ) { + my $casaId = $query->param('casaId'); + my $title = $query->param('title'); + my $description = $query->param('description'); + my $casData1 = $query->param('casData1'); + my $casData2 = $query->param('casData2'); + my $casData3 = $query->param('casData3'); + my $startDate = output_pref( dt_from_string( $query->param('startDate') ), 'iso' ); + my $endDate = output_pref( dt_from_string( $query->param('endDate') ), 'iso' ); + + my ( $createdSuccessfully, $errorMessage ) = AddClubOrService( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ); + + $template->param( + previousActionCreate => 1, + createdTitle => $title, + ); + + if ($createdSuccessfully) { + $template->param( createSuccess => 1 ); + } else { + $template->param( createFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } +} + +## Delete a club or service +elsif ( $query->param('action') eq 'delete' ) { + my $casId = $query->param('casId'); + my $success = DeleteClubOrService($casId); + + $template->param( previousActionDelete => 1 ); + if ($success) { + $template->param( deleteSuccess => 1 ); + } else { + $template->param( deleteFailure => 1 ); + } +} + +## Edit a club or service: grab data, put in form. +elsif ( $query->param('action') eq 'edit' ) { + my $casId = $query->param('casId'); + my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $timestamp ) = GetClubOrService($casId); + + my ($casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment, $casData1Title, + $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, + $casData2Desc, $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $casaTimestamp + ) = GetClubOrServiceArchetype($casaId); + + $template->param( + previousActionSelectArchetype => 1, + previousActionEdit => 1, + editCasId => $casId, + editCasaId => $casaId, + editTitle => $title, + editDescription => $description, + editCasData1 => $casData1, + editCasData2 => $casData2, + editCasData3 => $casData3, + editStartDate => $startDate, + editEndDate => $endDate, + editTimestamp => $timestamp, + + casaId => $casaId, + casaTitle => $casaTitle, + casData1Title => $casData1Title, + casData2Title => $casData2Title, + casData3Title => $casData3Title, + casData1Desc => $casData1Desc, + casData2Desc => $casData2Desc, + casData3Desc => $casData3Desc + ); +} + +# Update a Club or Service +if ( $query->param('action') eq 'update' ) { + my $casId = $query->param('casId'); + my $casaId = $query->param('casaId'); + my $title = $query->param('title'); + my $description = $query->param('description'); + my $casData1 = $query->param('casData1'); + my $casData2 = $query->param('casData2'); + my $casData3 = $query->param('casData3'); + my $startDate = output_pref( dt_from_string( $query->param('startDate') ), 'iso' ); + my $endDate = output_pref( dt_from_string( $query->param('endDate') ), 'iso' ); + + my ( $createdSuccessfully, $errorMessage ) = UpdateClubOrService( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate ); + + $template->param( + previousActionUpdate => 1, + updatedTitle => $title, + ); + + if ($createdSuccessfully) { + $template->param( updateSuccess => 1 ); + } else { + $template->param( updateFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } +} + +my $clubs = GetClubsAndServices( 'club', $query->cookie('branch') ); +my $services = GetClubsAndServices( 'service', $query->cookie('branch') ); +my $archetypes = GetClubsAndServicesArchetypes(); + +if ($archetypes) { ## Disable 'Create New Club or Service' if there are no archetypes defined. + $template->param( archetypes => 1 ); +} + +$template->param( + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + + edit_clubs_services => 1, + + clubsLoop => $clubs, + servicesLoop => $services, + archetypesLoop => $archetypes, +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/clubs_services/enroll_clubs_services.pl b/clubs_services/enroll_clubs_services.pl new file mode 100755 index 0000000..37b33a8 --- /dev/null +++ b/clubs_services/enroll_clubs_services.pl @@ -0,0 +1,111 @@ +#!/usr/bin/perl + +# Author: Kyle M Hall +# +# 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::Auth; +use C4::Context; +use C4::ClubsAndServices; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "clubs_services/enroll_clubs_services.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { clubs_services => 'enroll_borrower' }, + } +); + +my $branchcode = $query->cookie('branch'); + +if ( $query->param('action') eq 'enroll' ) { + my $borrowerBarcode = $query->param('borrowerBarcode'); + my $casId = $query->param('casId'); + my $casaId = $query->param('casaId'); + my $data1 = $query->param('data1'); + my $data2 = $query->param('data2'); + my $data3 = $query->param('data3'); + + my $dateEnrolled; # Will default to Today + + my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, $borrowerBarcode, $dateEnrolled, $data1, $data2, $data3, $branchcode ); + + $template->param( + previousActionEnroll => 1, + enrolledBarcode => $borrowerBarcode, + ); + + if ($success) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + +} + +my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') ); +my ($casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment, $casData1Title, + $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, + $casData2Desc, $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $timestamp +) = GetClubOrServiceArchetype($casaId); + +$template->param( + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + + casId => $casId, + casTitle => $casTitle, + casDescription => $casDescription, + casStartDate => $casStartDate, + casEndDate => $casEndDate, + casTimeStamp => $casTimestamp, + + casaId => $casaId, + casaType => $casaType, + casaTitle => $casaTitle, + casaDescription => $casaDescription, + casaPublicEnrollment => $casaPublicEnrollment, +); + +if ($caseData1Title) { + $template->param( caseData1Title => $caseData1Title ); +} +if ($caseData2Title) { + $template->param( caseData2Title => $caseData2Title ); +} +if ($caseData3Title) { + $template->param( caseData3Title => $caseData3Title ); +} + +if ($caseData1Desc) { + $template->param( caseData1Desc => $caseData1Desc ); +} +if ($caseData2Desc) { + $template->param( caseData2Desc => $caseData2Desc ); +} +if ($caseData3Desc) { + $template->param( caseData3Desc => $caseData3Desc ); +} + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.sql b/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.txt b/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/de-DE/mandatory/userflags.sql b/installer/data/mysql/de-DE/mandatory/userflags.sql index 9399f4a..22f52d0 100644 --- a/installer/data/mysql/de-DE/mandatory/userflags.sql +++ b/installer/data/mysql/de-DE/mandatory/userflags.sql @@ -17,3 +17,4 @@ INSERT INTO `userflags` VALUES(16,'reports','Zugriff auf Reportmodul',0); INSERT INTO `userflags` VALUES(17,'staffaccess','Berechtigungen/Logins für Bibliotheksmitarbeiter vergeben',0); INSERT INTO `userflags` VALUES(18,'coursereserves','Semesteraparate',0); INSERT INTO `userflags` VALUES(19,'plugins', 'Koha Plugins', '0'); +INSERT INTO `userflags` VALUES(20,'clubs_services','Access to the clubs & services module',0); diff --git a/installer/data/mysql/de-DE/mandatory/userpermissions.sql b/installer/data/mysql/de-DE/mandatory/userpermissions.sql index 9c754ee..a6fcc33 100644 --- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql +++ b/installer/data/mysql/de-DE/mandatory/userpermissions.sql @@ -65,5 +65,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Plugins verwalten (installieren/deinstallieren)'), (19, 'tool', 'Werkzeug-Plugins verwenden'), (19, 'report', 'Report-Plugins verwenden'), - (19, 'configure', 'Plugins konfigurieren') + (19, 'configure', 'Plugins konfigurieren'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.sql b/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.txt b/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/en/mandatory/userflags.sql b/installer/data/mysql/en/mandatory/userflags.sql index c00db34..5b66b9a 100644 --- a/installer/data/mysql/en/mandatory/userflags.sql +++ b/installer/data/mysql/en/mandatory/userflags.sql @@ -17,4 +17,5 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES (16,'reports','Allow access to the reports module',0), (17,'staffaccess','Allow staff members to modify permissions for other staff members',0), (18,'coursereserves','Course Reserves',0), -(19, 'plugins', 'Koha plugins', '0'); +(19, 'plugins', 'Koha plugins', '0'), +(20,'clubs_services','Access to the clubs & services module',0); diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql index eb1275c..9b7bd49 100644 --- a/installer/data/mysql/en/mandatory/userpermissions.sql +++ b/installer/data/mysql/en/mandatory/userpermissions.sql @@ -65,5 +65,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.sql b/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.txt b/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/es-ES/mandatory/userflags.sql b/installer/data/mysql/es-ES/mandatory/userflags.sql index 55fa157..a0f229c 100644 --- a/installer/data/mysql/es-ES/mandatory/userflags.sql +++ b/installer/data/mysql/es-ES/mandatory/userflags.sql @@ -17,3 +17,4 @@ INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports modu 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'); +INSERT INTO `userflags` VALUES(20,'clubs_services','Access to the clubs & services module',0); diff --git a/installer/data/mysql/es-ES/mandatory/userpermissions.sql b/installer/data/mysql/es-ES/mandatory/userpermissions.sql index 2f42224..1466233 100644 --- a/installer/data/mysql/es-ES/mandatory/userpermissions.sql +++ b/installer/data/mysql/es-ES/mandatory/userpermissions.sql @@ -65,5 +65,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.sql b/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.txt b/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql b/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql index 1eb167a..a9596bd 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql @@ -18,3 +18,4 @@ 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'); +INSERT INTO `userflags` VALUES(20,'clubs_services','Access to the clubs & services module',0); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql index 702db68..8011ccb 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql @@ -65,5 +65,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.sql b/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.txt b/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/it-IT/necessari/userflags.sql b/installer/data/mysql/it-IT/necessari/userflags.sql index d1c3a57..2e064ef 100644 --- a/installer/data/mysql/it-IT/necessari/userflags.sql +++ b/installer/data/mysql/it-IT/necessari/userflags.sql @@ -19,5 +19,6 @@ INSERT INTO `userflags` VALUES(16,'reports','autorizza accesso al modulo dei rep 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'); +INSERT INTO `userflags` VALUES(20,'clubs_services','Access to the clubs & services module',0); 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 0d27fc0..203d2d4 100644 --- a/installer/data/mysql/it-IT/necessari/userpermissions.sql +++ b/installer/data/mysql/it-IT/necessari/userpermissions.sql @@ -67,6 +67,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; SET FOREIGN_KEY_CHECKS=1; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 363217b..3724564 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3393,6 +3393,106 @@ CREATE TABLE IF NOT EXISTS marc_modification_template_actions ( CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `clubsAndServicesArchetypes` +-- + +DROP TABLE IF EXISTS `clubsAndServicesArchetypes`; +CREATE TABLE `clubsAndServicesArchetypes` ( + `casaId` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(64) DEFAULT NULL, + `type` enum('club','service') NOT NULL DEFAULT 'club', + `title` text NOT NULL, -- 'title of this archetype', + `description` text NOT NULL, -- 'long description of this archetype', + `publicEnrollment` tinyint(1) NOT NULL DEFAULT '0', -- 'If 1, patron should be able to enroll in club or service from OPAC, if 0, only a librarian should be able to enroll a patron in the club or service.', + `casData1Title` text, -- 'Title of contents in cas.data1', + `casData2Title` text, -- 'Title of contents in cas.data2', + `casData3Title` text, -- 'Title of contents in cas.data3', + `caseData1Title` text, -- 'Name of what is stored in cAsE.data1', + `caseData2Title` text, -- 'Name of what is stored in cAsE.data2', + `caseData3Title` text, -- 'Name of what is stored in cAsE.data3', + `casData1Desc` text, + `casData2Desc` text, + `casData3Desc` text, + `caseData1Desc` text, + `caseData2Desc` text, + `caseData3Desc` text, + `caseRequireEmail` tinyint(1) NOT NULL DEFAULT '0', + `branchcode` varchar(4) DEFAULT NULL, -- 'branch where archetype was created.', + `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `system_defined` tinyint(1) NOT NULL DEFAULT '0', -- 'if true, archetype comes as part of koha. These archetypes have associated scripts such that modifying the archetype would break the script.', + PRIMARY KEY (`casaId`), + KEY `branchcode` (`branchcode`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Constraints for table `clubsAndServicesArchetypes` +-- +ALTER TABLE `clubsAndServicesArchetypes` + ADD CONSTRAINT `clubsAndServicesArchetypes_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Table structure for table `clubsAndServices` +-- + +DROP TABLE IF EXISTS `clubsAndServices`; +CREATE TABLE `clubsAndServices` ( + `casId` int(11) NOT NULL AUTO_INCREMENT, + `casaId` int(11) NOT NULL DEFAULT '0', -- 'foreign key to clubsAndServicesArchetypes', + `title` text NOT NULL, + `description` text, + `casData1` text, -- 'Data described in casa.casData1Title', + `casData2` text, -- 'Data described in casa.casData2Title', + `casData3` text, -- 'Data described in casa.casData3Title', + `startDate` date NOT NULL DEFAULT '0000-00-00', + `endDate` date DEFAULT NULL, + `branchcode` varchar(4) NOT NULL, -- 'branch where club or service was created.', + `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`casId`), + KEY `casaId` (`casaId`), + KEY `branchcode` (`branchcode`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Constraints for table `clubsAndServices` +-- +ALTER TABLE `clubsAndServices` + ADD CONSTRAINT `clubsAndServices_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServices_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Table structure for table `clubsAndServicesEnrollments` +-- + +DROP TABLE IF EXISTS `clubsAndServicesEnrollments`; +CREATE TABLE `clubsAndServicesEnrollments` ( + `caseId` int(11) NOT NULL AUTO_INCREMENT, + `casaId` int(11) NOT NULL DEFAULT '0', -- 'foreign key to clubsAndServicesArchtypes', + `casId` int(11) NOT NULL DEFAULT '0', -- 'foreign key to clubsAndServices', + `borrowernumber` int(11) NOT NULL DEFAULT '0', -- 'foreign key to borrowers', + `data1` text, -- 'data described in casa.data1description', + `data2` text, + `data3` text, + `dateEnrolled` date NOT NULL DEFAULT '0000-00-00', -- 'date borrowers service begins', + `dateCanceled` date DEFAULT NULL, -- 'date borrower decided to end service', + `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `branchcode` varchar(4) DEFAULT NULL, -- 'foreign key to branches', + PRIMARY KEY (`caseId`), + KEY `casaId` (`casaId`), + KEY `casId` (`casId`), + KEY `borrowernumber` (`borrowernumber`), + KEY `branchcode` (`branchcode`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Constraints for table `clubsAndServicesEnrollments` +-- +ALTER TABLE `clubsAndServicesEnrollments` + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_2` FOREIGN KEY (`casId`) REFERENCES `clubsAndServices` (`casId`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.txt b/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql index 6323b36..f8d3e5c 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql @@ -38,3 +38,4 @@ 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'); +INSERT INTO `userflags` VALUES(20,'clubs_services','Access to the clubs & services module',0); diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql index c581bbd..01a9fa1 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql @@ -85,5 +85,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.sql b/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.txt b/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file diff --git a/installer/data/mysql/pl-PL/mandatory/userflags.sql b/installer/data/mysql/pl-PL/mandatory/userflags.sql index 55fa157..a0f229c 100644 --- a/installer/data/mysql/pl-PL/mandatory/userflags.sql +++ b/installer/data/mysql/pl-PL/mandatory/userflags.sql @@ -17,3 +17,4 @@ INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports modu 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'); +INSERT INTO `userflags` VALUES(20,'clubs_services','Access to the clubs & services module',0); diff --git a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql index dcd8aef..bbac83f 100644 --- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql +++ b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql @@ -66,5 +66,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.sql b/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.txt b/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file 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 acf904d..aca2498 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 @@ -20,6 +20,7 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES (17,'staffaccess', 'Смена имени(логина)/привилегий для работников библиотеки',0), (18,'coursereserves', 'Course Reserves',0), (19,'plugins', 'Koha plugins', '0') + (20,'clubs_services', 'Access to the clubs & services module',0); ; TRUNCATE permissions; @@ -91,6 +92,9 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), - (19, 'configure', 'Configure plugins') + (19, 'configure', 'Configure plugins'), + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.sql b/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.sql new file mode 100644 index 0000000..4ba245f --- /dev/null +++ b/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.sql @@ -0,0 +1,3 @@ +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); diff --git a/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.txt b/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.txt new file mode 100644 index 0000000..fab36ab --- /dev/null +++ b/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.txt @@ -0,0 +1,2 @@ +System defined archetypes for the clubs and services feature. +These archetypes are required by Koha for certain functionality. \ No newline at end of file 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 adee3ff..c8ae7c3 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 @@ -20,6 +20,7 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES (17,'staffaccess', 'Зміна імені(логіну)/привілеїв для працівників бібліотеки',0), (18,'coursereserves', 'Course Reserves',0), (19,'plugins', 'Koha plugins', '0') + (20,'clubs_services', 'Access to the clubs & services module',0); ; TRUNCATE permissions; @@ -92,5 +93,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), (19, 'configure', 'Configure plugins') + (20, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'), + (20, 'create_archetype', 'Create and edit archetype.'), + (20, 'enroll_borrower', 'Enroll borrower in a club or service.') ; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f043d0b..819bc2e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7950,6 +7950,110 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $dbh->do("ALTER TABLE biblioitems CHANGE url url TEXT NULL DEFAULT NULL"); $dbh->do("ALTER TABLE deletedbiblioitems CHANGE url url TEXT NULL DEFAULT NULL"); print "Upgrade to $DBversion done (Bug 11268 - Biblioitems URL field is too small for some URLs)\n"; + +$DBversion = "3.15.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + + $dbh->do(" +CREATE TABLE `clubsAndServicesArchetypes` ( + `casaId` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(64) DEFAULT NULL, + `type` enum('club','service') NOT NULL DEFAULT 'club', + `title` text NOT NULL COMMENT 'title of this archetype', + `description` text NOT NULL COMMENT 'long description of this archetype', + `publicEnrollment` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'If 1, patron should be able to enroll in club or service from OPAC, if 0, only a librarian should be able to enroll a patron in the club or service.', + `casData1Title` text COMMENT 'Title of contents in cas.data1', + `casData2Title` text COMMENT 'Title of contents in cas.data2', + `casData3Title` text COMMENT 'Title of contents in cas.data3', + `caseData1Title` text COMMENT 'Name of what is stored in cAsE.data1', + `caseData2Title` text COMMENT 'Name of what is stored in cAsE.data2', + `caseData3Title` text COMMENT 'Name of what is stored in cAsE.data3', + `casData1Desc` text, + `casData2Desc` text, + `casData3Desc` text, + `caseData1Desc` text, + `caseData2Desc` text, + `caseData3Desc` text, + `caseRequireEmail` tinyint(1) NOT NULL DEFAULT '0', + `branchcode` varchar(4) DEFAULT NULL COMMENT 'branch where archetype was created.', + `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `system_defined` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'if true, archetype comes as part of koha. These archetypes have associated scripts such that modifying the archetype would break the script.', + PRIMARY KEY (`casaId`), + KEY `branchcode` (`branchcode`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +"): + + $dbh->do(" +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES +(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1), +(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1); +"); + + $dbh->do(" +ALTER TABLE `clubsAndServicesArchetypes` + ADD CONSTRAINT `clubsAndServicesArchetypes_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE; +"); + + $dbh->do(" +CREATE TABLE `clubsAndServices` ( + `casId` int(11) NOT NULL AUTO_INCREMENT, + `casaId` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to clubsAndServicesArchetypes', + `title` text NOT NULL, + `description` text, + `casData1` text COMMENT 'Data described in casa.casData1Title', + `casData2` text COMMENT 'Data described in casa.casData2Title', + `casData3` text COMMENT 'Data described in casa.casData3Title', + `startDate` date NOT NULL DEFAULT '0000-00-00', + `endDate` date DEFAULT NULL, + `branchcode` varchar(4) NOT NULL COMMENT 'branch where club or service was created.', + `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`casId`), + KEY `casaId` (`casaId`), + KEY `branchcode` (`branchcode`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +"); + + $dbh->do(" +ALTER TABLE `clubsAndServices` + ADD CONSTRAINT `clubsAndServices_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServices_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE; +"); + + $dbh->do(" +CREATE TABLE `clubsAndServicesEnrollments` ( + `caseId` int(11) NOT NULL AUTO_INCREMENT, + `casaId` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to clubsAndServicesArchtypes', + `casId` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to clubsAndServices', + `borrowernumber` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to borrowers', + `data1` text COMMENT 'data described in casa.data1description', + `data2` text, + `data3` text, + `dateEnrolled` date NOT NULL DEFAULT '0000-00-00' COMMENT 'date borrowers service begins', + `dateCanceled` date DEFAULT NULL COMMENT 'date borrower decided to end service', + `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `branchcode` varchar(4) DEFAULT NULL COMMENT 'foreign key to branches', + PRIMARY KEY (`caseId`), + KEY `casaId` (`casaId`), + KEY `casId` (`casId`), + KEY `borrowernumber` (`borrowernumber`), + KEY `branchcode` (`branchcode`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +"); + + $dbh->do(" +ALTER TABLE `clubsAndServicesEnrollments` + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_2` FOREIGN KEY (`casId`) REFERENCES `clubsAndServices` (`casId`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE; +"); + + $dbh->do("INSERT INTO userflags ( bit, flag, flagdesc, defaulton ) VALUES ('20', 'clubs_services', 'Access to the clubs & services module', '0' )"); + $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '20', 'create_club_service', 'Create and edit clubs and services from existing archetypes.' )"); + $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '20', 'create_archetype', 'Create and edit archetype' ) "); + $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '20', 'enroll_borrower', 'Enroll borrower in a club or service.' )"); + + print "Upgrade to $DBversion done ( Added Clubs & Services )\n"; SetVersion($DBversion); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index 5687d01..6f35d8f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -76,6 +76,7 @@ [% IF ( CAN_user_parameters ) %] [% IF ( logview ) %]
  • [% ELSE %]
  • [% END %]Modification log
  • [% END %] + [% IF ( clubs_services ) %]
  • [% ELSE %]
  • [% END %]Clubs & Services
  • [% IF ( EnhancedMessagingPreferences ) %] [% IF ( sentnotices ) %]
  • [% ELSE %]
  • [% END %]Notices
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc index 9bd5285..272416d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc @@ -15,6 +15,7 @@ [% IF ( EnhancedMessagingPreferences ) %] [% IF ( sentnotices ) %]
  • [% ELSE %]
  • [% END %]Notices
  • [% END %] + [% IF clubs_services %]
  • [% ELSE %]
  • [% END %]">Clubs & Services
  • [% IF ( statisticsview ) %]
  • [% ELSE %]
  • [% END %]Statistics
  • [% IF EnableBorrowerFiles %] [% IF ( borrower_files ) %]
  • [% ELSE %]
  • [% END %]Files
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 5a6a82d..d7224b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -678,7 +678,14 @@ No patron matched [% message %] [% END %] - + [% IF ( ClubsAndServicesLoop ) %] +

    Clubs & Services

    + + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tt new file mode 100644 index 0000000..27c2184 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tt @@ -0,0 +1,93 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Tools › Clubs & services +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] + + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + [% IF ( clubsLoop ) %] + [% FOREACH clubsLoo IN clubsLoop %] + + + + + + + + + [% END %] + [% ELSE %] + + [% END %] + + + + + + + + + + + + + + + + [% IF ( servicesLoop ) %] + [% FOREACH servicesLoo IN servicesLoop %] + + + + + + + + + [% END %] + [% ELSE %] + + [% END %] +
    Clubs
    TitleDescriptionStart dateEnd date  
    [% clubsLoo.title %][% clubsLoo.description %][% clubsLoo.startDate %][% clubsLoo.endDate %]EnrollDetails
    There are no clubs currently defined.
     
    Services
    TitleDescriptionStart dateEnd date  
    [% servicesLoo.title %][% servicesLoo.description %][% servicesLoo.startDate %][% servicesLoo.endDate %]EnrollDetails
    There are no services currently defined.
    +
    +
    + +
    + +
    + +
    +
    + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services_enrollments.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services_enrollments.tt new file mode 100644 index 0000000..7a77327 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services_enrollments.tt @@ -0,0 +1,67 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Tools › Clubs & services +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] + + + +
    +
    +
    +
    + +

    Details for [% casTitle %]

    + + + + + + + + + + + [% IF ( enrollments_loop ) %] + [% FOREACH enrollments_loo IN enrollments_loop %] + + + + + + [% END %] + [% ELSE %] + + [% END %] +
    Enrollments +
    Name Borrower
    details
    Cancel
    Enrollment
    [% enrollments_loo.surname %], [% enrollments_loo.firstname %] Details + + Cancel enrollment + +
    There are borrowers currently enrolled.
    +
    +
    + +
    + +
    + +
    +
    + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tt new file mode 100644 index 0000000..49e64fe --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tt @@ -0,0 +1,270 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Tools › Clubs & services › Edit archetypes +[% INCLUDE 'doc-head-close.inc' %] + + + + + +[% INCLUDE 'header.inc' %] + + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + [% IF ( clubArchetypesLoop ) %] + [% FOREACH clubArchetypesLoo IN clubArchetypesLoop %] + + + + + + + + + + + + + + + + [% END %] + [% ELSE %] + + [% END %] + + + + + + + + + + + + + + + + + + + + [% IF ( serviceArchetypesLoop ) %] + [% FOREACH serviceArchetypesLoo IN serviceArchetypesLoop %] + + + + + + + + + + + + + + + + [% END %] +
    Club archetypes
    Owner + TitleDescriptionPublic enrollmentRequire emailClub data 1 titleClub data 2 titleClub data 3 titleEnrollment data 1 titleEnrollment data 2 titleEnrollment data 3 title  
    [% clubArchetypesLoo.branchcode %][% clubArchetypesLoo.title %][% clubArchetypesLoo.description %][% IF clubArchetypesLoo.publicEnrollment %]✔[% END %][% IF clubArchetypesLoo.caseRequireEmail %]✔[% END %][% clubArchetypesLoo.casData1Title %][% clubArchetypesLoo.casData2Title %][% clubArchetypesLoo.casData3Title %][% clubArchetypesLoo.caseData1Title %][% clubArchetypesLoo.caseData2Title %][% clubArchetypesLoo.caseData3Title %][% UNLESS ( clubArchetypesLoo.system_defined ) %]Edit[% END %][% UNLESS ( clubArchetypesLoo.system_defined ) %]Delete[% END %]
    There are no club archetypes currently defined.
     
    Service archetypes
    Owner + TitleDescriptionPublic enrollmentRequire emailService data 1 titleService data 2 titleService data 3 titleEnrollment data 1 titleEnrollment data 2 titleEnrollment data 3 title  
    [% serviceArchetypesLoo.branchcode %][% serviceArchetypesLoo.title %][% serviceArchetypesLoo.description %][% IF serviceArchetypesLoo.publicEnrollment %]✔[% END %][% IF serviceArchetypesLoo.caseRequireEmail %]✔[% END %][% serviceArchetypesLoo.casData1Title %][% serviceArchetypesLoo.casData2Title %][% serviceArchetypesLoo.casData3Title %][% serviceArchetypesLoo.caseData1Title %][% serviceArchetypesLoo.caseData2Title %][% serviceArchetypesLoo.caseData3Title %][% UNLESS ( serviceArchetypesLoo.system_defined ) %]Edit[% END %][% UNLESS ( serviceArchetypesLoo.system_defined ) %]Delete[% END %]
    + [% ELSE %] + There are no service archetypes currently defined. + [% END %] + + + + + + [% IF ( previousActionEdit ) %] + + [% ELSE %] + + [% END %] + + + + +
    Edit an archetypeCreate new archetype
    +
    + [% IF ( previousActionEdit ) %] + + + [% ELSE %] + + [% END %] + + + +
    + + + + required +
    + + + + required +
    + + + [% IF ( editPublicEnrollment ) %] + Yes + No + [% ELSE %] + Yes + No + [% END %] + +
    + +
    The following fields are generic fields that you can define to hold any data you might need upon club/service creation that is not stored elsewhere in Koha. + These fields will appear when a person creates a new club or service, at that time the system will ask for the data that is defined in this field. + For example, if you were to create a "Summer Reading Club" archetype, and you want to compare summer reading clubs by year, you would enter 'Year' in + the 'Title' field, and 'Year that this Summer Reading Club is Taking Place' in the 'Description' field. + If you do not need to store any extra data for a club or service, just leave these blank. +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    The following fields are generic fields that you can define to hold any data you might need on borrower enrollment that is not stored elsewhere in Koha. + These fields will appear on the enrollment page. + For example, if you were to create a "Summer Reading Club" archetype, and you need to keep track of which grade the reader will be entering after summer, + you would enterer 'Grade' in the 'Title' field and 'The grade the participant will be entering after summer' in the 'Description' field. + If you do not need to store any extra enrollment data for this club or service, just leave these blank. +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
    Require emailIf checked, a borrower will not be able to enroll unless he or she has a valid email address on record in the field specified in the System Preference 'AutoEmailPrimaryAddress'.
    + +
    + [% IF ( previousActionEdit ) %] + + [% ELSE %] + + [% END %] + +
    +
    +
    +
    + +
    + +
    + +
    +
    + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tt new file mode 100644 index 0000000..aa91494 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tt @@ -0,0 +1,258 @@ +[% USE KohaDates %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Tools › Clubs & services › Edit +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + + + + + +[% INCLUDE 'header.inc' %] + + + +
    +
    +
    +
    + + + + + + + + + + + + + [% IF ( clubsLoop ) %] + [% FOREACH clubsLoo IN clubsLoop %] + + + + + + + + + + [% END %] + [% ELSE %] + + [% END %] + + + + + + + + + + + + + + + + [% IF ( servicesLoop ) %] + [% FOREACH servicesLoo IN servicesLoop %] + + + + + + + + + + [% END %] +
    Clubs
    OwnerTitleDescriptionStart dateEnd date
    [% clubsLoo.branchcode %][% clubsLoo.title %][% clubsLoo.description %][% clubsLoo.startDate | $KohaDates %][% clubsLoo.endDate | $KohaDates %]EditDelete
    There are no clubs currently defined.
     
    Services
    OwnerTitleDescriptionStart dateEnd date
    [% servicesLoo.branchcode %][% servicesLoo.title %][% servicesLoo.description %][% servicesLoo.startDate | $KohaDates %][% servicesLoo.endDate | $KohaDates %]EditDelete
    + [% ELSE %] + There are no services currently defined. + [% END %] + + + [% IF ( previousActionSelectArchetype ) %] + + + [% IF ( previousActionEdit ) %] + + [% ELSE %] + + [% END %] + + [% IF ( previousActionEdit ) %] + + + [% ELSE %] + + [% END %] + + + + + + + + + + + + + + + + + [% IF ( casData1Title ) %] + + + + + + [% END %] + + [% IF ( casData2Title ) %] + + + + + + [% END %] + + [% IF ( casData3Title ) %] + + + + + + [% END %] + + + + + + + + + + + + + + + + +
    Edit a club or service
    Create new club or service
    + + + +
    + + + +
    + + + +
    + + + + [% casData1Desc %]
    + + + + [% casData2Desc %]
    + + + + [% casData3Desc %]
    + + + + + Optional: Leave blank for start date of today. +
    + + + + + Optional: Leave blank for no end date. +
    + [% IF ( previousActionEdit ) %] + + [% ELSE %] + + [% END %] +
    + + [% ELSE %] + + + + + + + + [% ELSE %] + No archetypes defined. + [% END %] + +
    Create new club or service
    + [% IF ( archetypes ) %] +
    + + + +
    + [% END %] + +
    +
    + +
    + +
    + +
    +
    + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt new file mode 100644 index 0000000..ab1c436 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt @@ -0,0 +1,95 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Tools › Clubs & services › Enroll +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] + + + +
    +
    +
    +
    +
    + [% IF ( previousActionEnroll ) %] + [% IF ( enrollSuccess ) %] +
    Patron with cardnumber '[% enrolledBarcode %]' enrolled succesfully!
    + [% ELSE %] +
    Failed to enroll patron with cardnumber '[% enrolledBarcode %]'!
    +
    + + [% IF failureMessage == 'NO_BORROWER' %]No patron was provided.[% END %] + [% IF failureMessage == 'NO_BORROWER_FOUND' %]No patron was found.[% END %] + [% IF failureMessage == 'NO_EMAIL' %]Email address required: no valid email address in borrower record.[% END %] + +
    + [% END %] + [% END %] + + +

    Enroll a patron in [% casTitle %]

    +
    + +
    +
    + + [% IF ( caseData1Title ) %] + + + + + + [% END %] + + [% IF ( caseData2Title ) %] + + + + + + [% END %] + + [% IF ( caseData3Title ) %] + + + + + + [% END %] + + + + + + + + + + +
    [% caseData1Desc %]
    [% caseData2Desc %]
    [% caseData3Desc %]
    +
    +
    + +
    +
    + +
    + +
    + +
    +
    + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt new file mode 100644 index 0000000..883cfc8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt @@ -0,0 +1,85 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Patrons › Account for [% firstname %] [% surname %] +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'patron-search.inc' %] + + + +
    +
    +
    +
    + + + + + + + + + + + + + + +[% IF ( enrolledClubsAndServicesLoop ) %] + + [% FOREACH enrolledClubsAndServicesLoo IN enrolledClubsAndServicesLoop %] + [% IF ( enrolledClubsAndServicesLoo.odd ) %][% ELSE %][% END %] + + + + + + + [% END %] + +[% ELSE %] + +[% END %] + + +[% IF ( CAN_user_clubs_services_enroll_borrower ) %] + + + + + + + + + + + + + + + [% IF ( enrollableClubsAndServicesLoop ) %] + + [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %] + [% IF ( enrollableClubsAndServicesLoo.odd ) %][% ELSE %][% END %] + + + + + + + [% END %] + [% ELSE %] + + [% END %] + +[% END %] +
    Currently Enrolled Clubs & Services
    TitleDescriptionLibraryType
    [% enrolledClubsAndServicesLoo.title %][% enrolledClubsAndServicesLoo.description %][% enrolledClubsAndServicesLoo.branchcode %][% enrolledClubsAndServicesLoo.type %][% IF ( CAN_user_clubs_services_enroll_borrower ) %]Cancel[% END %]
     
    Enroll In Clubs & Services
    TitleDescriptionLibraryType
    [% enrollableClubsAndServicesLoo.title %][% enrollableClubsAndServicesLoo.description %][% enrollableClubsAndServicesLoo.branchcode %][% enrollableClubsAndServicesLoo.type %]Enroll
    There Are No New Clubs Or Services To Enroll In
    + +
    +
    +
    +[% INCLUDE 'circ-menu.inc' %] +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tt new file mode 100644 index 0000000..04ce364 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tt @@ -0,0 +1,73 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Patrons › Account for [% firstname %] [% surname %] +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'patron-search.inc' %] + + + +
    +
    +
    +
    + +[% IF ( previousActionEnroll ) %] + [% IF ( enrollSuccess ) %] +
    Enrolled Succesfully!
    + + [% ELSE %] +
    Failed to Enroll!
    +
    Reason: [% failureMessage %]
    + + [% END %] +[% END %] + +[% IF ( caseData1Title ) %] +
    +

    Please Enter The Following Information

    +
    + + [% IF ( caseData1Title ) %] + + + + + + [% END %] + + [% IF ( caseData2Title ) %] + + + + + + [% END %] + + [% IF ( caseData3Title ) %] + + + + + + [% END %] + + + + + + +
    [% caseData1Desc %]
    [% caseData2Desc %]
    [% caseData3Desc %]
    +
    +
    +[% END %] + +
    +
    + +
    +[% INCLUDE 'circ-menu.inc' %] +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 4ab38c9..dc05348 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -65,6 +65,10 @@
    Upload patron images in a batch or one at a time
    [% END %] + [% IF ( CAN_user_clubs_services ) %] +
    Clubs & Services
    +
    Create and Edit Clubs & Services
    + [% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc index 5a07d95..5593486 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc @@ -32,7 +32,7 @@ [% IF ( virtualshelves ) %] [% IF ( listsview ) %]
  • [% ELSE %]
  • [% END %]my lists
  • [% END %] - + [% IF ( clubs_services ) %]
  • [% ELSE %]
  • [% END %]my clubs & services
  • [% END %][% ELSE %][% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices-enroll.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices-enroll.tt new file mode 100644 index 0000000..8180eb5 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices-enroll.tt @@ -0,0 +1,72 @@ +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog › Clubs & +[% FOREACH BORROWER_INF IN BORROWER_INFO %] + [% BORROWER_INF.firstname %][% BORROWER_INF.surname %] +[% END %] +[% INCLUDE 'doc-head-close.inc' %] + + + +
    +
    +[% INCLUDE 'masthead.inc' %] + +
    +
    + +[% IF ( previousActionEnroll ) %] + [% IF ( enrollSuccess ) %] +
    Enrolled Succesfully!
    + [% ELSE %] +
    Failed to Enroll!
    +
    Reason: [% failureMessage %]
    + [% END %] +[% END %] + +[% IF ( caseData1Title ) %] + + + + [% IF ( caseData1Title ) %] + + + + + + [% END %] + + [% IF ( caseData2Title ) %] + + + + + + [% END %] + + [% IF ( caseData3Title ) %] + + + + + + [% END %] + + + + + + + +
    Please Enter The Following Information
    [% caseData1Desc %]
    [% caseData2Desc %]
    [% caseData3Desc %]
    +[% END %] + +
    +
    +
    +
    +[% INCLUDE 'navigation.inc' %] +[% INCLUDE 'usermenu.inc' %] +
    +
    +
    +[% INCLUDE 'opac-bottom.inc' %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices.tt new file mode 100644 index 0000000..aa08696 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices.tt @@ -0,0 +1,84 @@ +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog › Clubs & Services for +[% FOREACH BORROWER_INF IN BORROWER_INFO %] + [% BORROWER_INF.firstname %][% BORROWER_INF.surname %] +[% END %] +[% INCLUDE 'doc-head-close.inc' %] + + + +
    +
    +[% INCLUDE 'masthead.inc' %] + +
    +
    + + + + + + + + + + + +[% IF ( enrolledClubsAndServicesLoop ) %] + + [% FOREACH enrolledClubsAndServicesLoo IN enrolledClubsAndServicesLoop %] + [% IF ( enrolledClubsAndServicesLoo.odd ) %][% ELSE %][% END %] + + + + + + + [% END %] + +[% ELSE %] + +[% END %] + + + + + + + + + + + + +[% IF ( enrollableClubsAndServicesLoop ) %] + + [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %] + [% IF ( enrollableClubsAndServicesLoo.odd ) %][% ELSE %][% END %] + + + + + + + [% END %] + +[% ELSE %] + +[% END %] +
    My Clubs & Services
    TitleDescriptionLibraryType
    [% enrolledClubsAndServicesLoo.title %][% enrolledClubsAndServicesLoo.description %][% enrolledClubsAndServicesLoo.branchcode %][% enrolledClubsAndServicesLoo.type %] + [% IF ( enrolledClubsAndServicesLoo.publicEnrollment ) %] + Cancel + [% END %] +
    You Are Not Enrolled In Any Clubs Or Services
     
    Enroll In Clubs & Services
    TitleDescriptionLibraryType
    [% enrollableClubsAndServicesLoo.title %][% enrollableClubsAndServicesLoo.description %][% enrollableClubsAndServicesLoo.branchcode %][% enrollableClubsAndServicesLoo.type %]Enroll
    There Are No New Clubs Or Services To Enroll In
    + +
    +
    +
    +
    +[% INCLUDE 'navigation.inc' %] +[% INCLUDE 'usermenu.inc' %] +
    +
    +
    +[% INCLUDE 'opac-bottom.inc' %] diff --git a/members/clubs_services.pl b/members/clubs_services.pl new file mode 100755 index 0000000..2e66b88 --- /dev/null +++ b/members/clubs_services.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +use Modern::Perl; + +use CGI; + +use C4::Output; +use C4::Search; +use C4::Auth; +use C4::Koha; +use C4::Members; +use C4::ClubsAndServices; + +my $query = new CGI; + +my $borrowernumber = $query->param('borrowernumber'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "members/clubs_services.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrow => 1 }, + debug => 1, + } +); + +# get borrower information .... +my $borrowerData = GetMemberDetails($borrowernumber); +$template->param( + borrowernumber => $borrowernumber, + surname => $borrowerData->{'surname'}, + firstname => $borrowerData->{'firstname'}, + cardnumber => $borrowerData->{'cardnumber'}, + address => $borrowerData->{'address'}, + city => $borrowerData->{'city'}, + phone => $borrowerData->{'phone'}, + email => $borrowerData->{'email'}, + categorycode => $borrowerData->{'categorycode'}, + categoryname => $borrowerData->{'description'}, + branchcode => $borrowerData->{'branchcode'}, + branchname => C4::Branch::GetBranchName( $borrowerData->{'branchcode'} ), +); + +if ( $query->param('action') eq 'cancel' ) { ## Cancel the enrollment in the passed club or service + CancelClubOrServiceEnrollment( $query->param('caseId') ); +} + +## Get the borrowers current clubs & services +my $enrolledClubsAndServices = GetEnrolledClubsAndServices($borrowernumber); +$template->param( enrolledClubsAndServicesLoop => $enrolledClubsAndServices ); + +## Get clubs & services the borrower can enroll in from the Intranet +my $enrollableClubsAndServices = GetAllEnrollableClubsAndServices( $borrowernumber, $query->cookie('branch') ); +$template->param( enrollableClubsAndServicesLoop => $enrollableClubsAndServices ); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/members/clubs_services_enroll.pl b/members/clubs_services_enroll.pl new file mode 100755 index 0000000..9b022f3 --- /dev/null +++ b/members/clubs_services_enroll.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl + +use Modern::Perl; + +use CGI; + +use C4::Output; +use C4::Search; +use C4::Auth; +use C4::Koha; +use C4::Members; +use C4::ClubsAndServices; + +my $query = new CGI; + +my $borrowernumber = $query->param('borrowernumber'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "members/clubs_services_enroll.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrow => 1 }, + debug => 1, + } +); + +# get borrower information .... +my $borrowerData = GetMemberDetails($borrowernumber); +$template->param( + borrowernumber => $borrowernumber, + surname => $borrowerData->{'surname'}, + firstname => $borrowerData->{'firstname'}, + cardnumber => $borrowerData->{'cardnumber'}, + address => $borrowerData->{'address'}, + city => $borrowerData->{'city'}, + phone => $borrowerData->{'phone'}, + email => $borrowerData->{'email'}, + categorycode => $borrowerData->{'categorycode'}, + categoryname => $borrowerData->{'description'}, + branchcode => $borrowerData->{'branchcode'}, + branchname => C4::Branch::GetBranchName( $borrowerData->{'branchcode'} ), +); + +if ( $query->param('action') eq 'enroll' ) { ## We were passed the necessary fields from the enrollment page. + my $casId = $query->param('casId'); + my $casaId = $query->param('casaId'); + my $data1 = $query->param('data1'); + my $data2 = $query->param('data2'); + my $data3 = $query->param('data3'); + + my $dateEnrolled; # Will default to Today + + my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, $data1, $data2, $data3, '', $borrowernumber ); + + $template->param( previousActionEnroll => 1, ); + + if ($success) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + +} elsif ( DoesEnrollmentRequireData( $query->param('casaId') ) ) { ## We were not passed any data, and the service requires extra data + my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') ); + my ($casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment, $casData1Title, + $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title, $casData1Desc, + $casData2Desc, $casData3Desc, $caseData1Desc, $caseData2Desc, $caseData3Desc, $timestamp + ) = GetClubOrServiceArchetype($casaId); + $template->param( + casId => $casId, + casTitle => $casTitle, + casDescription => $casDescription, + casStartDate => $casStartDate, + casEndDate => $casEndDate, + casTimeStamp => $casTimestamp, + casaId => $casaId, + casaType => $casaType, + casaTitle => $casaTitle, + casaDescription => $casaDescription, + casaPublicEnrollment => $casaPublicEnrollment, + + borrowernumber => $borrowernumber, + ); + + if ($caseData1Title) { + $template->param( caseData1Title => $caseData1Title ); + } + if ($caseData2Title) { + $template->param( caseData2Title => $caseData2Title ); + } + if ($caseData3Title) { + $template->param( caseData3Title => $caseData3Title ); + } + + if ($caseData1Desc) { + $template->param( caseData1Desc => $caseData1Desc ); + } + if ($caseData2Desc) { + $template->param( caseData2Desc => $caseData2Desc ); + } + if ($caseData3Desc) { + $template->param( caseData3Desc => $caseData3Desc ); + } + +} else { ## We were not passed any data, but the enrollment does not require any + + my $casId = $query->param('casId'); + my $casaId = $query->param('casaId'); + + my $dateEnrolled; # Will default to Today + + my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber ); + + $template->param( previousActionEnroll => 1, ); + + if ($success) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + +} +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/misc/cronjobs/mailinglist/mailinglist.pl b/misc/cronjobs/mailinglist/mailinglist.pl new file mode 100644 index 0000000..1fd57fa --- /dev/null +++ b/misc/cronjobs/mailinglist/mailinglist.pl @@ -0,0 +1,200 @@ +#!/usr/bin/perl -w +#----------------------------------- +# Description: This script generates e-mails +# sent to subscribers of e-mail lists from +# the New Items E-mail List archetype +# in the ClubsAndServices module +# +# 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 + +# DOCUMENTATION +# This script utilizes the 'New Items E-mail List' archetype +# from the ClubsAndServices.pm module. +# If you do not have this archtype, create an archetype of that name +# with club/service data 1 as Itemtype, and club/service data 2 as Callnumber. +# No other data is needed. + +# The script grabs all new items with the given itemtype and callnumber. +# When creating lists to use this script, use % as a wildcard. +# If all your science fiction books are of itemtype FIC and have a callnumber +# beginning with 'FIC SF', then you would create a service based on this +# Archetype and input 'FIC' as the Itemtype, and 'FIC SF%' as the Callnumber. + +# The e-mails are based on the included HTML::Template file mailinglist.tmpl +# If you would like to modify the style of the e-mail, just alter that file. + +use Modern::Perl; + +use C4::Context; +use C4::Dates; +use C4::Message; + +use Mail::Sendmail; +use Getopt::Long; +use Date::Calc qw(Add_Delta_Days); +use Template; + +use Data::Dumper; + +use Getopt::Long; +my ( $name, $start, $end, $help ); +my $verbose = 0; +GetOptions( + 'name=s' => \$name, + 'start=i' => \$start, + 'end=i' => \$end, + 'verbose' => \$verbose, + 'help' => \$help, +); + +if ($help) { + print +"\nmailinglist.pl --name [Club Name] --start [Days Ago] --end [Days Ago]\n\n"; + print +"Example: 'mailinglist.pl --name \"My Club' --start 7 --end 0\" will send\na list of items cataloged since last week to the members of the club\nnamed MyClub\n\n"; + print +"All arguments are optional. Defaults are to run for all clubs, with dates from 7 to 0 days ago.\n\n"; + exit; +} + +unless ( C4::Context->preference('OPACBaseURL') ) { + die("Koha System Preference 'OPACBaseURL' is not set!"); +} +my $opacUrl = 'http://' . C4::Context->preference('OPACBaseURL'); + +my $dbh = C4::Context->dbh; +my $sth; + +## Step 0: Get the date from last week +#Gets localtime on the computer executed on. +my ( $d, $m, $y ) = (localtime)[ 3, 4, 5 ]; + +## 0.1 Get start date +#Adjust the offset to either a neg or pos number of days. +my $offset = -7; +if ($start) { $offset = $start * -1; } + +#Formats the date and sets the offset to subtract 60 days form the #current date. This works with the first line above. +my ( $y2, $m2, $d2 ) = Add_Delta_Days( $y + 1900, $m + 1, $d, $offset ); + +#Checks to see if the month is greater than 10. +if ( $m2 < 10 ) { $m2 = "0" . $m2; } + +#Put in format of mysql date YYYY-MM-DD +my $afterDate = $y2 . '-' . $m2 . '-' . $d2; +if ($verbose) { print "Date $offset Days Ago: $afterDate\n"; } + +## 0.2 Get end date +#Adjust the offset to either a neg or pos number of days. +$offset = 0; +if ($end) { $offset = $end * -1; } +( $y2, $m2, $d2 ) = Add_Delta_Days( $y + 1900, $m + 1, $d, $offset ); +if ( $m2 < 10 ) { $m2 = "0" . $m2; } +my $beforeDate = $y2 . '-' . $m2 . '-' . $d2; +if ($verbose) { print "Date $offset Days Ago: $beforeDate\n"; } + +if ($name) { + + $sth = $dbh->prepare( + "SELECT * FROM clubsAndServices WHERE clubsAndServices.title = ?"); + $sth->execute($name); + +} +else { ## No name given, process all items + + ## Grab the "New Items E-mail List" Archetype + $sth = $dbh->prepare( +"SELECT * FROM clubsAndServicesArchetypes WHERE code = 'NEW_ITEMS_EMAIL_LIST'" + ); + $sth->execute; + my $archetype = $sth->fetchrow_hashref(); + + ## Grab all the mailing lists + $sth = $dbh->prepare( + "SELECT * FROM clubsAndServices WHERE clubsAndServices.casaId = ?"); + $sth->execute( $archetype->{'casaId'} ); + +} + +## For each mailing list, generate the list of new items, then get the subscribers, then mail the list to the subscribers +while ( my $mailingList = $sth->fetchrow_hashref() ) { + ## Get the new Items + if ($verbose) { + print "###\nWorking On Mailing List: " . $mailingList->{'title'} . "\n"; + } + my $itemtype = $mailingList->{'casData1'}; + my $callnumber = $mailingList->{'casData2'}; + ## If either are empty, ignore them with a wildcard + if ( !$itemtype ) { $itemtype = '%'; } + if ( !$callnumber ) { $callnumber = '%'; } + + my $sth2 = $dbh->prepare( + "SELECT + biblio.author, + biblio.title, + biblio.biblionumber, + biblioitems.isbn, + items.itemcallnumber + FROM + items, biblioitems, biblio + WHERE + biblio.biblionumber = biblioitems.biblionumber AND + biblio.biblionumber = items.biblionumber AND + biblioitems.itemtype LIKE ? AND + items.itemcallnumber LIKE ? AND + dateaccessioned >= ? AND + dateaccessioned <= ? + " + ); + $sth2->execute( $itemtype, $callnumber, $afterDate, $beforeDate ); + my @newItems; + while ( my $row = $sth2->fetchrow_hashref ) { + $row->{'opacUrl'} = $opacUrl; + push( @newItems, $row ); + } + print Dumper (@newItems); + $sth2->finish; + my $newItems = \@newItems; + my $template = Template->new(); + + my $vars = { + listTitle => $mailingList->{'title'}, + newItemsLoop => $newItems, + }; + my $email = $template->process( 'mailinglist.tt', $vars ); + + ## Get all the members subscribed to this list + $sth2 = $dbh->prepare( + "SELECT * FROM clubsAndServicesEnrollments, borrowers + WHERE + borrowers.borrowernumber = clubsAndServicesEnrollments.borrowernumber AND + clubsAndServicesEnrollments.dateCanceled IS NULL AND + clubsAndServicesEnrollments.casId = ?" + ); + $sth2->execute( $mailingList->{'casId'} ); + while ( my $borrower = $sth2->fetchrow_hashref() ) { + if ($verbose) { + print "Borrower Email: " . $borrower->{'email'} . "\n"; + } + + my $letter; + $letter->{'title'} = + 'New Items @ Your Library: ' . $mailingList->{'title'}; + $letter->{'content'} = $email; + $letter->{'code'} = 'MAILINGLIST'; + C4::Message->enqueue( $letter, $borrower, 'email' ); + } +} diff --git a/misc/cronjobs/mailinglist/mailinglist.tt b/misc/cronjobs/mailinglist/mailinglist.tt new file mode 100644 index 0000000..7cafb90 --- /dev/null +++ b/misc/cronjobs/mailinglist/mailinglist.tt @@ -0,0 +1,34 @@ + + + + +

    New Items @ Your Library!

    +

    [% listTitle %]

    + + [% FOREACH item IN newItemsLoop %] + +

    + [% item.title %] +

    +
    + +
    + + + + + +
    + View in the catalog. + +

    +

      +
    • Author: [% item.author %]
    • +
    • ISBN: [% item.isbn %]
    • +
    • Call Number: [% item.itemcallnumber %]
    • +
    +

    +
    + [% END %] + + diff --git a/opac/opac-clubsAndServices-enroll.pl b/opac/opac-clubsAndServices-enroll.pl new file mode 100755 index 0000000..33014be --- /dev/null +++ b/opac/opac-clubsAndServices-enroll.pl @@ -0,0 +1,145 @@ +#!/usr/bin/perl + +# 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; + +use CGI; + +use C4::Auth; +use C4::Koha; +use C4::Circulation; +use C4::Reserves; +use C4::Members; +use C4::Output; +use C4::Biblio; +use C4::Items; +use C4::Dates qw/format_date/; +use C4::Letters; +use C4::Branch; # GetBranches +use C4::ClubsAndServices; + +my $query = new CGI; + +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-clubsAndServices-enroll.tmpl", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => {borrow => 1}, + debug => 1, + }); + +# get borrower information .... +my ( $borr ) = GetMemberDetails( $borrowernumber ); + +$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} ); +$borr->{'expiry'} = format_date( $borr->{'expiry'} ); +$borr->{'dateofbirth'} = format_date( $borr->{'dateofbirth'} ); +$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} ); + + +if ( $query->param('action') eq 'enroll' ) { ## We were passed the necessary fields from the enrollment page. + my $casId = $query->param('casId'); + my $casaId = $query->param('casaId'); + my $data1 = $query->param('data1'); + my $data2 = $query->param('data2'); + my $data3 = $query->param('data3'); + + my $dateEnrolled; # Will default to Today + + my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, $data1, $data2, $data3, '', $borrowernumber ); + + $template->param( + previousActionEnroll => 1, + ); + + if ( $success ) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + +} elsif ( DoesEnrollmentRequireData( $query->param('casaId') ) ) { ## We were not passed any data, and the service requires extra data + my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') ); + my ( $casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment, + $casData1Title, $casData2Title, $casData3Title, + $caseData1Title, $caseData2Title, $caseData3Title, + $casData1Desc, $casData2Desc, $casData3Desc, + $caseData1Desc, $caseData2Desc, $caseData3Desc, + $timestamp )= GetClubOrServiceArchetype( $casaId ); + $template->param( + casId => $casId, + casTitle => $casTitle, + casDescription => $casDescription, + casStartDate => $casStartDate, + casEndDate => $casEndDate, + casTimeStamp => $casTimestamp, + casaId => $casaId, + casaType => $casaType, + casaTitle => $casaTitle, + casaDescription => $casaDescription, + casaPublicEnrollment => $casaPublicEnrollment, + + borrowernumber => $borrowernumber, + ); + + if ( $caseData1Title ) { + $template->param( caseData1Title => $caseData1Title ); + } + if ( $caseData2Title ) { + $template->param( caseData2Title => $caseData2Title ); + } + if ( $caseData3Title ) { + $template->param( caseData3Title => $caseData3Title ); + } + + if ( $caseData1Desc ) { + $template->param( caseData1Desc => $caseData1Desc ); + } + if ( $caseData2Desc ) { + $template->param( caseData2Desc => $caseData2Desc ); + } + if ( $caseData3Desc ) { + $template->param( caseData3Desc => $caseData3Desc ); + } + +} else { ## We were not passed any data, but the enrollment does not require any + + my $casId = $query->param('casId'); + my $casaId = $query->param('casaId'); + + my $dateEnrolled; # Will default to Today + + my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber ); + $template->param( + previousActionEnroll => 1, + ); + + if ( $success ) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( errorMessage => $errorMessage ); + } + + +} + +$template->param( clubs_services => 1 ); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/opac/opac-clubsAndServices.pl b/opac/opac-clubsAndServices.pl new file mode 100755 index 0000000..d782e38 --- /dev/null +++ b/opac/opac-clubsAndServices.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# 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; + +use CGI; + +use C4::Auth; +use C4::Koha; +use C4::Circulation; +use C4::Reserves; +use C4::Members; +use C4::Output; +use C4::Biblio; +use C4::Items; +use C4::Dates qw/format_date/; +use C4::Letters; +use C4::Branch; # GetBranches +use C4::ClubsAndServices; + +my $query = new CGI; + +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-clubsAndServices.tmpl", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => {borrow => 1}, + debug => 1, + }); + +# get borrower information .... +my ( $borr ) = GetMemberDetails( $borrowernumber ); + +$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} ); +$borr->{'expiry'} = format_date( $borr->{'expiry'} ); +$borr->{'dateofbirth'} = format_date( $borr->{'dateofbirth'} ); +$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} ); + +if ( $query->param('action') eq 'cancel' ) { ## Cancel the enrollment in the passed club or service + CancelClubOrServiceEnrollment( $query->param('caseId') ); +} + +## Get the borrowers current clubs & services +my $enrolledClubsAndServices = GetEnrolledClubsAndServices( $borrowernumber ); +$template->param( enrolledClubsAndServicesLoop => $enrolledClubsAndServices ); + +## Get clubs & services the borrower can enroll in from the OPAC +my $enrollableClubsAndServices = GetPubliclyEnrollableClubsAndServices( $borrowernumber ); +$template->param( enrollableClubsAndServicesLoop => $enrollableClubsAndServices ); + +$template->param( clubs_services => 1 ); + +output_html_with_http_headers $query, $cookie, $template->output; -- 1.7.2.5