From 585a181244ddeb273d3d96450a128d577f1bc0d8 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 17 Feb 2012 15:07:22 -0500 Subject: [PATCH] Clubs & Services 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. http://bugs.koha-community.org/show_bug.cgi?id=7572 --- C4/ClubsAndServices.pm | 1192 ++++++++++++++++++++ cataloguing/addbiblio.pl | 2 + circ/circulation.pl | 4 + clubs_services/clubs_services.pl | 38 + clubs_services/clubs_services_enrollments.pl | 39 + clubs_services/edit_archetypes.pl | 194 ++++ clubs_services/edit_clubs_services.pl | 200 ++++ clubs_services/enroll_clubs_services.pl | 104 ++ installer/data/mysql/kohastructure.sql | 79 ++ installer/data/mysql/updatedatabase.pl | 70 ++ .../intranet-tmpl/prog/en/includes/circ-menu.inc | 1 + .../prog/en/includes/members-menu.inc | 2 + .../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 | 325 ++++++ .../clubs_services/enroll_clubs_services.tt | 89 ++ .../prog/en/modules/members/clubs_services.tt | 84 ++ .../en/modules/members/clubs_services_enroll.tt | 73 ++ .../prog/en/modules/tools/tools-home.tt | 2 + 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 | 58 + members/clubs_services_enroll.pl | 133 +++ misc/cronjobs/mailinglist/mailinglist.pl | 178 +++ misc/cronjobs/mailinglist/mailinglist.tmpl | 35 + opac/opac-clubsAndServices-enroll.pl | 146 +++ opac/opac-clubsAndServices.pl | 69 ++ 30 files changed, 3712 insertions(+), 2 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 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.tmpl create mode 100755 opac/opac-clubsAndServices-enroll.pl create mode 100755 opac/opac-clubsAndServices.pl diff --git a/C4/ClubsAndServices.pm b/C4/ClubsAndServices.pm new file mode 100644 index 0000000..fe9969b --- /dev/null +++ b/C4/ClubsAndServices.pm @@ -0,0 +1,1192 @@ +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 2007 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 strict; + +require Exporter; + +use C4::Context; + +use DBI; + +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 +); + +## function 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 +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, 1, "No Type Given" ); + } + if ( ! $title ) { + return ( 0, 2, "No Title Given" ); + } + if ( ! $description ) { + return ( 0, 3, "No Description Given" ); + } + + 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 = "Database Failure"; + $errorCode = 4; + } + + return( $success, $errorCode, $errorMessage ); + +} + +## function 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 +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, 1, "No Id Given" ); + } + if ( ! $type ) { + return ( 0, 2, "No Type Given" ); + } + if ( ! $title ) { + return ( 0, 3, "No Title Given" ); + } + if ( ! $description ) { + return ( 0, 4, "No Description Given" ); + } + + 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 $errorCode = 6, my $errorMessage = $sth->errstr() ); + $sth->finish; + + return $success; + +} + +## function 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 +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; +} + +## function 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 +sub AddClubOrService { + my ( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) = @_; + + ## Check for all neccessary parameters + if ( ! $casaId ) { + return ( 0, 1, "No Archetype Given" ); + } + if ( ! $title ) { + return ( 0, 2, "No Title Given" ); + } + if ( ! $description ) { + return ( 0, 3, "No Description Given" ); + } + + 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 = "Database Failure"; + $errorCode = 5; + } + + return( $success, $errorCode, $errorMessage ); +} + +## function 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 +sub UpdateClubOrService { + my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate ) = @_; + + ## Check for all neccessary parameters + if ( ! $casId ) { + return ( 0, 1, "No casId Given" ); + } + if ( ! $casaId ) { + return ( 0, 2, "No Archetype Given" ); + } + if ( ! $title ) { + return ( 0, 3, "No Title Given" ); + } + if ( ! $description ) { + return ( 0, 4, "No Description Given" ); + } + + 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 = "Database Failure"; + $errorCode = 5; + } + + return( $success, $errorCode, $errorMessage ); +} + +## function 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 +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; +} + +## function 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 +sub EnrollInClubOrService { + my ( $casaId, $casId, $borrowerCardnumber, $dateEnrolled, $data1, $data2, $data3, $branchcode, $borrowernumber ) = @_; + + ## Check for all neccessary parameters + unless ( $casaId ) { + return ( 0, 1, "No casaId Given" ); + } + unless ( $casId ) { + return ( 0, 2, "No casId Given" ); + } + unless ( ( $borrowerCardnumber || $borrowernumber ) ) { + return ( 0, 3, "No Borrower Given" ); + } + + my $member; + if ( $borrowerCardnumber ) { + $member = C4::Members::GetMember( cardnumber => $borrowerCardnumber ); + } elsif ( $borrowernumber ) { + $member = C4::Members::GetMember( borrowernumber => $borrowernumber ); + } else { + return ( 0, 3, "No Borrower Given" ); + } + + unless ( $member ) { + return ( 0, 4, "No Matching Borrower Found" ); + } + + my $casa = GetClubOrServiceArchetype( $casaId, 1 ); + if ( $casa->{'caseRequireEmail'} ) { + my $AutoEmailPrimaryAddress = C4::Context->preference('AutoEmailPrimaryAddress'); + unless( $member->{ $AutoEmailPrimaryAddress } ) { + return( 0, 4, "Email Address Required: No Valid Email Address In Borrower Record" ); + } + } + + $borrowernumber = $member->{'borrowernumber'}; + + if ( isEnrolled( $casId, $borrowernumber ) ) { return ( 0, 5, "Member is already 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; +} + +## function 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 +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; +} + +## function 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 +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; +} + +## function 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 +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; + +} + + +## function GetClubOrService +## Returns information about a club or service +## Input: +## $casId: Id of club or service to get +## Output: +## $results: +## $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode +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'} + ); + +} + +## function 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 +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; +} + +## function 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: +## $results: +## ( $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 +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'} + ); +} + +## function 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 +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; + } +} + + +## function 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 +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; +} + +## function GetEnrolledClubsAndServices +## Returns information about clubs and services +## the given borrower is enrolled in. +## Input: +## $borrowernumber +## Output: +## $results: +## Reference to an array of associated arrays +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; + +} + +## function GetPubliclyEnrollableClubsAndServices +## Returns information about clubs and services +## the given borrower can enroll in. +## Input: +## $borrowernumber +## Output: +## $results: +## Reference to an array of associated arrays +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; + +} + +## function GetAllEnrollableClubsAndServices +## Returns information about clubs and services +## the given borrower can enroll in. +## Input: +## $borrowernumber +## Output: +## $results: +## Reference to an array of associated arrays +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; +} + +## This should really be moved to a new module, C4::ClubsAndServices::BestSellersClub +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 title 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 = "Automatic Reserve for Bestsellers Club", + $title, + my $checkitem, + my $found, + my $expire_date + ); + $priority++; + } +} + +1; + +__END__ + +=back + +=head1 AUTHOR + +Kyle Hall + +=cut diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index f29e410..eb6046a 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; @@ -952,6 +953,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")){ if ($frameworkcode eq 'FA'){ diff --git a/circ/circulation.pl b/circ/circulation.pl index e8d22cb..88e1bd5 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -35,6 +35,7 @@ use C4::Members; use C4::Biblio; use C4::Reserves; use C4::Context; +use C4::ClubsAndServices; use CGI::Session; use C4::Members::Attributes qw(GetBorrowerAttributes); @@ -99,6 +100,7 @@ my $findborrower = $query->param('findborrower'); $findborrower =~ s|,| |g; my $borrowernumber = $query->param('borrowernumber'); + $branch = C4::Context->userenv->{'branch'}; $printer = C4::Context->userenv->{'branchprinter'}; @@ -720,6 +722,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..4ef58bd --- /dev/null +++ b/clubs_services/clubs_services.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl +use strict; +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 => 1, + flagsrequired => { parameters => 1 }, + debug => 1, + } +); + +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..8360109 --- /dev/null +++ b/clubs_services/clubs_services_enrollments.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +use strict; +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 => 1, + flagsrequired => { parameters => 1 }, + debug => 1, + } +); + +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..7e5de88 --- /dev/null +++ b/clubs_services/edit_archetypes.pl @@ -0,0 +1,194 @@ +#!/usr/bin/perl +use strict; +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 => { parameters => 1 }, + debug => 1, + } +); + +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, $errorCode, $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( failureMessage => $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, $errorCode, $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( failureMessage => $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..2e1b7ea --- /dev/null +++ b/clubs_services/edit_clubs_services.pl @@ -0,0 +1,200 @@ +#!/usr/bin/perl +use strict; +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_clubs_services.tmpl", + query => $query, + type => "intranet", + authnotrequired => 1, + flagsrequired => { parameters => 1 }, + debug => 1, + } +); + +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 = $query->param('startDate'); + my $endDate = $query->param('endDate'); + + my ( $createdSuccessfully, $errorCode, $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( failureMessage => $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 = $query->param('startDate'); + my $endDate = $query->param('endDate'); + + my ( $createdSuccessfully, $errorCode, $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( failureMessage => $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..68b3178 --- /dev/null +++ b/clubs_services/enroll_clubs_services.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl +use strict; +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 => 1, + flagsrequired => { parameters => 1 }, + debug => 1, + } +); + +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, $errorCode, $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( failureMessage => $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/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 67149c9d..ad751d2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2687,6 +2687,85 @@ CREATE TABLE `bibliocoverimage` ( CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- 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' 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`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Table structure for table `clubsAndServicesArchetypes` +-- + +DROP TABLE IF EXISTS `clubsAndServicesArchetypes`; +CREATE TABLE `clubsAndServicesArchetypes` ( + `casaId` int(11) NOT NULL auto_increment, + `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`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Preset data for ClubsAndServicesArchetypes +-- + +INSERT INTO `clubsAndServicesArchetypes` ( `casaId` , `type` , `title` , `description` , `publicEnrollment` , `casData1Title` , `casData2Title` , `casData3Title` , `caseData1Title` , `caseData2Title` , `caseData3Title` , `casData1Desc` , `casData2Desc` , `casData3Desc` , `caseData1Desc` , `caseData2Desc` , `caseData3Desc` , `branchcode` , `last_updated`, `system_defined` ) +VALUES ( '', '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', '', '', '', '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.', '', '', '', 'NO_L', '2009-09-28 10:29:01', 1 ); +INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `branchcode`, `last_updated`, `system_defined` ) +VALUES ( '', '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, 'NO_L', '2009-05-17 08:57:10', 1); + +-- +-- 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' 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`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + /*!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/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d2d9d97..def0202 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4670,6 +4670,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +<<<<<<< HEAD $DBversion = "3.07.00.013"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define available export options on OPAC detail page.','','free');"); @@ -4712,6 +4713,75 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.07.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + + $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) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + $dbh->do("CREATE TABLE clubsAndServicesArchetypes ( + casaId int(11) NOT NULL auto_increment, + 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) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + $dbh->do("REPLACE INTO clubsAndServicesArchetypes ( casaId , type , title , description , publicEnrollment , casData1Title , casData2Title , casData3Title , caseData1Title , caseData2Title , caseData3Title , casData1Desc , casData2Desc , casData3Desc , caseData1Desc , caseData2Desc , caseData3Desc , branchcode , last_updated, system_defined ) +VALUES ( '', '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', '', '', '', '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, '2009-09-28 10:29:01', '1' ); +"); + $dbh->do("REPLACE INTO clubsAndServicesArchetypes (casaId, type, title, description, publicEnrollment, casData1Title, casData2Title, casData3Title, caseData1Title, caseData2Title, caseData3Title, casData1Desc, casData2Desc, casData3Desc, caseData1Desc, caseData2Desc, caseData3Desc, branchcode, last_updated, system_defined) +VALUES ( '', '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, NULL, '2009-05-17 08:57:10', '1'); +"); + + $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) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + print "Upgrade to $DBversion done ( Added tables for Clubs & Services )\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) 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 00dc445..dd0485d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -69,6 +69,7 @@ [% IF ( CAN_user_updatecharges ) %] [% IF ( finesview ) %]
  • [% ELSE %]
  • [% END %]Fines
  • [% END %] + [% IF ( clubs_services ) %]
  • [% ELSE %]
  • [% END %]Clubs & Services
  • [% IF ( intranetreadinghistory ) %][% IF ( readingrecordview ) %]
  • [% ELSE %]
  • [% END %]Circulation History
  • [% END %] [% IF ( CAN_user_parameters ) %][% IF ( logview ) %]
  • [% ELSE %]
  • [% END %]Modification Log
  • [% END %] [% IF ( EnhancedMessagingPreferences ) %] 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 cadd1cb..e581af5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc @@ -10,5 +10,7 @@ [% IF ( EnhancedMessagingPreferences ) %] [% END %] [% IF ( sentnotices ) %]
  • [% ELSE %]
  • [% END %]Notices
  • + [% IF clubs_services %]
  • [% ELSE %]
  • [% END %]">Clubs & Services
  • + [% END %] 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 1d0e07a..aa4aa0d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -658,7 +658,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..685a02e --- /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..4878ef0 --- /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..b70f379 --- /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 %] + + + +
    + + + +
    + + + +
    + + + Yes + No +
    + +
    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 reading 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 E-mailIf checked, a borrower will not be able to enroll unless he or she has a valid e-mail 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..63a6eae --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tt @@ -0,0 +1,325 @@ +[% 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 %][% clubsLoo.endDate %]EditDelete
    There are no Clubs currently defined.
     
    Services
    OwnerTitleDescriptionStart DateEnd Date
    [% servicesLoo.branchcode %][% servicesLoo.title %][% servicesLoo.description %][% servicesLoo.startDate %][% servicesLoo.endDate %]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 %]
    Date format is : YYYY-MM-DD
    + + + + + Show Calendar + + + + Optional: Leave blank for start date of today. +
    + + + + + Show Calendar + + + + 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..0f7de28 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt @@ -0,0 +1,89 @@ +[% 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 %]'!
    +
    Reason: [% failureMessage %]
    + [% 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..6fa7127 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt @@ -0,0 +1,84 @@ +[% 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 ( enrollableClubsAndServicesLoop ) %] + + [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %] + [% IF ( enrollableClubsAndServicesLoo.odd ) %][% ELSE %][% END %] + + + + + + + [% END %] +[% ELSE %] + +[% END %] + + +
    Currently Enrolled Clubs & Services
    TitleDescriptionLibraryType
    [% enrolledClubsAndServicesLoo.title %][% enrolledClubsAndServicesLoo.description %][% enrolledClubsAndServicesLoo.branchcode %][% enrolledClubsAndServicesLoo.type %]Cancel
     
    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..87bca56 --- /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 b71a1ee..5788843 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 @@ -55,6 +55,8 @@
    Upload patron images in batch or one at a time
    [% END %] +
    Clubs & Services
    +
    Create and Edit Clubs & Services
    diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc index 352d6b3..8d6bf2b 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..39e4b86 --- /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..b1cb20c --- /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..5a22a79 --- /dev/null +++ b/members/clubs_services.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl +use strict; + +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..920d4be --- /dev/null +++ b/members/clubs_services_enroll.pl @@ -0,0 +1,133 @@ +#!/usr/bin/perl +use strict; + +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, $errorCode, $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( failureMessage => $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, $errorCode, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber ); + + $template->param( + previousActionEnroll => 1, + ); + + if ( $success ) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( failureMessage => $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..261c7a8 --- /dev/null +++ b/misc/cronjobs/mailinglist/mailinglist.pl @@ -0,0 +1,178 @@ +#!/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 strict; + +use C4::Context; +use C4::Dates; +use C4::Message; + +use Mail::Sendmail; +use Getopt::Long; +use Date::Calc qw(Add_Delta_Days); +use HTML::Template::Pro; + +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 title = 'New Items E-mail 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 = HTML::Template->new( filename => 'mailinglist.tmpl' ); + $template->param( + listTitle => $mailingList->{'title'}, + newItemsLoop => $newItems, + ); + my $email = $template->output; + + ## 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'); + } + + +} \ No newline at end of file diff --git a/misc/cronjobs/mailinglist/mailinglist.tmpl b/misc/cronjobs/mailinglist/mailinglist.tmpl new file mode 100644 index 0000000..3b4d933 --- /dev/null +++ b/misc/cronjobs/mailinglist/mailinglist.tmpl @@ -0,0 +1,35 @@ + + + + +

    New Items @ Your Library!

    +

    + + +/cgi-bin/koha/opac-detail.pl?bib="> +

    + +

    +
    +
    + + + + +
    + /cgi-bin/koha/opac-detail.pl?bib=">http://images.amazon.com/images/P/.01.TZZZZZZZ.jpghttp://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif" alt="" class="thumbnail" /> + +

    +

      +
    • Author:
    • +
    • ISBN:
    • +
    • Call Number:
    • +
    +
    +

    +
    + + + + + diff --git a/opac/opac-clubsAndServices-enroll.pl b/opac/opac-clubsAndServices-enroll.pl new file mode 100755 index 0000000..41e0553 --- /dev/null +++ b/opac/opac-clubsAndServices-enroll.pl @@ -0,0 +1,146 @@ +#!/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 strict; + +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, $errorCode, $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( failureMessage => $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, $errorCode, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber ); + $template->param( + previousActionEnroll => 1, + ); + + if ( $success ) { + $template->param( enrollSuccess => 1 ); + } else { + $template->param( enrollFailure => 1 ); + $template->param( failureMessage => $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..4c76366 --- /dev/null +++ b/opac/opac-clubsAndServices.pl @@ -0,0 +1,69 @@ +#!/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 strict; + +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