fixing permissions on scripts
[koha.git] / serials / serials-collection.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::Koha;
26 use C4::Date;
27 use C4::Serials;
28 use C4::Letters;
29 use C4::Output;
30 use C4::Context;
31
32
33 my $query = new CGI;
34 my $op = $query->param('op');
35 my $dbh = C4::Context->dbh;
36
37 my $sth;
38 # my $id;
39 my ($template, $loggedinuser, $cookie);
40 ($template, $loggedinuser, $cookie)
41   = get_template_and_user({template_name => "serials/serials-collection.tmpl",
42                             query => $query,
43                             type => "intranet",
44                             authnotrequired => 0,
45                             flagsrequired => {serials => 1},
46                             debug => 1,
47                             });
48 my $biblionumber = $query->param('biblionumber');
49 my @subscriptionid = $query->param('subscriptionid');
50
51 my $subscriptiondescs ;
52 my $subscriptions;
53 if (@subscriptionid){
54    my @subscriptioninformation=();
55    foreach my $subscriptionid (@subscriptionid){
56     my $subs= GetSubscription($subscriptionid);
57     $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
58     $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
59     $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
60     ##these are display information
61     $subs->{ "periodicity" . $subs->{periodicity} } = 1;
62     $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
63     $subs->{ "status" . $subs->{'status'} } = 1;
64     $subs->{startdate}     = format_date( $subs->{startdate} );
65     $subs->{histstartdate} = format_date( $subs->{histstartdate} );
66     if ( $subs->{enddate} eq '0000-00-00' ) {
67         $subs->{enddate} = '';
68     }
69     else {
70         $subs->{enddate} = format_date( $subs->{enddate} );
71     }
72     $subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
73     $subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
74     push @$subscriptiondescs,$subs;
75     my $tmpsubscription= GetFullSubscription($subscriptionid);
76     @subscriptioninformation=(@$tmpsubscription,@subscriptioninformation);
77   }
78   $subscriptions=PrepareSerialsData(\@subscriptioninformation);
79 } else {
80   $subscriptiondescs = GetSubscriptionsFromBiblionumber($biblionumber) ;
81   my $subscriptioninformation = GetFullSubscriptionsFromBiblionumber($biblionumber);
82   $subscriptions=PrepareSerialsData($subscriptioninformation);
83 }
84
85 my $title = $subscriptiondescs->[0]{bibliotitle};
86 my $yearmax=($subscriptions->[0]{year} eq "manage" && scalar(@$subscriptions)>1)? $subscriptions->[1]{year} :$subscriptions->[0]{year};
87 my $yearmin=$subscriptions->[scalar(@$subscriptions)-1]{year};
88 my $subscriptionidlist="";
89 foreach my $subscription (@$subscriptiondescs){
90   $subscriptionidlist.=$subscription->{'subscriptionid'}."," ;
91   $biblionumber = $subscription->{'bibnum'} unless ($biblionumber);
92 }
93
94 # warn "title : $title yearmax : $yearmax nombre d'elements dans le tableau :".scalar(@$subscriptions);
95 #  use Data::Dumper; warn Dumper($subscriptions);
96 chop $subscriptionidlist;
97 $template->param(
98           onesubscription => (scalar(@$subscriptiondescs)==1),
99           subscriptionidlist => $subscriptionidlist,
100           biblionumber => $biblionumber,
101           subscriptions => $subscriptiondescs,
102           years => $subscriptions,
103           yearmin => $yearmin,
104           yearmax =>$yearmax,
105           bibliotitle => $title,
106           suggestion => C4::Context->preference("suggestion"),
107           virtualshelves => C4::Context->preference("virtualshelves"),
108           subscr=>$query->param('subscriptionid'),
109           );
110
111 output_html_with_http_headers $query, $cookie, $template->output;