Browse Source

Bug 12461 - Add patron clubs feature

This features would add the ability to create clubs which patrons may be
enrolled in. It would be particularly useful for tracking summer reading
programs, book clubs and other such clubs.

Test Plan:
1) Apply this patch
2) Run updatedatabase.pl
3) Ensure your staff user has the new 'Patron clubs' permissions
4) Under the tools menu, click the "Patron clubs" link
5) Create a new club template
   * Here you can add fields that can be filled out at the time
     a new club is created based on the template, or a new enrollment
     is created for a given club based on the template.
6) Create a new club based on that template
7) Attempt to enroll a patron in that club
8) Create a club with email required set
9) Attempt to enroll a patron without an email address in that club
10) Create a club that is enrollable from the OPAC
11) Attempt to enroll a patron in that club
12) Attempt to cancel a club enrollment from the OPAC
13) Attempt to cancel a club enrollment from the staff interface

Followed test plan, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
17.05.x
Kyle Hall 8 years ago
parent
commit
95429af685
  1. 5
      C4/Auth.pm
  2. 16
      C4/Members.pm
  3. 92
      Koha/Club.pm
  4. 78
      Koha/Club/Enrollment.pm
  5. 56
      Koha/Club/Enrollment/Field.pm
  6. 60
      Koha/Club/Enrollment/Fields.pm
  7. 60
      Koha/Club/Enrollments.pm
  8. 66
      Koha/Club/Field.pm
  9. 60
      Koha/Club/Fields.pm
  10. 75
      Koha/Club/Template.pm
  11. 54
      Koha/Club/Template/EnrollmentField.pm
  12. 60
      Koha/Club/Template/EnrollmentFields.pm
  13. 54
      Koha/Club/Template/Field.pm
  14. 60
      Koha/Club/Template/Fields.pm
  15. 60
      Koha/Club/Templates.pm
  16. 92
      Koha/Clubs.pm
  17. 38
      Koha/Patron.pm
  18. 6
      Koha/Schema/Result/AuthorisedValue.pm
  19. 19
      Koha/Schema/Result/Borrower.pm
  20. 49
      Koha/Schema/Result/Branch.pm
  21. 182
      Koha/Schema/Result/Club.pm
  22. 201
      Koha/Schema/Result/ClubEnrollment.pm
  23. 112
      Koha/Schema/Result/ClubEnrollmentField.pm
  24. 112
      Koha/Schema/Result/ClubField.pm
  25. 195
      Koha/Schema/Result/ClubTemplate.pm
  26. 119
      Koha/Schema/Result/ClubTemplateEnrollmentField.pm
  27. 104
      Koha/Schema/Result/ClubTemplateField.pm
  28. 4
      Koha/Template/Plugin/AuthorisedValues.pm
  29. 1
      Koha/Template/Plugin/Borrowers.pm
  30. 107
      clubs/clubs-add-modify.pl
  31. 60
      clubs/clubs.pl
  32. 55
      clubs/patron-clubs-tab.pl
  33. 50
      clubs/patron-enroll.pl
  34. 152
      clubs/templates-add-modify.pl
  35. 131
      installer/data/mysql/atomicupdate/bug_12461.sql
  36. 124
      installer/data/mysql/kohastructure.sql
  37. 3
      installer/data/mysql/userflags.sql
  38. 5
      installer/data/mysql/userpermissions.sql
  39. 4
      koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
  40. 3
      koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc
  41. 23
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
  42. 115
      koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt
  43. 252
      koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt
  44. 102
      koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt
  45. 66
      koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt
  46. 216
      koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt
  47. 22
      koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
  48. 5
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt
  49. 102
      koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt
  50. 66
      koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt
  51. 24
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
  52. 2
      members/moremember.pl
  53. 52
      opac/clubs/clubs-tab.pl
  54. 49
      opac/clubs/enroll.pl
  55. 47
      opac/svc/club/cancel_enrollment
  56. 77
      opac/svc/club/enroll
  57. 46
      svc/club/cancel_enrollment
  58. 48
      svc/club/delete
  59. 74
      svc/club/enroll
  60. 49
      svc/club/template/delete
  61. 221
      t/db_dependent/Clubs.t

5
C4/Auth.pm

@ -260,7 +260,7 @@ sub get_template_and_user {
my $all_perms = get_all_subpermissions();
my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
editcatalogue updatecharges management tools editauthorities serials reports acquisition);
editcatalogue updatecharges management tools editauthorities serials reports acquisition clubs);
# We are going to use the $flags returned by checkauth
# to create the template's parameters that will indicate
@ -283,8 +283,9 @@ sub get_template_and_user {
$template->param( CAN_user_staffaccess => 1 );
$template->param( CAN_user_plugins => 1 );
$template->param( CAN_user_coursereserves => 1 );
foreach my $module ( keys %$all_perms ) {
$template->param( CAN_user_clubs => 1 );
foreach my $module ( keys %$all_perms ) {
foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
$template->param( "CAN_user_${module}_${subperm}" => 1 );
}

16
C4/Members.pm

@ -989,20 +989,10 @@ addresses.
sub GetFirstValidEmailAddress {
my $borrowernumber = shift;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
$sth->execute( $borrowernumber );
my $data = $sth->fetchrow_hashref;
if ($data->{'email'}) {
return $data->{'email'};
} elsif ($data->{'emailpro'}) {
return $data->{'emailpro'};
} elsif ($data->{'B_email'}) {
return $data->{'B_email'};
} else {
return '';
}
my $borrower = Koha::Patrons->find( $borrowernumber );
return $borrower->first_valid_email_address();
}
=head2 GetNoticeEmailAddress

92
Koha/Club.pm

@ -0,0 +1,92 @@
package Koha::Club;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Templates;
use Koha::Club::Fields;
use Koha::Libraries;
use base qw(Koha::Object);
=head1 NAME
Koha::Club - Koha Club Object class
=head1 API
=head2 Class Methods
=cut
=head3 club_template
=cut
sub club_template {
my ($self) = @_;
return unless $self->club_template_id();
return Koha::Club::Templates->find( $self->club_template_id() );
}
=head3 club_fields
=cut
sub club_fields {
my ($self) = @_;
return unless $self->id();
return Koha::Club::Fields->search( { club_id => $self->id() } );
}
=head3 club_fields
=cut
sub branch {
my ($self) = @_;
return unless $self->branchcode();
return Koha::Libraries->find( $self->branchcode() );
}
=head3 type
=cut
sub _type {
return 'Club';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

78
Koha/Club/Enrollment.pm

@ -0,0 +1,78 @@
package Koha::Club::Enrollment;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Clubs;
use base qw(Koha::Object);
=head1 NAME
Koha::Club::Enrollment
Represents a "pattern" on which many clubs can be created.
In this way we can directly compare different clubs of the same 'template'
for statistical purposes.
=head1 API
=head2 Class Methods
=cut
=head3 cancel
=cut
sub cancel {
my ( $self ) = @_;
$self->_result()->update( { date_canceled => \'NOW()' } );
return $self;
}
=head3 club
=cut
sub club {
my ( $self ) = @_;
return Koha::Clubs->find( $self->club_id() );
}
=head3 type
=cut
sub _type {
return 'ClubEnrollment';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

56
Koha/Club/Enrollment/Field.pm

@ -0,0 +1,56 @@
package Koha::Club::Enrollment::Field;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use base qw(Koha::Object);
=head1 NAME
Koha::Club::Enrollment::Field
Represents a "pattern" on which many clubs can be created.
In this way we can directly compare different clubs of the same 'template'
for statistical purposes.
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubEnrollmentField';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

60
Koha/Club/Enrollment/Fields.pm

@ -0,0 +1,60 @@
package Koha::Club::Enrollment::Fields;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Enrollment::Field;
use base qw(Koha::Objects);
=head1 NAME
Koha::Club::Enrollment::Fields
This object represents a collection of club enrollemnt fields.
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubEnrollmentField';
}
sub object_class {
return 'Koha::Club::Enrollment::Field';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

60
Koha/Club/Enrollments.pm

@ -0,0 +1,60 @@
package Koha::Club::Enrollments;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Enrollment;
use base qw(Koha::Objects);
=head1 NAME
Koha::Club::Enrollments
This object represents a collection of club templates.
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubEnrollment';
}
sub object_class {
return 'Koha::Club::Enrollment';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

66
Koha/Club/Field.pm

@ -0,0 +1,66 @@
package Koha::Club::Field;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Template::Fields;
use base qw(Koha::Object);
=head1 NAME
Koha::Club::Field
Represents the value set at creation time for a Koha::Club::Template::Field
=head1 API
=head2 Class Methods
=cut
=head3 club_template_field
=cut
sub club_template_field {
my ( $self ) = @_;
return Koha::Club::Template::Fields->find( $self->club_template_field_id );
}
=head3 type
=cut
sub _type {
return 'ClubField';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

60
Koha/Club/Fields.pm

@ -0,0 +1,60 @@
package Koha::Club::Fields;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Field;
use base qw(Koha::Objects);
=head1 NAME
Koha::Club::Fields
Represents a collection of club fields.
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubField';
}
sub object_class {
return 'Koha::Club::Field';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

75
Koha/Club/Template.pm

@ -0,0 +1,75 @@
package Koha::Club::Template;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Template::Fields;
use Koha::Club::Template::EnrollmentFields;
use base qw(Koha::Object);
=head1 NAME
Koha::Club::Template
Represents a "pattern" on which many clubs can be created.
In this way we can directly compare different clubs of the same 'template'
for statistical purposes.
=head1 API
=head2 Class Methods
=cut
=head3 club_template_fields
=cut
sub club_template_fields {
my ($self) = @_;
return Koha::Club::Template::Fields->search( { club_template_id => $self->id() } );
}
sub club_template_enrollment_fields {
my ($self) = @_;
return Koha::Club::Template::EnrollmentFields->search( { club_template_id => $self->id() } );
}
=head3 type
=cut
sub _type {
return 'ClubTemplate';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

54
Koha/Club/Template/EnrollmentField.pm

@ -0,0 +1,54 @@
package Koha::Club::Template::EnrollmentField;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use base qw(Koha::Object);
=head1 NAME
Koha::Club::Template::EnrollemntField
Represents a club field that is only set at the time a patron is enrolled
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubTemplateEnrollmentField';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

60
Koha/Club/Template/EnrollmentFields.pm

@ -0,0 +1,60 @@
package Koha::Club::Template::EnrollmentFields;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Template::EnrollmentField;
use base qw(Koha::Objects);
=head1 NAME
Koha::Club::Template::EnrollemntFields
Represents a colleciton of club fields that are only set at the time a patron is enrolled
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubTemplateEnrollmentField';
}
sub object_class {
return 'Koha::Club::Template::EnrollmentField';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

54
Koha/Club/Template/Field.pm

@ -0,0 +1,54 @@
package Koha::Club::Template::Field;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use base qw(Koha::Object);
=head1 NAME
Koha::Club::Template::Field
Represents a club field that is set when the club is created
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubTemplateField';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

60
Koha/Club/Template/Fields.pm

@ -0,0 +1,60 @@
package Koha::Club::Template::Fields;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Template::Field;
use base qw(Koha::Objects);
=head1 NAME
Koha::Club::Template::Fields
Represents a collection of club fields that are set when the club is created
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubTemplateField';
}
sub object_class {
return 'Koha::Club::Template::Field';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

60
Koha/Club/Templates.pm

@ -0,0 +1,60 @@
package Koha::Club::Templates;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club::Template;
use base qw(Koha::Objects);
=head1 NAME
Koha::Club::Templates
This object represents a collection of club templates.
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ClubTemplate';
}
sub object_class {
return 'Koha::Club::Template';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

92
Koha/Clubs.pm

@ -0,0 +1,92 @@
package Koha::Clubs;
# Copyright ByWater Solutions 2014
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Club;
use base qw(Koha::Objects);
=head1 NAME
Koha::Clubs - Koha Clubs Object class
This object represents a collection of clubs a patron may enroll in.
=head1 API
=head2 Class Methods
=cut
=head3 get_enrollable
=cut
sub get_enrollable {
my ( $self, $params ) = @_;
# We need to filter out all the already enrolled in clubs
my $borrower = $params->{borrower};
if ($borrower) {
delete( $params->{borrower} );
my @enrollments = $borrower->get_club_enrollments();
if (@enrollments) {
$params->{'me.id'} = { -not_in => [ map { $_->club()->id() } @enrollments ] };
}
}
my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } );
if (wantarray) {
my $class = ref($self) ? ref($self) : $self;
return $class->_wrap( $rs->all() );
}
else {
my $class = ref($self) ? ref($self) : $self;
return $class->_new_from_dbic($rs);
}
}
=head3 type
=cut
sub _type {
return 'Club';
}
sub object_class {
return 'Koha::Club';
}
=head1 AUTHOR
Kyle M Hall <kyle@bywatersolutions.com>
=cut
1;

38
Koha/Patron.pm

@ -35,6 +35,7 @@ use Koha::Patron::HouseboundRole;
use Koha::Patron::Images;
use Koha::Patrons;
use Koha::Virtualshelves;
use Koha::Club::Enrollments;
use base qw(Koha::Object);
@ -584,6 +585,43 @@ sub holds {
return Koha::Holds->_new_from_dbic($holds_rs);
}
=head3 first_valid_email_address
=cut
sub first_valid_email_address {
my ($self) = @_;
return $self->email() || $self->emailpro() || $self->B_email() || q{};
}
=head3 get_club_enrollments
=cut
sub get_club_enrollments {
my ($self) = @_;
return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
}
=head3 get_enrollable_clubs
=cut
sub get_enrollable_clubs {
my ( $self, $is_enrollable_from_opac ) = @_;
my $params;
$params->{is_enrollable_from_opac} = $is_enrollable_from_opac
if $is_enrollable_from_opac;
$params->{is_email_required} = 0 unless $self->first_valid_email_address();
$params->{borrower} = $self;
return Koha::Clubs->get_enrollable($params);
}
=head3 type
=cut

6
Koha/Schema/Result/AuthorisedValue.pm

@ -130,9 +130,9 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-08-30 11:52:45
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LOArv8JQ0aiTZgcy+jb7pA
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:13:07
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YwvGOd/jzk71ekWfO56xrw
# You can replace this text with custom content, and it will be preserved on regeneration
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

19
Koha/Schema/Result/Borrower.pm

@ -860,6 +860,21 @@ __PACKAGE__->belongs_to(
{ is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
);
=head2 club_enrollments
Type: has_many
Related object: L<Koha::Schema::Result::ClubEnrollment>
=cut
__PACKAGE__->has_many(
"club_enrollments",
"Koha::Schema::Result::ClubEnrollment",
{ "foreign.borrowernumber" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 course_instructors
Type: has_many
@ -1341,8 +1356,8 @@ Composing rels: L</aqorder_users> -> ordernumber
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-02-10 07:30:06
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:35WEsGd5LmkZ3bB486M1yA
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qq3fmJ73x8Qv+Pqbs7zkow
__PACKAGE__->belongs_to(
"guarantor",

49
Koha/Schema/Result/Branch.pm

@ -360,6 +360,51 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_enrollments
Type: has_many
Related object: L<Koha::Schema::Result::ClubEnrollment>
=cut
__PACKAGE__->has_many(
"club_enrollments",
"Koha::Schema::Result::ClubEnrollment",
{ "foreign.branchcode" => "self.branchcode" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_templates
Type: has_many
Related object: L<Koha::Schema::Result::ClubTemplate>
=cut
__PACKAGE__->has_many(
"club_templates",
"Koha::Schema::Result::ClubTemplate",
{ "foreign.branchcode" => "self.branchcode" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 clubs
Type: has_many
Related object: L<Koha::Schema::Result::Club>
=cut
__PACKAGE__->has_many(
"clubs",
"Koha::Schema::Result::Club",
{ "foreign.branchcode" => "self.branchcode" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 collections
Type: has_many
@ -551,8 +596,8 @@ Composing rels: L</branchrelations> -> categorycode
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-03-23 13:30:04
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:r12VO55fG0lzxkz7fVDmAA
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:99U1YQ4iSum4LbBha4hDTQ
# You can replace this text with custom code or comments, and it will be preserved on regeneration

182
Koha/Schema/Result/Club.pm

@ -0,0 +1,182 @@
use utf8;
package Koha::Schema::Result::Club;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::Club
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<clubs>
=cut
__PACKAGE__->table("clubs");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 club_template_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 name
data_type: 'tinytext'
is_nullable: 0
=head2 description
data_type: 'text'
is_nullable: 1
=head2 date_start
data_type: 'date'
datetime_undef_if_invalid: 1
is_nullable: 1
=head2 date_end
data_type: 'date'
datetime_undef_if_invalid: 1
is_nullable: 1
=head2 branchcode
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 1
size: 10
=head2 date_created
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: current_timestamp
is_nullable: 0
=head2 date_updated
data_type: 'timestamp'
datetime_undef_if_invalid: 1
is_nullable: 1
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"club_template_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"name",
{ data_type => "tinytext", is_nullable => 0 },
"description",
{ data_type => "text", is_nullable => 1 },
"date_start",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"date_end",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"branchcode",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
"date_created",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
default_value => \"current_timestamp",
is_nullable => 0,
},
"date_updated",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
is_nullable => 1,
},
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 branchcode
Type: belongs_to
Related object: L<Koha::Schema::Result::Branch>
=cut
__PACKAGE__->belongs_to(
"branchcode",
"Koha::Schema::Result::Branch",
{ branchcode => "branchcode" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "RESTRICT",
on_update => "RESTRICT",
},
);
=head2 club_enrollments
Type: has_many
Related object: L<Koha::Schema::Result::ClubEnrollment>
=cut
__PACKAGE__->has_many(
"club_enrollments",
"Koha::Schema::Result::ClubEnrollment",
{ "foreign.club_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_template
Type: belongs_to
Related object: L<Koha::Schema::Result::ClubTemplate>
=cut
__PACKAGE__->belongs_to(
"club_template",
"Koha::Schema::Result::ClubTemplate",
{ id => "club_template_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H7MVPMvbDxo++sKrggmUyA
# You can replace this text with custom content, and it will be preserved on regeneration
1;

201
Koha/Schema/Result/ClubEnrollment.pm

@ -0,0 +1,201 @@
use utf8;
package Koha::Schema::Result::ClubEnrollment;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::ClubEnrollment
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<club_enrollments>
=cut
__PACKAGE__->table("club_enrollments");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 club_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 borrowernumber
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 date_enrolled
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: current_timestamp
is_nullable: 0
=head2 date_canceled
data_type: 'timestamp'
datetime_undef_if_invalid: 1
is_nullable: 1
=head2 date_created
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: '0000-00-00 00:00:00'
is_nullable: 0
=head2 date_updated
data_type: 'timestamp'
datetime_undef_if_invalid: 1
is_nullable: 1
=head2 branchcode
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 1
size: 10
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"club_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"borrowernumber",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"date_enrolled",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
default_value => \"current_timestamp",
is_nullable => 0,
},
"date_canceled",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
is_nullable => 1,
},
"date_created",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
default_value => "0000-00-00 00:00:00",
is_nullable => 0,
},
"date_updated",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
is_nullable => 1,
},
"branchcode",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 borrowernumber
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"borrowernumber",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "borrowernumber" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 branchcode
Type: belongs_to
Related object: L<Koha::Schema::Result::Branch>
=cut
__PACKAGE__->belongs_to(
"branchcode",
"Koha::Schema::Result::Branch",
{ branchcode => "branchcode" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 club
Type: belongs_to
Related object: L<Koha::Schema::Result::Club>
=cut
__PACKAGE__->belongs_to(
"club",
"Koha::Schema::Result::Club",
{ id => "club_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 club_enrollment_fields
Type: has_many
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
=cut
__PACKAGE__->has_many(
"club_enrollment_fields",
"Koha::Schema::Result::ClubEnrollmentField",
{ "foreign.club_enrollment_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a1uTIm+Y9A0jEBiumQ60jg
# You can replace this text with custom content, and it will be preserved on regeneration
1;

112
Koha/Schema/Result/ClubEnrollmentField.pm

@ -0,0 +1,112 @@
use utf8;
package Koha::Schema::Result::ClubEnrollmentField;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::ClubEnrollmentField
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<club_enrollment_fields>
=cut
__PACKAGE__->table("club_enrollment_fields");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 club_enrollment_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 club_template_enrollment_field_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 value
data_type: 'text'
is_nullable: 0
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"club_enrollment_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"club_template_enrollment_field_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"value",
{ data_type => "text", is_nullable => 0 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 club_enrollment
Type: belongs_to
Related object: L<Koha::Schema::Result::ClubEnrollment>
=cut
__PACKAGE__->belongs_to(
"club_enrollment",
"Koha::Schema::Result::ClubEnrollment",
{ id => "club_enrollment_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 club_template_enrollment_field
Type: belongs_to
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
=cut
__PACKAGE__->belongs_to(
"club_template_enrollment_field",
"Koha::Schema::Result::ClubTemplateEnrollmentField",
{ id => "club_template_enrollment_field_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2ANAs3mh3i/kd3Qxrcd5IA
# You can replace this text with custom content, and it will be preserved on regeneration
1;

112
Koha/Schema/Result/ClubField.pm

@ -0,0 +1,112 @@
use utf8;
package Koha::Schema::Result::ClubField;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
<