[Koha-patches] [PATCH] Clubs & Services ported from dev_week

Kyle Hall kyle.m.hall at gmail.com
Wed Jan 21 16:25:33 CET 2009


I would ignore this one for now. There are still some more additions I
need to make to this feature.

Kyle

http://www.kylehall.info
Information Technology
Crawford County Federated Library System ( http://www.ccfls.org )




On Wed, Dec 24, 2008 at 10:35 AM, Kyle Hall <kyle.m.hall at gmail.com> wrote:
> ---
>  C4/ClubsAndServices.pm                             | 1011 ++++++++++++++++++++
>  clubs_services/clubs_services.pl                   |   35 +
>  clubs_services/edit_archetypes.pl                  |  202 ++++
>  clubs_services/edit_clubs_services.pl              |  177 ++++
>  clubs_services/enroll_clubs_services.pl            |   94 ++
>  installer/data/mysql/kohastructure.sql             |   68 ++
>  installer/data/mysql/updatedatabase.pl             |   78 ++
>  .../intranet-tmpl/prog/en/includes/circ-menu.inc   |    1 +
>  .../prog/en/includes/members-menu.inc              |    2 +
>  .../en/modules/clubs_services/clubs_services.tmpl  |   88 ++
>  .../en/modules/clubs_services/edit_archetypes.tmpl |  249 +++++
>  .../clubs_services/edit_clubs_services.tmpl        |  257 +++++
>  .../clubs_services/enroll_clubs_services.tmpl      |   89 ++
>  .../prog/en/modules/members/clubs_services.tmpl    |   84 ++
>  .../en/modules/members/clubs_services_enroll.tmpl  |   73 ++
>  .../prog/en/modules/tools/tools-home.tmpl          |    4 +
>  members/clubs_services.pl                          |   50 +
>  members/clubs_services_enroll.pl                   |  125 +++
>  18 files changed, 2687 insertions(+), 0 deletions(-)
>  create mode 100644 C4/ClubsAndServices.pm
>  create mode 100755 clubs_services/clubs_services.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.tmpl
>  create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tmpl
>  create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tmpl
>  create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tmpl
>  create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tmpl
>  create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tmpl
>  create mode 100755 members/clubs_services.pl
>  create mode 100755 members/clubs_services_enroll.pl
>
> diff --git a/C4/ClubsAndServices.pm b/C4/ClubsAndServices.pm
> new file mode 100644
> index 0000000..e28f9ab
> --- /dev/null
> +++ b/C4/ClubsAndServices.pm
> @@ -0,0 +1,1011 @@
> +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
> +
> + at ISA = qw( Exporter );
> + at EXPORT = qw(
> +  AddClubOrServiceArchetype
> +  UpdateClubOrServiceArchetype
> +  DeleteClubOrServiceArchetype
> +
> +  AddClubOrService
> +  UpdateClubOrService
> +  DeleteClubOrService
> +
> +  EnrollInClubOrService
> +  GetEnrollments
> +  GetClubsAndServices
> +  GetClubOrService
> +  GetClubsAndServicesArchetypes
> +  GetClubOrServiceArchetype
> +  DoesEnrollmentRequireData
> +  CancelClubOrServiceEnrollment
> +  GetEnrolledClubsAndServices
> +  GetPubliclyEnrollableClubsAndServices
> +  GetAllEnrollableClubsAndServices
> +
> +  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
> +##   $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,
> +       $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, branchcode, timestamp )
> +                        VALUES ( NULL, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
> +  $sth->execute( $type, $title, $description, $publicEnrollment, $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
> +## 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
> +     ) = @_;
> +
> +  ## 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 = ?,
> +                        timestamp = NOW() WHERE casaId = ?");
> +#  $sth = $dbh->prepare("INSERT INTO clubsAndServicesArchetypes ( casaId, type, title, description, publicEnrollment, timestamp )
> +#                        VALUES ( NULL, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
> +  $sth->execute( $type, $title, $description, $publicEnrollment,
> +                 $casData1Title, $casData2Title, $casData3Title,
> +                 $caseData1Title, $caseData2Title, $caseData3Title,
> +                 $casData1Desc, $casData2Desc, $casData3Desc,
> +                 $caseData1Desc, $caseData2Desc, $caseData3Desc,
> +                 $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;
> +
> +  if ( $success ) {
> +    $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casaId = ?");
> +    $sth->execute( $casaId ) or $success = 0;
> +    $sth->finish;
> +  }
> +
> +  if ( $success ) {
> +    $sth = $dbh->prepare("DELETE FROM clubsAndServicesArchetypes WHERE casaId = ?");
> +    $sth->execute( $casaId ) or $success = 0;
> +    $sth->finish;
> +  }
> +
> +  return $success;
> +}
> +
> +## 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, timestamp )
> +                             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, timestamp )
> +                             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 = ?, timestamp = 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 = ?, timestamp = 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 ) = @_;
> +  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;
> +
> +  if ( $success ) {
> +    $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casId = ?");
> +    $sth->execute( $casId ) or $success = 0;
> +    $sth->finish;
> +  }
> +
> +  return $success;
> +}
> +
> +## 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
> +  if ( ! $casaId ) {
> +    return ( 0, 1, "No casaId Given" );
> +  }
> +  if ( ! $casId ) {
> +    return ( 0, 2, "No casId Given" );
> +  }
> +  if ( ! ( $borrowerCardnumber || $borrowernumber ) ) {
> +    return ( 0, 3, "No Borrower Given" );
> +  }
> +
> +  if ( ! $borrowernumber ) {
> +    $borrowernumber = getBorrowernumberByCardnumber( $borrowerCardnumber );
> +  }
> +
> +  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, timestamp, 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 GetClubsAndServices
> +## Returns information about clubs and services
> +## Input:
> +##   $type: ( Optional: 'club' or 'service' )
> +##   $branchcode: ( Optional: Get clubs and services only created by this branch )
> +## Output:
> +##   $results:
> +##     Reference to an array of associated arrays
> +sub GetClubsAndServices {
> +  my ( $type, $branchcode ) = @_;
> +
> +  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.timestamp,
> +                                 clubsAndServices.branchcode
> +                          FROM clubsAndServices, clubsAndServicesArchetypes
> +                          WHERE (
> +                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
> +                            AND clubsAndServices.branchcode = ?
> +                            AND clubsAndServicesArchetypes.type = ?
> +                        )");
> +    $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.timestamp,
> +                                 clubsAndServices.branchcode
> +                          FROM clubsAndServices, clubsAndServicesArchetypes
> +                          WHERE (
> +                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
> +                            AND clubsAndServicesArchetypes.type = ?
> +                        )");
> +    $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.timestamp,
> +                                 clubsAndServices.branchcode
> +                          FROM clubsAndServices, clubsAndServicesArchetypes
> +                          WHERE (
> +                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
> +                            AND clubsAndServices.branchcode = ?
> +                        )");
> +    $sth->execute( $branchcode ) or return 0;
> +
> +  } else { ## Get all clubs and services
> +    $sth = $dbh->prepare("SELECT * FROM clubsAndServices");
> +    $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, $timestamp, $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{'timestamp'},
> +      $$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
> +## Output:
> +##   $results:
> +##     ( $casaId, $type, $title, $description, $publicEnrollment,
> +##     $casData1Title, $casData2Title, $casData3Title,
> +##     $caseData1Title, $caseData2Title, $caseData3Title,
> +##     $casData1Desc, $casData2Desc, $casData3Desc,
> +##     $caseData1Desc, $caseData2Desc, $caseData3Desc,
> +##     $timestamp, $branchcode )
> +##     Except: 0 on failure
> +sub GetClubOrServiceArchetype {
> +  my ( $casaId ) = @_;
> +
> +  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;
> +
> +  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{'timestamp'},
> +      $$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(), timestamp = 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;
> +}
> +
> +1;
> +
> +__END__
> +
> +=back
> +
> +=head1 AUTHOR
> +
> +Kyle Hall <kylemhall at gmail.com>
> +
> +=cut
> diff --git a/clubs_services/clubs_services.pl b/clubs_services/clubs_services.pl
> new file mode 100755
> index 0000000..03ec051
> --- /dev/null
> +++ b/clubs_services/clubs_services.pl
> @@ -0,0 +1,35 @@
> +#!/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 = $query->cookie('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/edit_archetypes.pl b/clubs_services/edit_archetypes.pl
> new file mode 100755
> index 0000000..0271f6c
> --- /dev/null
> +++ b/clubs_services/edit_archetypes.pl
> @@ -0,0 +1,202 @@
> +#!/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 = $query->cookie('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');
> +  if ( $publicEnrollment eq 'yes' ) {
> +    $publicEnrollment = 1;
> +  } else {
> +    $publicEnrollment = 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 ( $createdSuccessfully, $errorCode, $errorMessage ) = AddClubOrServiceArchetype(
> +                                                             $type,
> +                                                             $title,
> +                                                             $description,
> +                                                             $publicEnrollment,
> +                                                             $casData1Title,
> +                                                             $casData2Title,
> +                                                             $casData3Title,
> +                                                             $caseData1Title,
> +                                                             $caseData2Title,
> +                                                             $caseData3Title,
> +                                                             $casData1Desc,
> +                                                             $casData2Desc,
> +                                                             $casData3Desc,
> +                                                             $caseData1Desc,
> +                                                             $caseData2Desc,
> +                                                             $caseData3Desc,
> +                                                             $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,
> +       $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,
> +      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');
> +  if ( $publicEnrollment eq 'yes' ) {
> +    $publicEnrollment = 1;
> +  } else {
> +    $publicEnrollment = 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 ( $createdSuccessfully, $errorCode, $errorMessage ) =
> +    UpdateClubOrServiceArchetype(
> +      $casaId, $type, $title, $description, $publicEnrollment,
> +      $casData1Title, $casData2Title, $casData3Title,
> +      $caseData1Title, $caseData2Title, $caseData3Title,
> +      $casData1Desc, $casData2Desc, $casData3Desc,
> +      $caseData1Desc, $caseData2Desc, $caseData3Desc
> +    );
> +
> +  $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..72e8133
> --- /dev/null
> +++ b/clubs_services/edit_clubs_services.pl
> @@ -0,0 +1,177 @@
> +#!/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 = $query->cookie('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();
> +
> +$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..75adbcc
> --- /dev/null
> +++ b/clubs_services/enroll_clubs_services.pl
> @@ -0,0 +1,94 @@
> +#!/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 670539a..3a6eb2d 100644
> --- a/installer/data/mysql/kohastructure.sql
> +++ b/installer/data/mysql/kohastructure.sql
> @@ -2339,6 +2339,74 @@ CREATE TABLE branch_transfer_limits (
>     PRIMARY KEY  (limitId)
>  ) 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,
> +  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
> +  PRIMARY KEY  (`casId`)
> +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
> +
> +--
> +-- Table structure for table `clubsAndServicesArchetypes`
> +--
> +
> +DROP TABLE IF EXISTS `clubsAndServicesArchetypes`;
> +CREATE TABLE `clubsAndServicesArchetypes` (
> +  `casaId` int(11) NOT NULL auto_increment,
> +  `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,
> +  `branchcode` varchar(4) default NULL COMMENT 'branch where archetype was created.',
> +  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
> +  PRIMARY KEY  (`casaId`)
> +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
> +
> +--
> +-- 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',
> +  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
> +  `branchcode` varchar(4) default NULL COMMENT 'foreign key to branches',
> +  PRIMARY KEY  (`caseId`)
> +) ENGINE=InnoDB 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 a819f8f..6f36f83 100755
> --- a/installer/data/mysql/updatedatabase.pl
> +++ b/installer/data/mysql/updatedatabase.pl
> @@ -2184,6 +2184,84 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
>     SetVersion ($DBversion);
>  }
>
> +$DBversion = '3.01.00.017';
> +if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
> +
> +    my $sql = <<'END_SQL';
> +--
> +-- 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,
> +  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
> +  PRIMARY KEY  (`casId`)
> +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
> +
> +--
> +-- Table structure for table `clubsAndServicesArchetypes`
> +--
> +
> +DROP TABLE IF EXISTS `clubsAndServicesArchetypes`;
> +CREATE TABLE `clubsAndServicesArchetypes` (
> +  `casaId` int(11) NOT NULL auto_increment,
> +  `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,
> +  `branchcode` varchar(4) default NULL COMMENT 'branch where archetype was created.',
> +  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
> +  PRIMARY KEY  (`casaId`)
> +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
> +
> +--
> +-- 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',
> +  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
> +  `branchcode` varchar(4) default NULL COMMENT 'foreign key to branches',
> +  PRIMARY KEY  (`caseId`)
> +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
> +END_SQL
> +        $dbh->do($sql);
> +    }
> +    print "Upgrade to $DBversion done ( Created tables for Clubs & Services)\n";
> +    SetVersion($DBversion);
> +}
> +
>  =item DropAllForeignKeys($table)
>
>   Drop all foreign keys of the table $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 20e9ab4..7868fef 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
> +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
> @@ -60,6 +60,7 @@
>         <!-- TMPL_IF NAME="CAN_user_updatecharges" -->
>        <!-- TMPL_IF NAME="finesview" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Fines</a></li>
>        <!-- /TMPL_IF -->
> +       <!-- TMPL_IF NAME="clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Clubs &amp; Services</a></li>
>        <!-- TMPL_IF NAME="intranetreadinghistory" --><!-- TMPL_IF NAME="readingrecordview" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Circulation History</a></li><!-- /TMPL_IF -->
>        <!-- TMPL_IF NAME="CAN_user_parameters"--><!-- TMPL_IF NAME="logview" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/tools/viewlog.pl?do_it=1&amp;module=MEMBERS&amp;action=MODIFY&amp;object=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;src=circ">Modification Log</a></li><!-- /TMPL_IF -->
>         <!-- TMPL_IF NAME="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 892c312..62b6afb 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc
> +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc
> @@ -7,6 +7,8 @@
>        <!-- /TMPL_IF -->
>        <!-- TMPL_IF NAME="intranetreadinghistory" --><!-- TMPL_IF NAME="readingrecordview" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Circulation History</a></li><!-- /TMPL_IF -->
>        <!-- TMPL_IF NAME="CAN_user_parameters"--><!-- TMPL_IF NAME="logview" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/tools/viewlog.pl?do_it=1&amp;module=MEMBERS&amp;action=MODIFY&amp;object=<!-- TMPL_VAR NAME="borrowernumber" -->">Modification Log</a></li><!-- /TMPL_IF -->
> +       <!-- TMPL_IF NAME="clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Clubs &amp; Services</a></li>
> +
>  <!-- TMPL_IF NAME="EnhancedMessagingPreferences" -->
>           <!-- TMPL_IF NAME="messagingview" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/members/messaging.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Messaging</a></li>
>         <!-- /TMPL_IF -->
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tmpl
> new file mode 100644
> index 0000000..17f0440
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tmpl
> @@ -0,0 +1,88 @@
> +<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
> +<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp Services</title>
> +<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
> +</head>
> +<body>
> +<!-- TMPL_INCLUDE NAME="header.inc" -->
> +
> +<div id="breadcrumbs">
> +  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
> +  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
> +  &rsaquo; Clubs &amp; Services
> +</div>
> +
> +<div id="doc3" class="yui-t2">
> +   <div id="bd">
> +        <div id="yui-main">
> +        <div class="yui-b">
> +
> +        <!-- TMPL_IF NAME="clubsLoop" -->
> +          <table>
> +            <tr>
> +               <th colspan="5">Clubs</th>
> +          </tr>
> +
> +            <tr>
> +              <th>Title</th>
> +              <th>Description</th>
> +              <th>Start Date</th>
> +              <th>End Date</th>
> +              <th></th>
> +            </tr>
> +            <!-- TMPL_LOOP NAME="clubsLoop" -->
> +              <tr>
> +                <td><!-- TMPL_VAR NAME="title" --></td>
> +                <td><!-- TMPL_VAR NAME="description" --></td>
> +                <td><!-- TMPL_VAR NAME="startDate" --></td>
> +                <td><!-- TMPL_VAR NAME="endDate" --></td>
> +                <td><a href="enroll_clubs_services.pl?casId=<!-- TMPL_VAR NAME="casId" -->">Enroll</a></td>
> +              </tr>
> +            <!-- /TMPL_LOOP -->
> +        <!-- TMPL_ELSE -->
> +          <tr><td colspan="5"><h3>There are no Clubs currently defined.</h3></td></tr>
> +        <!-- /TMPL_IF -->
> +
> +            <tr><td colspan="5">&nbsp;</td></tr>
> +
> +            <tr>
> +                <th colspan="5">Services</th>
> +            </tr>
> +
> +            <tr>
> +              <th>Title</th>
> +              <th>Description</th>
> +              <th>Start Date</th>
> +              <th>End Date</th>
> +              <th></th>
> +            </tr>
> +        <!-- TMPL_IF NAME="servicesLoop" -->
> +            <!-- TMPL_LOOP NAME="servicesLoop" -->
> +              <tr>
> +                <td><!-- TMPL_VAR NAME="title" --></td>
> +                <td><!-- TMPL_VAR NAME="description" --></td>
> +                <td><!-- TMPL_VAR NAME="startDate" --></td>
> +                <td><!-- TMPL_VAR NAME="endDate" --></td>
> +                <td><a href="enroll_clubs_services.pl?casId=<!-- TMPL_VAR NAME="casId" -->">Enroll</a></td>
> +              </tr>
> +            <!-- /TMPL_LOOP -->
> +        <!-- TMPL_ELSE -->
> +          <tr><td colspan="5"><h3>There are no Services currently defined.</h3></td></tr>
> +        <!-- /TMPL_IF -->
> +        </table>
> +</div>
> +</div>
> +
> +<div class="yui-b">
> +<div id="menu">
> +  <ul>
> +    <!-- TMPL_IF NAME="clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="clubs_services.pl">Clubs &amp; Services Home</a></li>
> +    <!-- TMPL_IF NAME="edit_archetypes" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_archetypes.pl">Edit Archetypes</a></li>
> +    <!-- TMPL_IF NAME="edit_clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_clubs_services.pl">Edit Clubs & Services</a></li>
> +  </ul>
> +</div>
> +</div>
> +
> +</div>
> +</div>
> +
> +<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tmpl
> new file mode 100644
> index 0000000..4d450b6
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tmpl
> @@ -0,0 +1,249 @@
> +<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
> +<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp Services &rsaquo; Edit Archetypes</title>
> +<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
> +</head>
> +<body>
> +<!-- TMPL_INCLUDE NAME="header.inc" -->
> +
> +<div id="breadcrumbs">
> +  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
> +  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
> +  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; Services</a>
> +  &rsaquo; Edit Archetypes
> +</div>
> +
> +<div id="doc3" class="yui-t2">
> +   <div id="bd">
> +        <div id="yui-main">
> +        <div class="yui-b">
> +
> +      <!-- TMPL_IF NAME="previousActionCreate" -->
> +        <!-- TMPL_IF NAME="createSuccess" -->
> +          <div>Archtype '<!-- TMPL_VAR NAME="createdTitle" -->' Created Succesfully!</div>
> +        <!-- TMPL_ELSE -->
> +          <div>Archtype '<!-- TMPL_VAR NAME="createdTitle" -->' Failed To Be Created!</div>
> +          <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
> +        <!-- /TMPL_IF -->
> +      <!-- /TMPL_IF -->
> +
> +      <!-- TMPL_IF NAME="previousActionDelete" -->
> +        <!-- TMPL_IF NAME="DeleteSuccess" -->
> +          <div>Archtype Deleted Succesfully!</div>
> +        <!-- TMPL_ELSE -->
> +          <div>Archtype Failed To Be Deleted!</div>
> +        <!-- /TMPL_IF -->
> +      <!-- /TMPL_IF -->
> +
> +      <!-- TMPL_IF NAME="previousActionUpdate" -->
> +        <!-- TMPL_IF NAME="updateSuccess" -->
> +          <div>Archetype '<!-- TMPL_VAR NAME="updatedTitle" -->' Updated Succesfully!</div>
> +        <!-- TMPL_ELSE -->
> +          <div>Archetype '<!-- TMPL_VAR NAME="updatedTitle" -->' Failed To Be Updated!</div>
> +          <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
> +        <!-- /TMPL_IF -->
> +      <!-- /TMPL_IF -->
> +
> +      <!-- LIST ALL ARCHETYPES -->
> +          <table>
> +            <tr><th colspan="12">Club Archetypes</th></tr>
> +            <tr>
> +              <th>Owner</strong</td>
> +              <th>Title</th>
> +              <th>Description</th>
> +              <th>Public Enrollment</th>
> +             <th>Club Data 1 Title</th>
> +             <th>Club Data 2 Title</th>
> +              <th>Club Data 3 Title</th>
> +             <th>Enrollment Data 1 Title</th>
> +             <th>Enrollment Data 2 Title</th>
> +              <th>Enrollment Data 3 Title</th>
> +             <th></th>
> +              <th></th>
> +            </tr>
> +
> +        <!-- TMPL_IF NAME="clubArchetypesLoop" -->
> +            <!-- TMPL_LOOP NAME="clubArchetypesLoop" -->
> +              <tr>
> +                <td><!-- TMPL_VAR NAME="branchcode" --></td>
> +                <td><!-- TMPL_VAR NAME="title" --></td>
> +                <td><!-- TMPL_VAR NAME="description" --></td>
> +                <td><!-- TMPL_VAR NAME="publicEnrollment" --></td>
> +                <td><!-- TMPL_VAR NAME="casData1Title" --></td>
> +                <td><!-- TMPL_VAR NAME="casData2Title" --></td>
> +                <td><!-- TMPL_VAR NAME="casData3Title" --></td>
> +                <td><!-- TMPL_VAR NAME="caseData1Title" --></td>
> +                <td><!-- TMPL_VAR NAME="caseData2Title" --></td>
> +                <td><!-- TMPL_VAR NAME="caseData3Title" --></td>
> +                <td><a href="edit_archetypes.pl?action=edit&casaId=<!-- TMPL_VAR NAME="casaId" -->">Edit</a></td>
> +                <td><a href="edit_archetypes.pl?action=delete&casaId=<!-- TMPL_VAR NAME="casaId" -->">Delete</a></td>
> +              </tr>
> +            <!-- /TMPL_LOOP -->
> +        <!-- TMPL_ELSE -->
> +            <tr><th colspan="12">There are no Club Archetypes currently defined.</th></tr>
> +        <!-- /TMPL_IF -->
> +
> +            <tr><td colspan="12">&nbsp;</td></tr>
> +
> +            <tr><th colspan="12">Service Archetypes</th></tr>
> +            <tr>
> +              <th>Owner</strong</td>
> +              <th>Title</th>
> +              <th>Description</th>
> +              <th>Public Enrollment</th>
> +             <th>Service Data 1 Title</th>
> +             <th>Service Data 2 Title</th>
> +              <th>Service Data 3 Title</th>
> +             <th>Enrollment Data 1 Title</th>
> +             <th>Enrollment Data 2 Title</th>
> +              <th>Enrollment Data 3 Title</th>
> +             <th></th>
> +              <th></th>
> +            </tr>
> +
> +        <!-- TMPL_IF NAME="serviceArchetypesLoop" -->
> +            <!-- TMPL_LOOP NAME="serviceArchetypesLoop" -->
> +              <tr>
> +                <td><!-- TMPL_VAR NAME="branchcode" --></td>
> +                <td><!-- TMPL_VAR NAME="title" --></td>
> +                <td><!-- TMPL_VAR NAME="description" --></td>
> +                <td><!-- TMPL_VAR NAME="publicEnrollment" --></td>
> +                <td><!-- TMPL_VAR NAME="casData1Title" --></td>
> +                <td><!-- TMPL_VAR NAME="casData2Title" --></td>
> +                <td><!-- TMPL_VAR NAME="casData3Title" --></td>
> +                <td><!-- TMPL_VAR NAME="caseData1Title" --></td>
> +                <td><!-- TMPL_VAR NAME="caseData2Title" --></td>
> +                <td><!-- TMPL_VAR NAME="caseData3Title" --></td>
> +                <td><a href="edit_archetypes.pl?action=edit&casaId=<!-- TMPL_VAR NAME="casaId" -->">Edit</a></td>
> +                <td><a href="edit_archetypes.pl?action=delete&casaId=<!-- TMPL_VAR NAME="casaId" -->">Delete</a></td>
> +              </tr>
> +            <!-- /TMPL_LOOP -->
> +          </table>
> +        <!-- TMPL_ELSE -->
> +            <tr><th colspan="12"> There are no Service Archetypes currently defined.</th></tr>
> +        <!-- /TMPL_IF -->
> +
> +      <!-- ADD NEW ARCHETYPE FORM -->
> +
> +        <!-- TMPL_IF NAME="previousActionEdit" -->
> +          <h1>Edit an Archetype</h1>
> +        <!-- TMPL_ELSE -->
> +          <h1>Create New Archetype</h1>
> +        <!-- /TMPL_IF -->
> +        <form action="edit_archetypes.pl" method="post">
> +          <!-- TMPL_IF NAME="previousActionEdit" -->
> +            <input type="hidden" name="action" value="update" />
> +            <input type="hidden" name="casaId" value="<!-- TMPL_VAR NAME="editCasaId" -->" />
> +          <!-- TMPL_ELSE -->
> +            <input type="hidden" name="action" value="create" />
> +          <!-- /TMPL_IF -->
> +
> +          <label for="type">Type: </label>
> +          <select name="type">
> +            <!-- TMPL_IF NAME="editType" --><option label="Keep Current Type" value="<!-- TMPL_VAR NAME="editType" -->">Keep Current Type</option><!-- /TMPL_IF -->
> +            <option label="Club" value="club">Club</option>
> +            <option label="Service" value="service">Service</option>
> +          </select>
> +          <br />
> +
> +          <label for="title">Title: </label>
> +          <input type="text" name="title" <!-- TMPL_IF NAME="editTitle" --> value="<!-- TMPL_VAR NAME="editTitle" -->" <!-- /TMPL_IF --> />
> +          <br />
> +
> +          <label for="description">Description: </label>
> +          <input type="text" size="75" name="description" <!-- TMPL_IF NAME="editDescription" --> value="<!-- TMPL_VAR NAME="editDescription" -->" <!-- /TMPL_IF -->  />
> +          <br />
> +
> +          <label for="publicEnrollment">Public Enrollment</label>
> +          <input type="radio" name="publicEnrollment" value="yes" <!-- TMPL_IF NAME="editPublicEnrollment" --> checked <!-- /TMPL_IF --> >Yes</input>
> +          <input type="radio" name="publicEnrollment" value="no" <!-- TMPL_IF NAME="editPublicEnrollment" --><!-- TMPL_ELSE --> checked <!-- /TMPL_IF -->>No</input>
> +          <br />
> +
> +             <h6>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.
> +             </h6>
> +          <table>
> +            <tr>
> +              <td><label>Club/Service Data 1</lable></td>
> +              <td><label for="casData1Title">Title</label></td>
> +              <td><input type="text" name="casData1Title" <!-- TMPL_IF NAME="editCasData1Title" --> value="<!-- TMPL_VAR NAME="editCasData1Title" -->" <!-- /TMPL_IF --> /></td>
> +              <td><label for="casData1Title">Description</label></td>
> +              <td><input type="text" name="casData1Desc" <!-- TMPL_IF NAME="editCasData1Desc" --> value="<!-- TMPL_VAR NAME="editCasData1Desc" -->" <!-- /TMPL_IF --> /></td>
> +            </tr>
> +
> +            <tr>
> +              <td><label>Club/Service Data 2</lable></td>
> +              <td><label for="casData2Title">Title</label></td>
> +              <td><input type="text" name="casData2Title" <!-- TMPL_IF NAME="editCasData2Title" --> value="<!-- TMPL_VAR NAME="editCasData2Title" -->" <!-- /TMPL_IF --> /></td>
> +              <td><label for="casData2Title">Description</label></td>
> +              <td><input type="text" name="casData2Desc" <!-- TMPL_IF NAME="editCasData2Desc" --> value="<!-- TMPL_VAR NAME="editCasData2Desc" -->" <!-- /TMPL_IF --> /></td>
> +            </tr>
> +
> +            <tr>
> +              <td><label>Club/Service Data 3</lable></td>
> +              <td><label for="casData3Title">Title</label></td>
> +              <td><input type="text" name="casData3Title" <!-- TMPL_IF NAME="editCasData3Title" --> value="<!-- TMPL_VAR NAME="editCasData3Title" -->" <!-- /TMPL_IF --> /></td>
> +              <td><label for="casData3Title">Description</label></td>
> +              <td><input type="text" name="casData3Desc" <!-- TMPL_IF NAME="editCasData3Desc" --> value="<!-- TMPL_VAR NAME="editCasData3Desc" -->" <!-- /TMPL_IF --> /></td>
> +            </tr>
> +          </table>
> +             <h6>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.
> +             </h6>
> +          <table>
> +            <tr>
> +              <td><label>Enrollment Data 1</lable></td>
> +              <td><label for="caseData1Title">Title</label></td>
> +              <td><input type="text" name="caseData1Title" <!-- TMPL_IF NAME="editCaseData1Title" --> value="<!-- TMPL_VAR NAME="editCaseData1Title" -->" <!-- /TMPL_IF --> /></td>
> +              <td><label for="caseData1Title">Description</label></td>
> +              <td><input type="text" name="caseData1Desc" <!-- TMPL_IF NAME="editCaseData1Desc" --> value="<!-- TMPL_VAR NAME="editCaseData1Desc" -->" <!-- /TMPL_IF --> /></td>
> +            </tr>
> +
> +            <tr>
> +              <td><label>Enrollment Data 2</lable></td>
> +              <td><label for="caseData2Title">Title</label></td>
> +              <td><input type="text" name="caseData2Title" <!-- TMPL_IF NAME="editCaseData2Title" --> value="<!-- TMPL_VAR NAME="editCaseData2Title" -->" <!-- /TMPL_IF --> /></td>
> +              <td><label for="caseData2Title">Description</label></td>
> +              <td><input type="text" name="caseData2Desc" <!-- TMPL_IF NAME="editCaseData2Desc" --> value="<!-- TMPL_VAR NAME="editCaseData2Desc" -->" <!-- /TMPL_IF --> /></td>
> +            </tr>
> +
> +            <tr>
> +              <td><label>Enrollment Data 3</lable></td>
> +              <td><label for="caseData3Title">Title</label></td>
> +              <td><input type="text" name="caseData3Title" <!-- TMPL_IF NAME="editCaseData3Title" --> value="<!-- TMPL_VAR NAME="editCaseData3Title" -->" <!-- /TMPL_IF --> /></td>
> +              <td><label for="caseData3Title">Description</label></td>
> +              <td><input type="text" name="caseData3Desc" <!-- TMPL_IF NAME="editCaseData3Desc" --> value="<!-- TMPL_VAR NAME="editCaseData3Desc" -->" <!-- /TMPL_IF --> /></td>
> +            </tr>
> +          </table>
> +
> +          <br />
> +          <!-- TMPL_IF NAME="previousActionEdit" -->
> +            <input type="submit" value="Update" />
> +          <!-- TMPL_ELSE -->
> +            <input type="submit" value="Create" />
> +          <!-- /TMPL_IF -->
> +
> +        </form>
> +
> +</div>
> +</div>
> +
> +<div class="yui-b">
> +<div id="menu">
> +  <ul>
> +    <!-- TMPL_IF NAME="clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="clubs_services.pl">Clubs &amp; Services Home</a></li>
> +    <!-- TMPL_IF NAME="edit_archetypes" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_archetypes.pl">Edit Archetypes</a></li>
> +    <!-- TMPL_IF NAME="edit_clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_clubs_services.pl">Edit Clubs & Services</a></li>
> +  </ul>
> +</div>
> +</div>
> +
> +</div>
> +</div>
> +
> +<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tmpl
> new file mode 100644
> index 0000000..4d705aa
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tmpl
> @@ -0,0 +1,257 @@
> +<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
> +<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp Services &rsaquo; Edit</title>
> +<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
> +</head>
> +<body>
> +<!-- TMPL_INCLUDE NAME="header.inc" -->
> +
> +<div id="breadcrumbs">
> +  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
> +  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
> +  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; Services</a>
> +  &rsaquo; Edit
> +</div>
> +
> +<div id="doc3" class="yui-t2">
> +   <div id="bd">
> +        <div id="yui-main">
> +        <div class="yui-b">
> +
> +      <!-- TMPL_IF NAME="previousActionCreate" -->
> +        <!-- TMPL_IF NAME="createSuccess" -->
> +          <p>Club Or Service '<!-- TMPL_VAR NAME="createdTitle" -->' Created Succesfully!</p>
> +        <!-- TMPL_ELSE -->
> +          <p>Club or Service '<!-- TMPL_VAR NAME="createdTitle" -->' Failed To Be Created!</p>
> +          <p>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></p>
> +        <!-- /TMPL_IF -->
> +      <!-- /TMPL_IF -->
> +
> +      <!-- TMPL_IF NAME="previousActionDelete" -->
> +        <!-- TMPL_IF NAME="DeleteSuccess" -->
> +          <p>Club or Service Deleted Succesfully!</p>
> +        <!-- TMPL_ELSE -->
> +          <p>Club or Service Failed To Be Deleted!</p>
> +        <!-- /TMPL_IF -->
> +      <!-- /TMPL_IF -->
> +
> +      <!-- TMPL_IF NAME="previousActionUpdate" -->
> +        <!-- TMPL_IF NAME="updateSuccess" -->
> +          <p>Club Or Service '<!-- TMPL_VAR NAME="updatedTitle" -->' Updated Succesfully!</p>
> +        <!-- TMPL_ELSE -->
> +          <p>Club or Service '<!-- TMPL_VAR NAME="updatedTitle" -->' Failed To Be Updated!</p>
> +          <p>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></p>
> +        <!-- /TMPL_IF -->
> +      <!-- /TMPL_IF -->
> +
> +          <table>
> +          <tr><th colspan="7">Clubs</th></tr>
> +            <tr>
> +              <th>Owner</th>
> +              <th>Title</th>
> +              <th>Description</th>
> +              <th>Start Date</th>
> +              <th>End Date</th>
> +              <th></th>
> +              <th></th>
> +            </tr>
> +         <!-- TMPL_IF NAME="clubsLoop" -->
> +            <!-- TMPL_LOOP NAME="clubsLoop" -->
> +              <tr>
> +                <td><!-- TMPL_VAR NAME="branchcode" --></td>
> +                <td><!-- TMPL_VAR NAME="title" --></td>
> +                <td><!-- TMPL_VAR NAME="description" --></td>
> +                <td><!-- TMPL_VAR NAME="startDate" --></td>
> +                <td><!-- TMPL_VAR NAME="endDate" --></td>
> +                <td><a href="edit_clubs_services.pl?action=edit&casaId=<!-- TMPL_VAR NAME="casaId" -->&casId=<!-- TMPL_VAR NAME="casId" -->">Edit</a></td>
> +                <td><a href="edit_clubs_services.pl?action=delete&casId=<!-- TMPL_VAR NAME="casId" -->">Delete</a></td>
> +              </tr>
> +            <!-- /TMPL_LOOP -->
> +        <!-- TMPL_ELSE -->
> +          <tr><td colspan="7">There are no Clubs currently defined.</td></tr>
> +        <!-- /TMPL_IF -->
> +
> +          <tr><td colspan="7">&nbsp;</td></tr>
> +
> +          <tr><th colspan="7">Services</th></tr>
> +
> +            <tr>
> +              <th>Owner</th>
> +              <th>Title</th>
> +              <th>Description</th>
> +              <th>Start Date</th>
> +              <th>End Date</th>
> +              <th></th>
> +              <th></th>
> +            </tr>
> +
> +        <!-- TMPL_IF NAME="servicesLoop" -->
> +            <!-- TMPL_LOOP NAME="servicesLoop" -->
> +              <tr>
> +                <td><!-- TMPL_VAR NAME="branchcode" --></td>
> +                <td><!-- TMPL_VAR NAME="title" --></td>
> +                <td><!-- TMPL_VAR NAME="description" --></td>
> +                <td><!-- TMPL_VAR NAME="startDate" --></td>
> +                <td><!-- TMPL_VAR NAME="endDate" --></td>
> +                <td><a href="edit_clubs_services.pl?action=edit&casaId=<!-- TMPL_VAR NAME="casaId" -->&casId=<!-- TMPL_VAR NAME="casId" -->">Edit</a></td>
> +                <td><a href="edit_clubs_services.pl?action=delete&casId=<!-- TMPL_VAR NAME="casId" -->">Delete</a></td>
> +              </tr>
> +            <!-- /TMPL_LOOP -->
> +          </table>
> +        <!-- TMPL_ELSE -->
> +          <tr><td colspan="7">There are no Services currently defined.</td></tr>
> +        <!-- /TMPL_IF -->
> +
> +
> +    <!-- TMPL_IF NAME="previousActionSelectArchetype" -->
> +      <!-- ADD NEW CAS FORM -->
> +        <!-- TMPL_IF NAME="previousActionEdit" -->
> +          <h1>Edit a Club or Service</h1>
> +        <!-- TMPL_ELSE -->
> +          <h1>Create New Club Or Service</h1>
> +        <!-- /TMPL_IF -->
> +        <form action="edit_clubs_services.pl" method="post">
> +          <!-- TMPL_IF NAME="previousActionEdit" -->
> +            <input type="hidden" name="action" value="update" />
> +            <input type="hidden" name="casId" value="<!-- TMPL_VAR NAME="editCasId" -->" />
> +          <!-- TMPL_ELSE -->
> +            <input type="hidden" name="action" value="create" />
> +          <!-- /TMPL_IF -->
> +
> +          <table>
> +
> +            <tr>
> +              <td>
> +                <label for="casaId">Archetype: </label>
> +              </td>
> +              <td>
> +                <select name="casaId">
> +                  <option value="<!-- TMPL_VAR NAME="casaId" -->"><!-- TMPL_VAR NAME="casaTitle" --></option>
> +                </select>
> +              </td>
> +            </tr>
> +            <tr>
> +              <td>
> +                <label for="title">Title: </label>
> +              </td>
> +              <td>
> +               <input type="text" name="title" <!-- TMPL_IF NAME="editTitle" --> value="<!-- TMPL_VAR NAME="editTitle" -->" <!-- /TMPL_IF --> />
> +              </td>
> +            </tr>
> +
> +            <tr>
> +              <td>
> +                <label for="description">Description: </label>
> +              </td>
> +              <td colspan="2">
> +                <input type="text" size="50" name="description" <!-- TMPL_IF NAME="editDescription" --> value="<!-- TMPL_VAR NAME="editDescription" -->" <!-- /TMPL_IF --> />
> +              </td>
> +            </tr>
> +
> +            <!-- TMPL_IF NAME="casData1Title" -->
> +              <tr>
> +                <td>
> +                  <label for="casData1"><!-- TMPL_VAR NAME="casData1Title" -->: </label>
> +                </td>
> +                <td>
> +                  <input type="text" name="casData1" <!-- TMPL_IF NAME="editCasData1" --> value="<!-- TMPL_VAR NAME="editCasData1" -->" <!-- /TMPL_IF --> />
> +                </td>
> +                <td><i><!-- TMPL_VAR NAME="casData1Desc" --></i></td>
> +              </tr>
> +            <!-- /TMPL_IF -->
> +
> +            <!-- TMPL_IF NAME="casData2Title" -->
> +              <tr>
> +                <td>
> +                  <label for="casData2"><!-- TMPL_VAR NAME="casData2Title" -->: </label>
> +                </td>
> +                <td>
> +                  <input type="text" name="casData2" <!-- TMPL_IF NAME="editCasData2" --> value="<!-- TMPL_VAR NAME="editCasData2" -->" <!-- /TMPL_IF --> />
> +                </td>
> +                <td><i><!-- TMPL_VAR NAME="casData2Desc" --></i></td>
> +              </tr>
> +            <!-- /TMPL_IF -->
> +
> +            <!-- TMPL_IF NAME="casData3Title" -->
> +              <tr>
> +                <td>
> +                  <label for="casData3"><!-- TMPL_VAR NAME="casData3Title" -->: </label>
> +                </td>
> +                <td>
> +                  <input type="text" name="casData3" <!-- TMPL_IF NAME="editCasData3" --> value="<!-- TMPL_VAR NAME="editCasData3" -->" <!-- /TMPL_IF --> />
> +                </td>
> +                <td><i><!-- TMPL_VAR NAME="casData3Desc" --></i></td>
> +              </tr>
> +            <!-- /TMPL_IF -->
> +
> +            <tr><td colspan="3"><i>Date format is : YYYY-MM-DD</i></td></tr>
> +
> +
> +            <tr>
> +              <td>
> +                <label for="startDate">Start Date: </label>
> +              </td>
> +              <td>
> +                <input type="text" maxlength="10" name="startDate" <!-- TMPL_IF NAME="editStartDate" --> value="<!-- TMPL_VAR NAME="editStartDate" -->" <!-- /TMPL_IF --> />
> +              </td>
> +              <td>
> +                <i>Optional: Leave blank for start date of today.</i>
> +              </td>
> +            </tr>
> +
> +            <tr>
> +              <td>
> +                <label for="startDate">End Date: </label>
> +              </td>
> +              <td>
> +                <input type="text" maxlength="10" name="endDate" <!-- TMPL_IF NAME="editEndDate" --> value="<!-- TMPL_VAR NAME="editEndDate" -->" <!-- /TMPL_IF --> />
> +              </td>
> +              <td>
> +                <i>Optional: Leave blank for no end date.</i>
> +              </td>
> +            </tr>
> +
> +            <tr>
> +              <td colspan="3">
> +                <!-- TMPL_IF NAME="previousActionEdit" -->
> +                  <input type="submit" value="Update" />
> +                <!-- TMPL_ELSE -->
> +                  <input type="submit" value="Create" />
> +                <!-- /TMPL_IF -->
> +              </td>
> +            </tr>
> +          </table>
> +        </form>
> +    <!-- TMPL_ELSE -->
> +
> +      <!-- SELECT ARCHETYPE FORM -->
> +      <h1>Create New Club or Service</h1>
> +      <form action="edit_clubs_services.pl" method="post">
> +        <input type="hidden" name="action" value="selectArchetype" />
> +        <label for="casaId">Select Archetype</label>
> +        <select name="casaId">
> +          <!-- TMPL_LOOP NAME="archetypesLoop" -->
> +            <option value="<!-- TMPL_VAR NAME="casaId" -->"><!-- TMPL_VAR NAME="title" --></option>
> +          <!-- /TMPL_LOOP -->
> +        </select>
> +        <input type="submit" value="Create" />
> +       </form>
> +     <!-- /TMPL_IF -->
> +
> +</div>
> +</div>
> +
> +<div class="yui-b">
> +<div id="menu">
> +  <ul>
> +    <!-- TMPL_IF NAME="clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="clubs_services.pl">Clubs &amp; Services Home</
> +    <!-- TMPL_IF NAME="edit_archetypes" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_archetypes.pl">Edit Archetypes</a></li>
> +    <!-- TMPL_IF NAME="edit_clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_clubs_services.pl">Edit Clubs & Services</a></li>
> +  </ul>
> +</div>
> +</div>
> +
> +</div>
> +</div>
> +
> +<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
> +
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tmpl
> new file mode 100644
> index 0000000..6ca6c28
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tmpl
> @@ -0,0 +1,89 @@
> +<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
> +<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp Services &rsaquo; Enroll</title>
> +<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
> +</head>
> +<body>
> +<!-- TMPL_INCLUDE NAME="header.inc" -->
> +
> +<div id="breadcrumbs">
> +  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
> +  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
> +  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; Services</a>
> +  &rsaquo; Enroll
> +</div>
> +
> +<div id="doc3" class="yui-t2">
> +   <div id="bd">
> +        <div id="yui-main">
> +        <div class="yui-b">
> +      <div>
> +          <!-- TMPL_IF NAME="previousActionEnroll" -->
> +            <!-- TMPL_IF NAME="enrollSuccess" -->
> +              <div>Patron with cardnumber '<!-- TMPL_VAR NAME="enrolledBarcode" -->' Enrolled Succesfully!</div>
> +            <!-- TMPL_ELSE -->
> +              <div>Failed to Enroll Patron with cardnumber '<!-- TMPL_VAR NAME="enrolledBarcode" -->'!</div>
> +              <div>Reason: <strong><!-- TMPL_VAR NAME="failureMessage" --></strong></div>
> +            <!-- /TMPL_IF -->
> +          <!-- /TMPL_IF -->
> +
> +
> +          <h3>Enroll a Patron in <i><!-- TMPL_VAR NAME="casTitle" --></i></h3>
> +      </div>
> +
> +      <div>
> +        <form action="enroll_clubs_services.pl" method="post">
> +        <table>
> +          <!-- TMPL_IF NAME="caseData1Title" -->
> +            <tr>
> +              <th><label for="data1"><!-- TMPL_VAR NAME="caseData1Title" -->: </label></th>
> +              <td><input type="text" id="data1" name="data1" /></td>
> +              <td><i><!-- TMPL_VAR NAME="caseData1Desc" --></i></td>
> +            </tr>
> +          <!-- /TMPL_IF -->
> +
> +          <!-- TMPL_IF NAME="caseData2Title" -->
> +            <tr>
> +              <th><label for="data2"><!-- TMPL_VAR NAME="caseData2Title" -->: </label></th>
> +              <td><input type="text" id="data2" name="data2" /></td>
> +              <td><i><!-- TMPL_VAR NAME="caseData2Desc" --></i></td>
> +            </tr>
> +          <!-- /TMPL_IF -->
> +
> +          <!-- TMPL_IF NAME="caseData3Title" -->
> +            <tr>
> +              <th><label for="data3"><!-- TMPL_VAR NAME="caseData3Title" -->: </label></th>
> +              <td><input type="text" id="data3" name="data3" /></td>
> +              <td><i><!-- TMPL_VAR NAME="caseData3Desc" --></i></td>
> +            </tr>
> +          <!-- /TMPL_IF -->
> +
> +          <tr>
> +            <th><label for="borrowerBarcode">Borrower Cardnumber: </label></th>
> +            <td colspan="2"><input type="text" id="borrowerBarcode" name="borrowerBarcode" /></td>
> +          </tr>
> +
> +          <input type="hidden" id="casId" name="casId" value="<!-- TMPL_VAR NAME="casId" -->" />
> +          <input type="hidden" id="casaId" name="casaId" value="<!-- TMPL_VAR NAME="casaId" -->" />
> +          <input type="hidden" name="action" value="enroll" />
> +          <tr><td colspan="3"><input type="submit" value="Enroll" /></td></tr>
> +        </table>
> +        </form>
> +      </div>
> +
> +</div>
> +</div>
> +
> +<div class="yui-b">
> +<div id="menu">
> +  <ul>
> +    <!-- TMPL_IF NAME="clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="clubs_services.pl">Clubs &amp; Services Home</a></li>
> +    <!-- TMPL_IF NAME="edit_archetypes" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_archetypes.pl">Edit Archetypes</a></li>
> +    <!-- TMPL_IF NAME="edit_clubs_services" --><li class="active"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="edit_clubs_services.pl">Edit Clubs & Services</a></li>
> +  </ul>
> +</div>
> +</div>
> +
> +</div>
> +</div>
> +
> +<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tmpl
> new file mode 100644
> index 0000000..f69105a
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tmpl
> @@ -0,0 +1,84 @@
> +<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
> +<title>Koha &rsaquo; Patrons &rsaquo; Account for <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></title>
> +<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
> +</head>
> +<body>
> +<!-- TMPL_INCLUDE NAME="header.inc" -->
> +<!-- TMPL_INCLUDE NAME="patron-search.inc" -->
> +
> +<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Clubs &amp; Services for <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></div>
> +
> +<div id="doc3" class="yui-t2">
> +   <div id="bd">
> +        <div id="yui-main">
> +        <div class="yui-b">
> +
> +  <table>
> +  <thead>
> +  <tr><th colspan="5">Currently Enrolled Clubs & Services</th></tr>
> +  <tr>
> +    <th>Title</th>
> +    <th>Description</th>
> +    <th>Library</th>
> +    <th>Type</th>
> +    <th></th>
> +  </tr>
> +  </thead>
> +  <tbody>
> +
> +<!-- TMPL_IF NAME="enrolledClubsAndServicesLoop" -->
> +
> +    <!-- TMPL_LOOP NAME="enrolledClubsAndServicesLoop" -->
> +      <!-- TMPL_IF NAME="odd" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
> +        <td><!-- TMPL_VAR NAME="title" --></td>
> +        <td><!-- TMPL_VAR NAME="description" --></td>
> +        <td><!-- TMPL_VAR NAME="branchcode" --></td>
> +        <td><!-- TMPL_VAR NAME="type" --></td>
> +        <td><a href="clubs_services.pl?action=cancel&caseId=<!-- TMPL_VAR NAME="caseId" -->&borrowernumber=<!-- TMPL_VAR NAME="borrowernumber"-->">Cancel</a></td>
> +      </tr>
> +    <!-- /TMPL_LOOP -->
> +
> +<!-- TMPL_ELSE -->
> +  <tr><td colspan="5"><Patron Is Not Enrolled In Any Clubs Or Services</tr></td>
> +<!-- /TMPL_IF -->
> +  </tbody>
> +
> +  <tr><td colspan="5">&nbsp;</td></tr>
> +
> +  <thead>
> +  <tr><th colspan="5">Enroll In Clubs & Services</th></tr>
> +  <tr>
> +    <th>Title</th>
> +    <th>Description</th>
> +    <th>Library</th>
> +    <th>Type</th>
> +    <th></th>
> +  </tr>
> +  </thead>
> +
> +  <tbody>
> +<!-- TMPL_IF NAME="enrollableClubsAndServicesLoop" -->
> +
> +    <!-- TMPL_LOOP NAME="enrollableClubsAndServicesLoop" -->
> +      <!-- TMPL_IF NAME="odd" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
> +        <td><!-- TMPL_VAR NAME="title" --></td>
> +        <td><!-- TMPL_VAR NAME="description" --></td>
> +        <td><!-- TMPL_VAR NAME="branchcode" --></td>
> +        <td><!-- TMPL_VAR NAME="type" --></td>
> +        <td><a href="clubs_services_enroll.pl?casId=<!-- TMPL_VAR NAME="casId" -->&casaId=<!-- TMPL_VAR NAME="casaId" -->&borrowernumber=<!-- TMPL_VAR NAME="borrowernumber"-->">Enroll</a></td>
> +      </tr>
> +    <!-- /TMPL_LOOP -->
> +<!-- TMPL_ELSE -->
> +  <tr><td colspan="5">There Are No New Clubs Or Services To Enroll In</td></tr>
> +<!-- /TMPL_IF -->
> +  </tbody>
> +
> +  </table>
> +
> +</div>
> +</div>
> +<div class="yui-b">
> +<!-- TMPL_INCLUDE NAME="circ-menu.inc" -->
> +</div>
> +</div>
> +<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tmpl
> new file mode 100644
> index 0000000..be90bef
> --- /dev/null
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.t...
>
> [Message clipped]



More information about the Koha-patches mailing list