bug fix: wrong address for redirect in mancredit.pl and mainvoice.pl
[koha.git] / opac / opac-alert-subscribe.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 # $Id$
21
22 use strict;
23 use CGI;
24 use C4::Auth;
25 use C4::Date;
26 use C4::Output;
27 use C4::Interface::CGI::Output;
28 use C4::Context;
29 use C4::Koha;
30 use C4::Letters;
31 use C4::Serials;
32 # use C4::Search;
33 use HTML::Template;
34
35 my $query = new CGI;
36 my $op = $query->param('op');
37 my $dbh = C4::Context->dbh;
38
39 my $sth;
40 my ($template, $loggedinuser, $cookie);
41 my $externalid = $query->param('externalid');
42 my $alerttype = $query->param('alerttype');
43 my $biblionumber = $query->param('biblionumber');
44
45 ($template, $loggedinuser, $cookie)
46         = get_template_and_user({template_name => "opac-alert-subscribe.tmpl",
47                                 query => $query,
48                                 type => "opac",
49                                 authnotrequired => 1,
50                                 debug => 1,
51                                 });
52
53 if ($op eq 'alert_confirmed') {
54         addalert($loggedinuser,$alerttype,$externalid);
55         if ($alerttype eq 'issue') {
56                 print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
57                 exit;
58         }
59 } elsif ($op eq 'cancel_confirmed') {
60         my $alerts =getalert($loggedinuser,$alerttype,$externalid);
61         foreach (@$alerts) { # we are supposed to have only 1 result, but just in case...
62                 delalert($_->{alertid});
63         }
64         if ($alerttype eq 'issue') {
65                 print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
66                 exit;
67         }
68
69 } else {
70         if ($alerttype eq 'issue') { # alert for subscription issues
71                 my $subscription = &GetSubscription($externalid);
72                 $template->param("typeissue$op" => 1,
73                                                 bibliotitle => $subscription->{bibliotitle},
74                                                 notes => $subscription->{notes},
75                                                 externalid => $externalid,
76                                                 biblionumber => $biblionumber,
77                                                 );
78         } else {
79         }
80         
81 }
82 output_html_with_http_headers $query, $cookie, $template->output;