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

(-)a/Koha/Clubs.pm (-16 / +4 lines)
Lines 50-58 sub get_enrollable { Link Here
50
    my $borrower = $params->{borrower};
50
    my $borrower = $params->{borrower};
51
    if ($borrower) {
51
    if ($borrower) {
52
        delete( $params->{borrower} );
52
        delete( $params->{borrower} );
53
        my @enrollments = $borrower->get_club_enrollments();
53
        my $enrollments = $borrower->get_club_enrollments();
54
        if (@enrollments) {
54
        if ($enrollments->count) {
55
            $params->{'me.id'} = { -not_in => [ map { $_->club()->id() } @enrollments ] };
55
            $params->{'me.id'} = { -not_in => [ $enrollments->get_column('id') ] };
56
        }
56
        }
57
    }
57
    }
58
58
Lines 62-80 sub get_enrollable { Link Here
62
        -or => [ 'me.branchcode' => $borrower->branchcode, 'me.branchcode' => undef ]
62
        -or => [ 'me.branchcode' => $borrower->branchcode, 'me.branchcode' => undef ]
63
    ];
63
    ];
64
64
65
    my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } );
65
    return $self->search( $params, { prefetch => 'club_template' } );
66
67
    if (wantarray) {
68
        my $class = ref($self) ? ref($self) : $self;
69
70
        return $class->_wrap( $rs->all() );
71
72
    }
73
    else {
74
        my $class = ref($self) ? ref($self) : $self;
75
76
        return $class->_new_from_dbic($rs);
77
    }
78
}
66
}
79
67
80
=head3 type
68
=head3 type
(-)a/Koha/Patron.pm (-12 / +5 lines)
Lines 600-612 sub first_valid_email_address { Link Here
600
=cut
600
=cut
601
601
602
sub get_club_enrollments {
602
sub get_club_enrollments {
603
    my ( $self, $return_scalar ) = @_;
603
    my ( $self ) = @_;
604
605
    my $e = Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
606
607
    return $e if $return_scalar;
608
604
609
    return wantarray ? $e->as_list : $e;
605
    my $club_rs = $self->_result->club_enrollments->search( { date_canceled => undef } );
606
    return Koha::Club::Enrollments->_new_from_dbic($club_rs);
610
}
607
}
611
608
612
=head3 get_enrollable_clubs
609
=head3 get_enrollable_clubs
Lines 614-620 sub get_club_enrollments { Link Here
614
=cut
611
=cut
615
612
616
sub get_enrollable_clubs {
613
sub get_enrollable_clubs {
617
    my ( $self, $is_enrollable_from_opac, $return_scalar ) = @_;
614
    my ( $self, $is_enrollable_from_opac ) = @_;
618
615
619
    my $params;
616
    my $params;
620
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
617
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
Lines 623-633 sub get_enrollable_clubs { Link Here
623
620
624
    $params->{borrower} = $self;
621
    $params->{borrower} = $self;
625
622
626
    my $e = Koha::Clubs->get_enrollable($params);
623
    return Koha::Clubs->get_enrollable($params);
627
628
    return $e if $return_scalar;
629
630
    return wantarray ? $e->as_list : $e;
631
}
624
}
632
625
633
=head3 type
626
=head3 type
(-)a/clubs/patron-clubs-tab.pl (-4 / +4 lines)
Lines 43-54 my $patronnumber = $cgi->param('borrowernumber'); Link Here
43
43
44
my $patron = Koha::Patrons->find($patronnumber);
44
my $patron = Koha::Patrons->find($patronnumber);
45
45
46
my @enrollments = $patron->get_club_enrollments();
46
my $enrollments = $patron->get_club_enrollments();
47
my @clubs       = $patron->get_enrollable_clubs();
47
my $clubs       = $patron->get_enrollable_clubs();
48
48
49
$template->param(
49
$template->param(
50
    enrollments    => \@enrollments,
50
    enrollments    => $enrollments,
51
    clubs          => \@clubs,
51
    clubs          => $clubs,
52
    borrowernumber => $patronnumber
52
    borrowernumber => $patronnumber
53
);
53
);
54
54
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-5 / +5 lines)
Lines 895-906 No patron matched <span class="ex">[% message | html %]</span> Link Here
895
        [% END %]
895
        [% END %]
896
    </li>
896
    </li>
897
897
898
    [% SET enrollments = patron.get_club_enrollments(1) %]
898
    [% SET nb_enrollments = patron.get_club_enrollments.count %]
899
    [% SET enrollable  = patron.get_enrollable_clubs(0,1) %]
899
    [% SET nb_enrollable  = patron.get_enrollable_clubs.count %]
900
    [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
900
    [% IF CAN_user_clubs && ( nb_enrollable || nb_enrollments ) %]
901
        <li>
901
        <li>
902
            <a id="clubs-tab-link" href="#clubs-tab">
902
            <a id="clubs-tab-link" href="#clubs-tab">
903
                Clubs ([% enrollments.count %]/[% enrollable.count %])
903
                Clubs ([% nb_enrollments %]/[% nb_enrollable %])
904
            </a>
904
            </a>
905
        </li>
905
        </li>
906
    [% END %]
906
    [% END %]
Lines 953-959 No patron matched <span class="ex">[% message | html %]</span> Link Here
953
    </div>
953
    </div>
954
[% END %]
954
[% END %]
955
955
956
[% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
956
[% IF CAN_user_clubs && ( nb_enrollable|| nb_enrollments ) %]
957
    <div id="clubs-tab">
957
    <div id="clubs-tab">
958
        Loading...
958
        Loading...
959
    </div>
959
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt (-2 / +2 lines)
Lines 1-6 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
2
3
[% IF enrollments %]
3
[% IF enrollments.count %]
4
    <table>
4
    <table>
5
        <thead>
5
        <thead>
6
            <tr>
6
            <tr>
Lines 35-41 Link Here
35
    </table>
35
    </table>
36
[% END %]
36
[% END %]
37
37
38
[% IF clubs %]
38
[% IF clubs.count %]
39
    <table>
39
    <table>
40
        <thead>
40
        <thead>
41
            <tr>
41
            <tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-3 / +3 lines)
Lines 524-532 function validate1(date) { Link Here
524
        [% END %]
524
        [% END %]
525
        <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
526
527
        [% SET enrollments = patron.get_club_enrollments(1) %]
527
        [% SET nb_enrollments = patron.get_club_enrollments.count %]
528
        [% SET enrollable  = patron.get_enrollable_clubs(0,1) %]
528
        [% SET nb_enrollable  = patron.get_enrollable_clubs.count %]
529
        [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
529
        [% IF CAN_user_clubs && ( nb_enrollable || nb_enrollments ) %]
530
            <li>
530
            <li>
531
                <a id="clubs-tab-link" href="#clubs-tab">
531
                <a id="clubs-tab-link" href="#clubs-tab">
532
                    Clubs ([% enrollments.count %]/[% enrollable.count %])
532
                    Clubs ([% enrollments.count %]/[% enrollable.count %])
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-5 / +5 lines)
Lines 4-11 Link Here
4
[% USE ItemTypes %]
4
[% USE ItemTypes %]
5
[% USE Price %]
5
[% USE Price %]
6
6
7
[% SET borrower_club_enrollments =  borrower.get_club_enrollments(1) %]
7
[% SET nb_club_enrollments =  borrower.get_club_enrollments.count %]
8
[% SET borrower_enrollable_clubs = borrower.get_enrollable_clubs(1,1) %]
8
[% SET nb_enrollable_clubs = borrower.get_enrollable_clubs(1).count %]
9
9
10
[% INCLUDE 'doc-head-open.inc' %]
10
[% INCLUDE 'doc-head-open.inc' %]
11
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your library home</title>
11
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your library home</title>
Lines 139-148 Using this account is not recommended because some parts of Koha will not functi Link Here
139
                                [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %]
139
                                [% IF ( BORROWER_INFO.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% amountoutstanding | $Price %])</a></li>[% END %]
140
                            [% END %]
140
                            [% END %]
141
141
142
                            [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %]
142
                            [% IF nb_club_enrollments || borrower_enrollable_clubs %]
143
                                <li>
143
                                <li>
144
                                    <a id="opac-user-clubs-tab-link" href="#opac-user-clubs">
144
                                    <a id="opac-user-clubs-tab-link" href="#opac-user-clubs">
145
                                        Clubs ([% borrower_club_enrollments.count || 0 %]/[% borrower_enrollable_clubs.count || 0 %])
145
                                        Clubs ([% nb_club_enrollments %]/[% nb_enrollable_clubs %])
146
                                    </a>
146
                                    </a>
147
                                </li>
147
                                </li>
148
                            [% END %]
148
                            [% END %]
Lines 343-349 Using this account is not recommended because some parts of Koha will not functi Link Here
343
                            [% END # IF issues_count %]
343
                            [% END # IF issues_count %]
344
                        </div> <!-- / .opac-user-checkouts -->
344
                        </div> <!-- / .opac-user-checkouts -->
345
345
346
                        [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %]
346
                        [% IF nb_club_enrollments || nb_enrollable_clubs %]
347
                            <div id="opac-user-clubs">
347
                            <div id="opac-user-clubs">
348
                                Loading...
348
                                Loading...
349
                            </div>
349
                            </div>
(-)a/opac/clubs/clubs-tab.pl (-5 / +4 lines)
Lines 40-51 my $borrowernumber = $cgi->param('borrowernumber'); Link Here
40
40
41
my $borrower = Koha::Patrons->find($borrowernumber);
41
my $borrower = Koha::Patrons->find($borrowernumber);
42
42
43
my @enrollments = $borrower->get_club_enrollments();
43
my $enrollments = $borrower->get_club_enrollments();
44
my @clubs = $borrower->get_enrollable_clubs( my $opac = 1 );
44
my $clubs = $borrower->get_enrollable_clubs( my $opac = 1 );
45
45
46
$template->param(
46
$template->param(
47
    enrollments => \@enrollments,
47
    enrollments => $enrollments,
48
    clubs       => \@clubs,
48
    clubs       => $clubs,
49
    borrower    => $borrower,
49
    borrower    => $borrower,
50
);
50
);
51
51
52
- 

Return to bug 18559