Bug 7298: add option to export late orders as CSV
[koha.git] / serials / showpredictionpattern.pl
index e56695c..690705d 100755 (executable)
@@ -1,20 +1,21 @@
 #!/usr/bin/perl
 
-# Copyright 2011 BibLibre SARL
+# Copyright 2011-2013 Biblibre SARL
+#
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 =head1 NAME
 
@@ -55,15 +56,11 @@ my $sublength = $input->param('sublength');
 my $custompattern = $input->param('custompattern');
 
 
-my %val = (
-    locale          => $input->param('locale') // '',
+my %pattern = (
     numberingmethod => $input->param('numberingmethod') // '',
     numbering1      => $input->param('numbering1') // '',
     numbering2      => $input->param('numbering2') // '',
     numbering3      => $input->param('numbering3') // '',
-    lastvalue1      => $input->param('lastvalue1') // '',
-    lastvalue2      => $input->param('lastvalue2') // '',
-    lastvalue3      => $input->param('lastvalue3') // '',
     add1            => $input->param('add1') // '',
     add2            => $input->param('add2') // '',
     add3            => $input->param('add3') // '',
@@ -76,9 +73,6 @@ my %val = (
     every1          => $input->param('every1') // '',
     every2          => $input->param('every2') // '',
     every3          => $input->param('every3') // '',
-    innerloop1      => $input->param('innerloop1') // '',
-    innerloop2      => $input->param('innerloop2') // '',
-    innerloop3      => $input->param('innerloop3') // '',
 );
 
 if(!defined $firstacquidate || $firstacquidate eq ''){
@@ -100,6 +94,13 @@ if($nextacquidate) {
 my $date = $nextacquidate;
 
 my %subscription = (
+    locale      => $input->param('locale') // '',
+    lastvalue1      => $input->param('lastvalue1') // '',
+    lastvalue2      => $input->param('lastvalue2') // '',
+    lastvalue3      => $input->param('lastvalue3') // '',
+    innerloop1      => $input->param('innerloop1') // '',
+    innerloop2      => $input->param('innerloop2') // '',
+    innerloop3      => $input->param('innerloop3') // '',
     irregularity    => '',
     periodicity     => $frequencyid,
     countissuesperunit  => 1,
@@ -114,7 +115,7 @@ if(defined $subscriptionid) {
 }
 
 my @predictions_loop;
-my ($calculated) = GetSeq(\%val);
+my ($calculated) = GetSeq(\%subscription, \%pattern);
 push @predictions_loop, {
     number => $calculated,
     publicationdate => $date,
@@ -159,7 +160,7 @@ while( $i < 1000 ) {
         last;
     }
 
-    ($calculated, $val{'lastvalue1'}, $val{'lastvalue2'}, $val{'lastvalue3'}, $val{'innerloop1'}, $val{'innerloop2'}, $val{'innerloop3'}) = GetNextSeq(\%val);
+    ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern);
     $issuenumber++;
     $line{'number'} = $calculated;
     $line{'issuenumber'} = $issuenumber;