syncing dev-week and HEAD
[koha.git] / opac / opac-serial-issues.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5 use C4::Auth;
6 use C4::Koha;
7 use C4::Date;
8 use C4::Bull;
9 use C4::Letters;
10 use C4::Output;
11 use C4::Interface::CGI::Output;
12 use C4::Context;
13 use HTML::Template;
14
15 my $query = new CGI;
16 my $op = $query->param('op');
17 my $dbh = C4::Context->dbh;
18 my $selectview = $query->param('selectview');
19 $selectview = C4::Context->preference("SubscriptionHistory") unless $selectview;
20
21 my $sth;
22 # my $id;
23 my ($template, $loggedinuser, $cookie);
24 my $biblionumber = $query->param('biblionumber');
25 if ($selectview eq "full"){
26         my $subscriptions = get_full_subscription_list_from_biblionumber($biblionumber);
27         
28         my $title = $subscriptions->[0]{bibliotitle};
29         my $yearmin=$subscriptions->[0]{year};
30         my $yearmax=$subscriptions->[scalar(@$subscriptions)-1]{year};
31
32         ($template, $loggedinuser, $cookie)
33         = get_template_and_user({template_name => "opac-full-serial-issues.tmpl",
34                                         query => $query,
35                                         type => "opac",
36                                         authnotrequired => 1,
37                                         debug => 1,
38                                         });
39         
40         # replace CR by <br> in librarian note
41         # $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
42         
43         $template->param(
44                 biblionumber => $query->param('biblionumber'),
45                 years => $subscriptions,
46                 yearmin => $yearmin,
47                 yearmax =>$yearmax,
48                 bibliotitle => $title,
49                 suggestion => C4::Context->preference("suggestion"),
50                 virtualshelves => C4::Context->preference("virtualshelves"),
51                 );
52
53 } else {
54         my $subscriptions = get_subscription_list_from_biblionumber($biblionumber);
55         
56         ($template, $loggedinuser, $cookie)
57         = get_template_and_user({template_name => "opac-serial-issues.tmpl",
58                                         query => $query,
59                                         type => "opac",
60                                         authnotrequired => 1,
61                                         debug => 1,
62                                         });
63         
64         # replace CR by <br> in librarian note
65         # $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
66         
67         $template->param(
68                 biblionumber => $query->param('biblionumber'),
69                 subscription_LOOP => $subscriptions,
70                 );
71 }
72 output_html_with_http_headers $query, $cookie, $template->output;