Bugzilla – Attachment 62779 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 [QA Followup]
Bug-12461-QA-Followup.patch (text/plain), 20.67 KB, created by
Kyle M Hall (khall)
on 2017-04-27 14:26:22 UTC
(
hide
)
Description:
Bug 12461 [QA Followup]
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-04-27 14:26:22 UTC
Size:
20.67 KB
patch
obsolete
>From 01fc8897c33c9a924c718e43a3d65fce81949d2a Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 27 Apr 2017 08:24:29 -0400 >Subject: [PATCH] Bug 12461 [QA Followup] > >--- > Koha/Club.pm | 12 ++++ > Koha/Club/Enrollment.pm | 10 +++ > Koha/Clubs.pm | 3 + > Koha/Patron.pm | 16 +++-- > clubs/club-enrollments.pl | 47 ++++++++++++++ > clubs/clubs-add-modify.pl | 8 ++- > .../prog/en/modules/circ/circulation.tt | 10 +-- > .../prog/en/modules/clubs/club-enrollments.tt | 74 ++++++++++++++++++++++ > .../intranet-tmpl/prog/en/modules/clubs/clubs.tt | 28 +++++++- > .../prog/en/modules/clubs/patron-enroll.tt | 2 +- > .../prog/en/modules/members/moremember.tt | 9 +-- > .../bootstrap/en/modules/clubs/clubs-tab.tt | 2 +- > .../opac-tmpl/bootstrap/en/modules/clubs/enroll.tt | 2 +- > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 9 ++- > t/db_dependent/Clubs.t | 5 +- > 15 files changed, 214 insertions(+), 23 deletions(-) > create mode 100755 clubs/club-enrollments.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/clubs/club-enrollments.tt > >diff --git a/Koha/Club.pm b/Koha/Club.pm >index 89f9409..0d93f8c 100644 >--- a/Koha/Club.pm >+++ b/Koha/Club.pm >@@ -63,6 +63,18 @@ sub club_fields { > return Koha::Club::Fields->search( { club_id => $self->id() } ); > } > >+=head3 club_enrollments >+ >+=cut >+ >+sub club_enrollments { >+ my ($self) = @_; >+ >+ return unless $self->id(); >+ >+ return scalar Koha::Club::Enrollments->search( { club_id => $self->id() } ); >+} >+ > =head3 club_fields > > =cut >diff --git a/Koha/Club/Enrollment.pm b/Koha/Club/Enrollment.pm >index f7489d0..788f956 100644 >--- a/Koha/Club/Enrollment.pm >+++ b/Koha/Club/Enrollment.pm >@@ -23,6 +23,7 @@ use Carp; > > use Koha::Database; > use Koha::Clubs; >+use Koha::Patrons; > > use base qw(Koha::Object); > >@@ -61,6 +62,15 @@ sub club { > return Koha::Clubs->find( $self->club_id() ); > } > >+=head3 patron >+ >+=cut >+ >+sub patron { >+ my ( $self ) = @_; >+ return Koha::Patrons->find( $self->borrowernumber() ); >+} >+ > =head3 type > > =cut >diff --git a/Koha/Clubs.pm b/Koha/Clubs.pm >index fff88d8..a553314 100644 >--- a/Koha/Clubs.pm >+++ b/Koha/Clubs.pm >@@ -56,6 +56,9 @@ sub get_enrollable { > } > } > >+ # Only clubs with no end date or an end date in the future can be enrolled in >+ $params->{'-or'} = [ date_end => { '>=' => \'CURRENT_DATE()' }, date_end => undef ]; >+ > my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } ); > > if (wantarray) { >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 759d2d6..b97bceb 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -600,9 +600,13 @@ sub first_valid_email_address { > =cut > > sub get_club_enrollments { >- my ($self) = @_; >+ my ( $self, $return_scalar ) = @_; >+ >+ my $e = Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } ); >+ >+ return $e if $return_scalar; > >- return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } ); >+ return wantarray ? $e->as_list : $e; > } > > =head3 get_enrollable_clubs >@@ -610,7 +614,7 @@ sub get_club_enrollments { > =cut > > sub get_enrollable_clubs { >- my ( $self, $is_enrollable_from_opac ) = @_; >+ my ( $self, $is_enrollable_from_opac, $return_scalar ) = @_; > > my $params; > $params->{is_enrollable_from_opac} = $is_enrollable_from_opac >@@ -619,7 +623,11 @@ sub get_enrollable_clubs { > > $params->{borrower} = $self; > >- return Koha::Clubs->get_enrollable($params); >+ my $e = Koha::Clubs->get_enrollable($params); >+ >+ return $e if $return_scalar; >+ >+ return wantarray ? $e->as_list : $e; > } > > =head3 type >diff --git a/clubs/club-enrollments.pl b/clubs/club-enrollments.pl >new file mode 100755 >index 0000000..e3cd12d >--- /dev/null >+++ b/clubs/club-enrollments.pl >@@ -0,0 +1,47 @@ >+#!/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::Clubs; >+ >+my $cgi = new CGI; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => 'clubs/club-enrollments.tt', >+ query => $cgi, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { clubs => 'edit_clubs' }, >+ } >+); >+ >+my $id = $cgi->param('id'); >+my $club = Koha::Clubs->find($id); >+ >+$template->param( >+ club => $club, >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/clubs/clubs-add-modify.pl b/clubs/clubs-add-modify.pl >index d1873d4..9d0ff08 100755 >--- a/clubs/clubs-add-modify.pl >+++ b/clubs/clubs-add-modify.pl >@@ -44,7 +44,13 @@ my $schema = Koha::Database->new()->schema(); > > my $id = $cgi->param('id'); > my $club = $id ? Koha::Clubs->find($id) : Koha::Club->new(); >-my $stored = $cgi->param('name') ? $id ? 'updated' : 'stored' : undef; >+ >+my $stored = >+ $cgi->param('name') >+ ? $id >+ ? 'updated' >+ : 'stored' >+ : undef; > > my $club_template_id = $cgi->param('club_template_id'); > my $club_template = $club->club_template() || Koha::Club::Templates->find($club_template_id); >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 c0a6572..e133b95 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -895,12 +895,12 @@ No patron matched <span class="ex">[% message | html %]</span> > [% END %] > </li> > >- [% SET enrollments = patron.get_club_enrollments.size || 0 %] >- [% SET enrollable = patron.get_enrollable_clubs.size || 0 %] >- [% IF CAN_user_clubs && ( enrollable || enrollments ) %] >+ [% SET enrollments = patron.get_club_enrollments(1) %] >+ [% SET enrollable = patron.get_enrollable_clubs(0,1) %] >+ [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %] > <li> > <a id="clubs-tab-link" href="#clubs-tab"> >- Clubs ([% enrollments %]/[% enrollable %]) >+ Clubs ([% enrollments.count %]/[% enrollable.count %]) > </a> > </li> > [% END %] >@@ -923,7 +923,7 @@ No patron matched <span class="ex">[% message | html %]</span> > </li> > [% END %] > >- <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li> >+ <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.count %] Restrictions</a></li> > </ul> > > <!-- SUMMARY : TODAY & PREVIOUS ISSUES --> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/club-enrollments.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/club-enrollments.tt >new file mode 100644 >index 0000000..72af5b8 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/club-enrollments.tt >@@ -0,0 +1,74 @@ >+[% USE KohaDates %] >+[% USE Branches %] >+[% USE Koha %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools › Patron clubs › Club enrollments</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >+[% INCLUDE 'datatables.inc' %] >+ >+<script type="text/javascript"> >+//<![CDATA[ >+ $(document).ready(function() { >+ eTable = $('#enrollments-table').dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sPaginationType": "four_button", >+ "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>', >+ "aoColumnDefs": [ >+ { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, >+ ] >+ } )); >+ }); >+//]]> >+</script> >+ >+</head> >+ >+<body id="club_enrollments" class="clubs"> >+[% 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 › Club enrollments</div> >+ >+<div id="doc3" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <h1>Club enrollments for <i>[% club.name %]</i></h1> >+ >+ <table id="enrollments-table"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Card number</th> >+ <th> </th> >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH e IN club.club_enrollments %] >+ [% SET p = e.patron %] >+ <tr> >+ <td> >+ [% p.firstname %] [% p.surname %] >+ </td> >+ <td> >+ [% p.cardnumber %] >+ </td> >+ <td> >+ <a class="btn btn-sm" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% p.id %]"> >+ <i class="fa fa-eye"></i> >+ View patron >+ </a> >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ </div> >+ <div class="yui-b noprint"> >+ [% INCLUDE 'tools-menu.inc' %] >+ </div> >+ </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 >index 15680bb..14fded1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >@@ -1,3 +1,4 @@ >+[% USE KohaDates %] > [% USE Branches %] > [% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -171,7 +172,11 @@ > [% IF CAN_user_clubs_edit_clubs %] > <div class="btn-toolbar"> > <div class="btn-group"> >- <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button> >+ [% IF club_templates %] >+ <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button> >+ [% ELSE %] >+ <button disabled="disabled" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button> >+ [% END %] > <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> >@@ -190,6 +195,9 @@ > <th>Public enrollment</th> > <th>Email required</th> > <th>Library</th> >+ <th>Start date</th> >+ <th>End date</th> >+ <th>Enrolled patrons</th> > <th> </th> > <th> </th> > </tr> >@@ -218,6 +226,22 @@ > </td> > <td>[% Branches.GetName( c.branchcode ) %]</td> > <td> >+ [% IF c.date_start %] >+ [% c.date_start | $KohaDates %] >+ [% END %] >+ </td> >+ <td> >+ [% IF c.date_end %] >+ [% c.date_end | $KohaDates %] >+ [% END %] >+ </td> >+ <td> >+ [% c.club_enrollments.count %] >+ <a class="btn btn-xs" href="club-enrollments.pl?id=[% c.id %]"> >+ View enrollments >+ </a> >+ </td> >+ <td> > [% IF CAN_user_clubs_edit_clubs %] > <a class="btn btn-default" style="white-space:nowrap" href="clubs-add-modify.pl?id=[% c.id %]"> > <i class="fa fa-edit"></i> Edit >@@ -236,7 +260,7 @@ > [% ELSE %] > <tr> > <td colspan="8"> >- No club templates defined. >+ No clubs defined. > </td> > </td> > [% 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 >index 25ee4ca..5b938d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >@@ -28,7 +28,7 @@ > [% END %] > > <li> >- <a href="#" class="btn btn-default" onclick="addEnrollment(); return false;"><i class="fa fa-plus"></i> Enroll</a> >+ <a href="#" class="btn btn-default" onclick="addEnrollment(); return false;"><i class="fa fa-plus"></i> Finish enrollment</a> > <a href="#" onclick="showClubs(); return false;">Cancel</a> > </li> > </ol> >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 1ae43de..bba77f0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -523,12 +523,13 @@ function validate1(date) { > </li> > [% END %] > <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li> >- [% SET enrollments = borrower.get_club_enrollments.size || 0 %] >- [% SET enrollable = borrower.get_enrollable_clubs.size || 0 %] >- [% IF CAN_user_clubs && ( enrollments || enrollable ) %] >+ >+ [% SET enrollments = patron.get_club_enrollments(1) %] >+ [% SET enrollable = patron.get_enrollable_clubs(0,1) %] >+ [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %] > <li> > <a id="clubs-tab-link" href="#clubs-tab"> >- Clubs ([% enrollments %]/[% enrollable %]) >+ Clubs ([% enrollments.count %]/[% enrollable.count %]) > </a> > </li> > [% END %] >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 >index 76ed1fc..cc604b6 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt >@@ -56,7 +56,7 @@ > <td>[% c.name %]</td> > <td>[% c.description %]</td> > <td> >- [% IF !c.club_template.is_email_required || ( c.club_template.is_email_required && borrower.FirstValidEmailAddress ) %] >+ [% IF !c.club_template.is_email_required || ( c.club_template.is_email_required && borrower.first_valid_email_address ) %] > <a class="btn btn-xs" onclick="loadEnrollmentForm([% c.id %])"> > <i class="icon-plus"></i> Enroll > </a> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt >index 6ea5094..2c53918 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt >@@ -28,7 +28,7 @@ > [% END %] > > <li> >- <a href="#" class="btn btn-default" onclick="addEnrollment(); return false;"><i class="fa fa-plus"></i> Enroll</a> >+ <a href="#" class="btn btn-default" onclick="addEnrollment(); return false;"><i class="fa fa-plus"></i> Finish enrollment</a> > <a href="#" onclick="showClubs(); return false;">Cancel</a> > </li> > </ol> >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 1541dc3..65e6f54 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -4,6 +4,9 @@ > [% USE ItemTypes %] > [% USE Price %] > >+[% SET borrower_club_enrollments = borrower.get_club_enrollments(1) %] >+[% SET borrower_enrollable_clubs = borrower.get_enrollable_clubs(1,1) %] >+ > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -134,10 +137,10 @@ Using this account is not recommended because some parts of Koha will not functi > [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %] > [% END %] > >- [% IF borrower.get_club_enrollments.size || borrower.get_enrollable_clubs(1).size %] >+ [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %] > <li> > <a id="opac-user-clubs-tab-link" href="#opac-user-clubs"> >- Clubs ([% borrower.get_club_enrollments.size %]/[% borrower.get_enrollable_clubs(1).size || 0 %]) >+ Clubs ([% borrower_club_enrollments.count || 0 %]/[% borrower_enrollable_clubs.count || 0 %]) > </a> > </li> > [% END %] >@@ -326,7 +329,7 @@ Using this account is not recommended because some parts of Koha will not functi > [% END # IF issues_count %] > </div> <!-- / .opac-user-checkouts --> > >- [% IF borrower.get_club_enrollments_count.size || borrower.get_enrollable_clubs(1).size %] >+ [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %] > <div id="opac-user-clubs"> > Loading... > </div> >diff --git a/t/db_dependent/Clubs.t b/t/db_dependent/Clubs.t >index 1ca9321..ed426f9 100755 >--- a/t/db_dependent/Clubs.t >+++ b/t/db_dependent/Clubs.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 36; >+use Test::More tests => 37; > use Test::Warn; > > use C4::Context; >@@ -129,6 +129,8 @@ my $club = Koha::Club->new( > club_template_id => $club_template->id, > name => "Test Club", > branchcode => $branchcode, >+ date_start => '1900-01-01', >+ date_end => '9999-01-01', > } > )->store(); > >@@ -216,6 +218,7 @@ is( $patron->get_club_enrollments->count, > 1, 'Got 1 club enrollment for patron' ); > is( $patron->get_enrollable_clubs->count, > 0, 'No more enrollable clubs for patron' ); >+is( $club->club_enrollments->count, 1, 'There is 1 enrollment for club' ); > > $schema->storage->txn_rollback(); > 1; >-- >2.10.2
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