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

(-)a/Koha/Patron.pm (+18 lines)
Lines 2490-2495 sub get_savings { Link Here
2490
    )->next->get_column('total_savings') // 0;
2490
    )->next->get_column('total_savings') // 0;
2491
}
2491
}
2492
2492
2493
=head3 subscription_alerts
2494
2495
    my $subscription_alerts = $patron->subscription_alerts;
2496
2497
Return a Koha::Subscriptions object containing subscriptions for which the patron has subscribed to email alerts.
2498
2499
=cut
2500
2501
sub subscription_alerts {
2502
    my ( $self ) = @_;
2503
2504
    my $schema = Koha::Database->new->schema;
2505
    my @alerts = $schema->resultset('Alert')->search({ borrowernumber => $self->borrowernumber });
2506
    my @subscription_ids = map { $_->externalid } @alerts;
2507
2508
    return Koha::Subscriptions->search({ subscriptionid => \@subscription_ids });
2509
}
2510
2493
=head2 Internal methods
2511
=head2 Internal methods
2494
2512
2495
=head3 _type
2513
=head3 _type
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (+3 lines)
Lines 185-190 Link Here
185
    [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %]
185
    [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %]
186
        [% IF recallsview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/recallshistory.pl?borrowernumber=[% patron.borrowernumber | uri %]">Recalls history</a></li>
186
        [% IF recallsview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/recallshistory.pl?borrowernumber=[% patron.borrowernumber | uri %]">Recalls history</a></li>
187
    [% END %]
187
    [% END %]
188
    [% IF ( CAN_user_serials && patron.subscription_alerts.count ) %]
189
        [% IF alertsview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/subscription-alerts.pl?borrowernumber=[% patron.borrowernumber | uri %]">Subscription alerts ([% patron.subscription_alerts.count | html %])</a></li>
190
    [% END %]
188
</ul></div>
191
</ul></div>
189
192
190
[% IF patronimages && CAN_user_tools_batch_upload_patron_images %]
193
[% IF patronimages && CAN_user_tools_batch_upload_patron_images %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/subscription-alerts.tt (+110 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE AuthorisedValues  %]
4
[% USE Branches %]
5
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Subscription alerts for [% INCLUDE 'patron-title.inc' no_html = 1 %] &rsaquo; Patrons &rsaquo; Koha</title>
8
[% INCLUDE 'doc-head-close.inc' %]
9
</head>
10
11
<body id="pat_subscription_alerts" class="pat">
12
[% WRAPPER 'header.inc' %]
13
    [% INCLUDE 'patron-search-header.inc' %]
14
[% END %]
15
16
[% WRAPPER 'sub-header.inc' %]
17
    [% WRAPPER breadcrumbs %]
18
        [% WRAPPER breadcrumb_item %]
19
            <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
20
        [% END %]
21
        [% WRAPPER breadcrumb_item %]
22
            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
23
        [% END %]
24
        [% WRAPPER breadcrumb_item bc_active= 1 %]
25
            <span>Subscription alerts</span>
26
        [% END %]
27
    [% END #/ WRAPPER breadcrumbs %]
28
[% END #/ WRAPPER sub-header.inc %]
29
30
<div class="main container-fluid">
31
    <div class="row">
32
        <div class="col-sm-10 col-sm-push-2">
33
            <main>
34
35
                [% INCLUDE 'members-toolbar.inc' %]
36
                <h1>Subscription alerts</h1>
37
38
                [% IF patron.subscription_alerts.count %]
39
                    <div class="page-section">
40
                        <table id="alerts">
41
                            <thead>
42
                                <tr>
43
                                <th>ISSN</th>
44
                                <th>Title</th>
45
                                <th>Library</th>
46
                                <th>Location</th>
47
                                <th>Call number</th>
48
                                <th>Actions</th>
49
                                </tr>
50
                            </thead>
51
52
                            <tbody>
53
                                [% FOREACH sub IN patron.subscription_alerts %]
54
                                    <tr>
55
                                        <td>
56
                                            [% IF sub.biblio.biblioitem.issn %][% sub.biblio.biblioitem.issn | html %][% END %]
57
                                        </td>
58
                                        <td>
59
                                            <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid | uri %]" class="button" title="subscription detail">[% sub.biblio.title | html %] [% sub.biblio.subtitle | html %]</a>
60
                                        </td>
61
                                        <td>
62
                                            [% IF ( sub.branchcode ) %][% Branches.GetName( sub.branchcode ) | html %][% END %]
63
                                        </td>
64
                                        <td>
65
                                            [% IF ( sub.location ) %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => sub.location ) | html %][% END %]
66
                                        </td>
67
                                        <td>
68
                                            [% IF ( sub.callnumber ) %][% sub.callnumber | html %][% END %]
69
                                        </td>
70
                                        <td class="actions">
71
                                            <form action="/cgi-bin/koha/members/subscription-alerts.pl" method="post">
72
                                                <input type="hidden" name="subscription_id" value="[% sub.subscriptionid %]">
73
                                                <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]">
74
                                                <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-times"></i> Unsubscribe from email alerts</button>
75
                                            </form>
76
                                        </td>
77
                                    </tr>
78
                                [% END %]
79
                            </tbody>
80
                        </table>
81
                </div> <!-- /.page-section -->
82
                [% ELSE %]
83
                    <div class="dialog message">
84
                        <p>This patron has not subscribed to email alerts for any subscriptions.</p>
85
                    </div>
86
                [% END %]
87
88
            </main>
89
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
90
91
        <div class="col-sm-2 col-sm-pull-10">
92
            <aside>
93
                [% INCLUDE 'circ-menu.inc' %]
94
            </aside>
95
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
96
     </div> <!-- /.row -->
97
98
[% MACRO jsinclude BLOCK %]
99
    [% INCLUDE 'str/members-menu.inc' %]
100
    [% Asset.js("js/members-menu.js") | $raw %]
101
    [% INCLUDE 'datatables.inc' %]
102
    <script>
103
        $(document).ready(function() {
104
            $("#alerts").dataTable($.extend(true, {}, dataTablesDefaults, {
105
            }));
106
        });
107
    </script>
108
[% END %]
109
110
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/members/subscription-alerts.pl (-1 / +56 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2023 Aleisha Amohia <aleisha@catalyst.net.nz>
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 qw ( -utf8 );
23
use C4::Auth qw( get_template_and_user );
24
use C4::Context;
25
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
26
use Koha::Patrons;
27
28
my $input = CGI->new;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {   template_name   => "members/subscription-alerts.tt",
32
        query           => $input,
33
        type            => "intranet",
34
        flagsrequired   => { serials => '*' },
35
    }
36
);
37
38
my $borrowernumber = $input->param('borrowernumber');
39
40
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
41
my $patron         = Koha::Patrons->find( $borrowernumber );
42
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
43
44
my $subscription_id = $input->param('subscription_id');
45
if ( $subscription_id ) {
46
    my $subscription = Koha::Subscriptions->find( $subscription_id );
47
    $subscription->remove_subscriber( $patron );
48
    print $input->redirect("/cgi-bin/koha/members/subscription-alerts.pl?borrowernumber=".$borrowernumber);
49
}
50
51
$template->param(
52
    patron => $patron,
53
    alertsview  => 1,
54
);
55
56
output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 28130