Browse Source
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
61 changed files with 4414 additions and 28 deletions
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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 |
|||
< |