Bug 11944: TT Plugins should not encode strings
[koha.git] / serials / subscription-history.pl
1 #!/usr/bin/perl
2
3 # Copyright 2011-2013 Biblibre SARL
4 #
5 # This file is part of Koha.
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 =head1 NAME
21
22 subscription-history.pl
23
24 =head1 DESCRIPTION
25
26 Modify subscription history
27
28 =cut
29
30 use Modern::Perl;
31
32 use CGI;
33 use C4::Auth;
34 use C4::Output;
35
36 use C4::Biblio;
37 use C4::Dates qw(format_date_in_iso);
38 use C4::Serials;
39
40 my $input = new CGI;
41 my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
42     template_name   => 'serials/subscription-history.tt',
43     query           => $input,
44     type            => 'intranet',
45     authnotrequired => 0,
46     flagsrequired   => { 'serials' => 'edit_subscription' },
47     debug           => 1,
48 } );
49
50 my $subscriptionid  = $input->param('subscriptionid');
51 my $op              = $input->param('op');
52
53 if(!defined $subscriptionid || $subscriptionid eq '') {
54     print $input->redirect('/cgi-bin/koha/serials/serials-home.pl');
55     exit;
56 }
57
58 if($op && $op eq 'mod') {
59     my $histstartdate   = $input->param('histstartdate');
60     my $histenddate     = $input->param('histenddate');
61     my $receivedlist    = $input->param('receivedlist');
62     my $missinglist     = $input->param('missinglist');
63     my $opacnote        = $input->param('opacnote');
64     my $librariannote   = $input->param('librariannote');
65
66     ModSubscriptionHistory( $subscriptionid, format_date_in_iso($histstartdate),
67         format_date_in_iso($histenddate), $receivedlist, $missinglist, $opacnote,
68         $librariannote );
69
70     print $input->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
71     exit;
72 } else {
73     my $history = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
74     my (undef, $biblio) = GetBiblio($history->{'biblionumber'});
75
76     $template->param(
77         subscriptionid  => $subscriptionid,
78         title           => $biblio->{'title'},
79         histstartdate   => $history->{'histstartdate'},
80         histenddate     => $history->{'histenddate'},
81         receivedlist    => $history->{'recievedlist'},
82         missinglist     => $history->{'missinglist'},
83         opacnote        => $history->{'opacnote'},
84         librariannote   => $history->{'librariannote'},
85     );
86
87     output_html_with_http_headers $input, $cookie, $template->output;
88 }