3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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
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.
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
25 use C4::Dates qw/format_date/;
33 my $op = $query->param('op');
34 my $dbh = C4::Context->dbh;
38 my ($template, $loggedinuser, $cookie);
39 ($template, $loggedinuser, $cookie)
40 = get_template_and_user({template_name => "serials/serials-collection.tmpl",
44 flagsrequired => {serials => 1},
47 my $biblionumber = $query->param('biblionumber');
48 my @subscriptionid = $query->param('subscriptionid');
50 my $subscriptiondescs ;
53 if($op eq "gennext" && @subscriptionid){
54 my $subscriptionid = @subscriptionid[0];
55 my $subscription = GetSubscription($subscriptionid);
57 my $expected = GetNextExpected($subscriptionid);
60 $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
61 $newinnerloop1, $newinnerloop2, $newinnerloop3
62 ) = GetNextSeq($subscription);
64 ## We generate the next publication date
65 my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription );
67 ## Creating the new issue
68 NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
69 1, $nextpublisheddate, $nextpublisheddate );
71 ## Updating the subscription seq status
72 my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
73 WHERE subscriptionid = ?";
74 $sth = $dbh->prepare($squery);
76 $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1,
77 $newinnerloop2, $newinnerloop3, $subscriptionid
80 print $query->redirect('/cgi-bin/koha/serials/serials-collection.pl?subscriptionid='.$subscriptionid);
84 my @subscriptioninformation=();
85 foreach my $subscriptionid (@subscriptionid){
86 my $subs= GetSubscription($subscriptionid);
87 $subs->{opacnote} =~ s/\n/\<br\/\>/g;
88 $subs->{missinglist} =~ s/\n/\<br\/\>/g;
89 $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
90 ##these are display information
91 $subs->{ "periodicity" . $subs->{periodicity} } = 1;
92 $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
93 $subs->{ "status" . $subs->{'status'} } = 1;
94 $subs->{startdate} = format_date( $subs->{startdate} );
95 $subs->{histstartdate} = format_date( $subs->{histstartdate} );
96 if ( $subs->{enddate} eq '0000-00-00' ) {
97 $subs->{enddate} = '';
100 $subs->{enddate} = format_date( $subs->{enddate} );
102 $subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
103 $subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
104 $subs->{'subscriptionid'} = $subscriptionid; # FIXME - why was this lost ?
105 push @$subscriptiondescs,$subs;
106 my $tmpsubscription= GetFullSubscription($subscriptionid);
107 @subscriptioninformation=(@$tmpsubscription,@subscriptioninformation);
109 $subscriptions=PrepareSerialsData(\@subscriptioninformation);
111 $subscriptiondescs = GetSubscriptionsFromBiblionumber($biblionumber) ;
112 my $subscriptioninformation = GetFullSubscriptionsFromBiblionumber($biblionumber);
113 $subscriptions=PrepareSerialsData($subscriptioninformation);
116 my $title = $subscriptiondescs->[0]{bibliotitle};
117 my $yearmax=($subscriptions->[0]{year} eq "manage" && scalar(@$subscriptions)>1)? $subscriptions->[1]{year} :$subscriptions->[0]{year};
118 my $yearmin=$subscriptions->[scalar(@$subscriptions)-1]{year};
119 my $subscriptionidlist="";
120 foreach my $subscription (@$subscriptiondescs){
121 $subscriptionidlist.=$subscription->{'subscriptionid'}."," ;
122 $biblionumber = $subscription->{'bibnum'} unless ($biblionumber);
125 # warn "title : $title yearmax : $yearmax nombre d'elements dans le tableau :".scalar(@$subscriptions);
126 # use Data::Dumper; warn Dumper($subscriptions);
127 chop $subscriptionidlist;
129 onesubscription => (scalar(@$subscriptiondescs)==1),
130 subscriptionidlist => $subscriptionidlist,
131 biblionumber => $biblionumber,
132 subscriptions => $subscriptiondescs,
133 years => $subscriptions,
136 bibliotitle => $title,
137 suggestion => C4::Context->preference("suggestion"),
138 virtualshelves => C4::Context->preference("virtualshelves"),
139 subscr=>$query->param('subscriptionid'),
142 output_html_with_http_headers $query, $cookie, $template->output;