Bug 12461 [QA Followup]
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
95429af685
commit
589aa06991
15 changed files with 214 additions and 23 deletions
12
Koha/Club.pm
12
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -600,9 +600,13 @@ sub first_valid_email_address {
|
|||
=cut
|
||||
|
||||
sub get_club_enrollments {
|
||||
my ($self) = @_;
|
||||
my ( $self, $return_scalar ) = @_;
|
||||
|
||||
return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
|
||||
my $e = Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
|
||||
|
||||
return $e if $return_scalar;
|
||||
|
||||
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
|
||||
|
|
47
clubs/club-enrollments.pl
Executable file
47
clubs/club-enrollments.pl
Executable file
|
@ -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 );
|
|
@ -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);
|
||||
|
|
|
@ -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 -->
|
||||
|
|
|
@ -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' %]
|
|
@ -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>
|
||||
|
@ -217,6 +225,22 @@
|
|||
[% END %]
|
||||
</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 %]">
|
||||
|
@ -236,7 +260,7 @@
|
|||
[% ELSE %]
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
No club templates defined.
|
||||
No clubs defined.
|
||||
</td>
|
||||
</td>
|
||||
[% END %]
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %]
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %]
|
||||
|
@ -328,7 +331,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>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue