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

(-)a/C4/Auth.pm (-2 / +3 lines)
Lines 260-266 sub get_template_and_user { Link Here
260
        my $all_perms = get_all_subpermissions();
260
        my $all_perms = get_all_subpermissions();
261
261
262
        my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
262
        my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
263
          editcatalogue updatecharges management tools editauthorities serials reports acquisition);
263
          editcatalogue updatecharges management tools editauthorities serials reports acquisition clubs);
264
264
265
        # We are going to use the $flags returned by checkauth
265
        # We are going to use the $flags returned by checkauth
266
        # to create the template's parameters that will indicate
266
        # to create the template's parameters that will indicate
Lines 283-290 sub get_template_and_user { Link Here
283
            $template->param( CAN_user_staffaccess      => 1 );
283
            $template->param( CAN_user_staffaccess      => 1 );
284
            $template->param( CAN_user_plugins          => 1 );
284
            $template->param( CAN_user_plugins          => 1 );
285
            $template->param( CAN_user_coursereserves   => 1 );
285
            $template->param( CAN_user_coursereserves   => 1 );
286
            foreach my $module ( keys %$all_perms ) {
286
            $template->param( CAN_user_clubs            => 1 );
287
287
288
            foreach my $module ( keys %$all_perms ) {
288
                foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
289
                foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
289
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
290
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
290
                }
291
                }
(-)a/C4/Members.pm (-13 / +3 lines)
Lines 989-1008 addresses. Link Here
989
989
990
sub GetFirstValidEmailAddress {
990
sub GetFirstValidEmailAddress {
991
    my $borrowernumber = shift;
991
    my $borrowernumber = shift;
992
    my $dbh = C4::Context->dbh;
993
    my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
994
    $sth->execute( $borrowernumber );
995
    my $data = $sth->fetchrow_hashref;
996
992
997
    if ($data->{'email'}) {
993
    my $borrower = Koha::Patrons->find( $borrowernumber );
998
       return $data->{'email'};
994
999
    } elsif ($data->{'emailpro'}) {
995
    return $borrower->first_valid_email_address();
1000
       return $data->{'emailpro'};
1001
    } elsif ($data->{'B_email'}) {
1002
       return $data->{'B_email'};
1003
    } else {
1004
       return '';
1005
    }
1006
}
996
}
1007
997
1008
=head2 GetNoticeEmailAddress
998
=head2 GetNoticeEmailAddress
(-)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::Libraries;
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::Libraries->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 (+78 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
=head3 club
56
57
=cut
58
59
sub club {
60
    my ( $self ) = @_;
61
    return Koha::Clubs->find( $self->club_id() );
62
}
63
64
=head3 type
65
66
=cut
67
68
sub _type {
69
    return 'ClubEnrollment';
70
}
71
72
=head1 AUTHOR
73
74
Kyle M Hall <kyle@bywatersolutions.com>
75
76
=cut
77
78
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 (+92 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 get_enrollable
43
44
=cut
45
46
sub get_enrollable {
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->get_club_enrollments();
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
=head3 type
75
76
=cut
77
78
sub _type {
79
    return 'Club';
80
}
81
82
sub object_class {
83
    return 'Koha::Club';
84
}
85
86
=head1 AUTHOR
87
88
Kyle M Hall <kyle@bywatersolutions.com>
89
90
=cut
91
92
1;
(-)a/Koha/Patron.pm (+38 lines)
Lines 35-40 use Koha::Patron::HouseboundRole; Link Here
35
use Koha::Patron::Images;
35
use Koha::Patron::Images;
36
use Koha::Patrons;
36
use Koha::Patrons;
37
use Koha::Virtualshelves;
37
use Koha::Virtualshelves;
38
use Koha::Club::Enrollments;
38
39
39
use base qw(Koha::Object);
40
use base qw(Koha::Object);
40
41
Lines 584-589 sub holds { Link Here
584
    return Koha::Holds->_new_from_dbic($holds_rs);
585
    return Koha::Holds->_new_from_dbic($holds_rs);
585
}
586
}
586
587
588
=head3 first_valid_email_address
589
590
=cut
591
592
sub first_valid_email_address {
593
    my ($self) = @_;
594
595
    return $self->email() || $self->emailpro() || $self->B_email() || q{};
596
}
597
598
=head3 get_club_enrollments
599
600
=cut
601
602
sub get_club_enrollments {
603
    my ($self) = @_;
604
605
    return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
606
}
607
608
=head3 get_enrollable_clubs
609
610
=cut
611
612
sub get_enrollable_clubs {
613
    my ( $self, $is_enrollable_from_opac ) = @_;
614
615
    my $params;
616
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
617
      if $is_enrollable_from_opac;
618
    $params->{is_email_required} = 0 unless $self->first_valid_email_address();
619
620
    $params->{borrower} = $self;
621
622
    return Koha::Clubs->get_enrollable($params);
623
}
624
587
=head3 type
625
=head3 type
588
626
589
=cut
627
=cut
(-)a/Koha/Schema/Result/AuthorisedValue.pm (-3 / +3 lines)
Lines 130-138 __PACKAGE__->belongs_to( Link Here
130
);
130
);
131
131
132
132
133
# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-08-30 11:52:45
133
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:13:07
134
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LOArv8JQ0aiTZgcy+jb7pA
134
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YwvGOd/jzk71ekWfO56xrw
135
135
136
136
137
# You can replace this text with custom content, and it will be preserved on regeneration
137
# You can replace this text with custom code or comments, and it will be preserved on regeneration
138
1;
138
1;
(-)a/Koha/Schema/Result/Borrower.pm (-2 / +17 lines)
Lines 860-865 __PACKAGE__->belongs_to( Link Here
860
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
860
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
861
);
861
);
862
862
863
=head2 club_enrollments
864
865
Type: has_many
866
867
Related object: L<Koha::Schema::Result::ClubEnrollment>
868
869
=cut
870
871
__PACKAGE__->has_many(
872
  "club_enrollments",
873
  "Koha::Schema::Result::ClubEnrollment",
874
  { "foreign.borrowernumber" => "self.borrowernumber" },
875
  { cascade_copy => 0, cascade_delete => 0 },
876
);
877
863
=head2 course_instructors
878
=head2 course_instructors
864
879
865
Type: has_many
880
Type: has_many
Lines 1341-1348 Composing rels: L</aqorder_users> -> ordernumber Link Here
1341
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1356
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1342
1357
1343
1358
1344
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-02-10 07:30:06
1359
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
1345
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:35WEsGd5LmkZ3bB486M1yA
1360
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qq3fmJ73x8Qv+Pqbs7zkow
1346
1361
1347
__PACKAGE__->belongs_to(
1362
__PACKAGE__->belongs_to(
1348
    "guarantor",
1363
    "guarantor",
(-)a/Koha/Schema/Result/Branch.pm (-2 / +47 lines)
Lines 360-365 __PACKAGE__->has_many( Link Here
360
  { cascade_copy => 0, cascade_delete => 0 },
360
  { cascade_copy => 0, cascade_delete => 0 },
361
);
361
);
362
362
363
=head2 club_enrollments
364
365
Type: has_many
366
367
Related object: L<Koha::Schema::Result::ClubEnrollment>
368
369
=cut
370
371
__PACKAGE__->has_many(
372
  "club_enrollments",
373
  "Koha::Schema::Result::ClubEnrollment",
374
  { "foreign.branchcode" => "self.branchcode" },
375
  { cascade_copy => 0, cascade_delete => 0 },
376
);
377
378
=head2 club_templates
379
380
Type: has_many
381
382
Related object: L<Koha::Schema::Result::ClubTemplate>
383
384
=cut
385
386
__PACKAGE__->has_many(
387
  "club_templates",
388
  "Koha::Schema::Result::ClubTemplate",
389
  { "foreign.branchcode" => "self.branchcode" },
390
  { cascade_copy => 0, cascade_delete => 0 },
391
);
392
393
=head2 clubs
394
395
Type: has_many
396
397
Related object: L<Koha::Schema::Result::Club>
398
399
=cut
400
401
__PACKAGE__->has_many(
402
  "clubs",
403
  "Koha::Schema::Result::Club",
404
  { "foreign.branchcode" => "self.branchcode" },
405
  { cascade_copy => 0, cascade_delete => 0 },
406
);
407
363
=head2 collections
408
=head2 collections
364
409
365
Type: has_many
410
Type: has_many
Lines 551-558 Composing rels: L</branchrelations> -> categorycode Link Here
551
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
596
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
552
597
553
598
554
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-03-23 13:30:04
599
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
555
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:r12VO55fG0lzxkz7fVDmAA
600
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:99U1YQ4iSum4LbBha4hDTQ
556
601
557
602
558
# You can replace this text with custom code or comments, and it will be preserved on regeneration
603
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)a/Koha/Schema/Result/Club.pm (+182 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: 10
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 => 10 },
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_template
162
163
Type: belongs_to
164
165
Related object: L<Koha::Schema::Result::ClubTemplate>
166
167
=cut
168
169
__PACKAGE__->belongs_to(
170
  "club_template",
171
  "Koha::Schema::Result::ClubTemplate",
172
  { id => "club_template_id" },
173
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
174
);
175
176
177
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
178
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H7MVPMvbDxo++sKrggmUyA
179
180
181
# You can replace this text with custom content, and it will be preserved on regeneration
182
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: 10
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 => 10 },
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.07042 @ 2017-04-26 16:17:25
197
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a1uTIm+Y9A0jEBiumQ60jg
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     => "CASCADE",
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.07042 @ 2017-04-26 16:17:25
193
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:29ssLVCIoLxBmUi8E5gHqg
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 (+104 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_template
84
85
Type: belongs_to
86
87
Related object: L<Koha::Schema::Result::ClubTemplate>
88
89
=cut
90
91
__PACKAGE__->belongs_to(
92
  "club_template",
93
  "Koha::Schema::Result::ClubTemplate",
94
  { id => "club_template_id" },
95
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
96
);
97
98
99
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-04-26 16:17:25
100
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xhCyOHUrXuU+UoHeGk1ZKw
101
102
103
# You can replace this text with custom content, and it will be preserved on regeneration
104
1;
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (-2 / +2 lines)
Lines 35-42 sub GetByCode { Link Here
35
}
35
}
36
36
37
sub Get {
37
sub Get {
38
    my ( $self, $category, $opac ) = @_;
38
    my ( $self, $category, $selected, $opac ) = @_;
39
    return GetAuthorisedValues( $category, $opac );
39
    return GetAuthorisedValues( $category, $selected, $opac );
40
}
40
}
41
41
42
sub GetAuthValueDropbox {
42
sub GetAuthValueDropbox {
(-)a/Koha/Template/Plugin/Borrowers.pm (-1 lines)
Lines 57-61 sub HasOverdues { Link Here
57
    return Koha::Patrons->find( $borrowernumber )->has_overdues;
57
    return Koha::Patrons->find( $borrowernumber )->has_overdues;
58
}
58
}
59
59
60
61
1;
60
1;
(-)a/clubs/clubs-add-modify.pl (+107 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
my $stored = $cgi->param('name') ? $id ? 'updated' : 'stored' : undef;
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->multi_param('club_template_field_id');
72
    my @club_field_id          = $cgi->multi_param('club_field_id');
73
    my @club_field             = $cgi->multi_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
    print $cgi->redirect("/cgi-bin/koha/clubs/clubs.pl?stored=$stored&club_id=$id");
97
    exit;
98
}
99
100
$club = Koha::Clubs->find($id);
101
102
$template->param(
103
    club_template => $club_template,
104
    club          => $club,
105
);
106
107
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/clubs.pl (+60 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 $stored = $cgi->param('stored');
43
my $club_template_id = $cgi->param('club_template_id');
44
my $club_id = $cgi->param('club_id');
45
46
my $club_template = $club_template_id ? Koha::Club::Templates->find( $club_template_id ) : undef;
47
my $club = $club_id ? Koha::Clubs->find( $club_id ) : undef;
48
49
my @club_templates = Koha::Club::Templates->search();
50
my @clubs          = Koha::Clubs->search();
51
52
$template->param(
53
    stored         => $stored,
54
    club_template  => $club_template,
55
    club           => $club,
56
    club_templates => \@club_templates,
57
    clubs          => \@clubs,
58
);
59
60
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::Patrons;
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 $patronnumber = $cgi->param('borrowernumber');
43
44
my $patron = Koha::Patrons->find($patronnumber);
45
46
my @enrollments = $patron->get_club_enrollments();
47
my @clubs       = $patron->get_enrollable_clubs();
48
49
$template->param(
50
    enrollments    => \@enrollments,
51
    clubs          => \@clubs,
52
    borrowernumber => $patronnumber
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 (+152 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
my $stored;
51
52
if ( $cgi->param('name') ) {    # Update or create club
53
    if ($id) {
54
        $club_template = Koha::Club::Templates->find($id);
55
        $stored        = 'updated';
56
    }
57
    else {
58
        $club_template = Koha::Club::Template->new();
59
        $stored = 'created';
60
    }
61
62
    $club_template->set(
63
        {
64
            id          => $id                        || undef,
65
            name        => $cgi->param('name')        || undef,
66
            description => $cgi->param('description') || undef,
67
            branchcode  => $cgi->param('branchcode')  || undef,
68
            date_updated            => dt_from_string(),
69
            is_email_required       => $cgi->param('is_email_required') ? 1 : 0,
70
            is_enrollable_from_opac => $cgi->param('is_enrollable_from_opac') ? 1 : 0,
71
        }
72
    )->store();
73
74
    $id ||= $club_template->id();
75
76
    # Update club creation fields
77
    my @field_id                        = $cgi->multi_param('club_template_field_id');
78
    my @field_name                      = $cgi->multi_param('club_template_field_name');
79
    my @field_description               = $cgi->multi_param('club_template_field_description');
80
    my @field_authorised_value_category = $cgi->multi_param('club_template_field_authorised_value_category');
81
82
    my @field_delete = $cgi->multi_param('club_template_field_delete');
83
84
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
85
        my $field_id                        = $field_id[$i];
86
        my $field_name                      = $field_name[$i];
87
        my $field_description               = $field_description[$i];
88
        my $field_authorised_value_category = $field_authorised_value_category[$i];
89
90
        my $field =
91
          $field_id
92
          ? Koha::Club::Template::Fields->find($field_id)
93
          : Koha::Club::Template::Field->new();
94
95
        if ( grep( /^$field_id$/, @field_delete ) ) {
96
            $field->delete();
97
        }
98
        else {
99
            $field->set(
100
                {
101
                    club_template_id          => $id,
102
                    name                      => $field_name,
103
                    description               => $field_description,
104
                    authorised_value_category => $field_authorised_value_category,
105
                }
106
            )->store();
107
        }
108
    }
109
110
    # Update club enrollment fields
111
    @field_id                        = $cgi->multi_param('club_template_enrollment_field_id');
112
    @field_name                      = $cgi->multi_param('club_template_enrollment_field_name');
113
    @field_description               = $cgi->multi_param('club_template_enrollment_field_description');
114
    @field_authorised_value_category = $cgi->multi_param('club_template_enrollment_field_authorised_value_category');
115
116
    @field_delete = $cgi->multi_param('club_template_enrollment_field_delete');
117
118
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
119
        my $field_id                        = $field_id[$i];
120
        my $field_name                      = $field_name[$i];
121
        my $field_description               = $field_description[$i];
122
        my $field_authorised_value_category = $field_authorised_value_category[$i];
123
124
        my $field =
125
          $field_id
126
          ? Koha::Club::Template::EnrollmentFields->find($field_id)
127
          : Koha::Club::Template::EnrollmentField->new();
128
129
        if ( grep( /^$field_id$/, @field_delete ) ) {
130
            $field->delete();
131
        }
132
        else {
133
            $field->set(
134
                {
135
                    id                        => $field_id,
136
                    club_template_id          => $id,
137
                    name                      => $field_name,
138
                    description               => $field_description,
139
                    authorised_value_category => $field_authorised_value_category,
140
                }
141
            )->store();
142
        }
143
    }
144
145
    print $cgi->redirect("/cgi-bin/koha/clubs/clubs.pl?stored=$stored&club_template_id=$id");
146
    exit;
147
}
148
149
$club_template ||= Koha::Club::Templates->find($id);
150
$template->param( club_template => $club_template );
151
152
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/installer/data/mysql/atomicupdate/bug_12461.sql (+131 lines)
Line 0 Link Here
1
--
2
-- Table structure for table 'club_templates'
3
--
4
5
CREATE TABLE IF NOT EXISTS club_templates (
6
  id int(11) NOT NULL AUTO_INCREMENT,
7
  `name` tinytext NOT NULL,
8
  description text,
9
  is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
10
  is_email_required tinyint(1) NOT NULL DEFAULT '0',
11
  branchcode varchar(10) NULL DEFAULT NULL,
12
  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
13
  date_updated timestamp NULL DEFAULT NULL,
14
  is_deletable tinyint(1) NOT NULL DEFAULT '1',
15
  PRIMARY KEY (id),
16
  KEY ct_branchcode (branchcode),
17
  CONSTRAINT `club_templates_ibfk_1` FOREIGN KEY (branchcode) REFERENCES `branches` (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
18
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
19
20
--
21
-- Table structure for table 'clubs'
22
--
23
24
CREATE TABLE IF NOT EXISTS clubs (
25
  id int(11) NOT NULL AUTO_INCREMENT,
26
  club_template_id int(11) NOT NULL,
27
  `name` tinytext NOT NULL,
28
  description text,
29
  date_start date DEFAULT NULL,
30
  date_end date DEFAULT NULL,
31
  branchcode varchar(10) NULL DEFAULT NULL,
32
  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
33
  date_updated timestamp NULL DEFAULT NULL,
34
  PRIMARY KEY (id),
35
  KEY club_template_id (club_template_id),
36
  KEY branchcode (branchcode),
37
  CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
38
  CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
39
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
40
41
--
42
-- Table structure for table 'club_enrollments'
43
--
44
45
CREATE TABLE IF NOT EXISTS club_enrollments (
46
  id int(11) NOT NULL AUTO_INCREMENT,
47
  club_id int(11) NOT NULL,
48
  borrowernumber int(11) NOT NULL,
49
  date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
50
  date_canceled timestamp NULL DEFAULT NULL,
51
  date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
52
  date_updated timestamp NULL DEFAULT NULL,
53
  branchcode varchar(10) NULL DEFAULT NULL,
54
  PRIMARY KEY (id),
55
  KEY club_id (club_id),
56
  KEY borrowernumber (borrowernumber),
57
  KEY branchcode (branchcode),
58
  CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
59
  CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
60
  CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE
61
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
62
63
--
64
-- Table structure for table 'club_template_enrollment_fields'
65
--
66
67
CREATE TABLE IF NOT EXISTS club_template_enrollment_fields (
68
  id int(11) NOT NULL AUTO_INCREMENT,
69
  club_template_id int(11) NOT NULL,
70
  `name` tinytext NOT NULL,
71
  description text,
72
  authorised_value_category varchar(16) DEFAULT NULL,
73
  PRIMARY KEY (id),
74
  KEY club_template_id (club_template_id),
75
  CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
76
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
77
78
--
79
-- Table structure for table 'club_enrollment_fields'
80
--
81
82
CREATE TABLE IF NOT EXISTS club_enrollment_fields (
83
  id int(11) NOT NULL AUTO_INCREMENT,
84
  club_enrollment_id int(11) NOT NULL,
85
  club_template_enrollment_field_id int(11) NOT NULL,
86
  `value` text NOT NULL,
87
  PRIMARY KEY (id),
88
  KEY club_enrollment_id (club_enrollment_id),
89
  KEY club_template_enrollment_field_id (club_template_enrollment_field_id),
90
  CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment_id) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
91
  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
92
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
93
94
--
95
-- Table structure for table 'club_template_fields'
96
--
97
98
CREATE TABLE IF NOT EXISTS club_template_fields (
99
  id int(11) NOT NULL AUTO_INCREMENT,
100
  club_template_id int(11) NOT NULL,
101
  `name` tinytext NOT NULL,
102
  description text,
103
  authorised_value_category varchar(16) DEFAULT NULL,
104
  PRIMARY KEY (id),
105
  KEY club_template_id (club_template_id),
106
  CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
107
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
108
109
--
110
-- Table structure for table 'club_fields'
111
--
112
113
CREATE TABLE IF NOT EXISTS club_fields (
114
  id int(11) NOT NULL AUTO_INCREMENT,
115
  club_template_field_id int(11) NOT NULL,
116
  club_id int(11) NOT NULL,
117
  `value` text,
118
  PRIMARY KEY (id),
119
  KEY club_template_field_id (club_template_field_id),
120
  KEY club_id (club_id),
121
  CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field_id) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
122
  CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE
123
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
124
125
INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES (21, 'clubs', 'Patron clubs', '0');
126
127
INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
128
   (21, 'edit_templates', 'Create and update club templates'),
129
   (21, 'edit_clubs', 'Create and update clubs'),
130
   (21, 'enroll', 'Enroll patrons in clubs')
131
;
(-)a/installer/data/mysql/kohastructure.sql (+124 lines)
Lines 3960-3965 CREATE TABLE deletedbiblio_metadata ( Link Here
3960
    CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
3960
    CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
3961
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3961
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3962
3962
3963
--
3964
-- Table structure for table 'club_templates'
3965
--
3966
3967
CREATE TABLE IF NOT EXISTS club_templates (
3968
  id int(11) NOT NULL AUTO_INCREMENT,
3969
  `name` tinytext NOT NULL,
3970
  description text,
3971
  is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
3972
  is_email_required tinyint(1) NOT NULL DEFAULT '0',
3973
  branchcode varchar(10) NULL DEFAULT NULL,
3974
  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3975
  date_updated timestamp NULL DEFAULT NULL,
3976
  is_deletable tinyint(1) NOT NULL DEFAULT '1',
3977
  PRIMARY KEY (id),
3978
  KEY ct_branchcode (branchcode),
3979
  CONSTRAINT `club_templates_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3980
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3981
3982
--
3983
-- Table structure for table 'clubs'
3984
--
3985
3986
CREATE TABLE IF NOT EXISTS clubs (
3987
  id int(11) NOT NULL AUTO_INCREMENT,
3988
  club_template_id int(11) NOT NULL,
3989
  `name` tinytext NOT NULL,
3990
  description text,
3991
  date_start date DEFAULT NULL,
3992
  date_end date DEFAULT NULL,
3993
  branchcode varchar(10) NULL DEFAULT NULL,
3994
  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3995
  date_updated timestamp NULL DEFAULT NULL,
3996
  PRIMARY KEY (id),
3997
  KEY club_template_id (club_template_id),
3998
  KEY branchcode (branchcode),
3999
  CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
4000
  CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
4001
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4002
4003
--
4004
-- Table structure for table 'club_enrollments'
4005
--
4006
4007
CREATE TABLE IF NOT EXISTS club_enrollments (
4008
  id int(11) NOT NULL AUTO_INCREMENT,
4009
  club_id int(11) NOT NULL,
4010
  borrowernumber int(11) NOT NULL,
4011
  date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
4012
  date_canceled timestamp NULL DEFAULT NULL,
4013
  date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
4014
  date_updated timestamp NULL DEFAULT NULL,
4015
  branchcode varchar(10) NULL DEFAULT NULL,
4016
  PRIMARY KEY (id),
4017
  KEY club_id (club_id),
4018
  KEY borrowernumber (borrowernumber),
4019
  KEY branchcode (branchcode),
4020
  CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
4021
  CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
4022
  CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE
4023
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4024
4025
--
4026
-- Table structure for table 'club_template_enrollment_fields'
4027
--
4028
4029
CREATE TABLE IF NOT EXISTS club_template_enrollment_fields (
4030
  id int(11) NOT NULL AUTO_INCREMENT,
4031
  club_template_id int(11) NOT NULL,
4032
  `name` tinytext NOT NULL,
4033
  description text,
4034
  authorised_value_category varchar(16) DEFAULT NULL,
4035
  PRIMARY KEY (id),
4036
  KEY club_template_id (club_template_id),
4037
  CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
4038
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4039
4040
--
4041
-- Table structure for table 'club_enrollment_fields'
4042
--
4043
4044
CREATE TABLE IF NOT EXISTS club_enrollment_fields (
4045
  id int(11) NOT NULL AUTO_INCREMENT,
4046
  club_enrollment_id int(11) NOT NULL,
4047
  club_template_enrollment_field_id int(11) NOT NULL,
4048
  `value` text NOT NULL,
4049
  PRIMARY KEY (id),
4050
  KEY club_enrollment_id (club_enrollment_id),
4051
  KEY club_template_enrollment_field_id (club_template_enrollment_field_id),
4052
  CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment_id) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
4053
  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
4054
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4055
4056
--
4057
-- Table structure for table 'club_template_fields'
4058
--
4059
4060
CREATE TABLE IF NOT EXISTS club_template_fields (
4061
  id int(11) NOT NULL AUTO_INCREMENT,
4062
  club_template_id int(11) NOT NULL,
4063
  `name` tinytext NOT NULL,
4064
  description text,
4065
  authorised_value_category varchar(16) DEFAULT NULL,
4066
  PRIMARY KEY (id),
4067
  KEY club_template_id (club_template_id),
4068
  CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
4069
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4070
4071
--
4072
-- Table structure for table 'club_fields'
4073
--
4074
4075
CREATE TABLE IF NOT EXISTS club_fields (
4076
  id int(11) NOT NULL AUTO_INCREMENT,
4077
  club_template_field_id int(11) NOT NULL,
4078
  club_id int(11) NOT NULL,
4079
  `value` text,
4080
  PRIMARY KEY (id),
4081
  KEY club_template_field_id (club_template_field_id),
4082
  KEY club_id (club_id),
4083
  CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field_id) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
4084
  CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE
4085
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4086
3963
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
4087
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3964
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
4088
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3965
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
4089
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/userflags.sql (-1 / +2 lines)
Lines 17-21 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES Link Here
17
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
17
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
18
(18,'coursereserves','Course reserves',0),
18
(18,'coursereserves','Course reserves',0),
19
(19, 'plugins', 'Koha plugins', '0'),
19
(19, 'plugins', 'Koha plugins', '0'),
20
(20, 'lists', 'Lists', 0)
20
(20, 'lists', 'Lists', 0),
21
(21, 'clubs', 'Patron clubs', '0')
21
;
22
;
(-)a/installer/data/mysql/userpermissions.sql (-1 / +4 lines)
Lines 78-82 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
78
   (19, 'tool', 'Use tool plugins'),
78
   (19, 'tool', 'Use tool plugins'),
79
   (19, 'report', 'Use report plugins'),
79
   (19, 'report', 'Use report plugins'),
80
   (19, 'configure', 'Configure plugins'),
80
   (19, 'configure', 'Configure plugins'),
81
   (20, 'delete_public_lists', 'Delete public lists')
81
   (20, 'delete_public_lists', 'Delete public lists'),
82
   (21, 'edit_templates', 'Create and update club templates'),
83
   (21, 'edit_clubs', 'Create and update clubs'),
84
   (21, 'enroll', 'Enroll patrons in clubs')
82
;
85
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+4 lines)
Lines 19-24 Link Here
19
    [%- CASE 'coursereserves' -%]<span>Course reserves</span>
19
    [%- CASE 'coursereserves' -%]<span>Course reserves</span>
20
    [%- CASE 'plugins' -%]<span>Koha plugins</span>
20
    [%- CASE 'plugins' -%]<span>Koha plugins</span>
21
    [%- CASE 'lists' -%]<span>Lists</span>
21
    [%- CASE 'lists' -%]<span>Lists</span>
22
    [%- CASE 'clubs' -%]<span>Patron clubs</span>
22
    [%- END -%]
23
    [%- END -%]
23
[%- END -%]
24
[%- END -%]
24
25
Lines 103-107 Link Here
103
    [%- CASE 'delete_public_lists' -%]<span>Delete public lists</span>
104
    [%- CASE 'delete_public_lists' -%]<span>Delete public lists</span>
104
    [%- CASE 'upload_general_files' -%]<span>Upload any file</span>
105
    [%- CASE 'upload_general_files' -%]<span>Upload any file</span>
105
    [%- CASE 'upload_manage' -%]<span>Manage uploaded files (<i>Useless without upload_general_files</i>)</span>
106
    [%- CASE 'upload_manage' -%]<span>Manage uploaded files (<i>Useless without upload_general_files</i>)</span>
107
    [%- CASE 'edit_clubs' -%]<span>Create and edit clubs</span>
108
    [%- CASE 'edit_templates' -%]<span>Create and edit club templates</span>
109
    [%- CASE 'enroll' -%]<span>Enroll patrons in clubs</span>
106
    [%- END -%]
110
    [%- END -%]
107
[%- END -%]
111
[%- END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (+3 lines)
Lines 25-30 Link Here
25
    [% IF ( CAN_user_tools_manage_patron_lists ) %]
25
    [% IF ( CAN_user_tools_manage_patron_lists ) %]
26
	<li><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a></li>
26
	<li><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a></li>
27
    [% END %]
27
    [% END %]
28
    [% IF (CAN_user_clubs) %]
29
        <li><a href="/cgi-bin/koha/clubs/clubs.pl">Patron clubs</a></li>
30
    [% END %]
28
    [% IF ( CAN_user_tools_moderate_comments ) %]
31
    [% IF ( CAN_user_tools_moderate_comments ) %]
29
	<li><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a></li>
32
	<li><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a></li>
30
    [% END %]
33
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+23 lines)
Lines 94-99 $(document).ready(function() { Link Here
94
        }
94
        }
95
    });
95
    });
96
96
97
    if ( $('#clubs-tab').length ) {
98
        $('#clubs-tab-link').on('click', function() {
99
            $('#clubs-tab').text(_("Loading..."));
100
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
101
        });
102
    }
103
97
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
104
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
98
        // listen submit to trigger qslip on empty checkout
105
        // listen submit to trigger qslip on empty checkout
99
        $('#mainform').bind('submit',function() {
106
        $('#mainform').bind('submit',function() {
Lines 888-893 No patron matched <span class="ex">[% message | html %]</span> Link Here
888
        [% END %]
895
        [% END %]
889
    </li>
896
    </li>
890
897
898
    [% SET enrollments = patron.get_club_enrollments.size || 0 %]
899
    [% SET enrollable  = patron.get_enrollable_clubs.size || 0 %]
900
    [% IF CAN_user_clubs && ( enrollable || enrollments ) %]
901
        <li>
902
            <a id="clubs-tab-link" href="#clubs-tab">
903
                Clubs ([% enrollments %]/[% enrollable %])
904
            </a>
905
        </li>
906
    [% END %]
907
891
    [% IF relatives_issues_count %]
908
    [% IF relatives_issues_count %]
892
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
909
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
893
    [% END %]
910
    [% END %]
Lines 936-941 No patron matched <span class="ex">[% message | html %]</span> Link Here
936
    </div>
953
    </div>
937
[% END %]
954
[% END %]
938
955
956
[% IF CAN_user_clubs && ( enrollable || enrollments ) %]
957
    <div id="clubs-tab">
958
        Loading...
959
    </div>
960
[% END %]
961
939
[% INCLUDE borrower_debarments.inc %]
962
[% INCLUDE borrower_debarments.inc %]
940
963
941
<div id="reserves">
964
<div id="reserves">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt (+115 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Branches %]
3
[% USE AuthorisedValues %]
4
[% SET AuthorisedValuesCategories = AuthorisedValues.GetCategories %]
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
</head>
10
11
<body id="clubs_add_modify" class="clubs">
12
[% INCLUDE 'header.inc' %]
13
[% INCLUDE 'cat-search.inc' %]
14
<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>
15
16
<div class="yui-t7">
17
    <div class="yui-main">
18
        <form method="post" class="validated">
19
            <input type="hidden" name="id" value="[% club.id %]" />
20
            <input type="hidden" name="club_template_id" value="[% club_template.id %]" />
21
22
            <fieldset class="rows">
23
24
                <legend>
25
                    [% IF club %]
26
                        Modify club <i>[% club.name %]</i>
27
                    [% ELSE %]
28
                        Create a new <i>[% club_template.name %]</i> club
29
                    [% END %]
30
                </legend>
31
32
                <ol>
33
                    <li>
34
                        <label class="required" for="name">Name:</label>
35
                        <input id="club-name" name="name" type="text" value="[% club.name %]" required="required"/>
36
                        <span class="required">Required</span>
37
                    </li>
38
39
                    <li>
40
                        <label for="description">Description:</label>
41
                        <input id="club-template-name" name="description" type="text" value="[% club.description %]" />
42
                    </li>
43
44
                    <li>
45
                        <label for="date_start">Start date:</label>
46
                        <input name="date_start" id="from" size="10" readonly="readonly" class="datepickerfrom" value="[% club.date_start | $KohaDates %]">
47
                    </li>
48
49
                    <li>
50
                        <label for="date_end">End date:</label>
51
                        <input name="date_end" id="to" size="10" readonly="readonly" class="datepickerto" value="[% club.date_end | $KohaDates %]" >
52
                    </li>
53
54
                    <li>
55
                        <label for="name">Library:</label>
56
                        <select name="branchcode" id="club-template-branchcode">
57
                            <option value="">&nbsp</option>
58
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => club.branch.branchcode ) %]
59
                        </select>
60
                    </li>
61
62
                    [% IF club %]
63
                        [% FOREACH f IN club.club_fields %]
64
                            <li>
65
                                <input type="hidden" name="club_template_field_id" value="[% f.club_template_field.id %]" />
66
                                <input type="hidden" name="club_field_id" value="[% f.id %]" />
67
68
                                <label for="club_field">[% f.club_template_field.name %]</label>
69
                                [% IF f.club_template_field.authorised_value_category %]
70
                                    <select name="club_field">
71
                                        [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
72
                                            [% IF a.authorised_value == f.value %]
73
                                                <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
74
                                            [% ELSE %]
75
                                                <option value="[% a.authorised_value %]">[% a.lib %]</option>
76
                                            [% END %]
77
                                        [% END %]
78
                                    </select>
79
                                [% ELSE %]
80
                                    <input type="text" name="club_field" value="[% f.value %]" />
81
                                [% END %]
82
                            </li>
83
                        [% END %]
84
                    [% ELSE %]
85
                        [% FOREACH f IN club_template.club_template_fields %]
86
                            <li>
87
                                <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
88
89
                                <label for="club_field">[% f.name %]</label>
90
                                [% IF f.authorised_value_category %]
91
                                    <select name="club_field">
92
                                        [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
93
                                            <option value="[% a.authorised_value %]">[% a.lib %]</option>
94
                                        [% END %]
95
                                    </select>
96
                                [% ELSE %]
97
                                    <input type="text" name="club_field" />
98
                                [% END %]
99
                            </li>
100
                        [% END %]
101
                    [% END %]
102
103
                </ol>
104
105
            </fieldset>
106
107
            <fieldset class="action">
108
                <input type="submit" class="btn btn-default" value="Save" />
109
                <a href="clubs.pl" class="cancel">Cancel</a>
110
            </fieldset>
111
        </form>
112
    </div>
113
</div>
114
115
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt (+252 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="[% interface %]/[% theme %]/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
            "sPaginationType": "four_button",
15
            "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
16
            "aoColumnDefs": [
17
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
18
            ]
19
        } ));
20
21
        cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
22
            "sPaginationType": "four_button",
23
            "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
24
            "aoColumnDefs": [
25
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
26
            ]
27
        } ));
28
    });
29
30
    function ConfirmDeleteTemplate( id, name, a ) {
31
        if ( confirm( _("Are you sure you want to delete the club template %s?" ).format(name) ) ) {
32
            $.ajax({
33
                type: "POST",
34
                url: '/cgi-bin/koha/svc/club/template/delete',
35
                data: { id: id },
36
                success: function( data ) {
37
                    if ( data.success ) {
38
                        tTable.fnDeleteRow(a.closest("tr")[0]);
39
                    } else {
40
                        alert(_("Unable to delete template!"));
41
                    }
42
                },
43
                dataType: 'json'
44
            });
45
        }
46
    }
47
48
    function ConfirmDeleteClub( id, name, a ) {
49
        if ( confirm( _("Are you sure you want to delete the club %s?" ).format(name) ) ) {
50
            $.ajax({
51
                type: "POST",
52
                url: '/cgi-bin/koha/svc/club/delete',
53
                data: { id: id },
54
                success: function( data ) {
55
                    if ( data.success ) {
56
                        cTable.fnDeleteRow(a.closest("tr")[0]);
57
                    } else {
58
                        alert(_("Unable to delete club!"));
59
                    }
60
                },
61
                dataType: 'json'
62
            });
63
        }
64
    }
65
//]]>
66
</script>
67
68
</head>
69
70
<body id="clubs_clubs" class="clubs">
71
[% INCLUDE 'header.inc' %]
72
[% INCLUDE 'cat-search.inc' %]
73
<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>
74
75
<div id="doc3" class="yui-t2">
76
   <div id="bd">
77
        <div id="yui-main">
78
            <div class="yui-b">
79
                <h1>Patron clubs</h1>
80
81
                [% IF club_template %]
82
                    <div class="dialog message">
83
                        [% IF stored == 'updated' %]
84
                            <p>Club template <i>[% club_template.name %]</i> was updated.</p>
85
                        [% ELSE %]
86
                            <p>Club template <i>[% club_template.name %]</i> was saved.</p>
87
                        [% END %]
88
                    </div>
89
                [% ELSIF club %]
90
                    <div class="dialog message">
91
                        [% IF stored == 'updated' %]
92
                            <p>Club <i>[% club.name %]</i> was updated.</p>
93
                        [% ELSE %]
94
                            <p>Club <i>[% club.name %]</i> was saved.</p>
95
                        [% END %]
96
                    </div>
97
                [% END %]
98
99
                <h3>Club templates</h3>
100
101
                [% IF CAN_user_clubs_edit_templates %]
102
                    <div class="btn-toolbar">
103
                        <div class="btn-group">
104
                            <a class="btn btn-default" href="templates-add-modify.pl"><i class="fa fa-plus"></i> New club template</a>
105
                        </div>
106
                    </div>
107
                [% END %]
108
109
                <table id="club-templates-table">
110
                    <thead>
111
                        <tr>
112
                            <th>Name</th>
113
                            <th>Description</th>
114
                            <th>Public enrollment</th>
115
                            <th>Email required</th>
116
                            <th>Library</th>
117
                            <th>&nbsp;</th>
118
                            <th>&nbsp;</th>
119
                        </tr>
120
                    </thead>
121
122
                    <tbody>
123
                        [% IF club_templates %]
124
                            [% FOREACH t IN club_templates %]
125
                                <tr>
126
                                    <td>[% t.name %]</td>
127
                                    <td>[% t.description %]</td>
128
                                    <td>
129
                                        [% IF t.is_enrollable_from_opac %]
130
                                            Yes
131
                                        [% ELSE %]
132
                                            No
133
                                        [% END %]
134
                                    </td>
135
                                    <td>
136
                                        [% IF t.is_email_required %]
137
                                            Yes
138
                                        [% ELSE %]
139
                                            No
140
                                        [% END %]
141
                                    </td>
142
                                    <td>[% Branches.GetName( t.branchcode ) %]</td>
143
                                    <td>
144
                                        [% IF CAN_user_clubs_edit_templates %]
145
                                            <a class="btn btn-default" style="white-space:nowrap"  href="templates-add-modify.pl?id=[% t.id %]">
146
                                                <i class="fa fa-edit"></i> Edit
147
                                            </a>
148
                                        [% END %]
149
                                    </td>
150
                                    <td>
151
                                        [% IF CAN_user_clubs_edit_templates %]
152
                                            <a class="btn btn-default" href="#" onclick='ConfirmDeleteTemplate([% t.id %], "[% t.name | html %]", $(this) ); return false;'>
153
                                                <i class="fa fa-trash"></i> Delete
154
                                            </a>
155
                                        [% END %]
156
                                    </td>
157
                                </tr>
158
                            [% END %]
159
                        [% ELSE %]
160
                            <tr>
161
                                <td colspan="7">
162
                                    No club templates defined.
163
                                </td>
164
                            </td>
165
                        [% END %]
166
                    </tbody>
167
                </table>
168
169
                <h3>Clubs</h3>
170
171
                [% IF CAN_user_clubs_edit_clubs %]
172
                    <div class="btn-toolbar">
173
                        <div class="btn-group">
174
                            <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
175
                            <ul class="dropdown-menu">
176
                                [% FOREACH t IN club_templates %]
177
                                    <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id %]">[% t.name %]</a></li>
178
                                [% END %]
179
                            </ul>
180
                        </div>
181
                    </div>
182
                [% END %]
183
184
                <table id="clubs-table">
185
                    <thead>
186
                        <tr>
187
                            <th>Name</th>
188
                            <th>Template</th>
189
                            <th>Description</th>
190
                            <th>Public enrollment</th>
191
                            <th>Email required</th>
192
                            <th>Library</th>
193
                            <th>&nbsp;</th>
194
                            <th>&nbsp;</th>
195
                        </tr>
196
                    </thead>
197
198
                    <tbody>
199
                        [% IF clubs %]
200
                            [% FOREACH c IN clubs %]
201
                                <tr>
202
                                    <td>[% c.name %]</td>
203
                                    <td>[% c.club_template.name %]</td>
204
                                    <td>[% c.description %]</td>
205
                                    <td>
206
                                        [% IF c.club_template.is_enrollable_from_opac %]
207
                                            Yes
208
                                        [% ELSE %]
209
                                            No
210
                                        [% END %]
211
                                    </td>
212
                                    <td>
213
                                        [% IF c.club_template.is_email_required %]
214
                                            Yes
215
                                        [% ELSE %]
216
                                            No
217
                                        [% END %]
218
                                    </td>
219
                                    <td>[% Branches.GetName( c.branchcode ) %]</td>
220
                                    <td>
221
                                        [% IF CAN_user_clubs_edit_clubs %]
222
                                            <a class="btn btn-default" style="white-space:nowrap" href="clubs-add-modify.pl?id=[% c.id %]">
223
                                                <i class="fa fa-edit"></i> Edit
224
                                            </a>
225
                                        [% END %]
226
                                    </td>
227
                                    <td>
228
                                        [% IF CAN_user_clubs_edit_clubs %]
229
                                            <a class="btn btn-default" href="#" onclick='ConfirmDeleteClub([% c.id %], "[% c.name | html %]", $(this) ); return false;'>
230
                                                <i class="fa fa-trash"></i> Delete
231
                                            </a>
232
                                        [% END %]
233
                                    </td>
234
                                </tr>
235
                            [% END %]
236
                        [% ELSE %]
237
                            <tr>
238
                                <td colspan="8">
239
                                    No club templates defined.
240
                                </td>
241
                            </td>
242
                        [% END %]
243
                    </tbody>
244
                </table>
245
            </div>
246
        </div>
247
        <div class="yui-b noprint">
248
            [% INCLUDE 'tools-menu.inc' %]
249
        </div>
250
    </div>
251
</div>
252
[% 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-xs" onclick="cancelEnrollment( [% e.id %] )">
28
                                <i class="fa fa-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-xs" onclick="loadEnrollmentForm([% c.id %])">
61
                                <i class="fa fa-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.GetCategories %]
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 btn-default" onclick="addEnrollment(); return false;"><i class="fa fa-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 (+216 lines)
Line 0 Link Here
1
[% USE Branches %]
2
[% USE AuthorisedValues %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club template</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
</head>
7
8
<body id="clubs_templates_add_modify" class="clubs">
9
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'cat-search.inc' %]
11
<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>
12
13
<div class="yui-t7">
14
    <div class="yui-main">
15
        <form method="post" class="validated">
16
            <input type="hidden" name="id" value="[% club_template.id %]" />
17
18
            <fieldset class="rows">
19
20
                <legend>
21
                    [% IF club_template %]
22
                        Modify club template <i>[% club_template.name %]</i>
23
                    [% ELSE %]
24
                        Create a new club template
25
                    [% END %]
26
                </legend>
27
28
                <ol>
29
                    <li>
30
                        <label class="required" for="name">Name:</label>
31
                        <input id="club-template-name" name="name" type="text" value="[% club_template.name %]" required="required"/>
32
                        <span class="required">Required</span>
33
                    </li>
34
35
                    <li>
36
                        <label for="description">Description:</label>
37
                        <input id="club-template-description" name="description" type="text" value="[% club_template.description %]" />
38
                    </li>
39
40
                    <li>
41
                        <label for="is_enrollable_from_opac">Allow public enrollment:</label>
42
                        [% IF club_template.is_enrollable_from_opac %]
43
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" checked="checked" />
44
                        [% ELSE %]
45
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" />
46
                        [% END %]
47
                        <span class="hint">If a template allows public enrollment, patrons can enroll in a club based on this template from the public catalog.</span>
48
                    </li>
49
50
                    <li>
51
                        <label for="is_email_required">Require valid email address:</label>
52
                        [% IF club_template.is_email_required %]
53
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" checked="checked" />
54
                        [% ELSE %]
55
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" />
56
                        [% END %]
57
                        <span class="hint">If set, a club based on this template can only be enrolled in by patrons with a valid email address.</span>
58
                    </li>
59
60
                    <li>
61
                        <label for="branchcode">Library:</label>
62
                        <select name="branchcode" id="club-template-branchcode">
63
                            <option value="">&nbsp</option>
64
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => club_template.branchcode ) %]
65
                        </select>
66
                        <span class="hint">If set, only librarians logged in with this branch will be able to modify this club template.</span>
67
                    </li>
68
69
                </ol>
70
71
                <h2>Club fields:</h2>
72
                <p><span class="hint">These fields will be used in the creation of clubs based on this template</span></p>
73
                <span id="club-template-fields">
74
                    [% FOREACH f IN club_template.club_template_fields %]
75
                        <ul>
76
                            <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
77
                            <li>
78
                                <label for="field-name-[% f.id %]">Name:</label>
79
                                <input name="club_template_field_name" id="field-name-[% f.id %]" value="[% f.name %]" />
80
                            </li>
81
82
                            <li>
83
                                <label for="field-description-[% f.id %]">Description:</label>
84
                                <input name="club_template_field_description" id="field-description-[% f.id %]" value="[% f.description %]" />
85
                            </li>
86
87
                            <li>
88
                                <label for="field-description-[% f.id %]">Authorised value category:</label>
89
                                <select name="club_template_field_authorised_value_category" id="field-authorised-value-category-[% f.id %]">
90
                                    <option value="">&nbsp;</option>
91
                                    [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => f.authorised_value_category) %]
92
                                </select>
93
                            </li>
94
95
                            <li>
96
                                <label for="field-delete-[% f.id %]">Delete field:</label>
97
                                <input type="checkbox" name="club_template_field_delete" id="field-delete-[% f.id %]" value="[% f.id %]" />
98
                            </li>
99
100
                            <hr/>
101
                        </ul>
102
                    [% END %]
103
                </span>
104
                <div class="btn-toolbar">
105
                    <a href="#" class="btn btn-default" onclick="$('#new-field-template').clone().attr('id','').show().appendTo('#club-template-fields'); return false;">
106
                        <i class="fa fa-plus"></i> Add new field
107
                    </a>
108
                </div>
109
110
                <h2>Enrollment fields:</h2>
111
                <p><span class="hint">These fields will be used when enrolling a patron in a club based on this template</span></p>
112
                <span id="club-template-enrollment-fields">
113
                    [% FOREACH f IN club_template.club_template_enrollment_fields %]
114
                        <ul>
115
                            <input type="hidden" name="club_template_enrollment_field_id" value="[% f.id %]" />
116
                            <li>
117
                                <label for="enrollment-field-name-[% f.id %]">Name:</label>
118
                                <input name="club_template_enrollment_field_name" id="enrollment-field-name-[% f.id %]" value="[% f.name %]" />
119
                            </li>
120
121
                            <li>
122
                                <label for="enrollment-field-description-[% f.id %]">Description:</label>
123
                                <input name="club_template_enrollment_field_description" id="enrollment-field-description-[% f.id %]" value="[% f.description %]" />
124
                            </li>
125
126
                            <li>
127
                                <label for="enrollment-field-description-[% f.id %]">Authorised value category:</label>
128
                                <select name="club_template_enrollment_field_authorised_value_category" id="enrollment-field-authorised-value-category-[% f.id %]">
129
                                    <option value="">&nbsp;</option>
130
                                    [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => f.authorised_value_category) %]
131
                                </select>
132
                            </li>
133
134
                            <li>
135
                                <label for="enrollment-field-delete-[% f.id %]">Delete field:</label>
136
                                <input type="checkbox" name="club_template_enrollment_field_delete" id="enrollment-field-delete-[% f.id %]" value="[% f.id %]" />
137
                            </li>
138
139
                            <hr/>
140
                        </ul>
141
                    [% END %]
142
                </span>
143
                <div class="btn-toolbar">
144
                    <a href="#" class="btn btn-default" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;">
145
                        <i class="fa fa-plus"></i> Add new field
146
                    </a>
147
                </div>
148
149
            </fieldset>
150
151
            <fieldset class="action">
152
                <input type="hidden" name="id" value="[% club_template.id %]" />
153
                <input type="submit" class="btn btn-default" value="Save" />
154
                <a href="clubs.pl" class="cancel">Cancel</a>
155
            </fieldset>
156
        </form>
157
    </div>
158
</div>
159
160
<span id="new-field-template" style="display:none">
161
    <ul>
162
        <input type="hidden" name="club_template_field_id" value="" />
163
164
        <li>
165
            <label for="club_template_field_name">Name:</label>
166
            <input name="club_template_field_name" />
167
        </li>
168
169
        <li>
170
            <label for="club_template_field_description">Description:</label>
171
            <input name="club_template_field_description" />
172
        </li>
173
174
        <li>
175
            <label for="club_template_field_authorised_value_category">Authorised value category:</label>
176
            <select name="club_template_field_authorised_value_category">
177
                <option value="">&nbsp;</option>
178
                [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories() %]
179
            </select>
180
        </li>
181
182
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
183
184
        <hr/>
185
    </ul>
186
</span>
187
188
<span id="new-enrollment-field-template" style="display:none">
189
    <ul>
190
        <input type="hidden" name="club_template_enrollment_field_id" value="" />
191
192
        <li>
193
            <label for="club_template_enrollment_field_name">Name:</label>
194
            <input name="club_template_enrollment_field_name" />
195
        </li>
196
197
        <li>
198
            <label for="club_template_enrollment_field_description">Description:</label>
199
            <input name="club_template_enrollment_field_description" />
200
        </li>
201
202
        <li>
203
            <label for="club_template_enrollment_field_authorised_value_category">Authorised value category:</label>
204
            <select name="club_template_enrollment_field_authorised_value_category">
205
                <option value="">&nbsp;</option>
206
                [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories() %]
207
            </select>
208
        </li>
209
210
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
211
212
        <hr/>
213
    </ul>
214
</span>
215
216
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+22 lines)
Lines 45-50 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); Link Here
45
columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %]
45
columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %]
46
46
47
$(document).ready(function() {
47
$(document).ready(function() {
48
    if ( $('#clubs-tab').length ) {
49
        $('#clubs-tab-link').on('click', function() {
50
            $('#clubs-tab').text(_("Loading..."));
51
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
52
        });
53
    }
54
48
    $('#finesholdsissues').tabs({
55
    $('#finesholdsissues').tabs({
49
        // Correct table sizing for tables hidden in tabs
56
        // Correct table sizing for tables hidden in tabs
50
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
57
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 516-521 function validate1(date) { Link Here
516
            </li>
523
            </li>
517
        [% END %]
524
        [% END %]
518
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
525
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
526
        [% SET enrollments = borrower.get_club_enrollments.size || 0 %]
527
        [% SET enrollable  = borrower.get_enrollable_clubs.size || 0 %]
528
        [% IF CAN_user_clubs && ( enrollments || enrollable ) %]
529
            <li>
530
                <a id="clubs-tab-link" href="#clubs-tab">
531
                    Clubs ([% enrollments %]/[% enrollable %])
532
                </a>
533
            </li>
534
        [% END %]
519
    </ul>
535
    </ul>
520
536
521
[% INCLUDE "checkouts-table.inc" %]
537
[% INCLUDE "checkouts-table.inc" %]
Lines 551-556 function validate1(date) { Link Here
551
    [% END %]
567
    [% END %]
552
</div>
568
</div>
553
569
570
[% IF CAN_user_clubs && ( enrollments || enrollable ) %]
571
    <div id="clubs-tab">
572
        Loading...
573
    </div>
574
[% END %]
575
554
[% INCLUDE borrower_debarments.inc %]
576
[% INCLUDE borrower_debarments.inc %]
555
577
556
<div id="reserves">
578
<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="number_box"><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="number_box"><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-xs" 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 !c.club_template.is_email_required || ( c.club_template.is_email_required && borrower.FirstValidEmailAddress ) %]
60
                            <a class="btn btn-xs" 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.GetCategories %]
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 btn-default" onclick="addEnrollment(); return false;"><i class="fa fa-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 (-1 / +23 lines)
Lines 82-88 Using this account is not recommended because some parts of Koha will not functi Link Here
82
                                    [% ELSIF error == 'too_soon' %]
82
                                    [% ELSIF error == 'too_soon' %]
83
                                        It is too soon after the checkout date for this item to be renewed.
83
                                        It is too soon after the checkout date for this item to be renewed.
84
                                    [% ELSIF error == 'on_reserve' %]
84
                                    [% ELSIF error == 'on_reserve' %]
85
                                        This item is on hold for another patron.
85
                                        This item is on hold for another borrower.
86
                                    [% END %]
86
                                    [% END %]
87
                                [% END %]
87
                                [% END %]
88
                            </span>
88
                            </span>
Lines 133-138 Using this account is not recommended because some parts of Koha will not functi Link Here
133
                                [% IF ( BORROWER_INFO.amountoverzero ) %]<li><a href="#opac-user-fines">Fines ([% amountoutstanding | $Price %])</a></li>[% END %]
133
                                [% IF ( BORROWER_INFO.amountoverzero ) %]<li><a href="#opac-user-fines">Fines ([% amountoutstanding | $Price %])</a></li>[% END %]
134
                                [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %]
134
                                [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %]
135
                            [% END %]
135
                            [% END %]
136
137
                            [% IF borrower.get_club_enrollments.size || borrower.get_enrollable_clubs(1).size %]
138
                                <li>
139
                                    <a id="opac-user-clubs-tab-link" href="#opac-user-clubs">
140
                                        Clubs ([% borrower.get_club_enrollments.size %]/[% borrower.get_enrollable_clubs(1).size || 0 %])
141
                                    </a>
142
                                </li>
143
                            [% END %]
144
136
                            [% IF ( RESERVES.count ) %]<li><a href="#opac-user-holds">Holds ([% RESERVES.count %])</a></li>[% END %]
145
                            [% IF ( RESERVES.count ) %]<li><a href="#opac-user-holds">Holds ([% RESERVES.count %])</a></li>[% END %]
137
                            [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current %]<li><a href="#opac-user-article-requests">Article requests ([% borrower.article_requests_current.count %])</a></li>[% END %]
146
                            [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current %]<li><a href="#opac-user-article-requests">Article requests ([% borrower.article_requests_current.count %])</a></li>[% END %]
138
                            [% IF ( OverDriveCirculation ) %]
147
                            [% IF ( OverDriveCirculation ) %]
Lines 317-322 Using this account is not recommended because some parts of Koha will not functi Link Here
317
                            [% END # IF issues_count %]
326
                            [% END # IF issues_count %]
318
                        </div> <!-- / .opac-user-checkouts -->
327
                        </div> <!-- / .opac-user-checkouts -->
319
328
329
                        [% IF borrower.get_club_enrollments_count.size || borrower.get_enrollable_clubs(1).size %]
330
                            <div id="opac-user-clubs">
331
                                Loading...
332
                            </div>
333
                        [% END %]
334
320
                        [% IF ( OPACFinesTab ) %]
335
                        [% IF ( OPACFinesTab ) %]
321
                            <!-- FINES BOX -->
336
                            <!-- FINES BOX -->
322
                            [% IF BORROWER_INFO.amountoverfive %]
337
                            [% IF BORROWER_INFO.amountoverfive %]
Lines 901-906 Using this account is not recommended because some parts of Koha will not functi Link Here
901
            [% END %]
916
            [% END %]
902
917
903
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
918
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
919
920
            if ( $('#opac-user-clubs').length ) {
921
                $('#opac-user-clubs-tab-link').on('click', function() {
922
                    $('#opac-user-clubs').text(_("Loading..."));
923
                    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]');
924
                });
925
            }
904
        });
926
        });
905
        //]]>
927
        //]]>
906
    </script>
928
    </script>
(-)a/members/moremember.pl (+2 lines)
Lines 63-68 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
63
use DateTime;
63
use DateTime;
64
use Koha::DateUtils;
64
use Koha::DateUtils;
65
use Koha::Database;
65
use Koha::Database;
66
use Koha::Patrons;
66
use Koha::Patron::Categories;
67
use Koha::Patron::Categories;
67
use Koha::Token;
68
use Koha::Token;
68
69
Lines 355-360 $template->param( Link Here
355
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
356
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
356
    relatives_issues_count => $relatives_issues_count,
357
    relatives_issues_count => $relatives_issues_count,
357
    relatives_borrowernumbers => \@relatives,
358
    relatives_borrowernumbers => \@relatives,
359
    borrower => Koha::Patrons->find( $borrowernumber ),
358
);
360
);
359
361
360
output_html_with_http_headers $input, $cookie, $template->output;
362
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::Patrons;
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::Patrons->find($borrowernumber);
42
43
my @enrollments = $borrower->get_club_enrollments();
44
my @clubs = $borrower->get_enrollable_clubs( 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/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 (+49 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::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 } );
(-)a/t/db_dependent/Clubs.t (-1 / +221 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 36;
21
use Test::Warn;
22
23
use C4::Context;
24
use Koha::Database;
25
use Koha::Patrons;
26
27
use t::lib::TestBuilder;
28
29
BEGIN {
30
    use_ok('Koha::Club');
31
    use_ok('Koha::Clubs');
32
    use_ok('Koha::Club::Field');
33
    use_ok('Koha::Club::Fields');
34
    use_ok('Koha::Club::Template');
35
    use_ok('Koha::Club::Templates');
36
    use_ok('Koha::Club::Template::Field');
37
    use_ok('Koha::Club::Template::Fields');
38
    use_ok('Koha::Club::Enrollment::Field');
39
    use_ok('Koha::Club::Enrollment::Fields');
40
    use_ok('Koha::Club::Template::EnrollmentField');
41
    use_ok('Koha::Club::Template::EnrollmentFields');
42
}
43
44
# Start transaction
45
my $database = Koha::Database->new();
46
my $schema   = $database->schema();
47
my $dbh      = C4::Context->dbh;
48
my $builder  = t::lib::TestBuilder->new;
49
50
$schema->storage->txn_begin();
51
$dbh->do("DELETE FROM club_templates");
52
53
my $categorycode = $builder->build( { source => 'Category' } )->{categorycode};
54
my $branchcode   = $builder->build( { source => 'Branch' } )->{branchcode};
55
56
my $patron = Koha::Patron->new(
57
    {
58
        surname      => 'Test 1',
59
        branchcode   => $branchcode,
60
        categorycode => $categorycode
61
    }
62
);
63
$patron->store();
64
65
my $club_template = Koha::Club::Template->new(
66
    {
67
        name                    => "Test Club Template",
68
        is_enrollable_from_opac => 0,
69
        is_email_required       => 0,
70
    }
71
)->store();
72
is( ref($club_template), 'Koha::Club::Template', 'Club template created' );
73
74
# Add some template fields
75
my $club_template_field_1 = Koha::Club::Template::Field->new(
76
    {
77
        club_template_id => $club_template->id,
78
        name             => 'Test Club Template Field 1',
79
    }
80
)->store();
81
is( ref($club_template_field_1),
82
    'Koha::Club::Template::Field', 'Club template field 1 created' );
83
84
my $club_template_field_2 = Koha::Club::Template::Field->new(
85
    {
86
        club_template_id => $club_template->id,
87
        name             => 'Test Club Template Field 2',
88
    }
89
)->store();
90
is( ref($club_template_field_2),
91
    'Koha::Club::Template::Field', 'Club template field 2 created' );
92
93
is( $club_template->club_template_fields->count,
94
    2, 'Club template has two fields' );
95
96
## Add some template enrollment fields
97
my $club_template_enrollment_field_1 =
98
  Koha::Club::Template::EnrollmentField->new(
99
    {
100
        club_template_id => $club_template->id,
101
        name             => 'Test Club Template EnrollmentField 1',
102
    }
103
  )->store();
104
is(
105
    ref($club_template_enrollment_field_1),
106
    'Koha::Club::Template::EnrollmentField',
107
    'Club template field 1 created'
108
);
109
110
my $club_template_enrollment_field_2 =
111
  Koha::Club::Template::EnrollmentField->new(
112
    {
113
        club_template_id => $club_template->id,
114
        name             => 'Test Club Template EnrollmentField 2',
115
    }
116
  )->store();
117
is(
118
    ref($club_template_enrollment_field_2),
119
    'Koha::Club::Template::EnrollmentField',
120
    'Club template field 2 created'
121
);
122
123
is( $club_template->club_template_enrollment_fields->count,
124
    2, 'Club template has two enrollment fields' );
125
126
## Create a club based on this template
127
my $club = Koha::Club->new(
128
    {
129
        club_template_id => $club_template->id,
130
        name             => "Test Club",
131
        branchcode       => $branchcode,
132
    }
133
)->store();
134
135
my $club_field_1 = Koha::Club::Field->new(
136
    {
137
        club_template_field_id => $club_template_field_1->id,
138
        club_id                => $club->id,
139
        value                  => 'TEST',
140
    }
141
)->store();
142
is( ref($club_field_1), 'Koha::Club::Field', 'Club field 1 created' );
143
is(
144
    $club_field_1->club_template_field->id,
145
    $club_template_field_1->id,
146
    'Field 2 is linked to correct template field'
147
);
148
149
my $club_field_2 = Koha::Club::Field->new(
150
    {
151
        club_template_field_id => $club_template_field_2->id,
152
        club_id                => $club->id,
153
        value                  => 'TEST',
154
    }
155
)->store();
156
is( ref($club_field_2), 'Koha::Club::Field', 'Club field 2 created' );
157
is(
158
    $club_field_2->club_template_field->id,
159
    $club_template_field_2->id,
160
    'Field 2 is linked to correct template field'
161
);
162
163
is( ref($club), 'Koha::Club', 'Club created' );
164
is( $club->club_template->id,
165
    $club_template->id, 'Club is using correct template' );
166
is( $club->branch->id, $branchcode, 'Club is using correct branch' );
167
is( $club->club_fields->count, 2, 'Club has correct number of fields' );
168
is( Koha::Clubs->get_enrollable( { borrower => $patron } )->count,
169
    1, 'Koha::Clubs->get_enrollable returns 1 enrollable club for patron' );
170
is( $patron->get_enrollable_clubs->count,
171
    1, 'There is 1 enrollable club for patron' );
172
173
## Create an enrollment for this club
174
my $club_enrollment = Koha::Club::Enrollment->new(
175
    {
176
        club_id        => $club->id,
177
        borrowernumber => $patron->id,
178
        branchcode     => $branchcode,
179
    }
180
)->store();
181
is( ref($club_enrollment), 'Koha::Club::Enrollment',
182
    'Club enrollment created' );
183
184
my $club_enrollment_field_1 = Koha::Club::Enrollment::Field->new(
185
    {
186
        club_enrollment_id => $club_enrollment->id,
187
        club_template_enrollment_field_id =>
188
          $club_template_enrollment_field_1->id,
189
        value => 'TEST',
190
    }
191
)->store();
192
is(
193
    ref($club_enrollment_field_1),
194
    'Koha::Club::Enrollment::Field',
195
    'Enrollment field 1 created'
196
);
197
198
my $club_enrollment_field_2 = Koha::Club::Enrollment::Field->new(
199
    {
200
        club_enrollment_id => $club_enrollment->id,
201
        club_template_enrollment_field_id =>
202
          $club_template_enrollment_field_2->id,
203
        value => 'TEST',
204
    }
205
)->store();
206
is(
207
    ref($club_enrollment_field_2),
208
    'Koha::Club::Enrollment::Field',
209
    'Enrollment field 2 created'
210
);
211
212
is( $club_enrollment->club->id, $club->id, 'Got correct club for enrollment' );
213
is( Koha::Clubs->get_enrollable( { borrower => $patron } )->count,
214
    0, 'Koha::Clubs->get_enrollable returns 0 enrollable clubs for patron' );
215
is( $patron->get_club_enrollments->count,
216
    1, 'Got 1 club enrollment for patron' );
217
is( $patron->get_enrollable_clubs->count,
218
    0, 'No more enrollable clubs for patron' );
219
220
$schema->storage->txn_rollback();
221
1;

Return to bug 12461