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