quell warning if format parameter isn't passed to opac-search.pl
[koha.git] / serials / statecollection.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18
19 use strict;
20 use CGI;
21 use C4::Auth;
22 use C4::Dates qw/format_date format_date_in_iso/;
23 use C4::Output;
24 use C4::Context;
25 use C4::Serials;
26
27 my $query = new CGI;
28 my $op = $query->param('op');
29 my $dbh = C4::Context->dbh;
30 my $subscriptionid = $query->param('subscriptionid');
31 my $auser = $query->param('user');
32 my $histstartdate = format_date_in_iso($query->param('histstartdate'));
33 my $enddate = format_date_in_iso($query->param('enddate'));
34 my $recievedlist = $query->param('recievedlist');
35 my $missinglist = $query->param('missinglist');
36 my $opacnote = $query->param('opacnote');
37 my $librariannote = $query->param('librariannote');
38 my @serialids = $query->param('serialid');
39 my @serialseqs = $query->param('serialseq');
40 my @planneddates = $query->param('planneddate');
41 my @notes = $query->param('notes');
42 my @status = $query->param('status');
43
44 my ($template, $loggedinuser, $cookie)
45 = get_template_and_user({template_name => "serials/statecollection.tmpl",
46                                 query => $query,
47                                 type => "intranet",
48                                 authnotrequired => 0,
49                                 flagsrequired => {serials => 1},
50                                 debug => 1,
51                                 });
52
53 my $HasSubscriptionExpired = HasSubscriptionExpired($subscriptionid);
54 my $subscription=GetSubscription($subscriptionid);
55 if ($op eq 'modsubscriptionhistory') {
56         modsubscriptionhistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote);
57 }
58 # change status except, if subscription has expired, for the "waited" issue.
59 if ($op eq 'serialchangestatus') {
60         my $sth = $dbh->prepare("select status from serial where serialid=?");
61         for (my $i=0;$i<=$#serialids;$i++) {
62                 $sth->execute($serialids[$i]);
63                 my ($oldstatus) = $sth->fetchrow;
64                 if ($serialids[$i]) {
65                         serialchangestatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),$status[$i],$notes[$i]) unless ($HasSubscriptionExpired && $oldstatus == 1);
66                 } else {
67                         # add a special issue
68                         if ($serialseqs[$i]) {
69                                 my $subscription=getsubscription($subscriptionid);
70                                 newissue($serialseqs[$i],$subscriptionid,$subscription->{biblionumber},$status[$i], format_date_in_iso($planneddates[$i]));
71                         }
72                 }
73         }
74 }
75 my $subs = &GetSubscription($subscriptionid);
76 my ($totalissues,@serialslist) = GetSerials($subscriptionid,10);
77
78 my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?");
79 $sth->execute($subscriptionid);
80 my $solhistory = $sth->fetchrow_hashref;
81
82         $template->param(
83                         serialslist => \@serialslist,
84                         biblionumber => $subscription->{biblionumber},
85                         histstartdate => format_date($solhistory->{'histstartdate'}),
86                         enddate => format_date($solhistory->{'enddate'}),
87                         recievedlist => $solhistory->{'recievedlist'},
88                         missinglist => $solhistory->{'missinglist'},
89                         opacnote => $solhistory->{'opacnote'},
90                         librariannote => $solhistory->{'librariannote'},
91                         subscriptionid => $subscriptionid,
92                         bibliotitle => $subs->{bibliotitle},
93                         biblionumber => $subs->{biblionumber},
94                         hassubscriptionexpired =>$HasSubscriptionExpired,
95                 );
96 output_html_with_http_headers $query, $cookie, $template->output;