View | Details | Raw Unified | Return to bug 12461
Collapse All | Expand All

(-)a/C4/Auth.pm (-2 / +3 lines)
Lines 218-224 sub get_template_and_user { Link Here
218
        my $all_perms = get_all_subpermissions();
218
        my $all_perms = get_all_subpermissions();
219
219
220
        my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
220
        my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
221
          editcatalogue updatecharges management tools editauthorities serials reports acquisition);
221
          editcatalogue updatecharges management tools editauthorities serials reports acquisition clubs);
222
222
223
        # We are going to use the $flags returned by checkauth
223
        # We are going to use the $flags returned by checkauth
224
        # to create the template's parameters that will indicate
224
        # to create the template's parameters that will indicate
Lines 242-249 sub get_template_and_user { Link Here
242
            $template->param( CAN_user_staffaccess      => 1 );
242
            $template->param( CAN_user_staffaccess      => 1 );
243
            $template->param( CAN_user_plugins          => 1 );
243
            $template->param( CAN_user_plugins          => 1 );
244
            $template->param( CAN_user_coursereserves   => 1 );
244
            $template->param( CAN_user_coursereserves   => 1 );
245
            foreach my $module ( keys %$all_perms ) {
245
            $template->param( CAN_user_clubs            => 1 );
246
246
247
            foreach my $module ( keys %$all_perms ) {
247
                foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
248
                foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
248
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
249
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
249
                }
250
                }
(-)a/C4/Members.pm (-13 / +4 lines)
Lines 42-47 use Koha::Borrower::Debarments qw(IsDebarred); Link Here
42
use Text::Unaccent qw( unac_string );
42
use Text::Unaccent qw( unac_string );
43
use Koha::AuthUtils qw(hash_password);
43
use Koha::AuthUtils qw(hash_password);
44
use Koha::Database;
44
use Koha::Database;
45
use Koha::Borrowers;
45
use Module::Load;
46
use Module::Load;
46
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
47
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
47
    load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync );
48
    load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync );
Lines 1528-1547 addresses. Link Here
1528
1529
1529
sub GetFirstValidEmailAddress {
1530
sub GetFirstValidEmailAddress {
1530
    my $borrowernumber = shift;
1531
    my $borrowernumber = shift;
1531
    my $dbh = C4::Context->dbh;
1532
    my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
1533
    $sth->execute( $borrowernumber );
1534
    my $data = $sth->fetchrow_hashref;
1535
1532
1536
    if ($data->{'email'}) {
1533
    my $borrower = Koha::Borrowers->find( $borrowernumber );
1537
       return $data->{'email'};
1534
1538
    } elsif ($data->{'emailpro'}) {
1535
    return $borrower->FirstValidEmailAddress();
1539
       return $data->{'emailpro'};
1540
    } elsif ($data->{'B_email'}) {
1541
       return $data->{'B_email'};
1542
    } else {
1543
       return '';
1544
    }
1545
}
1536
}
1546
1537
1547
=head2 GetNoticeEmailAddress
1538
=head2 GetNoticeEmailAddress
(-)a/Koha/Borrower.pm (+64 lines)
Lines 23-28 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use Koha::Clubs;
27
use Koha::Club::Enrollments;
28
26
use base qw(Koha::Object);
29
use base qw(Koha::Object);
27
30
28
=head1 NAME
31
=head1 NAME
Lines 35-40 Koha::Borrower - Koha Borrower Object class Link Here
35
38
36
=cut
39
=cut
37
40
41
=head3 FirstValidEmailAddress
42
43
=cut
44
45
sub FirstValidEmailAddress {
46
    my ($self) = @_;
47
48
    return $self->email() || $self->emailpro() || $self->b_email() || q{};
49
}
50
51
=head3 GetClubEnrollments
52
53
=cut
54
55
sub GetClubEnrollments {
56
    my ($self) = @_;
57
58
    return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
59
}
60
61
=head3 GetClubEnrollmentsCount
62
63
=cut
64
65
sub GetClubEnrollmentsCount {
66
    my ($self) = @_;
67
68
    my $e = $self->GetClubEnrollments();
69
70
    return $e->count();
71
}
72
73
=head3 GetEnrollableClubs
74
75
=cut
76
77
sub GetEnrollableClubs {
78
    my ( $self, $is_enrollable_from_opac ) = @_;
79
80
    my $params;
81
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
82
      if $is_enrollable_from_opac;
83
    $params->{is_email_required} = 0 unless $self->FirstValidEmailAddress();
84
85
    $params->{borrower} = $self;
86
87
    return Koha::Clubs->GetEnrollable($params);
88
}
89
90
=head3 GetEnrollableClubsCount
91
92
=cut
93
94
sub GetEnrollableClubsCount {
95
    my ( $self, $is_enrollable_from_opac ) = @_;
96
97
    my $e = $self->GetEnrollableClubs($is_enrollable_from_opac);
98
99
    return $e->count();
100
}
101
38
=head3 type
102
=head3 type
39
103
40
=cut
104
=cut
(-)a/Koha/Branch.pm (+52 lines)
Line 0 Link Here
1
package Koha::Branch;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use base qw(Koha::Object);
27
28
=head1 NAME
29
30
Koha::Branch - Koha Branch Object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub type {
43
    return 'Branch';
44
}
45
46
=head1 AUTHOR
47
48
Kyle M Hall <kyle@bywatersolutions.com>
49
50
=cut
51
52
1;
(-)a/Koha/Branches.pm (+58 lines)
Line 0 Link Here
1
package Koha::Branches;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Branch;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Branches
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'Branch';
46
}
47
48
sub object_class {
49
    return 'Koha::Branch';
50
}
51
52
=head1 AUTHOR
53
54
Kyle M Hall <kyle@bywatersolutions.com>
55
56
=cut
57
58
1;
(-)a/Koha/Club.pm (+92 lines)
Line 0 Link Here
1
package Koha::Club;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Templates;
27
use Koha::Club::Fields;
28
use Koha::Branches;
29
30
use base qw(Koha::Object);
31
32
=head1 NAME
33
34
Koha::Club - Koha Club Object class
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 club_template
43
44
=cut
45
46
sub club_template {
47
    my ($self) = @_;
48
49
    return unless $self->club_template_id();
50
51
    return Koha::Club::Templates->find( $self->club_template_id() );
52
}
53
54
=head3 club_fields
55
56
=cut
57
58
sub club_fields {
59
    my ($self) = @_;
60
61
    return unless $self->id();
62
63
    return Koha::Club::Fields->search( { club_id => $self->id() } );
64
}
65
66
=head3 club_fields
67
68
=cut
69
70
sub branch {
71
    my ($self) = @_;
72
73
    return unless $self->branchcode();
74
75
    return Koha::Branches->find( $self->branchcode() );
76
}
77
78
=head3 type
79
80
=cut
81
82
sub type {
83
    return 'Club';
84
}
85
86
=head1 AUTHOR
87
88
Kyle M Hall <kyle@bywatersolutions.com>
89
90
=cut
91
92
1;
(-)a/Koha/Club/Enrollment.pm (+80 lines)
Line 0 Link Here
1
package Koha::Club::Enrollment;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
use Koha::Clubs;
26
27
use base qw(Koha::Object);
28
29
=head1 NAME
30
31
Koha::Club::Enrollment
32
33
Represents a "pattern" on which many clubs can be created.
34
In this way we can directly compare different clubs of the same 'template'
35
for statistical purposes.
36
37
=head1 API
38
39
=head2 Class Methods
40
41
=cut
42
43
=head3 cancel
44
45
=cut
46
47
sub cancel {
48
    my ( $self ) = @_;
49
50
    $self->_result()->update( { date_canceled => \'NOW()' } );
51
52
    return $self;
53
}
54
55
=cut
56
57
=head3 club
58
59
=cut
60
61
sub club {
62
    my ( $self ) = @_;
63
    return Koha::Clubs->find( $self->club_id() );
64
}
65
66
=head3 type
67
68
=cut
69
70
sub type {
71
    return 'ClubEnrollment';
72
}
73
74
=head1 AUTHOR
75
76
Kyle M Hall <kyle@bywatersolutions.com>
77
78
=cut
79
80
1;
(-)a/Koha/Club/Enrollment/Field.pm (+56 lines)
Line 0 Link Here
1
package Koha::Club::Enrollment::Field;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use base qw(Koha::Object);
27
28
=head1 NAME
29
30
Koha::Club::Enrollment::Field
31
32
Represents a "pattern" on which many clubs can be created.
33
In this way we can directly compare different clubs of the same 'template'
34
for statistical purposes.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubEnrollmentField';
48
}
49
50
=head1 AUTHOR
51
52
Kyle M Hall <kyle@bywatersolutions.com>
53
54
=cut
55
56
1;
(-)a/Koha/Club/Enrollment/Fields.pm (+60 lines)
Line 0 Link Here
1
package Koha::Club::Enrollment::Fields;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Enrollment::Field;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Club::Enrollment::Fields
33
34
This object represents a collection of club enrollemnt fields.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubEnrollmentField';
48
}
49
50
sub object_class {
51
    return 'Koha::Club::Enrollment::Field';
52
}
53
54
=head1 AUTHOR
55
56
Kyle M Hall <kyle@bywatersolutions.com>
57
58
=cut
59
60
1;
(-)a/Koha/Club/Enrollments.pm (+60 lines)
Line 0 Link Here
1
package Koha::Club::Enrollments;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Enrollment;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Club::Enrollments
33
34
This object represents a collection of club templates.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubEnrollment';
48
}
49
50
sub object_class {
51
    return 'Koha::Club::Enrollment';
52
}
53
54
=head1 AUTHOR
55
56
Kyle M Hall <kyle@bywatersolutions.com>
57
58
=cut
59
60
1;
(-)a/Koha/Club/Field.pm (+66 lines)
Line 0 Link Here
1
package Koha::Club::Field;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Template::Fields;
27
28
use base qw(Koha::Object);
29
30
=head1 NAME
31
32
Koha::Club::Field
33
34
Represents the value set at creation time for a Koha::Club::Template::Field
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 club_template_field
43
44
=cut
45
46
sub club_template_field {
47
    my ( $self ) = @_;
48
49
    return Koha::Club::Template::Fields->find( $self->club_template_field_id );
50
}
51
52
=head3 type
53
54
=cut
55
56
sub type {
57
    return 'ClubField';
58
}
59
60
=head1 AUTHOR
61
62
Kyle M Hall <kyle@bywatersolutions.com>
63
64
=cut
65
66
1;
(-)a/Koha/Club/Fields.pm (+60 lines)
Line 0 Link Here
1
package Koha::Club::Fields;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Field;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Club::Fields
33
34
Represents a collection of club fields.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubField';
48
}
49
50
sub object_class {
51
    return 'Koha::Club::Field';
52
}
53
54
=head1 AUTHOR
55
56
Kyle M Hall <kyle@bywatersolutions.com>
57
58
=cut
59
60
1;
(-)a/Koha/Club/Template.pm (+75 lines)
Line 0 Link Here
1
package Koha::Club::Template;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Template::Fields;
27
use Koha::Club::Template::EnrollmentFields;
28
29
use base qw(Koha::Object);
30
31
=head1 NAME
32
33
Koha::Club::Template
34
35
Represents a "pattern" on which many clubs can be created.
36
In this way we can directly compare different clubs of the same 'template'
37
for statistical purposes.
38
39
=head1 API
40
41
=head2 Class Methods
42
43
=cut
44
45
=head3 club_template_fields
46
47
=cut
48
49
sub club_template_fields {
50
    my ($self) = @_;
51
52
    return Koha::Club::Template::Fields->search( { club_template_id => $self->id() } );
53
}
54
55
sub club_template_enrollment_fields {
56
    my ($self) = @_;
57
58
    return Koha::Club::Template::EnrollmentFields->search( { club_template_id => $self->id() } );
59
}
60
61
=head3 type
62
63
=cut
64
65
sub type {
66
    return 'ClubTemplate';
67
}
68
69
=head1 AUTHOR
70
71
Kyle M Hall <kyle@bywatersolutions.com>
72
73
=cut
74
75
1;
(-)a/Koha/Club/Template/EnrollmentField.pm (+54 lines)
Line 0 Link Here
1
package Koha::Club::Template::EnrollmentField;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use base qw(Koha::Object);
27
28
=head1 NAME
29
30
Koha::Club::Template::EnrollemntField
31
32
Represents a club field that is only set at the time a patron is enrolled
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'ClubTemplateEnrollmentField';
46
}
47
48
=head1 AUTHOR
49
50
Kyle M Hall <kyle@bywatersolutions.com>
51
52
=cut
53
54
1;
(-)a/Koha/Club/Template/EnrollmentFields.pm (+60 lines)
Line 0 Link Here
1
package Koha::Club::Template::EnrollmentFields;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Template::EnrollmentField;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Club::Template::EnrollemntFields
33
34
Represents a colleciton of club fields that are only set at the time a patron is enrolled
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubTemplateEnrollmentField';
48
}
49
50
sub object_class {
51
    return 'Koha::Club::Template::EnrollmentField';
52
}
53
54
=head1 AUTHOR
55
56
Kyle M Hall <kyle@bywatersolutions.com>
57
58
=cut
59
60
1;
(-)a/Koha/Club/Template/Field.pm (+54 lines)
Line 0 Link Here
1
package Koha::Club::Template::Field;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use base qw(Koha::Object);
27
28
=head1 NAME
29
30
Koha::Club::Template::Field
31
32
Represents a club field that is set when the club is created
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub type {
45
    return 'ClubTemplateField';
46
}
47
48
=head1 AUTHOR
49
50
Kyle M Hall <kyle@bywatersolutions.com>
51
52
=cut
53
54
1;
(-)a/Koha/Club/Template/Fields.pm (+60 lines)
Line 0 Link Here
1
package Koha::Club::Template::Fields;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Template::Field;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Club::Template::Fields
33
34
Represents a collection of club fields that are set when the club is created
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubTemplateField';
48
}
49
50
sub object_class {
51
    return 'Koha::Club::Template::Field';
52
}
53
54
=head1 AUTHOR
55
56
Kyle M Hall <kyle@bywatersolutions.com>
57
58
=cut
59
60
1;
(-)a/Koha/Club/Templates.pm (+60 lines)
Line 0 Link Here
1
package Koha::Club::Templates;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club::Template;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Club::Templates
33
34
This object represents a collection of club templates.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 type
43
44
=cut
45
46
sub type {
47
    return 'ClubTemplate';
48
}
49
50
sub object_class {
51
    return 'Koha::Club::Template';
52
}
53
54
=head1 AUTHOR
55
56
Kyle M Hall <kyle@bywatersolutions.com>
57
58
=cut
59
60
1;
(-)a/Koha/Clubs.pm (+94 lines)
Line 0 Link Here
1
package Koha::Clubs;
2
3
# Copyright ByWater Solutions 2014
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Club;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Clubs - Koha Clubs Object class
33
34
This object represents a collection of clubs a patron may enroll in.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 GetEnrollable
43
44
=cut
45
46
sub GetEnrollable {
47
    my ( $self, $params ) = @_;
48
49
    # We need to filter out all the already enrolled in clubs
50
    my $borrower = $params->{borrower};
51
    if ($borrower) {
52
        delete( $params->{borrower} );
53
        my @enrollments = $borrower->GetClubEnrollments();
54
        if (@enrollments) {
55
            $params->{'me.id'} = { -not_in => [ map { $_->club()->id() } @enrollments ] };
56
        }
57
    }
58
59
    my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } );
60
61
    if (wantarray) {
62
        my $class = ref($self) ? ref($self) : $self;
63
64
        return $class->_wrap( $rs->all() );
65
66
    }
67
    else {
68
        my $class = ref($self) ? ref($self) : $self;
69
70
        return $class->_new_from_dbic($rs);
71
    }
72
}
73
74
=cut
75
76
=head3 type
77
78
=cut
79
80
sub type {
81
    return 'Club';
82
}
83
84
sub object_class {
85
    return 'Koha::Club';
86
}
87
88
=head1 AUTHOR
89
90
Kyle M Hall <kyle@bywatersolutions.com>
91
92
=cut
93
94
1;
(-)a/Koha/Schema/Result/AuthorisedValue.pm (-2 / +2 lines)
Lines 123-130 __PACKAGE__->has_many( Link Here
123
);
123
);
124
124
125
125
126
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-02-05 15:20:11
126
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:54:50
127
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GS7UBpk66HAhBptwrpKR7Q
127
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IzI/WpMbwvfZ8BpHtRCsiQ
128
128
129
129
130
# You can replace this text with custom content, and it will be preserved on regeneration
130
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/Koha/Schema/Result/Borrower.pm (-3 / +18 lines)
Lines 798-803 __PACKAGE__->belongs_to( Link Here
798
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
798
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
799
);
799
);
800
800
801
=head2 club_enrollments
802
803
Type: has_many
804
805
Related object: L<Koha::Schema::Result::ClubEnrollment>
806
807
=cut
808
809
__PACKAGE__->has_many(
810
  "club_enrollments",
811
  "Koha::Schema::Result::ClubEnrollment",
812
  { "foreign.borrowernumber" => "self.borrowernumber" },
813
  { cascade_copy => 0, cascade_delete => 0 },
814
);
815
801
=head2 course_instructors
816
=head2 course_instructors
802
817
803
Type: has_many
818
Type: has_many
Lines 1154-1162 Composing rels: L</aqorder_users> -> ordernumber Link Here
1154
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1169
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1155
1170
1156
1171
1157
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-04-27 16:08:40
1172
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
1158
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Z50zYBD3Hqlv5/EnoLnyZw
1173
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Wy9KSEiYp/SxYsw+xW0x1g
1159
1174
1160
1175
1161
# You can replace this text with custom content, and it will be preserved on regeneration
1176
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1162
1;
1177
1;
(-)a/Koha/Schema/Result/Branch.pm (-2 / +47 lines)
Lines 337-342 __PACKAGE__->has_many( Link Here
337
  { cascade_copy => 0, cascade_delete => 0 },
337
  { cascade_copy => 0, cascade_delete => 0 },
338
);
338
);
339
339
340
=head2 club_enrollments
341
342
Type: has_many
343
344
Related object: L<Koha::Schema::Result::ClubEnrollment>
345
346
=cut
347
348
__PACKAGE__->has_many(
349
  "club_enrollments",
350
  "Koha::Schema::Result::ClubEnrollment",
351
  { "foreign.branchcode" => "self.branchcode" },
352
  { cascade_copy => 0, cascade_delete => 0 },
353
);
354
355
=head2 club_templates
356
357
Type: has_many
358
359
Related object: L<Koha::Schema::Result::ClubTemplate>
360
361
=cut
362
363
__PACKAGE__->has_many(
364
  "club_templates",
365
  "Koha::Schema::Result::ClubTemplate",
366
  { "foreign.branchcode" => "self.branchcode" },
367
  { cascade_copy => 0, cascade_delete => 0 },
368
);
369
370
=head2 clubs
371
372
Type: has_many
373
374
Related object: L<Koha::Schema::Result::Club>
375
376
=cut
377
378
__PACKAGE__->has_many(
379
  "clubs",
380
  "Koha::Schema::Result::Club",
381
  { "foreign.branchcode" => "self.branchcode" },
382
  { cascade_copy => 0, cascade_delete => 0 },
383
);
384
340
=head2 collections
385
=head2 collections
341
386
342
Type: has_many
387
Type: has_many
Lines 513-520 Composing rels: L</branchrelations> -> categorycode Link Here
513
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
558
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
514
559
515
560
516
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-11-06 15:26:36
561
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
517
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CGNPB/MkGLOihDThj43/4A
562
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lvjA8x8u5RKeZQ0+uiLm7A
518
563
519
564
520
# You can replace this text with custom content, and it will be preserved on regeneration
565
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/Koha/Schema/Result/Club.pm (+197 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::Club;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::Club
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<clubs>
19
20
=cut
21
22
__PACKAGE__->table("clubs");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 club_template_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 0
37
38
=head2 name
39
40
  data_type: 'tinytext'
41
  is_nullable: 0
42
43
=head2 description
44
45
  data_type: 'text'
46
  is_nullable: 1
47
48
=head2 date_start
49
50
  data_type: 'date'
51
  datetime_undef_if_invalid: 1
52
  is_nullable: 1
53
54
=head2 date_end
55
56
  data_type: 'date'
57
  datetime_undef_if_invalid: 1
58
  is_nullable: 1
59
60
=head2 branchcode
61
62
  data_type: 'varchar'
63
  is_foreign_key: 1
64
  is_nullable: 1
65
  size: 11
66
67
=head2 date_created
68
69
  data_type: 'timestamp'
70
  datetime_undef_if_invalid: 1
71
  default_value: current_timestamp
72
  is_nullable: 0
73
74
=head2 date_updated
75
76
  data_type: 'timestamp'
77
  datetime_undef_if_invalid: 1
78
  is_nullable: 1
79
80
=cut
81
82
__PACKAGE__->add_columns(
83
  "id",
84
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
85
  "club_template_id",
86
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
87
  "name",
88
  { data_type => "tinytext", is_nullable => 0 },
89
  "description",
90
  { data_type => "text", is_nullable => 1 },
91
  "date_start",
92
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
93
  "date_end",
94
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
95
  "branchcode",
96
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 },
97
  "date_created",
98
  {
99
    data_type => "timestamp",
100
    datetime_undef_if_invalid => 1,
101
    default_value => \"current_timestamp",
102
    is_nullable => 0,
103
  },
104
  "date_updated",
105
  {
106
    data_type => "timestamp",
107
    datetime_undef_if_invalid => 1,
108
    is_nullable => 1,
109
  },
110
);
111
112
=head1 PRIMARY KEY
113
114
=over 4
115
116
=item * L</id>
117
118
=back
119
120
=cut
121
122
__PACKAGE__->set_primary_key("id");
123
124
=head1 RELATIONS
125
126
=head2 branchcode
127
128
Type: belongs_to
129
130
Related object: L<Koha::Schema::Result::Branch>
131
132
=cut
133
134
__PACKAGE__->belongs_to(
135
  "branchcode",
136
  "Koha::Schema::Result::Branch",
137
  { branchcode => "branchcode" },
138
  {
139
    is_deferrable => 1,
140
    join_type     => "LEFT",
141
    on_delete     => "RESTRICT",
142
    on_update     => "RESTRICT",
143
  },
144
);
145
146
=head2 club_enrollments
147
148
Type: has_many
149
150
Related object: L<Koha::Schema::Result::ClubEnrollment>
151
152
=cut
153
154
__PACKAGE__->has_many(
155
  "club_enrollments",
156
  "Koha::Schema::Result::ClubEnrollment",
157
  { "foreign.club_id" => "self.id" },
158
  { cascade_copy => 0, cascade_delete => 0 },
159
);
160
161
=head2 club_fields
162
163
Type: has_many
164
165
Related object: L<Koha::Schema::Result::ClubField>
166
167
=cut
168
169
__PACKAGE__->has_many(
170
  "club_fields",
171
  "Koha::Schema::Result::ClubField",
172
  { "foreign.club_id" => "self.id" },
173
  { cascade_copy => 0, cascade_delete => 0 },
174
);
175
176
=head2 club_template
177
178
Type: belongs_to
179
180
Related object: L<Koha::Schema::Result::ClubTemplate>
181
182
=cut
183
184
__PACKAGE__->belongs_to(
185
  "club_template",
186
  "Koha::Schema::Result::ClubTemplate",
187
  { id => "club_template_id" },
188
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
189
);
190
191
192
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
193
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nMwJy/qR8aWu12hQq4rORQ
194
195
196
# You can replace this text with custom content, and it will be preserved on regeneration
197
1;
(-)a/Koha/Schema/Result/ClubEnrollment.pm (+201 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ClubEnrollment;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ClubEnrollment
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<club_enrollments>
19
20
=cut
21
22
__PACKAGE__->table("club_enrollments");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 club_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 0
37
38
=head2 borrowernumber
39
40
  data_type: 'integer'
41
  is_foreign_key: 1
42
  is_nullable: 0
43
44
=head2 date_enrolled
45
46
  data_type: 'timestamp'
47
  datetime_undef_if_invalid: 1
48
  default_value: current_timestamp
49
  is_nullable: 0
50
51
=head2 date_canceled
52
53
  data_type: 'timestamp'
54
  datetime_undef_if_invalid: 1
55
  is_nullable: 1
56
57
=head2 date_created
58
59
  data_type: 'timestamp'
60
  datetime_undef_if_invalid: 1
61
  default_value: '0000-00-00 00:00:00'
62
  is_nullable: 0
63
64
=head2 date_updated
65
66
  data_type: 'timestamp'
67
  datetime_undef_if_invalid: 1
68
  is_nullable: 1
69
70
=head2 branchcode
71
72
  data_type: 'varchar'
73
  is_foreign_key: 1
74
  is_nullable: 1
75
  size: 11
76
77
=cut
78
79
__PACKAGE__->add_columns(
80
  "id",
81
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
82
  "club_id",
83
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
84
  "borrowernumber",
85
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
86
  "date_enrolled",
87
  {
88
    data_type => "timestamp",
89
    datetime_undef_if_invalid => 1,
90
    default_value => \"current_timestamp",
91
    is_nullable => 0,
92
  },
93
  "date_canceled",
94
  {
95
    data_type => "timestamp",
96
    datetime_undef_if_invalid => 1,
97
    is_nullable => 1,
98
  },
99
  "date_created",
100
  {
101
    data_type => "timestamp",
102
    datetime_undef_if_invalid => 1,
103
    default_value => "0000-00-00 00:00:00",
104
    is_nullable => 0,
105
  },
106
  "date_updated",
107
  {
108
    data_type => "timestamp",
109
    datetime_undef_if_invalid => 1,
110
    is_nullable => 1,
111
  },
112
  "branchcode",
113
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 },
114
);
115
116
=head1 PRIMARY KEY
117
118
=over 4
119
120
=item * L</id>
121
122
=back
123
124
=cut
125
126
__PACKAGE__->set_primary_key("id");
127
128
=head1 RELATIONS
129
130
=head2 borrowernumber
131
132
Type: belongs_to
133
134
Related object: L<Koha::Schema::Result::Borrower>
135
136
=cut
137
138
__PACKAGE__->belongs_to(
139
  "borrowernumber",
140
  "Koha::Schema::Result::Borrower",
141
  { borrowernumber => "borrowernumber" },
142
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
143
);
144
145
=head2 branchcode
146
147
Type: belongs_to
148
149
Related object: L<Koha::Schema::Result::Branch>
150
151
=cut
152
153
__PACKAGE__->belongs_to(
154
  "branchcode",
155
  "Koha::Schema::Result::Branch",
156
  { branchcode => "branchcode" },
157
  {
158
    is_deferrable => 1,
159
    join_type     => "LEFT",
160
    on_delete     => "SET NULL",
161
    on_update     => "CASCADE",
162
  },
163
);
164
165
=head2 club
166
167
Type: belongs_to
168
169
Related object: L<Koha::Schema::Result::Club>
170
171
=cut
172
173
__PACKAGE__->belongs_to(
174
  "club",
175
  "Koha::Schema::Result::Club",
176
  { id => "club_id" },
177
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
178
);
179
180
=head2 club_enrollment_fields
181
182
Type: has_many
183
184
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
185
186
=cut
187
188
__PACKAGE__->has_many(
189
  "club_enrollment_fields",
190
  "Koha::Schema::Result::ClubEnrollmentField",
191
  { "foreign.club_enrollment_id" => "self.id" },
192
  { cascade_copy => 0, cascade_delete => 0 },
193
);
194
195
196
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
197
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9ypc+smG/VlgtWW66PhvHQ
198
199
200
# You can replace this text with custom content, and it will be preserved on regeneration
201
1;
(-)a/Koha/Schema/Result/ClubEnrollmentField.pm (+112 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ClubEnrollmentField;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ClubEnrollmentField
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<club_enrollment_fields>
19
20
=cut
21
22
__PACKAGE__->table("club_enrollment_fields");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 club_enrollment_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 0
37
38
=head2 club_template_enrollment_field_id
39
40
  data_type: 'integer'
41
  is_foreign_key: 1
42
  is_nullable: 0
43
44
=head2 value
45
46
  data_type: 'text'
47
  is_nullable: 0
48
49
=cut
50
51
__PACKAGE__->add_columns(
52
  "id",
53
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
54
  "club_enrollment_id",
55
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
56
  "club_template_enrollment_field_id",
57
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
58
  "value",
59
  { data_type => "text", is_nullable => 0 },
60
);
61
62
=head1 PRIMARY KEY
63
64
=over 4
65
66
=item * L</id>
67
68
=back
69
70
=cut
71
72
__PACKAGE__->set_primary_key("id");
73
74
=head1 RELATIONS
75
76
=head2 club_enrollment
77
78
Type: belongs_to
79
80
Related object: L<Koha::Schema::Result::ClubEnrollment>
81
82
=cut
83
84
__PACKAGE__->belongs_to(
85
  "club_enrollment",
86
  "Koha::Schema::Result::ClubEnrollment",
87
  { id => "club_enrollment_id" },
88
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
89
);
90
91
=head2 club_template_enrollment_field
92
93
Type: belongs_to
94
95
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
96
97
=cut
98
99
__PACKAGE__->belongs_to(
100
  "club_template_enrollment_field",
101
  "Koha::Schema::Result::ClubTemplateEnrollmentField",
102
  { id => "club_template_enrollment_field_id" },
103
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
104
);
105
106
107
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
108
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2ANAs3mh3i/kd3Qxrcd5IA
109
110
111
# You can replace this text with custom content, and it will be preserved on regeneration
112
1;
(-)a/Koha/Schema/Result/ClubField.pm (+112 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ClubField;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ClubField
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<club_fields>
19
20
=cut
21
22
__PACKAGE__->table("club_fields");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 club_template_field_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 0
37
38
=head2 club_id
39
40
  data_type: 'integer'
41
  is_foreign_key: 1
42
  is_nullable: 0
43
44
=head2 value
45
46
  data_type: 'text'
47
  is_nullable: 1
48
49
=cut
50
51
__PACKAGE__->add_columns(
52
  "id",
53
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
54
  "club_template_field_id",
55
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
56
  "club_id",
57
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
58
  "value",
59
  { data_type => "text", is_nullable => 1 },
60
);
61
62
=head1 PRIMARY KEY
63
64
=over 4
65
66
=item * L</id>
67
68
=back
69
70
=cut
71
72
__PACKAGE__->set_primary_key("id");
73
74
=head1 RELATIONS
75
76
=head2 club
77
78
Type: belongs_to
79
80
Related object: L<Koha::Schema::Result::Club>
81
82
=cut
83
84
__PACKAGE__->belongs_to(
85
  "club",
86
  "Koha::Schema::Result::Club",
87
  { id => "club_id" },
88
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
89
);
90
91
=head2 club_template_field
92
93
Type: belongs_to
94
95
Related object: L<Koha::Schema::Result::ClubTemplateField>
96
97
=cut
98
99
__PACKAGE__->belongs_to(
100
  "club_template_field",
101
  "Koha::Schema::Result::ClubTemplateField",
102
  { id => "club_template_field_id" },
103
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
104
);
105
106
107
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
108
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m4GLLIVIHgRpRhCGLh12DQ
109
110
111
# You can replace this text with custom content, and it will be preserved on regeneration
112
1;
(-)a/Koha/Schema/Result/ClubTemplate.pm (+195 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ClubTemplate;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ClubTemplate
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<club_templates>
19
20
=cut
21
22
__PACKAGE__->table("club_templates");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 name
33
34
  data_type: 'tinytext'
35
  is_nullable: 0
36
37
=head2 description
38
39
  data_type: 'text'
40
  is_nullable: 1
41
42
=head2 is_enrollable_from_opac
43
44
  data_type: 'tinyint'
45
  default_value: 0
46
  is_nullable: 0
47
48
=head2 is_email_required
49
50
  data_type: 'tinyint'
51
  default_value: 0
52
  is_nullable: 0
53
54
=head2 branchcode
55
56
  data_type: 'varchar'
57
  is_foreign_key: 1
58
  is_nullable: 1
59
  size: 10
60
61
=head2 date_created
62
63
  data_type: 'timestamp'
64
  datetime_undef_if_invalid: 1
65
  default_value: current_timestamp
66
  is_nullable: 0
67
68
=head2 date_updated
69
70
  data_type: 'timestamp'
71
  datetime_undef_if_invalid: 1
72
  is_nullable: 1
73
74
=head2 is_deletable
75
76
  data_type: 'tinyint'
77
  default_value: 1
78
  is_nullable: 0
79
80
=cut
81
82
__PACKAGE__->add_columns(
83
  "id",
84
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
85
  "name",
86
  { data_type => "tinytext", is_nullable => 0 },
87
  "description",
88
  { data_type => "text", is_nullable => 1 },
89
  "is_enrollable_from_opac",
90
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
91
  "is_email_required",
92
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
93
  "branchcode",
94
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
95
  "date_created",
96
  {
97
    data_type => "timestamp",
98
    datetime_undef_if_invalid => 1,
99
    default_value => \"current_timestamp",
100
    is_nullable => 0,
101
  },
102
  "date_updated",
103
  {
104
    data_type => "timestamp",
105
    datetime_undef_if_invalid => 1,
106
    is_nullable => 1,
107
  },
108
  "is_deletable",
109
  { data_type => "tinyint", default_value => 1, is_nullable => 0 },
110
);
111
112
=head1 PRIMARY KEY
113
114
=over 4
115
116
=item * L</id>
117
118
=back
119
120
=cut
121
122
__PACKAGE__->set_primary_key("id");
123
124
=head1 RELATIONS
125
126
=head2 branchcode
127
128
Type: belongs_to
129
130
Related object: L<Koha::Schema::Result::Branch>
131
132
=cut
133
134
__PACKAGE__->belongs_to(
135
  "branchcode",
136
  "Koha::Schema::Result::Branch",
137
  { branchcode => "branchcode" },
138
  {
139
    is_deferrable => 1,
140
    join_type     => "LEFT",
141
    on_delete     => "SET NULL",
142
    on_update     => "CASCADE",
143
  },
144
);
145
146
=head2 club_template_enrollment_fields
147
148
Type: has_many
149
150
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
151
152
=cut
153
154
__PACKAGE__->has_many(
155
  "club_template_enrollment_fields",
156
  "Koha::Schema::Result::ClubTemplateEnrollmentField",
157
  { "foreign.club_template_id" => "self.id" },
158
  { cascade_copy => 0, cascade_delete => 0 },
159
);
160
161
=head2 club_template_fields
162
163
Type: has_many
164
165
Related object: L<Koha::Schema::Result::ClubTemplateField>
166
167
=cut
168
169
__PACKAGE__->has_many(
170
  "club_template_fields",
171
  "Koha::Schema::Result::ClubTemplateField",
172
  { "foreign.club_template_id" => "self.id" },
173
  { cascade_copy => 0, cascade_delete => 0 },
174
);
175
176
=head2 clubs
177
178
Type: has_many
179
180
Related object: L<Koha::Schema::Result::Club>
181
182
=cut
183
184
__PACKAGE__->has_many(
185
  "clubs",
186
  "Koha::Schema::Result::Club",
187
  { "foreign.club_template_id" => "self.id" },
188
  { cascade_copy => 0, cascade_delete => 0 },
189
);
190
191
192
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
193
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:j5aiACVUGzrdng4+jt6mfg
194
195
1;
(-)a/Koha/Schema/Result/ClubTemplateEnrollmentField.pm (+119 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ClubTemplateEnrollmentField;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ClubTemplateEnrollmentField
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<club_template_enrollment_fields>
19
20
=cut
21
22
__PACKAGE__->table("club_template_enrollment_fields");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 club_template_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 0
37
38
=head2 name
39
40
  data_type: 'tinytext'
41
  is_nullable: 0
42
43
=head2 description
44
45
  data_type: 'text'
46
  is_nullable: 1
47
48
=head2 authorised_value_category
49
50
  data_type: 'varchar'
51
  is_nullable: 1
52
  size: 16
53
54
=cut
55
56
__PACKAGE__->add_columns(
57
  "id",
58
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
59
  "club_template_id",
60
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
61
  "name",
62
  { data_type => "tinytext", is_nullable => 0 },
63
  "description",
64
  { data_type => "text", is_nullable => 1 },
65
  "authorised_value_category",
66
  { data_type => "varchar", is_nullable => 1, size => 16 },
67
);
68
69
=head1 PRIMARY KEY
70
71
=over 4
72
73
=item * L</id>
74
75
=back
76
77
=cut
78
79
__PACKAGE__->set_primary_key("id");
80
81
=head1 RELATIONS
82
83
=head2 club_enrollment_fields
84
85
Type: has_many
86
87
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
88
89
=cut
90
91
__PACKAGE__->has_many(
92
  "club_enrollment_fields",
93
  "Koha::Schema::Result::ClubEnrollmentField",
94
  { "foreign.club_template_enrollment_field_id" => "self.id" },
95
  { cascade_copy => 0, cascade_delete => 0 },
96
);
97
98
=head2 club_template
99
100
Type: belongs_to
101
102
Related object: L<Koha::Schema::Result::ClubTemplate>
103
104
=cut
105
106
__PACKAGE__->belongs_to(
107
  "club_template",
108
  "Koha::Schema::Result::ClubTemplate",
109
  { id => "club_template_id" },
110
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
111
);
112
113
114
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
115
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KGo2mEIAkTVYSPsOLoaBCg
116
117
118
# You can replace this text with custom content, and it will be preserved on regeneration
119
1;
(-)a/Koha/Schema/Result/ClubTemplateField.pm (+119 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::ClubTemplateField;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ClubTemplateField
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<club_template_fields>
19
20
=cut
21
22
__PACKAGE__->table("club_template_fields");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 club_template_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 0
37
38
=head2 name
39
40
  data_type: 'tinytext'
41
  is_nullable: 0
42
43
=head2 description
44
45
  data_type: 'text'
46
  is_nullable: 1
47
48
=head2 authorised_value_category
49
50
  data_type: 'varchar'
51
  is_nullable: 1
52
  size: 16
53
54
=cut
55
56
__PACKAGE__->add_columns(
57
  "id",
58
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
59
  "club_template_id",
60
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
61
  "name",
62
  { data_type => "tinytext", is_nullable => 0 },
63
  "description",
64
  { data_type => "text", is_nullable => 1 },
65
  "authorised_value_category",
66
  { data_type => "varchar", is_nullable => 1, size => 16 },
67
);
68
69
=head1 PRIMARY KEY
70
71
=over 4
72
73
=item * L</id>
74
75
=back
76
77
=cut
78
79
__PACKAGE__->set_primary_key("id");
80
81
=head1 RELATIONS
82
83
=head2 club_fields
84
85
Type: has_many
86
87
Related object: L<Koha::Schema::Result::ClubField>
88
89
=cut
90
91
__PACKAGE__->has_many(
92
  "club_fields",
93
  "Koha::Schema::Result::ClubField",
94
  { "foreign.club_template_field_id" => "self.id" },
95
  { cascade_copy => 0, cascade_delete => 0 },
96
);
97
98
=head2 club_template
99
100
Type: belongs_to
101
102
Related object: L<Koha::Schema::Result::ClubTemplate>
103
104
=cut
105
106
__PACKAGE__->belongs_to(
107
  "club_template",
108
  "Koha::Schema::Result::ClubTemplate",
109
  { id => "club_template_id" },
110
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
111
);
112
113
114
# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-01-12 09:56:17
115
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:P73ABSn2tzlTYbD3nov21g
116
117
118
# You can replace this text with custom content, and it will be preserved on regeneration
119
1;
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (+6 lines)
Lines 38-43 sub GetAuthValueDropbox { Link Here
38
    return C4::Koha::GetAuthvalueDropbox($category, $default);
38
    return C4::Koha::GetAuthvalueDropbox($category, $default);
39
}
39
}
40
40
41
sub Categories {
42
    my ( $self ) = @_;
43
44
    return GetAuthorisedValueCategories();
45
}
46
41
1;
47
1;
42
48
43
=head1 NAME
49
=head1 NAME
(-)a/Koha/Template/Plugin/Borrowers.pm (+4 lines)
Lines 48-51 sub IsDebarred { Link Here
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
49
}
49
}
50
50
51
sub HasValidEmailAddress {
52
53
}
54
51
1;
55
1;
(-)a/Koha/Template/Plugin/Branches.pm (+7 lines)
Lines 25-30 use base qw( Template::Plugin ); Link Here
25
use C4::Koha;
25
use C4::Koha;
26
use C4::Context;
26
use C4::Context;
27
27
28
sub GetBranches {
29
    my ($self) = @_;
30
31
    my $dbh = C4::Context->dbh;
32
    return $dbh->selectall_arrayref( "SELECT * FROM branches", { Slice => {} } );
33
}
34
28
sub GetName {
35
sub GetName {
29
    my ( $self, $branchcode ) = @_;
36
    my ( $self, $branchcode ) = @_;
30
37
(-)a/Koha/Template/Plugin/Koha.pm (+5 lines)
Lines 60-63 sub Version { Link Here
60
    };
60
    };
61
}
61
}
62
62
63
sub UserEnv {
64
    my ( $self, $key ) = @_;
65
    my $userenv = C4::Context->userenv;
66
    return $userenv ? $userenv->{$key} : undef;
67
}
63
1;
68
1;
(-)a/circ/circulation.pl (+4 lines)
Lines 46-51 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
46
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
46
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
47
use Koha::DateUtils;
47
use Koha::DateUtils;
48
use Koha::Database;
48
use Koha::Database;
49
use Koha::Borrowers;
49
50
50
use Date::Calc qw(
51
use Date::Calc qw(
51
  Today
52
  Today
Lines 580-585 $template->param( picture => 1 ) if $picture; Link Here
580
581
581
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
582
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
582
583
584
my $schema = Koha::Database->new()->schema();
585
583
$template->param(
586
$template->param(
584
    debt_confirmed            => $debt_confirmed,
587
    debt_confirmed            => $debt_confirmed,
585
    SpecifyDueDate            => $duedatespec_allow,
588
    SpecifyDueDate            => $duedatespec_allow,
Lines 588-593 $template->param( Link Here
588
    canned_bor_notes_loop     => $canned_notes,
591
    canned_bor_notes_loop     => $canned_notes,
589
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
592
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
590
    todaysdate                => dt_from_string()->set(hour => 23)->set(minute => 59),
593
    todaysdate                => dt_from_string()->set(hour => 23)->set(minute => 59),
594
    borrower                  => Koha::Borrowers->find( $borrowernumber ),
591
);
595
);
592
596
593
output_html_with_http_headers $query, $cookie, $template->output;
597
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs/clubs-add-modify.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
28
use Koha::Clubs;
29
use Koha::Club::Fields;
30
31
my $cgi = new CGI;
32
33
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => 'clubs/clubs-add-modify.tt',
36
        query           => $cgi,
37
        type            => 'intranet',
38
        authnotrequired => 0,
39
        flagsrequired   => { clubs => 'edit_clubs' },
40
    }
41
);
42
43
my $schema = Koha::Database->new()->schema();
44
45
my $id = $cgi->param('id');
46
my $club = $id ? Koha::Clubs->find($id) : Koha::Club->new();
47
$template->param( stored => $id ? 'updated' : 'stored' ) if $cgi->param('name');
48
49
my $club_template_id = $cgi->param('club_template_id');
50
my $club_template = $club->club_template() || Koha::Club::Templates->find($club_template_id);
51
$club_template_id ||= $club_template->id();
52
53
my $date_start = $cgi->param('date_start');
54
$date_start = $date_start ? dt_from_string($date_start) : undef;
55
my $date_end = $cgi->param('date_end');
56
$date_end = $date_end ? dt_from_string($date_end) : undef;
57
58
if ( $cgi->param('name') ) {    # Update or create club
59
    $club->set(
60
        {
61
            club_template_id => $cgi->param('club_template_id') || undef,
62
            name             => $cgi->param('name')             || undef,
63
            description      => $cgi->param('description')      || undef,
64
            branchcode       => $cgi->param('branchcode')       || undef,
65
            date_start       => $date_start,
66
            date_end         => $date_end,
67
            date_updated     => dt_from_string(),
68
        }
69
    )->store();
70
71
    my @club_template_field_id = $cgi->param('club_template_field_id');
72
    my @club_field_id          = $cgi->param('club_field_id');
73
    my @club_field             = $cgi->param('club_field');
74
75
    for ( my $i = 0 ; $i < @club_template_field_id ; $i++ ) {
76
        my $club_template_field_id = $club_template_field_id[$i] || undef;
77
        my $club_field_id          = $club_field_id[$i]          || undef;
78
        my $club_field             = $club_field[$i]             || undef;
79
80
        my $field =
81
          $club_field_id
82
          ? Koha::Club::Fields->find($club_field_id)
83
          : Koha::Club::Field->new();
84
85
        $field->set(
86
            {
87
                club_id                => $club->id(),
88
                club_template_field_id => $club_template_field_id,
89
                value                  => $club_field,
90
            }
91
        )->store();
92
    }
93
94
    $id ||= $club->id();
95
}
96
97
$club = Koha::Clubs->find($id);
98
99
$template->param(
100
    club_template => $club_template,
101
    club          => $club,
102
);
103
104
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/clubs.pl (+50 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
27
use Koha::Clubs;
28
use Koha::Club::Templates;
29
30
my $cgi = new CGI;
31
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "clubs/clubs.tt",
35
        query           => $cgi,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => { clubs => '*' },
39
    }
40
);
41
42
my @club_templates = Koha::Club::Templates->search();
43
my @clubs          = Koha::Clubs->search();
44
45
$template->param(
46
    club_templates => \@club_templates,
47
    clubs          => \@clubs,
48
);
49
50
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/patron-clubs-tab.pl (+55 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
27
use Koha::Borrowers;
28
use Koha::Club::Enrollments;
29
30
my $cgi = new CGI;
31
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "clubs/patron-clubs-tab.tt",
35
        query           => $cgi,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => { clubs => '*' },
39
    }
40
);
41
42
my $borrowernumber = $cgi->param('borrowernumber');
43
44
my $borrower = Koha::Borrowers->find($borrowernumber);
45
46
my @enrollments = $borrower->GetClubEnrollments();
47
my @clubs       = $borrower->GetEnrollableClubs();
48
49
$template->param(
50
    enrollments    => \@enrollments,
51
    clubs          => \@clubs,
52
    borrowernumber => $borrowernumber
53
);
54
55
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/patron-enroll.pl (+50 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Clubs;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/patron-enroll.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $id             = $cgi->param('id');
41
my $borrowernumber = $cgi->param('borrowernumber');
42
43
my $club = Koha::Clubs->find($id);
44
45
$template->param(
46
    club           => $club,
47
    borrowernumber => $borrowernumber,
48
);
49
50
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/templates-add-modify.pl (+150 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
27
use Koha::DateUtils qw(dt_from_string);
28
use Koha::Club::Templates;
29
use Koha::Club::Template::Fields;
30
use Koha::Club::Template::EnrollmentFields;
31
32
use Koha::Database;
33
my $schema = Koha::Database->new()->schema();
34
35
my $cgi = new CGI;
36
37
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38
    {
39
        template_name   => 'clubs/templates-add-modify.tt',
40
        query           => $cgi,
41
        type            => 'intranet',
42
        authnotrequired => 0,
43
        flagsrequired   => { clubs => 'edit_templates' },
44
    }
45
);
46
47
my $id = $cgi->param('id');
48
49
my $club_template;
50
51
if ( $cgi->param('name') ) {    # Update or create club
52
    if ($id) {
53
        $club_template = Koha::Club::Templates->find($id);
54
        $template->param( stored => 'updated' );
55
    }
56
    else {
57
        $club_template = Koha::Club::Template->new();
58
        $template->param( stored => 'created' );
59
    }
60
61
    $club_template->set(
62
        {
63
            id          => $id                        || undef,
64
            name        => $cgi->param('name')        || undef,
65
            description => $cgi->param('description') || undef,
66
            branchcode  => $cgi->param('branchcode')  || undef,
67
            date_updated            => dt_from_string(),
68
            is_email_required       => $cgi->param('is_email_required') ? 1 : 0,
69
            is_enrollable_from_opac => $cgi->param('is_enrollable_from_opac')
70
            ? 1
71
            : 0,
72
        }
73
    )->store();
74
75
    $id ||= $club_template->id();
76
77
    # Update club creation fields
78
    my @field_id                        = $cgi->param('club_template_field_id');
79
    my @field_name                      = $cgi->param('club_template_field_name');
80
    my @field_description               = $cgi->param('club_template_field_description');
81
    my @field_authorised_value_category = $cgi->param('club_template_field_authorised_value_category');
82
83
    my @field_delete = $cgi->param('club_template_field_delete');
84
85
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
86
        my $field_id                        = $field_id[$i];
87
        my $field_name                      = $field_name[$i];
88
        my $field_description               = $field_description[$i];
89
        my $field_authorised_value_category = $field_authorised_value_category[$i];
90
91
        my $field =
92
          $field_id
93
          ? Koha::Club::Template::Fields->find($field_id)
94
          : Koha::Club::Template::Field->new();
95
96
        if ( grep( /^$field_id$/, @field_delete ) ) {
97
            $field->delete();
98
        }
99
        else {
100
            $field->set(
101
                {
102
                    club_template_id          => $id,
103
                    name                      => $field_name,
104
                    description               => $field_description,
105
                    authorised_value_category => $field_authorised_value_category,
106
                }
107
            )->store();
108
        }
109
    }
110
111
    # Update club enrollment fields
112
    @field_id                        = $cgi->param('club_template_enrollment_field_id');
113
    @field_name                      = $cgi->param('club_template_enrollment_field_name');
114
    @field_description               = $cgi->param('club_template_enrollment_field_description');
115
    @field_authorised_value_category = $cgi->param('club_template_enrollment_field_authorised_value_category');
116
117
    @field_delete = $cgi->param('club_template_enrollment_field_delete');
118
119
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
120
        my $field_id                        = $field_id[$i];
121
        my $field_name                      = $field_name[$i];
122
        my $field_description               = $field_description[$i];
123
        my $field_authorised_value_category = $field_authorised_value_category[$i];
124
125
        my $field =
126
          $field_id
127
          ? Koha::Club::Template::EnrollmentFields->find($field_id)
128
          : Koha::Club::Template::EnrollmentField->new();
129
130
        if ( grep( /^$field_id$/, @field_delete ) ) {
131
            $field->delete();
132
        }
133
        else {
134
            $field->set(
135
                {
136
                    id                        => $field_id,
137
                    club_template_id          => $id,
138
                    name                      => $field_name,
139
                    description               => $field_description,
140
                    authorised_value_category => $field_authorised_value_category,
141
                }
142
            )->store();
143
        }
144
    }
145
}
146
147
$club_template ||= Koha::Club::Templates->find($id);
148
$template->param( club_template => $club_template );
149
150
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/installer/data/mysql/en/mandatory/userflags.sql (-1 / +2 lines)
Lines 18-22 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES Link Here
18
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
18
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
19
(18,'coursereserves','Course reserves',0),
19
(18,'coursereserves','Course reserves',0),
20
(19, 'plugins', 'Koha plugins', '0'),
20
(19, 'plugins', 'Koha plugins', '0'),
21
(20, 'lists', 'Lists', 0)
21
(20, 'lists', 'Lists', 0),
22
(21, 'clubs', 'Patron clubs', '0')
22
;
23
;
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (-1 / +4 lines)
Lines 73-77 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
73
   (19, 'tool', 'Use tool plugins'),
73
   (19, 'tool', 'Use tool plugins'),
74
   (19, 'report', 'Use report plugins'),
74
   (19, 'report', 'Use report plugins'),
75
   (19, 'configure', 'Configure plugins'),
75
   (19, 'configure', 'Configure plugins'),
76
   (20, 'delete_public_lists', 'Delete public lists')
76
   (20, 'delete_public_lists', 'Delete public lists'),
77
   (21, 'edit_templates', 'Create and update club templates'),
78
   (21, 'edit_clubs', 'Create and update clubs'),
79
   (21, 'enroll', 'Enroll patrons in clubs')
77
;
80
;
(-)a/installer/data/mysql/kohastructure.sql (+178 lines)
Lines 3519-3524 CREATE TABLE discharges ( Link Here
3519
  CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
3519
  CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
3520
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3520
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3521
3521
3522
--
3523
-- Table structure for table 'clubs'
3524
--
3525
3526
DROP TABLE IF EXISTS clubs;
3527
CREATE TABLE IF NOT EXISTS clubs (
3528
  id int(11) NOT NULL AUTO_INCREMENT,
3529
  club_template_id int(11) NOT NULL,
3530
  `name` tinytext NOT NULL,
3531
  description text,
3532
  date_start date DEFAULT NULL,
3533
  date_end date DEFAULT NULL,
3534
  branchcode varchar(11) DEFAULT NULL,
3535
  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3536
  date_updated timestamp NULL DEFAULT NULL,
3537
  PRIMARY KEY (id),
3538
  KEY club_template_id (club_template_id),
3539
  KEY branchcode (branchcode)
3540
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3541
3542
-- --------------------------------------------------------
3543
3544
--
3545
-- Table structure for table 'club_enrollments'
3546
--
3547
3548
DROP TABLE IF EXISTS club_enrollments;
3549
CREATE TABLE IF NOT EXISTS club_enrollments (
3550
  id int(11) NOT NULL AUTO_INCREMENT,
3551
  club_id int(11) NOT NULL,
3552
  borrowernumber int(11) NOT NULL,
3553
  date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3554
  date_canceled timestamp NULL DEFAULT NULL,
3555
  date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
3556
  date_updated timestamp NULL DEFAULT NULL,
3557
  branchcode varchar(11) DEFAULT NULL,
3558
  PRIMARY KEY (id),
3559
  KEY club_id (club_id),
3560
  KEY borrowernumber (borrowernumber),
3561
  KEY branchcode (branchcode)
3562
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3563
3564
-- --------------------------------------------------------
3565
3566
--
3567
-- Table structure for table 'club_enrollment_fields'
3568
--
3569
3570
DROP TABLE IF EXISTS club_enrollment_fields;
3571
CREATE TABLE IF NOT EXISTS club_enrollment_fields (
3572
  id int(11) NOT NULL AUTO_INCREMENT,
3573
  club_enrollment_id int(11) NOT NULL,
3574
  club_template_enrollment_field_id int(11) NOT NULL,
3575
  `value` text NOT NULL,
3576
  PRIMARY KEY (id),
3577
  KEY club_enrollment_id (club_enrollment_id),
3578
  KEY club_template_enrollment_field_id (club_template_enrollment_field_id)
3579
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3580
3581
-- --------------------------------------------------------
3582
3583
--
3584
-- Table structure for table 'club_fields'
3585
--
3586
3587
DROP TABLE IF EXISTS club_fields;
3588
CREATE TABLE IF NOT EXISTS club_fields (
3589
  id int(11) NOT NULL AUTO_INCREMENT,
3590
  club_template_field_id int(11) NOT NULL,
3591
  club_id int(11) NOT NULL,
3592
  `value` text,
3593
  PRIMARY KEY (id),
3594
  KEY club_template_field_id (club_template_field_id),
3595
  KEY club_id (club_id)
3596
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3597
3598
-- --------------------------------------------------------
3599
3600
--
3601
-- Table structure for table 'club_templates'
3602
--
3603
3604
DROP TABLE IF EXISTS club_templates;
3605
CREATE TABLE IF NOT EXISTS club_templates (
3606
  id int(11) NOT NULL AUTO_INCREMENT,
3607
  `name` tinytext NOT NULL,
3608
  description text,
3609
  is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
3610
  is_email_required tinyint(1) NOT NULL DEFAULT '0',
3611
  branchcode varchar(10) DEFAULT NULL,
3612
  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3613
  date_updated timestamp NULL DEFAULT NULL,
3614
  is_deletable tinyint(1) NOT NULL DEFAULT '1',
3615
  PRIMARY KEY (id),
3616
  KEY branchcode (branchcode)
3617
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3618
3619
-- --------------------------------------------------------
3620
3621
--
3622
-- Table structure for table 'club_template_enrollment_fields'
3623
--
3624
3625
DROP TABLE IF EXISTS club_template_enrollment_fields;
3626
CREATE TABLE IF NOT EXISTS club_template_enrollment_fields (
3627
  id int(11) NOT NULL AUTO_INCREMENT,
3628
  club_template_id int(11) NOT NULL,
3629
  `name` tinytext NOT NULL,
3630
  description text,
3631
  authorised_value_category varchar(16) DEFAULT NULL,
3632
  PRIMARY KEY (id),
3633
  KEY club_template_id (club_template_id)
3634
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3635
3636
-- --------------------------------------------------------
3637
3638
--
3639
-- Table structure for table 'club_template_fields'
3640
--
3641
3642
DROP TABLE IF EXISTS club_template_fields;
3643
CREATE TABLE IF NOT EXISTS club_template_fields (
3644
  id int(11) NOT NULL AUTO_INCREMENT,
3645
  club_template_id int(11) NOT NULL,
3646
  `name` tinytext NOT NULL,
3647
  description text,
3648
  authorised_value_category varchar(16) DEFAULT NULL,
3649
  PRIMARY KEY (id),
3650
  KEY club_template_id (club_template_id)
3651
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3652
3653
--
3654
-- Constraints for table `clubs`
3655
--
3656
ALTER TABLE `clubs`
3657
  ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
3658
  ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode);
3659
3660
--
3661
-- Constraints for table `club_enrollments`
3662
--
3663
ALTER TABLE `club_enrollments`
3664
  ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
3665
  ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3666
  ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3667
3668
--
3669
-- Constraints for table `club_enrollment_fields`
3670
--
3671
ALTER TABLE `club_enrollment_fields`
3672
  ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment_id) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
3673
  ADD CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field_id) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE;
3674
3675
--
3676
-- Constraints for table `club_fields`
3677
--
3678
ALTER TABLE `club_fields`
3679
  ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field_id) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
3680
  ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
3681
3682
--
3683
-- Constraints for table `club_templates`
3684
--
3685
ALTER TABLE `club_templates`
3686
  ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3687
3688
--
3689
-- Constraints for table `club_template_enrollment_fields`
3690
--
3691
ALTER TABLE `club_template_enrollment_fields`
3692
  ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3693
3694
--
3695
-- Constraints for table `club_template_fields`
3696
--
3697
ALTER TABLE `club_template_fields`
3698
  ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3699
3522
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3700
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3523
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3701
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3524
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3702
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+154 lines)
Lines 10399-10404 $DBversion = "3.19.00.039"; Link Here
10399
if ( CheckVersion($DBversion) ) {
10399
if ( CheckVersion($DBversion) ) {
10400
    print "Upgrade to $DBversion done (Koha 3.20 beta)\n";
10400
    print "Upgrade to $DBversion done (Koha 3.20 beta)\n";
10401
    SetVersion ($DBversion);
10401
    SetVersion ($DBversion);
10402
   SetVersion ($DBversion);
10403
}
10404
10405
$DBversion = "3.19.00.XXX";
10406
if ( CheckVersion($DBversion) ) {
10407
    $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('21', 'clubs', 'Patron clubs', '0')");
10408
10409
    $dbh->do("
10410
        INSERT INTO permissions (module_bit, code, description) VALUES
10411
        (21, 'edit_templates', 'Create and update club templates'),
10412
        (21, 'edit_clubs', 'Create and update clubs'),
10413
        (21, 'enroll', 'Enroll patrons in clubs')
10414
    ");
10415
10416
    $dbh->do("
10417
        CREATE TABLE clubs (
10418
            id int(11) NOT NULL AUTO_INCREMENT,
10419
            club_template_id int(11) NOT NULL,
10420
            `name` tinytext NOT NULL,
10421
            description text,
10422
            date_start date DEFAULT NULL,
10423
            date_end date DEFAULT NULL,
10424
            branchcode varchar(11) DEFAULT NULL,
10425
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
10426
            date_updated timestamp NULL DEFAULT NULL,
10427
            PRIMARY KEY (id),
10428
            KEY club_template_id (club_template_id),
10429
            KEY branchcode (branchcode)
10430
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10431
    ");
10432
10433
    $dbh->do("
10434
        CREATE TABLE club_enrollments (
10435
            id int(11) NOT NULL AUTO_INCREMENT,
10436
            club_id int(11) NOT NULL,
10437
            borrowernumber int(11) NOT NULL,
10438
            date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
10439
            date_canceled timestamp NULL DEFAULT NULL,
10440
            date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
10441
            date_updated timestamp NULL DEFAULT NULL,
10442
            branchcode varchar(11) DEFAULT NULL,
10443
            PRIMARY KEY (id),
10444
            KEY club_id (club_id),
10445
            KEY borrowernumber (borrowernumber),
10446
            KEY branchcode (branchcode)
10447
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10448
    ");
10449
10450
    $dbh->do("
10451
        CREATE TABLE club_enrollment_fields (
10452
            id int(11) NOT NULL AUTO_INCREMENT,
10453
            club_enrollment_id int(11) NOT NULL,
10454
            club_template_enrollment_field_id int(11) NOT NULL,
10455
            `value` text NOT NULL,
10456
            PRIMARY KEY (id),
10457
            KEY club_enrollment_id (club_enrollment_id),
10458
            KEY club_template_enrollment_field_id (club_template_enrollment_field_id)
10459
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10460
    ");
10461
10462
    $dbh->do("
10463
        CREATE TABLE club_fields (
10464
            id int(11) NOT NULL AUTO_INCREMENT,
10465
            club_template_field_id int(11) NOT NULL,
10466
            club_id int(11) NOT NULL,
10467
            `value` text,
10468
            PRIMARY KEY (id),
10469
            KEY club_template_field_id (club_template_field_id),
10470
            KEY club_id (club_id)
10471
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10472
    ");
10473
10474
    $dbh->do("
10475
        CREATE TABLE club_templates (
10476
            id int(11) NOT NULL AUTO_INCREMENT,
10477
            `name` tinytext NOT NULL,
10478
            description text,
10479
            is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
10480
            is_email_required tinyint(1) NOT NULL DEFAULT '0',
10481
            branchcode varchar(10) CHARACTER SET utf8 DEFAULT NULL,
10482
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
10483
            date_updated timestamp NULL DEFAULT NULL,
10484
            is_deletable tinyint(1) NOT NULL DEFAULT '1',
10485
            PRIMARY KEY (id),
10486
            KEY branchcode (branchcode)
10487
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10488
    ");
10489
10490
    $dbh->do("
10491
        CREATE TABLE club_template_enrollment_fields (
10492
            id int(11) NOT NULL AUTO_INCREMENT,
10493
            club_template_id int(11) NOT NULL,
10494
            `name` tinytext NOT NULL,
10495
            description text,
10496
            authorised_value_category varchar(16) DEFAULT NULL,
10497
            PRIMARY KEY (id),
10498
            KEY club_template_id (club_template_id)
10499
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10500
    ");
10501
10502
    $dbh->do("
10503
        CREATE TABLE club_template_fields (
10504
            id int(11) NOT NULL AUTO_INCREMENT,
10505
            club_template_id int(11) NOT NULL,
10506
            `name` tinytext NOT NULL,
10507
            description text,
10508
            authorised_value_category varchar(16) DEFAULT NULL,
10509
            PRIMARY KEY (id),
10510
            KEY club_template_id (club_template_id)
10511
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10512
    ");
10513
10514
    $dbh->do("
10515
        ALTER TABLE `clubs`
10516
            ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
10517
            ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode);
10518
    ");
10519
10520
    $dbh->do("
10521
        ALTER TABLE `club_enrollments`
10522
            ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
10523
            ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
10524
            ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
10525
    ");
10526
10527
    $dbh->do("
10528
        ALTER TABLE `club_enrollment_fields`
10529
            ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment_id) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
10530
            ADD CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field_id) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE;
10531
    ");
10532
10533
    $dbh->do("
10534
        ALTER TABLE `club_fields`
10535
            ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field_id) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
10536
            ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
10537
    ");
10538
10539
    $dbh->do("
10540
        ALTER TABLE `club_templates`
10541
            ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
10542
    ");
10543
10544
    $dbh->do("
10545
        ALTER TABLE `club_template_enrollment_fields`
10546
            ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
10547
    ");
10548
10549
    $dbh->do("
10550
        ALTER TABLE `club_template_fields`
10551
            ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
10552
    ");
10553
10554
   print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n";
10555
   SetVersion ($DBversion);
10402
}
10556
}
10403
10557
10404
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10558
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+23 lines)
Lines 77-82 $(document).ready(function() { Link Here
77
        }
77
        }
78
    });
78
    });
79
79
80
    if ( $('#clubs-tab').length ) {
81
        $('#clubs-tab-link').on('click', function() {
82
            $('#clubs-tab').text(_("Loading..."));
83
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
84
        });
85
    }
86
80
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
87
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
81
        // listen submit to trigger qslip on empty checkout
88
        // listen submit to trigger qslip on empty checkout
82
        $('#mainform').bind('submit',function() {
89
        $('#mainform').bind('submit',function() {
Lines 823-828 No patron matched <span class="ex">[% message %]</span> Link Here
823
        [% END %]
830
        [% END %]
824
    </li>
831
    </li>
825
832
833
    [% SET enrollments = borrower.GetClubEnrollmentsCount %]
834
    [% SET enrollable  = borrower.GetEnrollableClubsCount %]
835
    [% IF CAN_user_clubs && ( enrollable || enrollments ) %]
836
        <li>
837
            <a id="clubs-tab-link" href="#clubs-tab">
838
                Clubs ([% enrollments %]/[% enrollable %])
839
            </a>
840
        </li>
841
    [% END %]
842
826
    [% IF relatives_issues_count %]
843
    [% IF relatives_issues_count %]
827
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
844
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
828
    [% END %]
845
    [% END %]
Lines 862-867 No patron matched <span class="ex">[% message %]</span> Link Here
862
    </div>
879
    </div>
863
[% END %]
880
[% END %]
864
881
882
[% IF CAN_user_clubs %]
883
    <div id="clubs-tab">
884
        Loading...
885
    </div>
886
[% END %]
887
865
[% INCLUDE borrower_debarments.inc %]
888
[% INCLUDE borrower_debarments.inc %]
866
889
867
<div id="reserves">
890
<div id="reserves">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-2 / +2 lines)
Lines 67-73 Link Here
67
67
68
                            [% ELSIF error == "auto_too_soon" %]
68
                            [% ELSIF error == "auto_too_soon" %]
69
69
70
                                <p>[% item.biblio.title | $EncodeUTF8 %] [% item.biblioitem.subtitle | $EncodeUTF8 %] ( [% item.barcode %] ) has been scheduled for automatic renewal and cannot be renewed before [% soonestrenewdate | $KohaDates %]. </p>
70
                                <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal and cannot be renewed before [% soonestrenewdate | $KohaDates %]. </p>
71
71
72
                                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
72
                                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
73
                                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
73
                                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
Lines 79-85 Link Here
79
79
80
                            [% ELSIF error == "auto_renew" %]
80
                            [% ELSIF error == "auto_renew" %]
81
81
82
                                <p>[% item.biblio.title | $EncodeUTF8 %] [% item.biblioitem.subtitle | $EncodeUTF8 %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p>
82
                                <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p>
83
83
84
                                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
84
                                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
85
                                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
85
                                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt (+142 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Branches %]
3
[% USE AuthorisedValues %]
4
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'calendar.inc' %]
9
10
<script type="text/javascript">
11
//<![CDATA[
12
13
function CheckForm() {
14
  if ( !$("#club-name").val() ) {
15
    alert( _("Name is a required field!")  );
16
    return false;
17
  }
18
19
  return true;
20
}
21
22
//]]>
23
</script>
24
25
</head>
26
27
<body id="clubs_add_modify" class="clubs">
28
[% INCLUDE 'header.inc' %]
29
[% INCLUDE 'cat-search.inc' %]
30
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="clubs.pl">Patron clubs</a> &rsaquo; Add / modify club</div>
31
32
<div class="yui-t7">
33
    <div class="yui-main">
34
        [% IF stored %]
35
            <div class="alert">
36
                <p>Your club was [% IF stored == 'updated' %] updated [% ELSE %] saved [% END %]</p>
37
                <a href="clubs.pl">Return to patron clubs</a>
38
            </div>
39
        [% END %]
40
41
        <form method="post" onsubmit="return CheckForm()">
42
            <input type="hidden" name="id" value="[% club.id %]" />
43
            <input type="hidden" name="club_template_id" value="[% club_template.id %]" />
44
45
            <fieldset class="rows">
46
47
                <legend>
48
                    [% IF club %]
49
                        Modify club <i>[% club.name %]</i>
50
                    [% ELSE %]
51
                        Create a new <i>[% club_template.name %]</i> club
52
                    [% END %]
53
                </legend>
54
55
                <ol>
56
                    <li>
57
                        <label class="required" for="name">Name:</label>
58
                        <input id="club-name" name="name" type="text" value="[% club.name %]" />
59
                    </li>
60
61
                    <li>
62
                        <label for="description">Description:</label>
63
                        <input id="club-template-name" name="description" type="text" value="[% club.description %]" />
64
                    </li>
65
66
                    <li>
67
                        <label for="date_start">Start date:</label>
68
                        <input name="date_start" id="from" size="10" readonly="readonly" class="datepickerfrom" value="[% club.date_start | $KohaDates %]">
69
                    </li>
70
71
                    <li>
72
                        <label for="date_end">End date:</label>
73
                        <input name="date_end" id="to" size="10" readonly="readonly" class="datepickerto" value="[% club.date_end | $KohaDates %]" >
74
                    </li>
75
76
                    <li>
77
                        <label for="name">Branch:</label>
78
                        <select name="branchcode" id="club-template-branchcode">
79
                            <option value="">&nbsp</option>
80
                            [% FOREACH b IN Branches.GetBranches() %]
81
                                [% IF b.branchcode == club.branch.branchcode %]
82
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
83
                                [% ELSE %]
84
                                    <option value="[% b.branchcode %]">[% b.branchname %]</option>
85
                                [% END %]
86
                            [% END %]
87
                        </select>
88
                    </li>
89
90
                    [% IF club %]
91
                        [% FOREACH f IN club.club_fields %]
92
                            <li>
93
                                <input type="hidden" name="club_template_field_id" value="[% f.club_template_field.id %]" />
94
                                <input type="hidden" name="club_field_id" value="[% f.id %]" />
95
96
                                <label for="club_field">[% f.club_template_field.name %]</label>
97
                                [% IF f.club_template_field.authorised_value_category %]
98
                                    <select name="club_field">
99
                                        [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
100
                                            [% IF a.authorised_value == f.value %]
101
                                                <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
102
                                            [% ELSE %]
103
                                                <option value="[% a.authorised_value %]">[% a.lib %]</option>
104
                                            [% END %]
105
                                        [% END %]
106
                                    </select>
107
                                [% ELSE %]
108
                                    <input type="text" name="club_field" value="[% f.value %]" />
109
                                [% END %]
110
                            </li>
111
                        [% END %]
112
                    [% ELSE %]
113
                        [% FOREACH f IN club_template.club_template_fields %]
114
                            <li>
115
                                <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
116
117
                                <label for="club_field">[% f.name %]</label>
118
                                [% IF f.authorised_value_category %]
119
                                    <select name="club_field">
120
                                        [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
121
                                            <option value="[% a.authorised_value %]">[% a.lib %]</option>
122
                                        [% END %]
123
                                    </select>
124
                                [% ELSE %]
125
                                    <input type="text" name="club_field" />
126
                                [% END %]
127
                            </li>
128
                        [% END %]
129
                    [% END %]
130
131
                </ol>
132
133
            </fieldset>
134
135
            <input type="submit" class="btn" value="Save" />
136
137
            <a href="clubs.pl" class="cancel">Cancel</a>
138
        </form>
139
    </div>
140
</div>
141
142
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt (+206 lines)
Line 0 Link Here
1
[% USE Branches %]
2
[% USE Koha %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
7
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
[% INCLUDE 'datatables.inc' %]
9
10
<script type="text/javascript">
11
//<![CDATA[
12
    $(document).ready(function() {
13
        tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
14
            "aoColumnDefs": [
15
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
16
            ]
17
        } ));
18
19
        cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
20
            "aoColumnDefs": [
21
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
22
            ]
23
        } ));
24
    });
25
26
    function ConfirmDeleteTemplate( id, name, a ) {
27
        if ( confirm( _("Are you sure you want to delete the club template") + name + "?" ) ) {
28
            $.ajax({
29
                type: "POST",
30
                url: '/cgi-bin/koha/svc/club/template/delete',
31
                data: { id: id },
32
                success: function( data ) {
33
                    if ( data.success ) {
34
                        tTable.fnDeleteRow(a.closest("tr")[0]);
35
                    } else {
36
                        alert(_("Unable to delete template!"));
37
                    }
38
                },
39
                dataType: 'json'
40
            });
41
        }
42
    }
43
44
    function ConfirmDeleteClub( id, name, a ) {
45
        if ( confirm( _("Are you sure you want to delete the club ") + name + "?" ) ) {
46
            $.ajax({
47
                type: "POST",
48
                url: '/cgi-bin/koha/svc/club/delete',
49
                data: { id: id },
50
                success: function( data ) {
51
                    if ( data.success ) {
52
                        cTable.fnDeleteRow(a.closest("tr")[0]);
53
                    } else {
54
                        alert(_("Unable to delete club!"));
55
                    }
56
                },
57
                dataType: 'json'
58
            });
59
        }
60
    }
61
//]]>
62
</script>
63
64
</head>
65
66
<body id="clubs_clubs" class="clubs">
67
[% INCLUDE 'header.inc' %]
68
[% INCLUDE 'cat-search.inc' %]
69
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Patron clubs</div>
70
71
<div class="yui-t7">
72
    <div class="yui-main">
73
        <h1>Patron clubs</h1>
74
75
76
        <h3>Club templates</h3>
77
78
        [% IF CAN_user_clubs_edit_templates %]
79
            <div class="btn-group">
80
                <a class="btn btn-small" href="templates-add-modify.pl"><i class="icon-plus"></i> New club template</a>
81
            </div>
82
        [% END %]
83
84
        <table id="club-templates-table">
85
            <thead>
86
                <tr>
87
                    <th>Name</th>
88
                    <th>Description</th>
89
                    <th>Public enrollment</th>
90
                    <th>Email required</th>
91
                    <th>Branch</th>
92
                    <th>&nbsp;</th>
93
                    <th>&nbsp;</th>
94
                </tr>
95
            </thead>
96
97
            <tbody>
98
                [% FOREACH t IN club_templates %]
99
                    <tr>
100
                        <td>[% t.name %]</td>
101
                        <td>[% t.description %]</td>
102
                        <td>
103
                            [% IF t.is_enrollable_from_opac %]
104
                                Yes
105
                            [% ELSE %]
106
                                No
107
                            [% END %]
108
                        </td>
109
                        <td>
110
                            [% IF t.is_email_required %]
111
                                Yes
112
                            [% ELSE %]
113
                                No
114
                            [% END %]
115
                        </td>
116
                        <td>[% Branches.GetName( t.branchcode ) %]</td>
117
                        <td>
118
                            [% IF CAN_user_clubs_edit_templates %]
119
                                <a class="btn btn-mini" href="templates-add-modify.pl?id=[% t.id %]">
120
                                    <i class="icon-edit"></i> Edit
121
                                </a>
122
                            [% END %]
123
                        </td>
124
                        <td>
125
                            [% IF CAN_user_clubs_edit_templates %]
126
                                <a class="btn btn-mini" href="#" onclick='ConfirmDeleteTemplate([% t.id %], "[% t.name | html %]", $(this) ); return false;'>
127
                                    <i class="icon-trash"></i> Delete
128
                                </a>
129
                            [% END %]
130
                        </td>
131
                    </tr>
132
                [% END %]
133
            </tbody>
134
        </table>
135
136
        <h3>Clubs</h3>
137
138
        [% IF CAN_user_clubs_edit_clubs %]
139
            <div class="btn-group">
140
                <div class="btn-group">
141
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-plus"></i> New club <span class="caret"></span></button>
142
                    <ul class="dropdown-menu">
143
                        [% FOREACH t IN club_templates %]
144
                            <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id %]">[% t.name %]</a></li>
145
                        [% END %]
146
                    </ul>
147
                </div>
148
            </div>
149
        [% END %]
150
151
        <table id="clubs-table">
152
            <thead>
153
                <tr>
154
                    <th>Name</th>
155
                    <th>Template</th>
156
                    <th>Description</th>
157
                    <th>Public enrollment</th>
158
                    <th>Email required</th>
159
                    <th>Branch</th>
160
                    <th>&nbsp;</th>
161
                    <th>&nbsp;</th>
162
                </tr>
163
            </thead>
164
165
            <tbody>
166
                [% FOREACH c IN clubs %]
167
                    <tr>
168
                        <td>[% c.name %]</td>
169
                        <td>[% c.club_template.name %]</td>
170
                        <td>[% c.description %]</td>
171
                        <td>
172
                            [% IF c.club_template.is_enrollable_from_opac %]
173
                                Yes
174
                            [% ELSE %]
175
                                No
176
                            [% END %]
177
                        </td>
178
                        <td>
179
                            [% IF c.club_template.is_email_required %]
180
                                Yes
181
                            [% ELSE %]
182
                                No
183
                            [% END %]
184
                        </td>
185
                        <td>[% Branches.GetName( c.branchcode ) %]</td>
186
                        <td>
187
                            [% IF CAN_user_clubs_edit_clubs %]
188
                                <a class="btn btn-mini" href="clubs-add-modify.pl?id=[% c.id %]">
189
                                    <i class="icon-edit"></i> Edit
190
                                </a>
191
                            [% END %]
192
                        </td>
193
                        <td>
194
                            [% IF CAN_user_clubs_edit_clubs %]
195
                                <a class="btn btn-mini" href="#" onclick='ConfirmDeleteClub([% c.id %], "[% c.name | html %]", $(this) ); return false;'>
196
                                    <i class="icon-trash"></i> Delete
197
                                </a>
198
                            [% END %]
199
                        </td>
200
                    </tr>
201
                [% END %]
202
            </tbody>
203
        </table>
204
    </div>
205
</div>
206
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt (+102 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% IF enrollments %]
4
    <table>
5
        <thead>
6
            <tr>
7
                <th colspan="4">
8
                    Clubs currently enrolled in
9
                </th>
10
            </tr>
11
            <tr>
12
                <th>Name</th>
13
                <th>Description</th>
14
                <th>Date enrolled</th>
15
                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
16
            </tr>
17
        </thead>
18
19
        <tbody>
20
            [% FOREACH e IN enrollments %]
21
                <tr>
22
                    <td>[% e.club.name %]</td>
23
                    <td>[% e.club.description %]</td>
24
                    <td>[% e.date_enrolled | $KohaDates %]</td>
25
                    [% IF CAN_user_clubs_enroll %]
26
                        <td>
27
                            <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )">
28
                                <i class="icon-remove"></i> Cancel
29
                            </a>
30
                        </td>
31
                    [% END %]
32
                </tr>
33
            [% END %]
34
        </tbody>
35
    </table>
36
[% END %]
37
38
[% IF clubs %]
39
    <table>
40
        <thead>
41
            <tr>
42
                <th colspan="3">
43
                    Clubs not enrolled in
44
                </th>
45
            </tr>
46
            <tr>
47
                <th>Name</th>
48
                <th>Description</th>
49
                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
50
            </tr>
51
        </thead>
52
53
        <tbody>
54
            [% FOREACH c IN clubs %]
55
                <tr>
56
                    <td>[% c.name %]</td>
57
                    <td>[% c.description %]</td>
58
                    [% IF CAN_user_clubs_enroll %]
59
                        <td>
60
                            <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])">
61
                                <i class="icon-plus"></i> Enroll
62
                            </a>
63
                        </td>
64
                    [% END %]
65
                </tr>
66
            [% END %]
67
        </tbody>
68
    </table>
69
[% END %]
70
71
[% IF CAN_user_clubs_enroll %]
72
<script type="text/javascript">
73
function loadEnrollmentForm( id ) {
74
    $("body").css("cursor", "progress");
75
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber %]&id=' + id, function() {
76
        $("body").css("cursor", "default");
77
    });
78
79
    return false;
80
}
81
82
function cancelEnrollment( id ) {
83
    $("body").css("cursor", "progress");
84
    $.ajax({
85
        type: "POST",
86
        url: '/cgi-bin/koha/svc/club/cancel_enrollment',
87
        data: { id: id },
88
        success: function( data ) {
89
            if ( data.success ) {
90
                $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]', function() {
91
                    $("body").css("cursor", "default");
92
                });
93
            } else {
94
                alert(_("Unable to cancel enrollment!"));
95
            }
96
        },
97
        dataType: 'json'
98
    });
99
    return false;
100
}
101
</script>
102
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt (+66 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
3
4
<h3>
5
    Enroll in <i>[% club.name %]</i>
6
</h3>
7
8
<div class="container">
9
    <form id="patron-enrollment-form">
10
        <input type="hidden" name="id" value="[% club.id %]" />
11
        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
12
        <fieldset class="rows">
13
            <ol>
14
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
15
                    <li>
16
                        <label>[% f.name %]</label>
17
                        [% IF f.authorised_value_category %]
18
                            <select name="[% f.id %]">
19
                                [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
20
                                    <option value="[% a.authorised_value %]">[% a.lib %]</option>
21
                                [% END %]
22
                            </select>
23
                        [% ELSE %]
24
                            <input type="text" name="[% f.id %]" />
25
                        [% END %]
26
                        <span class="hint">[% f.description %]</span>
27
                    </li>
28
                [% END %]
29
30
                <li>
31
                    <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a>
32
                    <a href="#" onclick="showClubs(); return false;">Cancel</a>
33
                </li>
34
            </ol>
35
        </fieldset>
36
    </form>
37
</div>
38
39
<script type="text/javascript">
40
function addEnrollment() {
41
    $("body").css("cursor", "progress");
42
    $.ajax({
43
        type: "POST",
44
        url: '/cgi-bin/koha/svc/club/enroll',
45
        data: $( "#patron-enrollment-form" ).serialize(),
46
        success: function( data ) {
47
            if ( data.success ) {
48
                $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
49
                    $("body").css("cursor", "default");
50
                });
51
            } else {
52
                alert(_("Unable to create enrollment!"));
53
            }
54
        },
55
        dataType: 'json'
56
    });
57
    return false;
58
}
59
60
function showClubs() {
61
    $("body").css("cursor", "progress");
62
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
63
        $("body").css("cursor", "default");
64
    });
65
}
66
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt (+257 lines)
Line 0 Link Here
1
[% USE Branches %]
2
[% USE AuthorisedValues %]
3
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club template</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
8
<script type="text/javascript">
9
//<![CDATA[
10
11
function CheckForm() {
12
  if ( !$("#club-template-name").val() ) {
13
    alert( _("Name is a required field!")  );
14
    return false;
15
  }
16
17
  return true;
18
}
19
20
//]]>
21
</script>
22
23
</head>
24
25
<body id="clubs_templates_add_modify" class="clubs">
26
[% INCLUDE 'header.inc' %]
27
[% INCLUDE 'cat-search.inc' %]
28
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="clubs.pl">Patron clubs</a> &rsaquo; Add / modify club template</div>
29
30
<div class="yui-t7">
31
    <div class="yui-main">
32
        [% IF stored %]
33
            <div class="alert">
34
                <p>Your club template was [% IF stored == 'updated' %] updated [% ELSE %] saved [% END %]</p>
35
                <a href="clubs.pl">Return to patron clubs</a>
36
            </div>
37
        [% END %]
38
39
        <form method="post" onsubmit="return CheckForm()">
40
            <input type="hidden" name="id" value="[% club_template.id %]" />
41
42
            <fieldset class="rows">
43
44
                <legend>
45
                    [% IF club_template %]
46
                        Modify club template <i>[% club_template.name %]</i>
47
                    [% ELSE %]
48
                        Create a new club template
49
                    [% END %]
50
                </legend>
51
52
                <ol>
53
                    <li>
54
                        <label class="required" for="name">Name:</label>
55
                        <input id="club-template-name" name="name" type="text" value="[% club_template.name %]" />
56
                    </li>
57
58
                    <li>
59
                        <label for="description">Description:</label>
60
                        <input id="club-template-description" name="description" type="text" value="[% club_template.description %]" />
61
                    </li>
62
63
                    <li>
64
                        <label for="name">Allow public enrollment:</label>
65
                        [% IF club_template.is_enrollable_from_opac %]
66
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" checked="checked" />
67
                        [% ELSE %]
68
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" />
69
                        [% END %]
70
                        <span class="hint">If a template allows public enrollment, patrons can enroll in a club based on this template from the public catalog.</span>
71
                    </li>
72
73
                    <li>
74
                        <label for="name">Require valid email address:</label>
75
                        [% IF club_template.is_email_required %]
76
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" checked="checked" />
77
                        [% ELSE %]
78
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" />
79
                        [% END %]
80
                        <span class="hint">If set, a club based on this template can only be enrolled in by patrons with a valid email address.</span>
81
                    </li>
82
83
                    <li>
84
                        <label for="name">Branch:</label>
85
                        <select name="branchcode" id="club-template-branchcode">
86
                            <option value="">&nbsp</option>
87
                            [% FOREACH b IN Branches.GetBranches() %]
88
                                [% IF b.branchcode == club_template.branchcode %]
89
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
90
                                [% ELSE %]
91
                                    <option value="[% b.branchcode %]">[% b.branchname %]</option>
92
                                [% END %]
93
                            [% END %]
94
                        </select>
95
                        <span class="hint">If set, only librarians logged in with this branch will be able to modify this club template.</span>
96
                    </li>
97
98
                </ol>
99
100
                <h2>Club fields:</h2>
101
                <span class="hint">These fields will be used in the creation of clubs based on this template</span>
102
                <span id="club-template-fields">
103
                    [% FOREACH f IN club_template.club_template_fields %]
104
                        <ul>
105
                            <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
106
                            <li>
107
                                <label for="field-name-[% f.id %]">Name:</label>
108
                                <input name="club_template_field_name" id="field-name-[% f.id %]" value="[% f.name %]" />
109
                            </li>
110
111
                            <li>
112
                                <label for="field-description-[% f.id %]">Description:</label>
113
                                <input name="club_template_field_description" id="field-description-[% f.id %]" value="[% f.description %]" />
114
                            </li>
115
116
                            <li>
117
                                <label for="field-description-[% f.id %]">Authorised value category:</label>
118
                                <select name="club_template_field_authorised_value_category" id="field-authorised-value-category-[% f.id %]">
119
                                    <option value="">&nbsp;</option>
120
                                    [% FOREACH c IN AuthorisedValuesCategories %]
121
                                        [% IF f.authorised_value_category == c %]
122
                                            <option selected="selected" value="[% c %]">[% c %]</option>
123
                                        [% ELSE %]
124
                                            <option value="[% c %]">[% c %]</option>
125
                                        [% END %]
126
                                    [% END %]
127
                                </select>
128
                            </li>
129
130
                            <li>
131
                                <label for="field-delete-[% f.id %]">Delete field:</label>
132
                                <input type="checkbox" name="club_template_field_delete" id="field-delete-[% f.id %]" value="[% f.id %]" />
133
                            </li>
134
135
                            <hr/>
136
                        </ul>
137
                    [% END %]
138
                </span>
139
                <a href="#" class="btn" onclick="$('#new-field-template').clone().attr('id','').show().appendTo('#club-template-fields'); return false;">
140
                    Add new field
141
                </a>
142
143
                <h2>Enrollment fields:</h2>
144
                <span class="hint">These fields will be used when enrolling a patron in a club based on this template</span>
145
                <span id="club-template-enrollment-fields">
146
                    [% FOREACH f IN club_template.club_template_enrollment_fields %]
147
                        <ul>
148
                            <input type="hidden" name="club_template_enrollment_field_id" value="[% f.id %]" />
149
                            <li>
150
                                <label for="enrollment-field-name-[% f.id %]">Name:</label>
151
                                <input name="club_template_enrollment_field_name" id="enrollment-field-name-[% f.id %]" value="[% f.name %]" />
152
                            </li>
153
154
                            <li>
155
                                <label for="enrollment-field-description-[% f.id %]">Description:</label>
156
                                <input name="club_template_enrollment_field_description" id="enrollment-field-description-[% f.id %]" value="[% f.description %]" />
157
                            </li>
158
159
                            <li>
160
                                <label for="enrollment-field-description-[% f.id %]">Authorised value category:</label>
161
                                <select name="club_template_enrollment_field_authorised_value_category" id="enrollment-field-authorised-value-category-[% f.id %]">
162
                                    <option value="">&nbsp;</option>
163
                                    [% FOREACH c IN AuthorisedValuesCategories %]
164
                                        [% IF f.authorised_value_category == c %]
165
                                            <option selected="selected" value="[% c %]">[% c %]</option>
166
                                        [% ELSE %]
167
                                            <option value="[% c %]">[% c %]</option>
168
                                        [% END %]
169
                                    [% END %]
170
                                </select>
171
                            </li>
172
173
                            <li>
174
                                <label for="enrollment-field-delete-[% f.id %]">Delete field:</label>
175
                                <input type="checkbox" name="club_template_enrollment_field_delete" id="enrollment-field-delete-[% f.id %]" value="[% f.id %]" />
176
                            </li>
177
178
                            <hr/>
179
                        </ul>
180
                    [% END %]
181
                </span>
182
                <a href="#" class="btn" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;">
183
                    Add new field
184
                </a>
185
186
            </fieldset>
187
188
            <input type="hidden" name="id" value="[% club_template.id %]" />
189
190
            <input type="submit" class="btn" value="Save" />
191
192
            <a href="clubs.pl" class="cancel">Cancel</a>
193
        </form>
194
    </div>
195
</div>
196
197
<span id="new-field-template" style="display:none">
198
    <ul>
199
        <input type="hidden" name="club_template_field_id" value="" />
200
201
        <li>
202
            <label for="club_template_field_name">Name:</label>
203
            <input name="club_template_field_name" />
204
        </li>
205
206
        <li>
207
            <label for="club_template_field_description">Description:</label>
208
            <input name="club_template_field_description" />
209
        </li>
210
211
        <li>
212
            <label for="club_template_field_authorised_value_category">Authorised value category:</label>
213
            <select name="club_template_field_authorised_value_category">
214
                <option value="">&nbsp;</option>
215
                [% FOREACH c IN AuthorisedValuesCategories %]
216
                    <option value="[% c %]">[% c %]</option>
217
                [% END %]
218
            </select>
219
        </li>
220
221
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
222
223
        <hr/>
224
    </ul>
225
</span>
226
227
<span id="new-enrollment-field-template" style="display:none">
228
    <ul>
229
        <input type="hidden" name="club_template_enrollment_field_id" value="" />
230
231
        <li>
232
            <label for="club_template_enrollment_field_name">Name:</label>
233
            <input name="club_template_enrollment_field_name" />
234
        </li>
235
236
        <li>
237
            <label for="club_template_enrollment_field_description">Description:</label>
238
            <input name="club_template_enrollment_field_description" />
239
        </li>
240
241
        <li>
242
            <label for="club_template_enrollment_field_authorised_value_category">Authorised value category:</label>
243
            <select name="club_template_enrollment_field_authorised_value_category">
244
                <option value="">&nbsp;</option>
245
                [% FOREACH c IN AuthorisedValuesCategories %]
246
                    <option value="[% c %]">[% c %]</option>
247
                [% END %]
248
            </select>
249
        </li>
250
251
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
252
253
        <hr/>
254
    </ul>
255
</span>
256
257
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+22 lines)
Lines 46-51 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); Link Here
46
columns_settings = [% ColumnsSettings.GetColumns( 'member', 'moremember', 'issues-table', 'json' ) %]
46
columns_settings = [% ColumnsSettings.GetColumns( 'member', 'moremember', 'issues-table', 'json' ) %]
47
47
48
$(document).ready(function() {
48
$(document).ready(function() {
49
    if ( $('#clubs-tab').length ) {
50
        $('#clubs-tab-link').on('click', function() {
51
            $('#clubs-tab').text(_("Loading..."));
52
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
53
        });
54
    }
55
49
    $('#finesholdsissues').tabs({
56
    $('#finesholdsissues').tabs({
50
        // Correct table sizing for tables hidden in tabs
57
        // Correct table sizing for tables hidden in tabs
51
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
58
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 435-440 function validate1(date) { Link Here
435
            [% END %]
442
            [% END %]
436
        </li>
443
        </li>
437
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
444
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
445
        [% SET enrollments = borrower.GetClubEnrollmentsCount %]
446
        [% SET enrollable  = borrower.GetEnrollableClubsCount %]
447
        [% IF CAN_user_clubs && ( enrollments || enrollable ) %]
448
            <li>
449
                <a id="clubs-tab-link" href="#clubs-tab">
450
                    Clubs ([% enrollments %]/[% enrollable %])
451
                </a>
452
            </li>
453
        [% END %]
438
    </ul>
454
    </ul>
439
455
440
[% INCLUDE "checkouts-table.inc" %]
456
[% INCLUDE "checkouts-table.inc" %]
Lines 467-472 function validate1(date) { Link Here
467
    [% END %]
483
    [% END %]
468
</div>
484
</div>
469
485
486
[% IF CAN_user_clubs && ( enrollments || enrollable ) %]
487
    <div id="clubs-tab">
488
        Loading...
489
    </div>
490
[% END %]
491
470
[% INCLUDE borrower_debarments.inc %]
492
[% INCLUDE borrower_debarments.inc %]
471
493
472
<div id="reserves">
494
<div id="reserves">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 20-25 Link Here
20
    <dd>Manage lists of patrons.</dd>
20
    <dd>Manage lists of patrons.</dd>
21
    [% END %]
21
    [% END %]
22
22
23
    [% IF (CAN_user_clubs) %]
24
    <dt><a href="/cgi-bin/koha/clubs/clubs.pl">Patron clubs</a>
25
    <dd>Manage patron clubs..</dd>
26
    [% END %]
27
23
[% IF ( CAN_user_tools_moderate_comments ) %]
28
[% IF ( CAN_user_tools_moderate_comments ) %]
24
    <dt><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a> [% IF ( pendingcomments ) %]<span class="holdcount"><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">[% pendingcomments %]</a></span>[% END %]</dt>
29
    <dt><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a> [% IF ( pendingcomments ) %]<span class="holdcount"><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">[% pendingcomments %]</a></span>[% END %]</dt>
25
	<dd>Moderate patron comments. </dd>
30
	<dd>Moderate patron comments. </dd>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt (+102 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% IF enrollments %]
4
    <table id="clubs-table-enrolled" class="table table-bordered table-striped">
5
        <thead>
6
            <tr>
7
                <th colspan="4">
8
                    Clubs you are currently enrolled in
9
                </th>
10
            </tr>
11
            <tr>
12
                <th>Name</th>
13
                <th>Description</th>
14
                <th>Date enrolled</th>
15
                <th>&nbsp;</th>
16
            </tr>
17
        </thead>
18
19
        <tbody>
20
            [% FOREACH e IN enrollments %]
21
                <tr>
22
                    <td>[% e.club.name %]</td>
23
                    <td>[% e.club.description %]</td>
24
                    <td>[% e.date_enrolled | $KohaDates %]</td>
25
                    [% IF e.club.club_template.is_enrollable_from_opac %]
26
                        <td>
27
                            <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )">
28
                                <i class="icon-remove"></i> Cancel
29
                            </a>
30
                        </td>
31
                    [% END %]
32
                </tr>
33
            [% END %]
34
        </tbody>
35
    </table>
36
[% END %]
37
38
[% IF clubs %]
39
    <table id="clubs-table-unenrolled" class="table table-bordered table-striped">
40
        <thead>
41
            <tr>
42
                <th colspan="3">
43
                    Clubs you can enroll in
44
                </th>
45
            </tr>
46
            <tr>
47
                <th>Name</th>
48
                <th>Description</th>
49
                <th>&nbsp;</th>
50
            </tr>
51
        </thead>
52
53
        <tbody>
54
            [% FOREACH c IN clubs %]
55
                <tr>
56
                    <td>[% c.name %]</td>
57
                    <td>[% c.description %]</td>
58
                    <td>
59
                        [% IF borrower.FirstValidEmailAddress %]
60
                            <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])">
61
                                <i class="icon-plus"></i> Enroll
62
                            </a>
63
                        [% ELSE %]
64
                            <span class="hint">You must have an email address to enroll</span>
65
                        [% END %]
66
                    </td>
67
                </tr>
68
            [% END %]
69
        </tbody>
70
    </table>
71
[% END %]
72
73
<script type="text/javascript">
74
function loadEnrollmentForm( id ) {
75
    $("body").css("cursor", "progress");
76
    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/enroll.pl?borrowernumber=[% borrower.borrowernumber %]&id=' + id, function() {
77
        $("body").css("cursor", "default");
78
    });
79
80
    return false;
81
}
82
83
function cancelEnrollment( id ) {
84
    $("body").css("cursor", "progress");
85
    $.ajax({
86
        type: "POST",
87
        url: '/cgi-bin/koha/svc/club/cancel_enrollment',
88
        data: { id: id },
89
        success: function( data ) {
90
            if ( data.success ) {
91
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrower.borrowernumber %]', function() {
92
                    $("body").css("cursor", "default");
93
                });
94
            } else {
95
                alert(_("Unable to cancel enrollment!"));
96
            }
97
        },
98
        dataType: 'json'
99
    });
100
    return false;
101
}
102
</script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt (+66 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
3
4
<h3>
5
    Enroll in <i>[% club.name %]</i>
6
</h3>
7
8
<div class="container">
9
    <form id="patron-enrollment-form">
10
        <input type="hidden" name="id" value="[% club.id %]" />
11
        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
12
        <fieldset class="rows">
13
            <ol>
14
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
15
                    <li>
16
                        <label>[% f.name %]</label>
17
                        [% IF f.authorised_value_category %]
18
                            <select name="[% f.id %]">
19
                                [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
20
                                    <option value="[% a.authorised_value %]">[% a.lib %]</option>
21
                                [% END %]
22
                            </select>
23
                        [% ELSE %]
24
                            <input type="text" name="[% f.id %]" />
25
                        [% END %]
26
                        <span class="hint">[% f.description %]</span>
27
                    </li>
28
                [% END %]
29
30
                <li>
31
                    <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a>
32
                    <a href="#" onclick="showClubs(); return false;">Cancel</a>
33
                </li>
34
            </ol>
35
        </fieldset>
36
    </form>
37
</div>
38
39
<script type="text/javascript">
40
function addEnrollment() {
41
    $("body").css("cursor", "progress");
42
    $.ajax({
43
        type: "POST",
44
        url: '/cgi-bin/koha/svc/club/enroll',
45
        data: $( "#patron-enrollment-form" ).serialize(),
46
        success: function( data ) {
47
            if ( data.success ) {
48
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
49
                    $("body").css("cursor", "default");
50
                });
51
            } else {
52
                alert(_("Unable to create enrollment!"));
53
            }
54
        },
55
        dataType: 'json'
56
    });
57
    return false;
58
}
59
60
function showClubs() {
61
    $("body").css("cursor", "progress");
62
    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
63
        $("body").css("cursor", "default");
64
    });
65
}
66
</script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+21 lines)
Lines 111-116 Link Here
111
                                [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
111
                                [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
112
                            [% END %]
112
                            [% END %]
113
                            [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %]
113
                            [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %]
114
                            [% IF borrower.GetClubEnrollmentsCount || borrower.GetEnrollableClubsCount(1) %]
115
                                <li>
116
                                    <a id="opac-user-clubs-tab-link" href="#opac-user-clubs">
117
                                        Clubs ([% borrower.GetClubEnrollmentsCount %]/[% borrower.GetEnrollableClubsCount(1) %])
118
                                    </a>
119
                                </li>
120
                            [% END %]
121
114
                            [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %]
122
                            [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %]
115
                        </ul>
123
                        </ul>
116
124
Lines 280-285 Link Here
280
                            [% END # IF issues_count %]
288
                            [% END # IF issues_count %]
281
                        </div> <!-- / .opac-user-checkouts -->
289
                        </div> <!-- / .opac-user-checkouts -->
282
290
291
                        [% IF borrower.GetClubEnrollmentsCount || borrower.GetEnrollableClubsCount(1) %]
292
                            <div id="opac-user-clubs">
293
                                Loading...
294
                            </div>
295
                        [% END %]
296
283
                        [% IF ( OPACFinesTab ) %]
297
                        [% IF ( OPACFinesTab ) %]
284
                            <!-- FINES BOX -->
298
                            <!-- FINES BOX -->
285
                            [% IF ( BORROWER_INF.amountoverfive ) %]
299
                            [% IF ( BORROWER_INF.amountoverfive ) %]
Lines 733-738 Link Here
733
            [% END %]
747
            [% END %]
734
748
735
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
749
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
750
751
            if ( $('#opac-user-clubs').length ) {
752
                $('#opac-user-clubs-tab-link').on('click', function() {
753
                    $('#opac-user-clubs').text(_("Loading..."));
754
                    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]');
755
                });
756
            }
736
        });
757
        });
737
        //]]>
758
        //]]>
738
    </script>
759
    </script>
(-)a/members/moremember.pl (+2 lines)
Lines 62-67 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
62
use DateTime;
62
use DateTime;
63
use Koha::DateUtils;
63
use Koha::DateUtils;
64
use Koha::Database;
64
use Koha::Database;
65
use Koha::Borrowers;
65
66
66
use vars qw($debug);
67
use vars qw($debug);
67
68
Lines 363-368 $template->param( Link Here
363
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
364
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
364
    relatives_issues_count => $relatives_issues_count,
365
    relatives_issues_count => $relatives_issues_count,
365
    relatives_borrowernumbers => \@relatives,
366
    relatives_borrowernumbers => \@relatives,
367
    borrower => Koha::Borrowers->find( $borrowernumber ),
366
);
368
);
367
369
368
output_html_with_http_headers $input, $cookie, $template->output;
370
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/opac/clubs/clubs-tab.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Borrowers;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/clubs-tab.tt",
33
        query           => $cgi,
34
        type            => "opac",
35
        authnotrequired => 0,
36
    }
37
);
38
39
my $borrowernumber = $cgi->param('borrowernumber');
40
41
my $borrower = Koha::Borrowers->find($borrowernumber);
42
43
my @enrollments = $borrower->GetClubEnrollments();
44
my @clubs = $borrower->GetEnrollableClubs( my $opac = 1 );
45
46
$template->param(
47
    enrollments => \@enrollments,
48
    clubs       => \@clubs,
49
    borrower    => $borrower,
50
);
51
52
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/opac/clubs/enroll.pl (+49 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Clubs;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/enroll.tt",
33
        query           => $cgi,
34
        type            => "opac",
35
        authnotrequired => 0,
36
    }
37
);
38
39
my $id             = $cgi->param('id');
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $club = Koha::Clubs->find($id);
43
44
$template->param(
45
    club           => $club,
46
    borrowernumber => $borrowernumber,
47
);
48
49
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/opac/opac-user.pl (-3 / +2 lines)
Lines 36-41 use C4::Letters; Link Here
36
use C4::Branch; # GetBranches
36
use C4::Branch; # GetBranches
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Borrower::Debarments qw(IsDebarred);
38
use Koha::Borrower::Debarments qw(IsDebarred);
39
use Koha::Borrowers;
39
40
40
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
41
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
41
42
Lines 389-400 $template->param( Link Here
389
    patronupdate => $patronupdate,
390
    patronupdate => $patronupdate,
390
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
391
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
391
    userview => 1,
392
    userview => 1,
392
);
393
394
$template->param(
395
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
393
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
396
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
394
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
397
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
395
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
396
    borrower => Koha::Borrowers->find($borrowernumber),
398
);
397
);
399
398
400
output_html_with_http_headers $query, $cookie, $template->output;
399
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/svc/club/cancel_enrollment (+47 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Club::Enrollments;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID') );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $borrowernumber = C4::Context->userenv->{'number'};
38
39
my $id = $cgi->param('id');
40
41
my $enrollment = Koha::Club::Enrollments->find($id);
42
$enrollment->cancel();
43
44
binmode STDOUT, ':encoding(UTF-8)';
45
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
46
47
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/opac/svc/club/enroll (+77 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Club::Enrollment::Field;
28
use Koha::Club::Enrollment;
29
use Koha::Clubs;
30
31
my $cgi = new CGI;
32
33
my ( $auth_status, $sessionID ) =
34
  check_cookie_auth( $cgi->cookie('CGISESSID') );
35
if ( $auth_status ne "ok" ) {
36
    exit 0;
37
}
38
39
my $borrowernumber = C4::Context->userenv->{'number'};
40
41
my $id = $cgi->param('id');
42
43
my $enrollment;
44
if ( $borrowernumber && $id ) {
45
    my $club = Koha::Clubs->find($id);
46
47
    if ( $club->club_template()->is_enrollable_from_opac() ) {
48
        $enrollment = Koha::Club::Enrollment->new()->set(
49
            {
50
                club_id        => $club->id(),
51
                borrowernumber => $borrowernumber,
52
                date_enrolled  => \'NOW()',
53
                date_created   => \'NOW()',
54
                branchcode     => C4::Context->userenv
55
                ? C4::Context->userenv->{'branch'}
56
                : undef,
57
            }
58
        )->store();
59
60
        my @enrollment_fields = $club->club_template()->club_template_enrollment_fields();
61
62
        foreach my $e (@enrollment_fields) {
63
            Koha::Club::Enrollment::Field->new()->set(
64
                {
65
                    club_enrollment_id                => $enrollment->id(),
66
                    club_template_enrollment_field_id => $e->id(),
67
                    value                             => $cgi->param( $e->id() ),
68
                }
69
            )->store();
70
        }
71
    }
72
}
73
74
binmode STDOUT, ':encoding(UTF-8)';
75
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
76
77
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/cancel_enrollment (+46 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
28
use Koha::Club::Enrollments;
29
30
my $cgi = new CGI;
31
32
my ( $auth_status, $sessionID ) =
33
  check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } );
34
if ( $auth_status ne "ok" ) {
35
    exit 0;
36
}
37
38
my $id = $cgi->param('id');
39
40
my $enrollment = Koha::Club::Enrollments->find($id);
41
$enrollment->cancel() if $enrollment;
42
43
binmode STDOUT, ':encoding(UTF-8)';
44
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
45
46
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/delete (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Clubs;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'edit_clubs' } );
32
if ( $auth_status ne "ok" ) {
33
    exit 0;
34
}
35
36
my $success = 0;
37
38
my $id = $cgi->param('id');
39
40
my $club = Koha::Clubs->find($id);
41
if ($club) {
42
    $success = $club->delete();
43
}
44
45
binmode STDOUT, ':encoding(UTF-8)';
46
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
47
48
print to_json( { success => $success ? 1 : 0 } );
(-)a/svc/club/enroll (+74 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Club::Enrollment::Fields;
28
use Koha::Club::Enrollments;
29
use Koha::Clubs;
30
31
my $cgi = new CGI;
32
33
my ( $auth_status, $sessionID ) =
34
  check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } );
35
if ( $auth_status ne "ok" ) {
36
    exit 0;
37
}
38
39
my $id             = $cgi->param('id');
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $club = Koha::Clubs->find($id);
43
44
my $enrollment;
45
if ($club) {
46
    $enrollment = Koha::Club::Enrollment->new(
47
        {
48
            club_id        => $club->id(),
49
            borrowernumber => $borrowernumber,
50
            date_enrolled  => \'NOW()',
51
            date_created   => \'NOW()',
52
            branchcode     => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
53
        }
54
    )->store();
55
56
    if ($enrollment) {
57
        my @enrollment_fields = $club->club_template()->club_template_enrollment_fields();
58
59
        foreach my $e (@enrollment_fields) {
60
            my $club_enrollment_field = Koha::Club::Enrollment::Field->new(
61
                {
62
                    club_enrollment_id                => $enrollment->id(),
63
                    club_template_enrollment_field_id => $e->id(),
64
                    value                             => $cgi->param( $e->id() ),
65
                }
66
            )->store();
67
        }
68
    }
69
}
70
71
binmode STDOUT, ':encoding(UTF-8)';
72
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
73
74
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/template/delete (-1 / +49 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
28
use Koha::Club::Templates;
29
30
my $cgi = new CGI;
31
32
my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'edit_templates' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $success = 0;
38
39
my $id = $cgi->param('id');
40
41
my $club_template = Koha::Club::Templates->find($id);
42
if ($club_template) {
43
    $success = $club_template->delete();
44
}
45
46
binmode STDOUT, ':encoding(UTF-8)';
47
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
48
49
print to_json( { success => $success ? 1 : 0 } );

Return to bug 12461