Bug 22630: DBRev 19.12.00.081
[koha.git] / opac / opac-alert-subscribe.pl
blob098e42fb0e04d11bb213938190850ac428c388c6
1 #!/usr/bin/perl
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>.
21 use Modern::Perl;
22 use CGI qw ( -utf8 );
23 use C4::Auth;
24 use C4::Output;
25 use C4::Context;
26 use C4::Koha;
27 use C4::Letters;
28 use C4::Serials;
31 my $query = new CGI;
32 my $op = $query->param('op') || '';
33 my $dbh = C4::Context->dbh;
35 my $sth;
36 my ( $template, $loggedinuser, $cookie );
37 my $subscriptionid = $query->param('subscriptionid');
38 my $referer = $query->param('referer') || 'detail';
39 my $biblionumber = $query->param('biblionumber');
41 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "opac-alert-subscribe.tt",
44 query => $query,
45 type => "opac",
46 authnotrequired => 0, # user must logged in to request
47 # subscription notifications
48 debug => 1,
52 my $subscription = Koha::Subscriptions->find( $subscriptionid );
53 my $logged_in_patron = Koha::Patrons->find( $loggedinuser );
55 if ( $op eq 'alert_confirmed' ) {
56 $subscription->add_subscriber( $logged_in_patron );
57 if ( $referer eq 'serial' ) {
58 print $query->redirect(
59 "opac-serial-issues.pl?biblionumber=$biblionumber");
60 exit;
61 } else {
62 print $query->redirect(
63 "opac-detail.pl?biblionumber=$biblionumber");
64 exit;
67 elsif ( $op eq 'cancel_confirmed' ) {
68 $subscription->remove_subscriber( $logged_in_patron );
69 warn "CANCEL confirmed : $loggedinuser, $subscriptionid";
70 if ( $referer eq 'serial' ) {
71 print $query->redirect(
72 "opac-serial-issues.pl?biblionumber=$biblionumber");
73 exit;
74 } else {
75 print $query->redirect(
76 "opac-detail.pl?biblionumber=$biblionumber");
77 exit;
82 else {
83 my $subscription = &GetSubscription($subscriptionid);
84 $template->param(
85 referer => $referer,
86 "typeissue$op" => 1,
87 bibliotitle => $subscription->{bibliotitle},
88 notes => $subscription->{notes},
89 subscriptionid => $subscriptionid,
90 biblionumber => $biblionumber,
93 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };