3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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.
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.
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>.
22 use C4::Auth qw( get_template_and_user );
23 use C4::Output qw( output_html_with_http_headers );
25 use C4::Serials qw( GetSubscription );
28 my $op = $query->param('op') || '';
29 my $dbh = C4::Context->dbh;
31 my ( $template, $loggedinuser, $cookie );
32 my $subscriptionid = $query->param('subscriptionid');
33 my $referer = $query->param('referer') || 'detail';
34 my $biblionumber = $query->param('biblionumber');
36 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38 template_name => "opac-alert-subscribe.tt",
41 authnotrequired => 0, # user must be logged in to request
42 # subscription notifications
46 my $subscription = Koha::Subscriptions->find($subscriptionid);
47 my $logged_in_patron = Koha::Patrons->find($loggedinuser);
49 if ( $op eq 'cud-alert_confirmed' ) {
50 $subscription->add_subscriber($logged_in_patron);
51 if ( $referer eq 'serial' ) {
52 print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
55 print $query->redirect("opac-detail.pl?biblionumber=$biblionumber");
58 } elsif ( $op eq 'cud-cancel_confirmed' ) {
59 $subscription->remove_subscriber($logged_in_patron);
60 warn "CANCEL confirmed : $loggedinuser, $subscriptionid";
61 if ( $referer eq 'serial' ) {
62 print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
64 } elsif ( $referer eq 'patron' ) {
65 print $query->redirect("/cgi-bin/koha/opac-alert-subscriptions.pl");
67 print $query->redirect("opac-detail.pl?biblionumber=$biblionumber");
72 my $subscription = &GetSubscription($subscriptionid);
76 bibliotitle => $subscription->{bibliotitle},
77 notes => $subscription->{notes},
78 subscriptionid => $subscriptionid,
79 biblionumber => $biblionumber,
82 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };