Bugzilla – Attachment 30456 Details for
Bug 12461
Add patron clubs feature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12461 - Add patron clubs feature
Bug-12461---Add-patron-clubs-feature.patch (text/plain), 145.63 KB, created by
Kyle M Hall (khall)
on 2014-08-01 14:46:41 UTC
(
hide
)
Description:
Bug 12461 - Add patron clubs feature
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-08-01 14:46:41 UTC
Size:
145.63 KB
patch
obsolete
>From ef40735de668f6bd8595b76110f42744b6cc2cf0 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 23 May 2014 11:54:26 -0400 >Subject: [PATCH] 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 >--- > C4/Members.pm | 18 +- > Koha/Schema/Result/Borrower.pm | 660 ++++++++++++++++---- > Koha/Schema/Result/Club.pm | 168 +++++ > Koha/Schema/Result/ClubEnrollment.pm | 167 +++++ > Koha/Schema/Result/ClubEnrollmentField.pm | 97 +++ > Koha/Schema/Result/ClubField.pm | 127 ++++ > Koha/Schema/Result/ClubTemplate.pm | 168 +++++ > Koha/Schema/Result/ClubTemplateEnrollmentField.pm | 104 +++ > Koha/Schema/Result/ClubTemplateField.pm | 104 +++ > Koha/Template/Plugin/AuthorisedValues.pm | 6 + > Koha/Template/Plugin/Borrowers.pm | 4 + > Koha/Template/Plugin/Branches.pm | 7 + > Koha/Template/Plugin/Koha.pm | 5 + > circ/circulation.pl | 3 + > clubs/clubs-add-modify.pl | 125 ++++ > clubs/clubs.pl | 50 ++ > clubs/patron-clubs-tab.pl | 59 ++ > clubs/patron-enroll.pl | 52 ++ > clubs/templates-add-modify.pl | 139 ++++ > installer/data/mysql/en/mandatory/userflags.sql | 1 + > .../data/mysql/en/mandatory/userpermissions.sql | 3 + > installer/data/mysql/kohastructure.sql | 173 +++++ > installer/data/mysql/updatedatabase.pl | 148 +++++ > .../prog/en/modules/circ/circulation.tt | 19 + > .../prog/en/modules/clubs/clubs-add-modify.tt | 136 ++++ > .../intranet-tmpl/prog/en/modules/clubs/clubs.tt | 206 ++++++ > .../prog/en/modules/clubs/patron-clubs-tab.tt | 103 +++ > .../prog/en/modules/clubs/patron-enroll.tt | 67 ++ > .../prog/en/modules/clubs/templates-add-modify.tt | 252 ++++++++ > .../prog/en/modules/members/moremember.tt | 16 + > .../prog/en/modules/tools/tools-home.tt | 5 + > .../bootstrap/en/modules/clubs/clubs-tab.tt | 103 +++ > .../opac-tmpl/bootstrap/en/modules/clubs/enroll.tt | 67 ++ > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 17 + > members/moremember.pl | 3 + > opac/clubs/clubs-tab.pl | 67 ++ > opac/clubs/enroll.pl | 51 ++ > opac/opac-user.pl | 7 +- > opac/svc/club/cancel_enrollment | 52 ++ > opac/svc/club/enroll | 79 +++ > svc/club/cancel_enrollment | 48 ++ > svc/club/delete | 50 ++ > svc/club/enroll | 78 +++ > svc/club/template/delete | 50 ++ > 44 files changed, 3737 insertions(+), 127 deletions(-) > create mode 100644 Koha/Schema/Result/Club.pm > create mode 100644 Koha/Schema/Result/ClubEnrollment.pm > create mode 100644 Koha/Schema/Result/ClubEnrollmentField.pm > create mode 100644 Koha/Schema/Result/ClubField.pm > create mode 100644 Koha/Schema/Result/ClubTemplate.pm > create mode 100644 Koha/Schema/Result/ClubTemplateEnrollmentField.pm > create mode 100644 Koha/Schema/Result/ClubTemplateField.pm > create mode 100755 clubs/clubs-add-modify.pl > create mode 100755 clubs/clubs.pl > create mode 100755 clubs/patron-clubs-tab.pl > create mode 100755 clubs/patron-enroll.pl > create mode 100755 clubs/templates-add-modify.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt > create mode 100755 opac/clubs/clubs-tab.pl > create mode 100755 opac/clubs/enroll.pl > create mode 100755 opac/svc/club/cancel_enrollment > create mode 100755 opac/svc/club/enroll > create mode 100755 svc/club/cancel_enrollment > create mode 100755 svc/club/delete > create mode 100755 svc/club/enroll > create mode 100755 svc/club/template/delete > >diff --git a/C4/Members.pm b/C4/Members.pm >index 326344d..6b28ae6 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -1473,20 +1473,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::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber ); >+ >+ return $borrower->FirstValidEmailAddress(); > } > > =head2 GetNoticeEmailAddress >diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm >index b1f9e6f..eaa6376 100644 >--- a/Koha/Schema/Result/Borrower.pm >+++ b/Koha/Schema/Result/Borrower.pm >@@ -1,21 +1,17 @@ >-use utf8; > package Koha::Schema::Result::Borrower; > > # Created by DBIx::Class::Schema::Loader > # DO NOT MODIFY THE FIRST PART OF THIS FILE > >-=head1 NAME >- >-Koha::Schema::Result::Borrower >- >-=cut >- > use strict; > use warnings; > > use base 'DBIx::Class::Core'; > >-=head1 TABLE: C<borrowers> >+ >+=head1 NAME >+ >+Koha::Schema::Result::Borrower > > =cut > >@@ -191,7 +187,6 @@ __PACKAGE__->table("borrowers"); > =head2 dateofbirth > > data_type: 'date' >- datetime_undef_if_invalid: 1 > is_nullable: 1 > > =head2 branchcode >@@ -213,13 +208,11 @@ __PACKAGE__->table("borrowers"); > =head2 dateenrolled > > data_type: 'date' >- datetime_undef_if_invalid: 1 > is_nullable: 1 > > =head2 dateexpiry > > data_type: 'date' >- datetime_undef_if_invalid: 1 > is_nullable: 1 > > =head2 gonenoaddress >@@ -235,7 +228,6 @@ __PACKAGE__->table("borrowers"); > =head2 debarred > > data_type: 'date' >- datetime_undef_if_invalid: 1 > is_nullable: 1 > > =head2 debarredcomment >@@ -463,7 +455,7 @@ __PACKAGE__->add_columns( > "b_phone", > { data_type => "mediumtext", is_nullable => 1 }, > "dateofbirth", >- { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, >+ { data_type => "date", is_nullable => 1 }, > "branchcode", > { > data_type => "varchar", >@@ -481,15 +473,15 @@ __PACKAGE__->add_columns( > size => 10, > }, > "dateenrolled", >- { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, >+ { data_type => "date", is_nullable => 1 }, > "dateexpiry", >- { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, >+ { data_type => "date", is_nullable => 1 }, > "gonenoaddress", > { data_type => "tinyint", is_nullable => 1 }, > "lost", > { data_type => "tinyint", is_nullable => 1 }, > "debarred", >- { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, >+ { data_type => "date", is_nullable => 1 }, > "debarredcomment", > { data_type => "varchar", is_nullable => 1, size => 255 }, > "contactname", >@@ -547,51 +539,57 @@ __PACKAGE__->add_columns( > "privacy", > { data_type => "integer", default_value => 1, is_nullable => 0 }, > ); >+__PACKAGE__->set_primary_key("borrowernumber"); >+__PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]); > >-=head1 PRIMARY KEY >+=head1 RELATIONS > >-=over 4 >+=head2 accountlines_borrowernumbers > >-=item * L</borrowernumber> >+Type: has_many > >-=back >+Related object: L<Koha::Schema::Result::Accountline> > > =cut > >-__PACKAGE__->set_primary_key("borrowernumber"); >- >-=head1 UNIQUE CONSTRAINTS >- >-=head2 C<cardnumber> >+__PACKAGE__->has_many( >+ "accountlines_borrowernumbers", >+ "Koha::Schema::Result::Accountline", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); > >-=over 4 >+=head2 accountlines_borrowernumbers > >-=item * L</cardnumber> >+Type: has_many > >-=back >+Related object: L<Koha::Schema::Result::Accountline> > > =cut > >-__PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]); >- >-=head1 RELATIONS >+__PACKAGE__->has_many( >+ "accountlines_borrowernumbers", >+ "Koha::Schema::Result::Accountline", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); > >-=head2 accountlines >+=head2 accountoffsets_borrowernumbers > > Type: has_many > >-Related object: L<Koha::Schema::Result::Accountline> >+Related object: L<Koha::Schema::Result::Accountoffset> > > =cut > > __PACKAGE__->has_many( >- "accountlines", >- "Koha::Schema::Result::Accountline", >+ "accountoffsets_borrowernumbers", >+ "Koha::Schema::Result::Accountoffset", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 accountoffsets >+=head2 accountoffsets_borrowernumbers > > Type: has_many > >@@ -600,13 +598,28 @@ Related object: L<Koha::Schema::Result::Accountoffset> > =cut > > __PACKAGE__->has_many( >- "accountoffsets", >+ "accountoffsets_borrowernumbers", > "Koha::Schema::Result::Accountoffset", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 aqbasketusers >+=head2 aqbasketusers_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Aqbasketuser> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "aqbasketusers_borrowernumbers", >+ "Koha::Schema::Result::Aqbasketuser", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 aqbasketusers_borrowernumbers > > Type: has_many > >@@ -615,13 +628,28 @@ Related object: L<Koha::Schema::Result::Aqbasketuser> > =cut > > __PACKAGE__->has_many( >- "aqbasketusers", >+ "aqbasketusers_borrowernumbers", > "Koha::Schema::Result::Aqbasketuser", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 aqbudgetborrowers >+=head2 aqbudgetborrowers_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Aqbudgetborrower> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "aqbudgetborrowers_borrowernumbers", >+ "Koha::Schema::Result::Aqbudgetborrower", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 aqbudgetborrowers_borrowernumbers > > Type: has_many > >@@ -630,13 +658,13 @@ Related object: L<Koha::Schema::Result::Aqbudgetborrower> > =cut > > __PACKAGE__->has_many( >- "aqbudgetborrowers", >+ "aqbudgetborrowers_borrowernumbers", > "Koha::Schema::Result::Aqbudgetborrower", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 borrower_attributes >+=head2 borrower_attributes_borrowernumbers > > Type: has_many > >@@ -645,13 +673,28 @@ Related object: L<Koha::Schema::Result::BorrowerAttribute> > =cut > > __PACKAGE__->has_many( >- "borrower_attributes", >+ "borrower_attributes_borrowernumbers", > "Koha::Schema::Result::BorrowerAttribute", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 borrower_debarments >+=head2 borrower_attributes_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::BorrowerAttribute> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "borrower_attributes_borrowernumbers", >+ "Koha::Schema::Result::BorrowerAttribute", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 borrower_debarments_borrowernumbers > > Type: has_many > >@@ -660,13 +703,43 @@ Related object: L<Koha::Schema::Result::BorrowerDebarment> > =cut > > __PACKAGE__->has_many( >- "borrower_debarments", >+ "borrower_debarments_borrowernumbers", > "Koha::Schema::Result::BorrowerDebarment", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 borrower_files >+=head2 borrower_debarments_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::BorrowerDebarment> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "borrower_debarments_borrowernumbers", >+ "Koha::Schema::Result::BorrowerDebarment", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 borrower_files_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::BorrowerFile> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "borrower_files_borrowernumbers", >+ "Koha::Schema::Result::BorrowerFile", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 borrower_files_borrowernumbers > > Type: has_many > >@@ -675,13 +748,28 @@ Related object: L<Koha::Schema::Result::BorrowerFile> > =cut > > __PACKAGE__->has_many( >- "borrower_files", >+ "borrower_files_borrowernumbers", > "Koha::Schema::Result::BorrowerFile", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 borrower_message_preferences >+=head2 borrower_message_preferences_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::BorrowerMessagePreference> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "borrower_message_preferences_borrowernumbers", >+ "Koha::Schema::Result::BorrowerMessagePreference", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 borrower_message_preferences_borrowernumbers > > Type: has_many > >@@ -690,12 +778,27 @@ Related object: L<Koha::Schema::Result::BorrowerMessagePreference> > =cut > > __PACKAGE__->has_many( >- "borrower_message_preferences", >+ "borrower_message_preferences_borrowernumbers", > "Koha::Schema::Result::BorrowerMessagePreference", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >+=head2 categorycode >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Category> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "categorycode", >+ "Koha::Schema::Result::Category", >+ { categorycode => "categorycode" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ > =head2 branchcode > > Type: belongs_to >@@ -726,7 +829,52 @@ __PACKAGE__->belongs_to( > { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" }, > ); > >-=head2 course_instructors >+=head2 branchcode >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branchcode", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branchcode" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=head2 club_enrollments >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ClubEnrollment> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "club_enrollments", >+ "Koha::Schema::Result::ClubEnrollment", >+ { "foreign.borrower" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 course_instructors_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::CourseInstructor> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "course_instructors_borrowernumbers", >+ "Koha::Schema::Result::CourseInstructor", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 course_instructors_borrowernumbers > > Type: has_many > >@@ -735,13 +883,13 @@ Related object: L<Koha::Schema::Result::CourseInstructor> > =cut > > __PACKAGE__->has_many( >- "course_instructors", >+ "course_instructors_borrowernumbers", > "Koha::Schema::Result::CourseInstructor", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 creator_batches >+=head2 creator_batches_borrower_numbers > > Type: has_many > >@@ -750,13 +898,28 @@ Related object: L<Koha::Schema::Result::CreatorBatch> > =cut > > __PACKAGE__->has_many( >- "creator_batches", >+ "creator_batches_borrower_numbers", > "Koha::Schema::Result::CreatorBatch", > { "foreign.borrower_number" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 hold_fill_targets >+=head2 creator_batches_borrower_numbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::CreatorBatch> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "creator_batches_borrower_numbers", >+ "Koha::Schema::Result::CreatorBatch", >+ { "foreign.borrower_number" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 hold_fill_targets_borrowernumbers > > Type: has_many > >@@ -765,13 +928,43 @@ Related object: L<Koha::Schema::Result::HoldFillTarget> > =cut > > __PACKAGE__->has_many( >- "hold_fill_targets", >+ "hold_fill_targets_borrowernumbers", > "Koha::Schema::Result::HoldFillTarget", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 issues >+=head2 hold_fill_targets_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::HoldFillTarget> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "hold_fill_targets_borrowernumbers", >+ "Koha::Schema::Result::HoldFillTarget", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 issues_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Issue> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "issues_borrowernumbers", >+ "Koha::Schema::Result::Issue", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 issues_borrowernumbers > > Type: has_many > >@@ -780,13 +973,28 @@ Related object: L<Koha::Schema::Result::Issue> > =cut > > __PACKAGE__->has_many( >- "issues", >+ "issues_borrowernumbers", > "Koha::Schema::Result::Issue", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 message_queues >+=head2 message_queue_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::MessageQueue> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "message_queue_borrowernumbers", >+ "Koha::Schema::Result::MessageQueue", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 message_queue_borrowernumbers > > Type: has_many > >@@ -795,13 +1003,13 @@ Related object: L<Koha::Schema::Result::MessageQueue> > =cut > > __PACKAGE__->has_many( >- "message_queues", >+ "message_queue_borrowernumbers", > "Koha::Schema::Result::MessageQueue", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 old_issues >+=head2 old_issues_borrowernumbers > > Type: has_many > >@@ -810,13 +1018,28 @@ Related object: L<Koha::Schema::Result::OldIssue> > =cut > > __PACKAGE__->has_many( >- "old_issues", >+ "old_issues_borrowernumbers", > "Koha::Schema::Result::OldIssue", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 old_reserves >+=head2 old_issues_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::OldIssue> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "old_issues_borrowernumbers", >+ "Koha::Schema::Result::OldIssue", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 old_reserves_borrowernumbers > > Type: has_many > >@@ -825,13 +1048,43 @@ Related object: L<Koha::Schema::Result::OldReserve> > =cut > > __PACKAGE__->has_many( >- "old_reserves", >+ "old_reserves_borrowernumbers", > "Koha::Schema::Result::OldReserve", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 patron_list_patrons >+=head2 old_reserves_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::OldReserve> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "old_reserves_borrowernumbers", >+ "Koha::Schema::Result::OldReserve", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 patron_list_patrons_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::PatronListPatron> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "patron_list_patrons_borrowernumbers", >+ "Koha::Schema::Result::PatronListPatron", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 patron_list_patrons_borrowernumbers > > Type: has_many > >@@ -840,13 +1093,28 @@ Related object: L<Koha::Schema::Result::PatronListPatron> > =cut > > __PACKAGE__->has_many( >- "patron_list_patrons", >+ "patron_list_patrons_borrowernumbers", > "Koha::Schema::Result::PatronListPatron", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 patron_lists >+=head2 patron_lists_owners >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::PatronList> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "patron_lists_owners", >+ "Koha::Schema::Result::PatronList", >+ { "foreign.owner" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 patron_lists_owners > > Type: has_many > >@@ -855,13 +1123,13 @@ Related object: L<Koha::Schema::Result::PatronList> > =cut > > __PACKAGE__->has_many( >- "patron_lists", >+ "patron_lists_owners", > "Koha::Schema::Result::PatronList", > { "foreign.owner" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 patroncards >+=head2 patroncards_borrowernumbers > > Type: has_many > >@@ -870,13 +1138,28 @@ Related object: L<Koha::Schema::Result::Patroncard> > =cut > > __PACKAGE__->has_many( >- "patroncards", >+ "patroncards_borrowernumbers", > "Koha::Schema::Result::Patroncard", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 patronimage >+=head2 patroncards_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Patroncard> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "patroncards_borrowernumbers", >+ "Koha::Schema::Result::Patroncard", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 patronimage_borrowernumber > > Type: might_have > >@@ -885,13 +1168,43 @@ Related object: L<Koha::Schema::Result::Patronimage> > =cut > > __PACKAGE__->might_have( >- "patronimage", >+ "patronimage_borrowernumber", > "Koha::Schema::Result::Patronimage", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 ratings >+=head2 patronimage_borrowernumber >+ >+Type: might_have >+ >+Related object: L<Koha::Schema::Result::Patronimage> >+ >+=cut >+ >+__PACKAGE__->might_have( >+ "patronimage_borrowernumber", >+ "Koha::Schema::Result::Patronimage", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 ratings_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Rating> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "ratings_borrowernumbers", >+ "Koha::Schema::Result::Rating", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 ratings_borrowernumbers > > Type: has_many > >@@ -900,13 +1213,28 @@ Related object: L<Koha::Schema::Result::Rating> > =cut > > __PACKAGE__->has_many( >- "ratings", >+ "ratings_borrowernumbers", > "Koha::Schema::Result::Rating", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 reserves >+=head2 reserves_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Reserve> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "reserves_borrowernumbers", >+ "Koha::Schema::Result::Reserve", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 reserves_borrowernumbers > > Type: has_many > >@@ -915,13 +1243,13 @@ Related object: L<Koha::Schema::Result::Reserve> > =cut > > __PACKAGE__->has_many( >- "reserves", >+ "reserves_borrowernumbers", > "Koha::Schema::Result::Reserve", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 reviews >+=head2 reviews_borrowernumbers > > Type: has_many > >@@ -930,13 +1258,28 @@ Related object: L<Koha::Schema::Result::Review> > =cut > > __PACKAGE__->has_many( >- "reviews", >+ "reviews_borrowernumbers", > "Koha::Schema::Result::Review", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 subscriptionroutinglists >+=head2 reviews_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Review> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "reviews_borrowernumbers", >+ "Koha::Schema::Result::Review", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 subscriptionroutinglist_borrowernumbers > > Type: has_many > >@@ -945,13 +1288,43 @@ Related object: L<Koha::Schema::Result::Subscriptionroutinglist> > =cut > > __PACKAGE__->has_many( >- "subscriptionroutinglists", >+ "subscriptionroutinglist_borrowernumbers", > "Koha::Schema::Result::Subscriptionroutinglist", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 tags_all >+=head2 subscriptionroutinglist_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Subscriptionroutinglist> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "subscriptionroutinglist_borrowernumbers", >+ "Koha::Schema::Result::Subscriptionroutinglist", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 tags_all_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::TagAll> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "tags_all_borrowernumbers", >+ "Koha::Schema::Result::TagAll", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 tags_all_borrowernumbers > > Type: has_many > >@@ -960,13 +1333,28 @@ Related object: L<Koha::Schema::Result::TagAll> > =cut > > __PACKAGE__->has_many( >- "tags_all", >+ "tags_all_borrowernumbers", > "Koha::Schema::Result::TagAll", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 tags_approvals >+=head2 tags_approvals_approved_by >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::TagsApproval> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "tags_approvals_approved_by", >+ "Koha::Schema::Result::TagsApproval", >+ { "foreign.approved_by" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 tags_approvals_approved_by > > Type: has_many > >@@ -975,13 +1363,13 @@ Related object: L<Koha::Schema::Result::TagsApproval> > =cut > > __PACKAGE__->has_many( >- "tags_approvals", >+ "tags_approvals_approved_by", > "Koha::Schema::Result::TagsApproval", > { "foreign.approved_by" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 user_permissions >+=head2 user_permissions_borrowernumbers > > Type: has_many > >@@ -990,13 +1378,28 @@ Related object: L<Koha::Schema::Result::UserPermission> > =cut > > __PACKAGE__->has_many( >- "user_permissions", >+ "user_permissions_borrowernumbers", > "Koha::Schema::Result::UserPermission", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 virtualshelfcontents >+=head2 user_permissions_borrowernumbers >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::UserPermission> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "user_permissions_borrowernumbers", >+ "Koha::Schema::Result::UserPermission", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 virtualshelfcontents_borrowernumbers > > Type: has_many > >@@ -1005,76 +1408,113 @@ Related object: L<Koha::Schema::Result::Virtualshelfcontent> > =cut > > __PACKAGE__->has_many( >- "virtualshelfcontents", >+ "virtualshelfcontents_borrowernumbers", > "Koha::Schema::Result::Virtualshelfcontent", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 virtualshelfshares >+=head2 virtualshelfcontents_borrowernumbers > > Type: has_many > >-Related object: L<Koha::Schema::Result::Virtualshelfshare> >+Related object: L<Koha::Schema::Result::Virtualshelfcontent> > > =cut > > __PACKAGE__->has_many( >- "virtualshelfshares", >- "Koha::Schema::Result::Virtualshelfshare", >+ "virtualshelfcontents_borrowernumbers", >+ "Koha::Schema::Result::Virtualshelfcontent", > { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 virtualshelves >+=head2 virtualshelfshares_borrowernumbers > > Type: has_many > >-Related object: L<Koha::Schema::Result::Virtualshelve> >+Related object: L<Koha::Schema::Result::Virtualshelfshare> > > =cut > > __PACKAGE__->has_many( >- "virtualshelves", >- "Koha::Schema::Result::Virtualshelve", >- { "foreign.owner" => "self.borrowernumber" }, >+ "virtualshelfshares_borrowernumbers", >+ "Koha::Schema::Result::Virtualshelfshare", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, > { cascade_copy => 0, cascade_delete => 0 }, > ); > >-=head2 basketnoes >+=head2 virtualshelfshares_borrowernumbers > >-Type: many_to_many >+Type: has_many > >-Composing rels: L</aqbasketusers> -> basketno >+Related object: L<Koha::Schema::Result::Virtualshelfshare> > > =cut > >-__PACKAGE__->many_to_many("basketnoes", "aqbasketusers", "basketno"); >+__PACKAGE__->has_many( >+ "virtualshelfshares_borrowernumbers", >+ "Koha::Schema::Result::Virtualshelfshare", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); > >-=head2 budgets >+=head2 virtualshelves_owners > >-Type: many_to_many >+Type: has_many > >-Composing rels: L</aqbudgetborrowers> -> budget >+Related object: L<Koha::Schema::Result::Virtualshelve> > > =cut > >-__PACKAGE__->many_to_many("budgets", "aqbudgetborrowers", "budget"); >+__PACKAGE__->has_many( >+ "virtualshelves_owners", >+ "Koha::Schema::Result::Virtualshelve", >+ { "foreign.owner" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); > >-=head2 courses >+=head2 virtualshelves_owners > >-Type: many_to_many >+Type: has_many > >-Composing rels: L</course_instructors> -> course >+Related object: L<Koha::Schema::Result::Virtualshelve> > > =cut > >-__PACKAGE__->many_to_many("courses", "course_instructors", "course"); >+__PACKAGE__->has_many( >+ "virtualshelves_owners", >+ "Koha::Schema::Result::Virtualshelve", >+ { "foreign.owner" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); > > > # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-07-11 09:26:55 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5cfpOojccKCoVRMj+0mWHg >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TIft8zTHaGV8X/T6uhW8uw >+ >+sub FirstValidEmailAddress { >+ my ( $self ) = @_; >+ >+ return $self->email() || $self->emailpro() || $self->b_email() || q{}; >+} >+ >+sub ClubsEnrolledCount { >+ my ( $self ) = @_; >+ >+ return $self->club_enrollments({ date_canceled => undef })->count(); >+} >+ >+sub ClubsEnrollableCount { >+ 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->FirstValidEmailAddress(); > >+ return $self->result_source->schema->resultset('Club') >+ ->search( $params, { prefetch => 'club_template' } )->count(); >+} > >-# You can replace this text with custom content, and it will be preserved on regeneration > 1; >diff --git a/Koha/Schema/Result/Club.pm b/Koha/Schema/Result/Club.pm >new file mode 100644 >index 0000000..0462d00 >--- /dev/null >+++ b/Koha/Schema/Result/Club.pm >@@ -0,0 +1,168 @@ >+package Koha::Schema::Result::Club; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::Club >+ >+=cut >+ >+__PACKAGE__->table("clubs"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 club_template >+ >+ 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' >+ is_nullable: 0 >+ >+=head2 date_end >+ >+ data_type: 'date' >+ is_nullable: 1 >+ >+=head2 branch >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 11 >+ >+=head2 date_created >+ >+ data_type: 'timestamp' >+ default_value: current_timestamp >+ is_nullable: 0 >+ >+=head2 date_updated >+ >+ data_type: 'timestamp' >+ is_nullable: 1 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "club_template", >+ { 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", is_nullable => 0 }, >+ "date_end", >+ { data_type => "date", is_nullable => 1 }, >+ "branch", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 }, >+ "date_created", >+ { >+ data_type => "timestamp", >+ default_value => \"current_timestamp", >+ is_nullable => 0, >+ }, >+ "date_updated", >+ { data_type => "timestamp", is_nullable => 1 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=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" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 club_fields >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ClubField> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "club_fields", >+ "Koha::Schema::Result::ClubField", >+ { "foreign.club" => "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" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=head2 branch >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branch" }, >+ { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Y6kcTQulxM9XeOpDV+TiiQ >+ >+ >+# You can replace this text with custom content, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/ClubEnrollment.pm b/Koha/Schema/Result/ClubEnrollment.pm >new file mode 100644 >index 0000000..e456905 >--- /dev/null >+++ b/Koha/Schema/Result/ClubEnrollment.pm >@@ -0,0 +1,167 @@ >+package Koha::Schema::Result::ClubEnrollment; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::ClubEnrollment >+ >+=cut >+ >+__PACKAGE__->table("club_enrollments"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 club >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 borrower >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 date_enrolled >+ >+ data_type: 'timestamp' >+ default_value: current_timestamp >+ is_nullable: 0 >+ >+=head2 date_canceled >+ >+ data_type: 'timestamp' >+ is_nullable: 1 >+ >+=head2 date_created >+ >+ data_type: 'timestamp' >+ default_value: '0000-00-00 00:00:00' >+ is_nullable: 0 >+ >+=head2 date_updated >+ >+ data_type: 'timestamp' >+ is_nullable: 1 >+ >+=head2 branch >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 11 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "club", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "borrower", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "date_enrolled", >+ { >+ data_type => "timestamp", >+ default_value => \"current_timestamp", >+ is_nullable => 0, >+ }, >+ "date_canceled", >+ { data_type => "timestamp", is_nullable => 1 }, >+ "date_created", >+ { >+ data_type => "timestamp", >+ default_value => "0000-00-00 00:00:00", >+ is_nullable => 0, >+ }, >+ "date_updated", >+ { data_type => "timestamp", is_nullable => 1 }, >+ "branch", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=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" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 club >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Club> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "club", >+ "Koha::Schema::Result::Club", >+ { id => "club" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=head2 borrower >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Borrower> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "borrower", >+ "Koha::Schema::Result::Borrower", >+ { borrowernumber => "borrower" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=head2 branch >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branch" }, >+ { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mfTpVLaQhTKJ//QnRm2f5A >+ >+ >+# You can replace this text with custom content, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/ClubEnrollmentField.pm b/Koha/Schema/Result/ClubEnrollmentField.pm >new file mode 100644 >index 0000000..73c6c41 >--- /dev/null >+++ b/Koha/Schema/Result/ClubEnrollmentField.pm >@@ -0,0 +1,97 @@ >+package Koha::Schema::Result::ClubEnrollmentField; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::ClubEnrollmentField >+ >+=cut >+ >+__PACKAGE__->table("club_enrollment_fields"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 club_enrollment >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 club_template_enrollment_field >+ >+ 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", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "club_template_enrollment_field", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "value", >+ { data_type => "text", is_nullable => 0 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=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" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=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" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bOPkyazyrsDwUKKS4oHHdQ >+ >+ >+# You can replace this text with custom content, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/ClubField.pm b/Koha/Schema/Result/ClubField.pm >new file mode 100644 >index 0000000..047ff09 >--- /dev/null >+++ b/Koha/Schema/Result/ClubField.pm >@@ -0,0 +1,127 @@ >+package Koha::Schema::Result::ClubField; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::ClubField >+ >+=cut >+ >+__PACKAGE__->table("club_fields"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 club_template_field >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 club >+ >+ data_type: 'integer' >+ is_foreign_key: 1 >+ is_nullable: 0 >+ >+=head2 value >+ >+ data_type: 'text' >+ is_nullable: 1 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "club_template_field", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "club", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "value", >+ { data_type => "text", is_nullable => 1 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=head2 club_template_field >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::ClubTemplateField> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "club_template_field", >+ "Koha::Schema::Result::ClubTemplateField", >+ { id => "club_template_field" }, >+ { on_delete => "CASCADE", 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" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=head2 z_clubs_rewrite_clubs >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ZClubRewrite> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "z_clubs_rewrite_clubs", >+ "Koha::Schema::Result::ZClubRewrite", >+ { "foreign.club" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 z_clubs_rewrite_club_template_fields >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ZClubRewrite> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "z_clubs_rewrite_club_template_fields", >+ "Koha::Schema::Result::ZClubRewrite", >+ { "foreign.club_template_field" => "self.club_template_field" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B5i1BInvl7L9Mjor17Okrw >+ >+ >+# You can replace this text with custom content, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/ClubTemplate.pm b/Koha/Schema/Result/ClubTemplate.pm >new file mode 100644 >index 0000000..85f3d36 >--- /dev/null >+++ b/Koha/Schema/Result/ClubTemplate.pm >@@ -0,0 +1,168 @@ >+package Koha::Schema::Result::ClubTemplate; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::ClubTemplate >+ >+=cut >+ >+__PACKAGE__->table("club_templates"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 name >+ >+ data_type: 'tinytext' >+ is_nullable: 0 >+ >+=head2 description >+ >+ data_type: 'text' >+ is_nullable: 1 >+ >+=head2 is_enrollable_from_opac >+ >+ data_type: 'tinyint' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 is_email_required >+ >+ data_type: 'tinyint' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 branch >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=head2 date_created >+ >+ data_type: 'timestamp' >+ default_value: current_timestamp >+ is_nullable: 0 >+ >+=head2 date_updated >+ >+ data_type: 'timestamp' >+ is_nullable: 1 >+ >+=head2 is_deletable >+ >+ data_type: 'tinyint' >+ default_value: 1 >+ is_nullable: 0 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "name", >+ { data_type => "tinytext", is_nullable => 0 }, >+ "description", >+ { data_type => "text", is_nullable => 1 }, >+ "is_enrollable_from_opac", >+ { data_type => "tinyint", default_value => 0, is_nullable => 0 }, >+ "is_email_required", >+ { data_type => "tinyint", default_value => 0, is_nullable => 0 }, >+ "branch", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, >+ "date_created", >+ { >+ data_type => "timestamp", >+ default_value => \"current_timestamp", >+ is_nullable => 0, >+ }, >+ "date_updated", >+ { data_type => "timestamp", is_nullable => 1 }, >+ "is_deletable", >+ { data_type => "tinyint", default_value => 1, is_nullable => 0 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=head2 club_template_enrollment_fields >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "club_template_enrollment_fields", >+ "Koha::Schema::Result::ClubTemplateEnrollmentField", >+ { "foreign.club_template" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 club_template_fields >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ClubTemplateField> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "club_template_fields", >+ "Koha::Schema::Result::ClubTemplateField", >+ { "foreign.club_template" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 branch >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branch" }, >+ { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+=head2 clubs >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Club> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "clubs", >+ "Koha::Schema::Result::Club", >+ { "foreign.club_template" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-23 10:30:48 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XhoCAiWRvHG5FBNhr7JEkg >+ >+1; >diff --git a/Koha/Schema/Result/ClubTemplateEnrollmentField.pm b/Koha/Schema/Result/ClubTemplateEnrollmentField.pm >new file mode 100644 >index 0000000..c6aa838 >--- /dev/null >+++ b/Koha/Schema/Result/ClubTemplateEnrollmentField.pm >@@ -0,0 +1,104 @@ >+package Koha::Schema::Result::ClubTemplateEnrollmentField; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::ClubTemplateEnrollmentField >+ >+=cut >+ >+__PACKAGE__->table("club_template_enrollment_fields"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 club_template >+ >+ 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 authorised_value_category >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 16 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "club_template", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "name", >+ { data_type => "tinytext", is_nullable => 0 }, >+ "description", >+ { data_type => "text", is_nullable => 1 }, >+ "authorised_value_category", >+ { data_type => "varchar", is_nullable => 1, size => 16 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=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_template_enrollment_field" => "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" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FO/5gEcTgdIYma9hmhXdNw >+ >+ >+# You can replace this text with custom content, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/ClubTemplateField.pm b/Koha/Schema/Result/ClubTemplateField.pm >new file mode 100644 >index 0000000..ebffa71 >--- /dev/null >+++ b/Koha/Schema/Result/ClubTemplateField.pm >@@ -0,0 +1,104 @@ >+package Koha::Schema::Result::ClubTemplateField; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+ >+=head1 NAME >+ >+Koha::Schema::Result::ClubTemplateField >+ >+=cut >+ >+__PACKAGE__->table("club_template_fields"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 club_template >+ >+ 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 authorised_value_category >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 16 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "club_template", >+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, >+ "name", >+ { data_type => "tinytext", is_nullable => 0 }, >+ "description", >+ { data_type => "text", is_nullable => 1 }, >+ "authorised_value_category", >+ { data_type => "varchar", is_nullable => 1, size => 16 }, >+); >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=head2 club_fields >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::ClubField> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "club_fields", >+ "Koha::Schema::Result::ClubField", >+ { "foreign.club_template_field" => "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" }, >+ { on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-23 11:09:48 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rm9181l4mTPyIpDBQTERBQ >+ >+ >+# You can replace this text with custom content, and it will be preserved on regeneration >+1; >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index 65abac7..4475b6c 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -40,6 +40,12 @@ sub GetAuthValueDropbox { > return C4::Koha::GetAuthvalueDropbox($category, $default); > } > >+sub Categories { >+ my ( $self ) = @_; >+ >+ return GetAuthorisedValueCategories(); >+} >+ > 1; > > =head1 NAME >diff --git a/Koha/Template/Plugin/Borrowers.pm b/Koha/Template/Plugin/Borrowers.pm >index b8f3de5..39112f7 100644 >--- a/Koha/Template/Plugin/Borrowers.pm >+++ b/Koha/Template/Plugin/Borrowers.pm >@@ -48,4 +48,8 @@ sub IsDebarred { > return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}); > } > >+sub HasValidEmailAddress { >+ >+} >+ > 1; >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index ff43a38..8d67a2f 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -26,6 +26,13 @@ use Encode qw{encode decode}; > use C4::Koha; > use C4::Context; > >+sub GetBranches { >+ my ($self) = @_; >+ >+ my $dbh = C4::Context->dbh; >+ return $dbh->selectall_arrayref( "SELECT * FROM branches", { Slice => {} } ); >+} >+ > sub GetName { > my ( $self, $branchcode ) = @_; > >diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm >index 2eff9f1..bb4e47b 100644 >--- a/Koha/Template/Plugin/Koha.pm >+++ b/Koha/Template/Plugin/Koha.pm >@@ -44,4 +44,9 @@ sub Preference { > return C4::Context->preference( $pref ); > } > >+sub UserEnv { >+ my ( $self, $key ) = @_; >+ my $userenv = C4::Context->userenv; >+ return $userenv ? $userenv->{$key} : undef; >+} > 1; >diff --git a/circ/circulation.pl b/circ/circulation.pl >index b95bffa..b7a00fa 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -572,6 +572,8 @@ $template->param( picture => 1 ) if $picture; > > my $canned_notes = GetAuthorisedValues("BOR_NOTES"); > >+my $schema = Koha::Database->new()->schema(); >+ > $template->param( > debt_confirmed => $debt_confirmed, > SpecifyDueDate => $duedatespec_allow, >@@ -581,6 +583,7 @@ $template->param( > export_with_csv_profile => C4::Context->preference("ExportWithCsvProfile"), > canned_bor_notes_loop => $canned_notes, > debarments => GetDebarments({ borrowernumber => $borrowernumber }), >+ borrower => $schema->resultset('Borrower')->find( $borrowernumber ), > ); > > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/clubs/clubs-add-modify.pl b/clubs/clubs-add-modify.pl >new file mode 100755 >index 0000000..fefe46a >--- /dev/null >+++ b/clubs/clubs-add-modify.pl >@@ -0,0 +1,125 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => 'clubs/clubs-add-modify.tt', >+ query => $cgi, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { clubs => 'edit_clubs' }, >+ } >+); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $id = $cgi->param('id'); >+my $club = $schema->resultset('Club')->find($id); >+ >+my $club_template_id = >+ $club ? $club->club_template()->id() : $cgi->param('club_template_id'); >+my $club_template = $schema->resultset('ClubTemplate')->find($club_template_id); >+ >+my $date_start = $cgi->param('date_start'); >+$date_start = $date_start ? dt_from_string($date_start) : undef; >+my $date_end = $cgi->param('date_end'); >+$date_end = $date_end ? dt_from_string($date_end) : undef; >+ >+if ( $cgi->param('name') ) { # Update or create club >+ if ($club) { >+ $club->update( >+ { >+ id => $id || undef, >+ club_template => $cgi->param('club_template_id') || undef, >+ name => $cgi->param('name') || undef, >+ description => $cgi->param('description') || undef, >+ branch => $cgi->param('branchcode') || undef, >+ date_start => $date_start, >+ date_end => $date_end, >+ date_updated => dt_from_string(), >+ } >+ ); >+ } >+ else { >+ $club = $schema->resultset('Club')->create( >+ { >+ id => $id || undef, >+ club_template => $cgi->param('club_template_id') || undef, >+ name => $cgi->param('name') || undef, >+ description => $cgi->param('description') || undef, >+ branch => $cgi->param('branchcode') || undef, >+ date_start => $date_start, >+ date_end => $date_end, >+ date_updated => dt_from_string(), >+ } >+ ); >+ >+ } >+ >+ my @club_template_field_id = $cgi->param('club_template_field_id'); >+ my @club_field_id = $cgi->param('club_field_id'); >+ my @club_field = $cgi->param('club_field'); >+ >+ for ( my $i = 0 ; $i < @club_template_field_id ; $i++ ) { >+ my $club_template_field_id = $club_template_field_id[$i] || undef; >+ my $club_field_id = $club_field_id[$i] || undef; >+ my $club_field = $club_field[$i] || undef; >+ >+ if ($club_field_id) { >+ $schema->resultset('ClubField')->find($club_field_id)->update( >+ { >+ club => $club->id(), >+ club_template_field => $club_template_field_id, >+ value => $club_field, >+ } >+ ); >+ } >+ else { >+ $schema->resultset('ClubField')->create( >+ { >+ club => $club->id(), >+ club_template_field => $club_template_field_id, >+ value => $club_field, >+ } >+ ); >+ } >+ } >+ >+ $id ||= $club->id(); >+} >+ >+$club = $schema->resultset('Club')->find($id); >+ >+$template->param( >+ club_template => $club_template, >+ club => $club, >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/clubs/clubs.pl b/clubs/clubs.pl >new file mode 100755 >index 0000000..6e68231 >--- /dev/null >+++ b/clubs/clubs.pl >@@ -0,0 +1,50 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "clubs/clubs.tt", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { clubs => '*' }, >+ } >+); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my @club_templates = $schema->resultset("ClubTemplate")->all(); >+my @clubs = $schema->resultset("Club")->all(); >+ >+$template->param( >+ club_templates => \@club_templates, >+ clubs => \@clubs >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/clubs/patron-clubs-tab.pl b/clubs/patron-clubs-tab.pl >new file mode 100755 >index 0000000..2029ca9 >--- /dev/null >+++ b/clubs/patron-clubs-tab.pl >@@ -0,0 +1,59 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "clubs/patron-clubs-tab.tt", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { clubs => '*' }, >+ } >+); >+ >+my $borrowernumber = $cgi->param('borrowernumber'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my @enrollments = >+ $schema->resultset("ClubEnrollment") >+ ->search( { borrower => $borrowernumber, date_canceled => undef } ); >+ >+my @clubs = >+ $schema->resultset("Club") >+ ->search( >+ { id => { -not_in => [ map { $_->club()->id() } @enrollments ] } } ); >+ >+$template->param( >+ enrollments => \@enrollments, >+ clubs => \@clubs, >+ borrowernumber => $borrowernumber >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/clubs/patron-enroll.pl b/clubs/patron-enroll.pl >new file mode 100755 >index 0000000..41e7a34 >--- /dev/null >+++ b/clubs/patron-enroll.pl >@@ -0,0 +1,52 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "clubs/patron-enroll.tt", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { clubs => '*' }, >+ } >+); >+ >+my $id = $cgi->param('id'); >+my $borrowernumber = $cgi->param('borrowernumber'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $club = $schema->resultset("Club")->find($id); >+ >+$template->param( >+ club => $club, >+ borrowernumber => $borrowernumber, >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/clubs/templates-add-modify.pl b/clubs/templates-add-modify.pl >new file mode 100755 >index 0000000..4133257 >--- /dev/null >+++ b/clubs/templates-add-modify.pl >@@ -0,0 +1,139 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => 'clubs/templates-add-modify.tt', >+ query => $cgi, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { clubs => 'edit_templates' }, >+ } >+); >+ >+my $id = $cgi->param('id'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $club_template; >+ >+if ( $cgi->param('name') ) { # Update or create club >+ $club_template = $schema->resultset('ClubTemplate')->update_or_create( >+ { >+ id => $id || undef, >+ name => $cgi->param('name') || undef, >+ description => $cgi->param('description') || undef, >+ branch => $cgi->param('branchcode') || undef, >+ date_updated => dt_from_string(), >+ is_email_required => $cgi->param('is_email_required') ? 1 : 0, >+ is_enrollable_from_opac => $cgi->param('is_enrollable_from_opac') >+ ? 1 >+ : 0, >+ } >+ ); >+ >+ $id ||= $club_template->id(); >+ >+ # Update club creation fields >+ my @field_id = $cgi->param('club_template_field_id'); >+ my @field_name = $cgi->param('club_template_field_name'); >+ my @field_description = $cgi->param('club_template_field_description'); >+ my @field_authorised_value_category = >+ $cgi->param('club_template_field_authorised_value_category'); >+ >+ my @field_delete = $cgi->param('club_template_field_delete'); >+ >+ for ( my $i = 0 ; $i < @field_id ; $i++ ) { >+ my $field_id = $field_id[$i]; >+ my $field_name = $field_name[$i]; >+ my $field_description = $field_description[$i]; >+ my $field_authorised_value_category = >+ $field_authorised_value_category[$i]; >+ >+ if ( grep( /^$field_id$/, @field_delete ) ) { >+ $schema->resultset('ClubTemplateField')->find($field_id)->delete(); >+ } >+ else { >+ $club_template = >+ $schema->resultset('ClubTemplateField')->update_or_create( >+ { >+ id => $field_id, >+ club_template => $id, >+ name => $field_name, >+ description => $field_description, >+ authorised_value_category => >+ $field_authorised_value_category, >+ } >+ ); >+ } >+ } >+ >+ # Update club enrollment fields >+ @field_id = $cgi->param('club_template_enrollment_field_id'); >+ @field_name = $cgi->param('club_template_enrollment_field_name'); >+ @field_description = >+ $cgi->param('club_template_enrollment_field_description'); >+ @field_authorised_value_category = >+ $cgi->param('club_template_enrollment_field_authorised_value_category'); >+ >+ @field_delete = $cgi->param('club_template_enrollment_field_delete'); >+ >+ for ( my $i = 0 ; $i < @field_id ; $i++ ) { >+ my $field_id = $field_id[$i]; >+ my $field_name = $field_name[$i]; >+ my $field_description = $field_description[$i]; >+ my $field_authorised_value_category = >+ $field_authorised_value_category[$i]; >+ >+ if ( grep( /^$field_id$/, @field_delete ) ) { >+ $schema->resultset('ClubTemplateEnrollmentField')->find($field_id) >+ ->delete(); >+ } >+ else { >+ $club_template = >+ $schema->resultset('ClubTemplateEnrollmentField') >+ ->update_or_create( >+ { >+ id => $field_id, >+ club_template => $id, >+ name => $field_name, >+ description => $field_description, >+ authorised_value_category => >+ $field_authorised_value_category, >+ } >+ ); >+ } >+ } >+} >+ >+$club_template = $schema->resultset('ClubTemplate')->find($id); >+$template->param( club_template => $club_template ); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/installer/data/mysql/en/mandatory/userflags.sql b/installer/data/mysql/en/mandatory/userflags.sql >index e727f9e..8bc2bdf 100644 >--- a/installer/data/mysql/en/mandatory/userflags.sql >+++ b/installer/data/mysql/en/mandatory/userflags.sql >@@ -18,3 +18,4 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES > (17,'staffaccess','Allow staff members to modify permissions for other staff members',0), > (18,'coursereserves','Course reserves',0), > (19, 'plugins', 'Koha plugins', '0'); >+(20, 'clubs', 'Patron clubs', '0'); >diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql >index ba5ccd0..e1d3708 100644 >--- a/installer/data/mysql/en/mandatory/userpermissions.sql >+++ b/installer/data/mysql/en/mandatory/userpermissions.sql >@@ -68,4 +68,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (19, 'tool', 'Use tool plugins'), > (19, 'report', 'Use report plugins'), > (19, 'configure', 'Configure plugins') >+ (20, 'edit_templates', 'Create and update club templates'), >+ (20, 'edit_clubs', 'Create and update clubs'), >+ (20, 'enroll', 'Enroll patrons in clubs') > ; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index b46dc6a..50d20d8 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3422,6 +3422,179 @@ CREATE TABLE IF NOT EXISTS `misc_files` ( -- miscellaneous files attached to rec > KEY `record_id` (`record_id`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > >+-- >+-- Table structure for table 'clubs' >+-- >+ >+CREATE TABLE clubs ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template int(11) NOT NULL, >+ `name` tinytext NOT NULL, >+ description text, >+ date_start date DEFAULT NULL, >+ date_end date DEFAULT NULL, >+ branch varchar(11) DEFAULT NULL, >+ date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >+ date_updated timestamp NULL DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club_template (club_template), >+ KEY branch (branch) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- -------------------------------------------------------- >+ >+-- >+-- Table structure for table 'club_enrollments' >+-- >+ >+CREATE TABLE club_enrollments ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club int(11) NOT NULL, >+ borrower int(11) NOT NULL, >+ date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >+ date_canceled timestamp NULL DEFAULT NULL, >+ date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', >+ date_updated timestamp NULL DEFAULT NULL, >+ branch varchar(11) DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club (club), >+ KEY borrower (borrower), >+ KEY branch (branch) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- -------------------------------------------------------- >+ >+-- >+-- Table structure for table 'club_enrollment_fields' >+-- >+ >+CREATE TABLE club_enrollment_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_enrollment int(11) NOT NULL, >+ club_template_enrollment_field int(11) NOT NULL, >+ `value` text NOT NULL, >+ PRIMARY KEY (id), >+ KEY club_enrollment (club_enrollment), >+ KEY club_template_enrollment_field (club_template_enrollment_field), >+ KEY club_template_enrollment_field_2 (club_template_enrollment_field) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- -------------------------------------------------------- >+ >+-- >+-- Table structure for table 'club_fields' >+-- >+ >+CREATE TABLE club_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template_field int(11) NOT NULL, >+ club int(11) NOT NULL, >+ `value` text, >+ PRIMARY KEY (id), >+ KEY club_template_field (club_template_field,club), >+ KEY club (club) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- -------------------------------------------------------- >+ >+-- >+-- Table structure for table 'club_templates' >+-- >+ >+CREATE TABLE club_templates ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ `name` tinytext NOT NULL, >+ description text, >+ is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0', >+ is_email_required tinyint(1) NOT NULL DEFAULT '0', >+ branch varchar(10) CHARACTER SET utf8 DEFAULT NULL, >+ date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >+ date_updated timestamp NULL DEFAULT NULL, >+ is_deletable tinyint(1) NOT NULL DEFAULT '1', >+ PRIMARY KEY (id), >+ KEY branch (branch) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- -------------------------------------------------------- >+ >+-- >+-- Table structure for table 'club_template_enrollment_fields' >+-- >+ >+CREATE TABLE club_template_enrollment_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template int(11) NOT NULL, >+ `name` tinytext NOT NULL, >+ description text, >+ authorised_value_category varchar(16) DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club_template (club_template), >+ KEY club_template_2 (club_template) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- -------------------------------------------------------- >+ >+-- >+-- Table structure for table 'club_template_fields' >+-- >+ >+CREATE TABLE club_template_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template int(11) NOT NULL, >+ `name` tinytext NOT NULL, >+ description text, >+ authorised_value_category varchar(16) DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club_template (club_template) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- >+-- Constraints for table `clubs` >+-- >+ALTER TABLE `clubs` >+ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode); >+ >+-- >+-- Constraints for table `club_enrollments` >+-- >+ALTER TABLE `club_enrollments` >+ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, >+ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE; >+ >+-- >+-- Constraints for table `club_enrollment_fields` >+-- >+ALTER TABLE `club_enrollment_fields` >+ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ADD CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ >+-- >+-- Constraints for table `club_fields` >+-- >+ALTER TABLE `club_fields` >+ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ >+-- >+-- Constraints for table `club_templates` >+-- >+ALTER TABLE `club_templates` >+ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE; >+ >+-- >+-- Constraints for table `club_template_enrollment_fields` >+-- >+ALTER TABLE `club_template_enrollment_fields` >+ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ >+-- >+-- Constraints for table `club_template_fields` >+-- >+ALTER TABLE `club_template_fields` >+ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ > /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; > /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; > /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 531bb12..a2df325 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8589,6 +8589,154 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+$DBversion = "3.17.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('20', 'clubs', 'Patron clubs', '0')"); >+ >+ $dbh->do(" >+ CREATE TABLE clubs ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template int(11) NOT NULL, >+ `name` tinytext NOT NULL, >+ description text, >+ date_start date DEFAULT NULL, >+ date_end date DEFAULT NULL, >+ branch varchar(11) DEFAULT NULL, >+ date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >+ date_updated timestamp NULL DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club_template (club_template), >+ KEY branch (branch) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ CREATE TABLE club_enrollments ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club int(11) NOT NULL, >+ borrower int(11) NOT NULL, >+ date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >+ date_canceled timestamp NULL DEFAULT NULL, >+ date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', >+ date_updated timestamp NULL DEFAULT NULL, >+ branch varchar(11) DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club (club), >+ KEY borrower (borrower), >+ KEY branch (branch) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ CREATE TABLE club_enrollment_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_enrollment int(11) NOT NULL, >+ club_template_enrollment_field int(11) NOT NULL, >+ `value` text NOT NULL, >+ PRIMARY KEY (id), >+ KEY club_enrollment (club_enrollment), >+ KEY club_template_enrollment_field (club_template_enrollment_field), >+ KEY club_template_enrollment_field_2 (club_template_enrollment_field) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ CREATE TABLE club_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template_field int(11) NOT NULL, >+ club int(11) NOT NULL, >+ `value` text, >+ PRIMARY KEY (id), >+ KEY club_template_field (club_template_field,club), >+ KEY club (club) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ CREATE TABLE club_templates ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ `name` tinytext NOT NULL, >+ description text, >+ is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0', >+ is_email_required tinyint(1) NOT NULL DEFAULT '0', >+ branch varchar(10) CHARACTER SET utf8 DEFAULT NULL, >+ date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >+ date_updated timestamp NULL DEFAULT NULL, >+ is_deletable tinyint(1) NOT NULL DEFAULT '1', >+ PRIMARY KEY (id), >+ KEY branch (branch) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DEFAULT; >+ "); >+ >+ $dbh->do(" >+ CREATE TABLE club_template_enrollment_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template int(11) NOT NULL, >+ `name` tinytext NOT NULL, >+ description text, >+ authorised_value_category varchar(16) DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club_template (club_template), >+ KEY club_template_2 (club_template) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ CREATE TABLE club_template_fields ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ club_template int(11) NOT NULL, >+ `name` tinytext NOT NULL, >+ description text, >+ authorised_value_category varchar(16) DEFAULT NULL, >+ PRIMARY KEY (id), >+ KEY club_template (club_template) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `clubs` >+ ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode); >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `club_enrollments` >+ ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE; >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `club_enrollment_fields` >+ ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `club_fields` >+ ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE, >+ ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `club_templates` >+ ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE; >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `club_template_enrollment_fields` >+ ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ "); >+ >+ $dbh->do(" >+ ALTER TABLE `club_template_fields` >+ ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE; >+ "); >+ >+ print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index d573ba4..3f0769d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -45,6 +45,11 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); > > $(document).ready(function() { > [% IF !( CircAutoPrintQuickSlip == 'clear' ) %] >+ $('#clubs-tab-link').on('click', function() { >+ $('#clubs-tab').text(_("Loading...")); >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]'); >+ }); >+ > // listen submit to trigger qslip on empty checkout > $('#mainform').bind('submit',function() { > if ($('#barcode').val() == '') { >@@ -662,6 +667,14 @@ No patron matched <span class="ex">[% message %]</span> > [% END %] > </li> > >+ [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %] >+ <li> >+ <a id="clubs-tab-link" href="#clubs-tab"> >+ Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %]) >+ </a> >+ </li> >+ [% END %] >+ > [% IF relatives_issues_count %] > <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li> > [% END %] >@@ -737,6 +750,12 @@ No patron matched <span class="ex">[% message %]</span> > </div> > [% END %] > >+[% IF CAN_user_clubs %] >+ <div id="clubs-tab"> >+ Loading... >+ </div> >+[% END %] >+ > [% INCLUDE borrower_debarments.inc %] > > <div id="reserves"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt >new file mode 100644 >index 0000000..a0fa8f3 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt >@@ -0,0 +1,136 @@ >+[% USE KohaDates %] >+[% USE EncodeUTF8 %] >+[% USE Branches %] >+[% USE AuthorisedValues %] >+[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools › Patron clubs › Club</title> >+[% INCLUDE 'doc-head-close.inc' %] >+[% INCLUDE 'calendar.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ >+function CheckForm() { >+ if ( !$("#club-name").val() ) { >+ alert( _("Name is a required field!") ); >+ return false; >+ } >+ >+ return true; >+} >+ >+//]]> >+</script> >+ >+</head> >+ >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="clubs.pl">Patron clubs</a> › Add / modify club</div> >+ >+<div class="yui-t7"> >+ <div class="yui-main"> >+ <form method="post" onsubmit="return CheckForm()"> >+ <input type="hidden" name="id" value="[% club.id %]" /> >+ <input type="hidden" name="club_template_id" value="[% club_template.id %]" /> >+ >+ <fieldset class="rows"> >+ >+ <legend> >+ [% IF club %] >+ Modify club <i>[% club.name %]</i> >+ [% ELSE %] >+ Create a new <i>[% club_template.name %]</i> club >+ [% END %] >+ </legend> >+ >+ <ol> >+ <li> >+ <label class="required" for="name">Name:</label> >+ <input id="club-name" name="name" type="text" value="[% club.name %]" /> >+ </li> >+ >+ <li> >+ <label for="description">Description:</label> >+ <input id="club-template-name" name="description" type="text" value="[% club.description %]" /> >+ </li> >+ >+ <li> >+ <label for="date_start">Start date:</label> >+ <input name="date_start" id="from" size="10" readonly="readonly" class="datepickerfrom" value="[% club.date_start | $KohaDates %]"> >+ </li> >+ >+ <li> >+ <label for="date_end">End date:</label> >+ <input name="date_end" id="to" size="10" readonly="readonly" class="datepickerto" value="[% club.date_end | $KohaDates %]" > >+ </li> >+ >+ <li> >+ <label for="name">Branch:</label> >+ <select name="branchcode" id="club-template-branchcode"> >+ <option value=""> </option> >+ [% FOREACH b IN Branches.GetBranches() %] >+ [% IF b.branchcode == club.branch.branchcode %] >+ <option value="[% b.branchcode %]" selected="selected">[% b.branchname | $EncodeUTF8 %]</option> >+ [% ELSE %] >+ <option value="[% b.branchcode %]">[% b.branchname | $EncodeUTF8 %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ [% IF club %] >+ [% FOREACH f IN club.club_fields %] >+ <li> >+ <input type="hidden" name="club_template_field_id" value="[% f.club_template_field.id %]" /> >+ <input type="hidden" name="club_field_id" value="[% f.id %]" /> >+ >+ <label for="club_field">[% f.club_template_field.name %]</label> >+ [% IF f.club_template_field.authorised_value_category %] >+ <select name="club_field"> >+ [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %] >+ [% IF a.authorised_value == f.value %] >+ <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option> >+ [% ELSE %] >+ <option value="[% a.authorised_value %]">[% a.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="text" name="club_field" value="[% f.value %]" /> >+ [% END %] >+ </li> >+ [% END %] >+ [% ELSE %] >+ [% FOREACH f IN club_template.club_template_fields %] >+ <li> >+ <input type="hidden" name="club_template_field_id" value="[% f.id %]" /> >+ >+ <label for="club_field">[% f.name %]</label> >+ [% IF f.authorised_value_category %] >+ <select name="club_field"> >+ [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %] >+ <option value="[% a.authorised_value %]">[% a.lib %]</option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="text" name="club_field" /> >+ [% END %] >+ </li> >+ [% END %] >+ [% END %] >+ >+ </ol> >+ >+ </fieldset> >+ >+ <input type="submit" class="btn" value="Save" /> >+ >+ <a href="clubs.pl" class="cancel">Cancel</a> >+ </form> >+ </div> >+</div> >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >new file mode 100644 >index 0000000..31eecf2 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >@@ -0,0 +1,206 @@ >+[% USE EncodeUTF8 %] >+[% USE Koha %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools › Patron clubs</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+[% INCLUDE 'datatables.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ $(document).ready(function() { >+ tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, >+ ] >+ } )); >+ >+ cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, >+ ] >+ } )); >+ }); >+ >+ function ConfirmDeleteTemplate( id, name, a ) { >+ if ( confirm( _("Are you sure you want to delete the club template") + name + "?" ) ) { >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/template/delete', >+ data: { id: id }, >+ success: function( data ) { >+ if ( data.success ) { >+ tTable.fnDeleteRow(a.closest("tr")[0]); >+ } else { >+ alert(_("Unable to delete template!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ } >+ } >+ >+ function ConfirmDeleteClub( id, name, a ) { >+ if ( confirm( _("Are you sure you want to delete the club ") + name + "?" ) ) { >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/delete', >+ data: { id: id }, >+ success: function( data ) { >+ if ( data.success ) { >+ cTable.fnDeleteRow(a.closest("tr")[0]); >+ } else { >+ alert(_("Unable to delete club!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ } >+ } >+//]]> >+</script> >+ >+</head> >+ >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › Patron clubs</div> >+ >+<div class="yui-t7"> >+ <div class="yui-main"> >+ <h1>Patron clubs</h1> >+ >+ >+ <h3>Club templates</h3> >+ >+ [% IF CAN_user_clubs_edit_templates %] >+ <div class="btn-group"> >+ <a class="btn btn-small" href="templates-add-modify.pl"><i class="icon-plus"></i> New club template</a> >+ </div> >+ [% END %] >+ >+ <table id="club-templates-table"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Description</th> >+ <th>Public enrollment</th> >+ <th>Email required</th> >+ <th>Branch</th> >+ <th> </th> >+ <th> </th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH t IN club_templates %] >+ <tr> >+ <td>[% t.name | $EncodeUTF8 %]</td> >+ <td>[% t.description | $EncodeUTF8 %]</td> >+ <td> >+ [% IF t.is_enrollable_from_opac %] >+ Yes >+ [% ELSE %] >+ No >+ [% END %] >+ </td> >+ <td> >+ [% IF t.is_email_required %] >+ Yes >+ [% ELSE %] >+ No >+ [% END %] >+ </td> >+ <td>[% t.branch.branchname | $EncodeUTF8 %]</td> >+ <td> >+ [% IF CAN_user_clubs_edit_templates && t.is_deletable && ( CAN_user_superlibrarian || t.branch.branchcode == Koha.UserEnv('branch') ) %] >+ <a class="btn btn-mini" href="templates-add-modify.pl?id=[% t.id %]"> >+ <i class="icon-edit"></i> Edit >+ </a> >+ [% END %] >+ </td> >+ <td> >+ [% IF CAN_user_clubs_edit_templates && t.is_deletable && ( CAN_user_superlibrarian || t.branch.branchcode == Koha.UserEnv('branch') ) %] >+ <a class="btn btn-mini" href="#" onclick='ConfirmDeleteTemplate([% t.id %], "[% t.name | html %]", $(this) ); return false;'> >+ <i class="icon-trash"></i> Delete >+ </a> >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ >+ <h3>Clubs</h3> >+ >+ [% IF CAN_user_clubs_edit_clubs %] >+ <div class="btn-group"> >+ <div class="btn-group"> >+ <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-plus"></i> New club <span class="caret"></span></button> >+ <ul class="dropdown-menu"> >+ [% FOREACH t IN club_templates %] >+ <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id %]">[% t.name %]</a></li> >+ [% END %] >+ </ul> >+ </div> >+ </div> >+ [% END %] >+ >+ <table id="clubs-table"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Template</th> >+ <th>Description</th> >+ <th>Public enrollment</th> >+ <th>Email required</th> >+ <th>Branch</th> >+ <th> </th> >+ <th> </th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH c IN clubs %] >+ <tr> >+ <td>[% c.name | $EncodeUTF8 %]</td> >+ <td>[% c.club_template.name | $EncodeUTF8 %]</td> >+ <td>[% c.description | $EncodeUTF8 %]</td> >+ <td> >+ [% IF c.club_template.is_enrollable_from_opac %] >+ Yes >+ [% ELSE %] >+ No >+ [% END %] >+ </td> >+ <td> >+ [% IF c.club_template.is_email_required %] >+ Yes >+ [% ELSE %] >+ No >+ [% END %] >+ </td> >+ <td>[% c.branch.branchname | $EncodeUTF8 %]</td> >+ <td> >+ [% IF CAN_user_clubs_edit_clubs && ( CAN_user_superlibrarian || c.branch.branchcode == Koha.UserEnv('branch') ) %] >+ <a class="btn btn-mini" href="clubs-add-modify.pl?id=[% c.id %]"> >+ <i class="icon-edit"></i> Edit >+ </a> >+ [% END %] >+ </td> >+ <td> >+ [% IF CAN_user_clubs_edit_clubs && ( CAN_user_superlibrarian || c.branch.branchcode == Koha.UserEnv('branch') ) %] >+ <a class="btn btn-mini" href="#" onclick='ConfirmDeleteClub([% c.id %], "[% c.name | html %]", $(this) ); return false;'> >+ <i class="icon-trash"></i> Delete >+ </a> >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >new file mode 100644 >index 0000000..6365728 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >@@ -0,0 +1,103 @@ >+[% USE EncodeUTF8 %] >+[% USE KohaDates %] >+ >+[% IF enrollments %] >+ <table> >+ <thead> >+ <tr> >+ <th colspan="4"> >+ Clubs currently enrolled in >+ </th> >+ </tr> >+ <tr> >+ <th>Name</th> >+ <th>Description</th> >+ <th>Date enrolled</th> >+ [% IF CAN_user_clubs_enroll %]<th> </th>[% END %] >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH e IN enrollments %] >+ <tr> >+ <td>[% e.club.name | $EncodeUTF8 %]</td> >+ <td>[% e.club.description | $EncodeUTF8 %]</td> >+ <td>[% e.date_enrolled | $KohaDates %]</td> >+ [% IF CAN_user_clubs_enroll %] >+ <td> >+ <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )"> >+ <i class="icon-remove"></i> Cancel >+ </a> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+[% END %] >+ >+[% IF clubs %] >+ <table> >+ <thead> >+ <tr> >+ <th colspan="3"> >+ Clubs not enrolled in >+ </th> >+ </tr> >+ <tr> >+ <th>Name</th> >+ <th>Description</th> >+ [% IF CAN_user_clubs_enroll %]<th> </th>[% END %] >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH c IN clubs %] >+ <tr> >+ <td>[% c.name | $EncodeUTF8 %]</td> >+ <td>[% c.description | $EncodeUTF8 %]</td> >+ [% IF CAN_user_clubs_enroll %] >+ <td> >+ <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])"> >+ <i class="icon-plus"></i> Enroll >+ </a> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+[% END %] >+ >+[% IF CAN_user_clubs_enroll %] >+<script type="text/javascript"> >+function loadEnrollmentForm( id ) { >+ $("body").css("cursor", "progress"); >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber %]&id=' + id, function() { >+ $("body").css("cursor", "default"); >+ }); >+ >+ return false; >+} >+ >+function cancelEnrollment( id ) { >+ $("body").css("cursor", "progress"); >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/cancel_enrollment', >+ data: { id: id }, >+ success: function( data ) { >+ if ( data.success ) { >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]', function() { >+ $("body").css("cursor", "default"); >+ }); >+ } else { >+ alert(_("Unable to cancel enrollment!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ return false; >+} >+</script> >+[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >new file mode 100644 >index 0000000..cd105b8 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >@@ -0,0 +1,67 @@ >+[% USE EncodeUTF8 %] >+[% USE AuthorisedValues %] >+[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %] >+ >+<h3> >+ Enroll in <i>[% club.name | $EncodeUTF8 %]</i> >+</h3> >+ >+<div class="container"> >+ <form id="patron-enrollment-form"> >+ <input type="hidden" name="id" value="[% club.id %]" /> >+ <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >+ <fieldset class="rows"> >+ <ol> >+ [% FOREACH f IN club.club_template.club_template_enrollment_fields %] >+ <li> >+ <label>[% f.name %]</label> >+ [% IF f.authorised_value_category %] >+ <select name="[% f.id %]"> >+ [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %] >+ <option value="[% a.authorised_value %]">[% a.lib %]</option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="text" name="[% f.id %]" /> >+ [% END %] >+ <span class="hint">[% f.description %]</span> >+ </li> >+ [% END %] >+ >+ <li> >+ <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a> >+ <a href="#" onclick="showClubs(); return false;">Cancel</a> >+ </li> >+ </ol> >+ </fieldset> >+ </form> >+</div> >+ >+<script type="text/javascript"> >+function addEnrollment() { >+ $("body").css("cursor", "progress"); >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/enroll', >+ data: $( "#patron-enrollment-form" ).serialize(), >+ success: function( data ) { >+ if ( data.success ) { >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() { >+ $("body").css("cursor", "default"); >+ }); >+ } else { >+ alert(_("Unable to create enrollment!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ return false; >+} >+ >+function showClubs() { >+ $("body").css("cursor", "progress"); >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() { >+ $("body").css("cursor", "default"); >+ }); >+} >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt >new file mode 100644 >index 0000000..46df57d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt >@@ -0,0 +1,252 @@ >+[% USE EncodeUTF8 %] >+[% USE Branches %] >+[% USE AuthorisedValues %] >+[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools › Patron clubs › Club template</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ >+function CheckForm() { >+ if ( !$("#club-template-name").val() ) { >+ alert( _("Name is a required field!") ); >+ return false; >+ } >+ >+ return true; >+} >+ >+//]]> >+</script> >+ >+</head> >+ >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="clubs.pl">Patron clubs</a> › Add / modify club template</div> >+ >+<div class="yui-t7"> >+ <div class="yui-main"> >+ >+ <form method="post" onsubmit="return CheckForm()"> >+ <input type="hidden" name="id" value="[% club_template.id %]" /> >+ >+ <fieldset class="rows"> >+ >+ <legend> >+ [% IF club_template %] >+ Modify club template <i>[% club_template.name %]</i> >+ [% ELSE %] >+ Create a new club template >+ [% END %] >+ </legend> >+ >+ <ol> >+ <li> >+ <label class="required" for="name">Name:</label> >+ <input id="club-template-name" name="name" type="text" value="[% club_template.name %]" /> >+ </li> >+ >+ <li> >+ <label for="description">Description:</label> >+ <input id="club-template-description" name="description" type="text" value="[% club_template.description %]" /> >+ </li> >+ >+ <li> >+ <label for="name">Allow public enrollment:</label> >+ [% IF club_template.is_enrollable_from_opac %] >+ <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" /> >+ [% END %] >+ <span class="hint">If a template allows public enrollment, patrons can enroll in a club based on this template from the public catalog.</span> >+ </li> >+ >+ <li> >+ <label for="name">Require valid email address:</label> >+ [% IF club_template.is_email_required %] >+ <input type="checkbox" id="club-template-is-email-required" name="is_email_required" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" id="club-template-is-email-required" name="is_email_required" /> >+ [% END %] >+ <span class="hint">If set, a club based on this template can only be enrolled in by patrons with a valid email address.</span> >+ </li> >+ >+ <li> >+ <label for="name">Branch:</label> >+ <select name="branchcode" id="club-template-branchcode"> >+ <option value=""> </option> >+ [% FOREACH b IN Branches.GetBranches() %] >+ [% IF b.branchcode == club_template.branch.branchcode %] >+ <option value="[% b.branchcode %]" selected="selected">[% b.branchname | $EncodeUTF8 %]</option> >+ [% ELSE %] >+ <option value="[% b.branchcode %]">[% b.branchname | $EncodeUTF8 %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <span class="hint">If set, only librarians logged in with this branch will be able to modify this club template.</span> >+ </li> >+ >+ </ol> >+ >+ <h2>Club fields:</h2> >+ <span class="hint">These fields will be used in the creation of clubs based on this template</span> >+ <span id="club-template-fields"> >+ [% FOREACH f IN club_template.club_template_fields %] >+ <ul> >+ <input type="hidden" name="club_template_field_id" value="[% f.id %]" /> >+ <li> >+ <label for="field-name-[% f.id %]">Name:</label> >+ <input name="club_template_field_name" id="field-name-[% f.id %]" value="[% f.name %]" /> >+ </li> >+ >+ <li> >+ <label for="field-description-[% f.id %]">Description:</label> >+ <input name="club_template_field_description" id="field-description-[% f.id %]" value="[% f.description %]" /> >+ </li> >+ >+ <li> >+ <label for="field-description-[% f.id %]">Authorised value category:</label> >+ <select name="club_template_field_authorised_value_category" id="field-authorised-value-category-[% f.id %]"> >+ <option value=""> </option> >+ [% FOREACH c IN AuthorisedValuesCategories %] >+ [% IF f.authorised_value_category == c %] >+ <option selected="selected" value="[% c %]">[% c %]</option> >+ [% ELSE %] >+ <option value="[% c %]">[% c %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ <li> >+ <label for="field-delete-[% f.id %]">Delete field:</label> >+ <input type="checkbox" name="club_template_field_delete" id="field-delete-[% f.id %]" value="[% f.id %]" /> >+ </li> >+ >+ <hr/> >+ </ul> >+ [% END %] >+ </span> >+ <a href="#" class="btn" onclick="$('#new-field-template').clone().attr('id','').show().appendTo('#club-template-fields'); return false;"> >+ Add new field >+ </a> >+ >+ <h2>Enrollment fields:</h2> >+ <span class="hint">These fields will be used when enrolling a patron in a club based on this template</span> >+ <span id="club-template-enrollment-fields"> >+ [% FOREACH f IN club_template.club_template_enrollment_fields %] >+ <ul> >+ <input type="hidden" name="club_template_enrollment_field_id" value="[% f.id %]" /> >+ <li> >+ <label for="enrollment-field-name-[% f.id %]">Name:</label> >+ <input name="club_template_enrollment_field_name" id="enrollment-field-name-[% f.id %]" value="[% f.name %]" /> >+ </li> >+ >+ <li> >+ <label for="enrollment-field-description-[% f.id %]">Description:</label> >+ <input name="club_template_enrollment_field_description" id="enrollment-field-description-[% f.id %]" value="[% f.description %]" /> >+ </li> >+ >+ <li> >+ <label for="enrollment-field-description-[% f.id %]">Authorised value category:</label> >+ <select name="club_template_enrollment_field_authorised_value_category" id="enrollment-field-authorised-value-category-[% f.id %]"> >+ <option value=""> </option> >+ [% FOREACH c IN AuthorisedValuesCategories %] >+ [% IF f.authorised_value_category == c %] >+ <option selected="selected" value="[% c %]">[% c %]</option> >+ [% ELSE %] >+ <option value="[% c %]">[% c %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ <li> >+ <label for="enrollment-field-delete-[% f.id %]">Delete field:</label> >+ <input type="checkbox" name="club_template_enrollment_field_delete" id="enrollment-field-delete-[% f.id %]" value="[% f.id %]" /> >+ </li> >+ >+ <hr/> >+ </ul> >+ [% END %] >+ </span> >+ <a href="#" class="btn" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;"> >+ Add new field >+ </a> >+ >+ </fieldset> >+ >+ <input type="hidden" name="id" value="[% club_template.id %]" /> >+ >+ <input type="submit" class="btn" value="Save" /> >+ >+ <a href="clubs.pl" class="cancel">Cancel</a> >+ </form> >+ </div> >+</div> >+ >+<span id="new-field-template" style="display:none"> >+ <ul> >+ <input type="hidden" name="club_template_field_id" value="" /> >+ >+ <li> >+ <label for="club_template_field_name">Name:</label> >+ <input name="club_template_field_name" /> >+ </li> >+ >+ <li> >+ <label for="club_template_field_description">Description:</label> >+ <input name="club_template_field_description" /> >+ </li> >+ >+ <li> >+ <label for="club_template_field_authorised_value_category">Authorised value category:</label> >+ <select name="club_template_field_authorised_value_category"> >+ <option value=""> </option> >+ [% FOREACH c IN AuthorisedValuesCategories %] >+ <option value="[% c %]">[% c %]</option> >+ [% END %] >+ </select> >+ </li> >+ >+ <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a> >+ >+ <hr/> >+ </ul> >+</span> >+ >+<span id="new-enrollment-field-template" style="display:none"> >+ <ul> >+ <input type="hidden" name="club_template_enrollment_field_id" value="" /> >+ >+ <li> >+ <label for="club_template_enrollment_field_name">Name:</label> >+ <input name="club_template_enrollment_field_name" /> >+ </li> >+ >+ <li> >+ <label for="club_template_enrollment_field_description">Description:</label> >+ <input name="club_template_enrollment_field_description" /> >+ </li> >+ >+ <li> >+ <label for="club_template_enrollment_field_authorised_value_category">Authorised value category:</label> >+ <select name="club_template_enrollment_field_authorised_value_category"> >+ <option value=""> </option> >+ [% FOREACH c IN AuthorisedValuesCategories %] >+ <option value="[% c %]">[% c %]</option> >+ [% END %] >+ </select> >+ </li> >+ >+ <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a> >+ >+ <hr/> >+ </ul> >+</span> >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index e557fc3..9c67948 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -33,6 +33,11 @@ var relatives_borrowernumbers = new Array(); > [% END %] > > $(document).ready(function() { >+ $('#clubs-tab-link').on('click', function() { >+ $('#clubs-tab').text(_("Loading...")); >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]'); >+ }); >+ > $('#finesholdsissues').tabs({ > // Correct table sizing for tables hidden in tabs > // http://www.datatables.net/examples/api/tabs_and_scrolling.html >@@ -406,6 +411,13 @@ function validate1(date) { > [% END %] > </li> > <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li> >+ [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %] >+ <li> >+ <a id="clubs-tab-link" href="#clubs-tab"> >+ Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %]) >+ </a> >+ </li> >+ [% END %] > </ul> > > <div id="checkouts"> >@@ -498,6 +510,10 @@ function validate1(date) { > [% END %] > </div> > >+<div id="clubs-tab"> >+ Loading... >+</div> >+ > [% INCLUDE borrower_debarments.inc %] > > <div id="reserves"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >index 4ab38c9..88e8afa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >@@ -15,6 +15,11 @@ > <div class="yui-u first"> > <h3>Patrons and circulation</h3> > <dl> >+ [% IF CAN_user_clubs_edit_clubs || CAN_user_clubs_edit_templates %] >+ <dt><a href="/cgi-bin/koha/clubs/clubs.pl">Patron clubs</a> >+ <dd>Manage patrons clubs.</dd> >+ [% END %] >+ > [% IF (CAN_user_tools_manage_patron_lists) %] > <dt><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a> > <dd>Manage lists of patrons.</dd> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt >new file mode 100644 >index 0000000..ef9f600 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt >@@ -0,0 +1,103 @@ >+[% USE EncodeUTF8 %] >+[% USE KohaDates %] >+ >+[% IF enrollments %] >+ <table id="clubs-table-enrolled" class="table table-bordered table-striped"> >+ <thead> >+ <tr> >+ <th colspan="4"> >+ Clubs you are currently enrolled in >+ </th> >+ </tr> >+ <tr> >+ <th>Name</th> >+ <th>Description</th> >+ <th>Date enrolled</th> >+ <th> </th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH e IN enrollments %] >+ <tr> >+ <td>[% e.club.name | $EncodeUTF8 %]</td> >+ <td>[% e.club.description | $EncodeUTF8 %]</td> >+ <td>[% e.date_enrolled | $KohaDates %]</td> >+ [% IF e.club.club_template.is_enrollable_from_opac %] >+ <td> >+ <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )"> >+ <i class="icon-remove"></i> Cancel >+ </a> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+[% END %] >+ >+[% IF clubs %] >+ <table id="clubs-table-unenrolled" class="table table-bordered table-striped"> >+ <thead> >+ <tr> >+ <th colspan="3"> >+ Clubs you can enroll in >+ </th> >+ </tr> >+ <tr> >+ <th>Name</th> >+ <th>Description</th> >+ <th> </th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH c IN clubs %] >+ <tr> >+ <td>[% c.name | $EncodeUTF8 %]</td> >+ <td>[% c.description | $EncodeUTF8 %]</td> >+ <td> >+ [% IF borrower.FirstValidEmailAddress %] >+ <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])"> >+ <i class="icon-plus"></i> Enroll >+ </a> >+ [% ELSE %] >+ <span class="hint">You must have an email address to enroll</span> >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+[% END %] >+ >+<script type="text/javascript"> >+function loadEnrollmentForm( id ) { >+ $("body").css("cursor", "progress"); >+ $('#opac-user-clubs').load('/cgi-bin/koha/clubs/enroll.pl?borrowernumber=[% borrower.borrowernumber %]&id=' + id, function() { >+ $("body").css("cursor", "default"); >+ }); >+ >+ return false; >+} >+ >+function cancelEnrollment( id ) { >+ $("body").css("cursor", "progress"); >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/cancel_enrollment', >+ data: { id: id }, >+ success: function( data ) { >+ if ( data.success ) { >+ $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrower.borrowernumber %]', function() { >+ $("body").css("cursor", "default"); >+ }); >+ } else { >+ alert(_("Unable to cancel enrollment!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ return false; >+} >+</script> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt >new file mode 100644 >index 0000000..bcdf610 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt >@@ -0,0 +1,67 @@ >+[% USE EncodeUTF8 %] >+[% USE AuthorisedValues %] >+[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %] >+ >+<h3> >+ Enroll in <i>[% club.name | $EncodeUTF8 %]</i> >+</h3> >+ >+<div class="container"> >+ <form id="patron-enrollment-form"> >+ <input type="hidden" name="id" value="[% club.id %]" /> >+ <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >+ <fieldset class="rows"> >+ <ol> >+ [% FOREACH f IN club.club_template.club_template_enrollment_fields %] >+ <li> >+ <label>[% f.name %]</label> >+ [% IF f.authorised_value_category %] >+ <select name="[% f.id %]"> >+ [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %] >+ <option value="[% a.authorised_value %]">[% a.lib %]</option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="text" name="[% f.id %]" /> >+ [% END %] >+ <span class="hint">[% f.description %]</span> >+ </li> >+ [% END %] >+ >+ <li> >+ <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a> >+ <a href="#" onclick="showClubs(); return false;">Cancel</a> >+ </li> >+ </ol> >+ </fieldset> >+ </form> >+</div> >+ >+<script type="text/javascript"> >+function addEnrollment() { >+ $("body").css("cursor", "progress"); >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/enroll', >+ data: $( "#patron-enrollment-form" ).serialize(), >+ success: function( data ) { >+ if ( data.success ) { >+ $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() { >+ $("body").css("cursor", "default"); >+ }); >+ } else { >+ alert(_("Unable to create enrollment!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ return false; >+} >+ >+function showClubs() { >+ $("body").css("cursor", "progress"); >+ $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() { >+ $("body").css("cursor", "default"); >+ }); >+} >+</script> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index 7b7f023..81c6a8e 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -111,6 +111,14 @@ > [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %] > [% END %] > [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %] >+ [% IF borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount %] >+ <li> >+ <a id="opac-user-clubs-tab-link" href="#opac-user-clubs"> >+ Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %]) >+ </a> >+ </li> >+ [% END %] >+ > [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %] > </ul> > >@@ -277,6 +285,10 @@ > [% END # IF issues_count %] > </div> <!-- / .opac-user-checkouts --> > >+ <div id="opac-user-clubs"> >+ Loading... >+ </div> >+ > [% IF ( OPACFinesTab ) %] > <!-- FINES BOX --> > [% IF ( BORROWER_INF.amountoverfive ) %] >@@ -724,6 +736,11 @@ > [% END %] > > $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future >+ >+ $('#opac-user-clubs-tab-link').on('click', function() { >+ $('#opac-user-clubs').text(_("Loading...")); >+ $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]'); >+ }); > }); > //]]> > </script> >diff --git a/members/moremember.pl b/members/moremember.pl >index b1df1dd..11b3b42 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -341,6 +341,8 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { > # Computes full borrower address > my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'}; > >+my $schema = Koha::Database->new()->schema(); >+ > # in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) > $template->param( $data->{'categorycode'} => 1 ); > $template->param( >@@ -371,6 +373,7 @@ $template->param( > relatives_issues_count => $relatives_issues_count, > relatives_borrowernumbers => \@relatives, > address => $address >+ borrower => $schema->resultset('Borrower')->find( $borrowernumber ), > ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/opac/clubs/clubs-tab.pl b/opac/clubs/clubs-tab.pl >new file mode 100755 >index 0000000..812fbf4 >--- /dev/null >+++ b/opac/clubs/clubs-tab.pl >@@ -0,0 +1,67 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "clubs/clubs-tab.tt", >+ query => $cgi, >+ type => "opac", >+ authnotrequired => 0, >+ } >+); >+ >+my $borrowernumber = $cgi->param('borrowernumber'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $borrower = $schema->resultset('Borrower')->find($borrowernumber); >+ >+my @enrollments = $schema->resultset("ClubEnrollment")->search( >+ { >+ borrower => $borrowernumber, >+ date_canceled => undef, >+ }, >+ { prefetch => 'club' } >+); >+ >+my @clubs = $schema->resultset("Club")->search( >+ { >+ 'me.id' => { -not_in => [ map { $_->club()->id() } @enrollments ] }, >+ 'club_template.is_enrollable_from_opac' => 1, >+ }, >+ { prefetch => 'club_template' } >+); >+ >+$template->param( >+ enrollments => \@enrollments, >+ clubs => \@clubs, >+ borrower => $borrower, >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/opac/clubs/enroll.pl b/opac/clubs/enroll.pl >new file mode 100755 >index 0000000..cebd9d6 >--- /dev/null >+++ b/opac/clubs/enroll.pl >@@ -0,0 +1,51 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "clubs/enroll.tt", >+ query => $cgi, >+ type => "opac", >+ authnotrequired => 0, >+ } >+); >+ >+my $id = $cgi->param('id'); >+my $borrowernumber = $cgi->param('borrowernumber'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $club = $schema->resultset("Club")->find($id); >+ >+$template->param( >+ club => $club, >+ borrowernumber => $borrowernumber, >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 61b88ae..0b07e06 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -35,6 +35,9 @@ use C4::Items; > use C4::Letters; > use C4::Branch; # GetBranches > use Koha::DateUtils; >+use Koha::Database; >+ >+my $schema = Koha::Database->new()->schema(); > > use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; > >@@ -383,12 +386,10 @@ $template->param( > patronupdate => $patronupdate, > OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), > userview => 1, >-); >- >-$template->param( > SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), > AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), > OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), >+ borrower => $schema->resultset('Borrower')->find($borrowernumber), > ); > > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/opac/svc/club/cancel_enrollment b/opac/svc/club/cancel_enrollment >new file mode 100755 >index 0000000..4f11559 >--- /dev/null >+++ b/opac/svc/club/cancel_enrollment >@@ -0,0 +1,52 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw(to_json); >+ >+use C4::Auth qw(check_cookie_auth); >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $cgi->cookie('CGISESSID') ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $borrowernumber = C4::Context->userenv->{'number'}; >+ >+my $id = $cgi->param('id'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $enrollment = $schema->resultset('ClubEnrollment')->find($id); >+ >+if ( $enrollment && $enrollment->get_column('borrower') == $borrowernumber ) { >+ $enrollment->update( { date_canceled => \'NOW()' } ); >+} >+ >+binmode STDOUT, ':encoding(UTF-8)'; >+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+print to_json( { success => $enrollment ? 1 : 0 } ); >diff --git a/opac/svc/club/enroll b/opac/svc/club/enroll >new file mode 100755 >index 0000000..0569872 >--- /dev/null >+++ b/opac/svc/club/enroll >@@ -0,0 +1,79 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw(to_json); >+ >+use C4::Auth qw(check_cookie_auth); >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $cgi->cookie('CGISESSID') ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $borrowernumber = C4::Context->userenv->{'number'}; >+ >+my $id = $cgi->param('id'); >+ >+my $enrollment; >+if ( $borrowernumber && $id ) { >+ my $schema = Koha::Database->new()->schema(); >+ >+ my $club = $schema->resultset('Club')->find($id); >+ >+ if ( $club->club_template()->is_enrollable_from_opac() ) { >+ $enrollment = $schema->resultset('ClubEnrollment')->create( >+ { >+ club => $club->id(), >+ borrower => $borrowernumber, >+ date_enrolled => \'NOW()', >+ date_created => \'NOW()', >+ branch => C4::Context->userenv >+ ? C4::Context->userenv->{'branch'} >+ : undef, >+ } >+ ); >+ >+ my @enrollment_fields = >+ $club->club_template()->club_template_enrollment_fields(); >+ >+ foreach my $e (@enrollment_fields) { >+ my $club_enrollment_field = >+ $schema->resultset('ClubEnrollmentField')->create( >+ { >+ club_enrollment => $enrollment->id(), >+ club_template_enrollment_field => $e->id(), >+ value => $cgi->param( $e->id() ), >+ } >+ ); >+ } >+ } >+} >+ >+binmode STDOUT, ':encoding(UTF-8)'; >+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+print to_json( { success => $enrollment ? 1 : 0 } ); >diff --git a/svc/club/cancel_enrollment b/svc/club/cancel_enrollment >new file mode 100755 >index 0000000..9b9326c >--- /dev/null >+++ b/svc/club/cancel_enrollment >@@ -0,0 +1,48 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw(to_json); >+ >+use C4::Auth qw(check_cookie_auth); >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $id = $cgi->param('id'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $enrollment = >+ $schema->resultset('ClubEnrollment')->find($id) >+ ->update( { date_canceled => \'NOW()' } ); >+ >+binmode STDOUT, ':encoding(UTF-8)'; >+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+print to_json( { success => $enrollment ? 1 : 0 } ); >diff --git a/svc/club/delete b/svc/club/delete >new file mode 100755 >index 0000000..6c3f882 >--- /dev/null >+++ b/svc/club/delete >@@ -0,0 +1,50 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw(to_json); >+ >+use C4::Auth qw(check_cookie_auth); >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'), >+ { clubs => 'edit_clubs' } ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $success = 0; >+ >+my $id = $cgi->param('id'); >+ >+my $club = >+ Koha::Database->new()->schema()->resultset('Club')->find($id); >+if ($club) { >+ $success = $club->delete(); >+} >+ >+binmode STDOUT, ':encoding(UTF-8)'; >+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+print to_json( { success => $success ? 1 : 0 } ); >diff --git a/svc/club/enroll b/svc/club/enroll >new file mode 100755 >index 0000000..7c67031 >--- /dev/null >+++ b/svc/club/enroll >@@ -0,0 +1,78 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw(to_json); >+ >+use C4::Auth qw(check_cookie_auth); >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $id = $cgi->param('id'); >+my $borrowernumber = $cgi->param('borrowernumber'); >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $club = $schema->resultset('Club')->find($id); >+ >+my $enrollment; >+if ($club) { >+ $enrollment = $schema->resultset('ClubEnrollment')->create( >+ { >+ club => $club->id(), >+ borrower => $borrowernumber, >+ date_enrolled => \'NOW()', >+ date_created => \'NOW()', >+ branch => C4::Context->userenv >+ ? C4::Context->userenv->{'branch'} >+ : undef, >+ } >+ ); >+ >+ if ($enrollment) { >+ my @enrollment_fields = >+ $club->club_template()->club_template_enrollment_fields(); >+ >+ foreach my $e (@enrollment_fields) { >+ my $club_enrollment_field = >+ $schema->resultset('ClubEnrollmentField')->create( >+ { >+ club_enrollment => $enrollment->id(), >+ club_template_enrollment_field => $e->id(), >+ value => $cgi->param( $e->id() ), >+ } >+ ); >+ } >+ } >+} >+ >+binmode STDOUT, ':encoding(UTF-8)'; >+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+print to_json( { success => $enrollment ? 1 : 0 } ); >diff --git a/svc/club/template/delete b/svc/club/template/delete >new file mode 100755 >index 0000000..2b0ab20 >--- /dev/null >+++ b/svc/club/template/delete >@@ -0,0 +1,50 @@ >+#!/usr/bin/perl >+ >+# Copyright 2014 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw(to_json); >+ >+use C4::Auth qw(check_cookie_auth); >+use Koha::Database; >+ >+my $cgi = new CGI; >+ >+my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'), >+ { clubs => 'edit_templates' } ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $success = 0; >+ >+my $id = $cgi->param('id'); >+ >+my $club_template = >+ Koha::Database->new()->schema()->resultset('ClubTemplate')->find($id); >+if ($club_template) { >+ $success = $club_template->delete(); >+} >+ >+binmode STDOUT, ':encoding(UTF-8)'; >+print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+print to_json( { success => $success ? 1 : 0 } ); >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12461
:
29105
|
30456
|
31567
|
35104
|
36098
|
36099
|
36192
|
38748
|
39181
|
43428
|
47821
|
47824
|
47825
|
47856
|
49110
|
49121
|
50422
|
50423
|
50426
|
50427
|
58818
|
58819
|
58820
|
59272
|
59273
|
60519
|
60520
|
60521
|
60610
|
60611
|
60612
|
60613
|
60614
|
60615
|
60616
|
60617
|
60618
|
60624
|
62778
|
62779
|
62813
|
62814
|
62815