X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=serials%2Flateissues-excel.pl;h=e5cc8498d1eda6e9166fb59fb880561216ef8342;hb=3746ce17ba8caa50bf5c8c9b7154e490f7389f6f;hp=e07eb93c7004a807cda5a50838e62317f0d8b347;hpb=100e6a9808ead4ee8d951da59ead1550e75bb4c3;p=srvgit diff --git a/serials/lateissues-excel.pl b/serials/lateissues-excel.pl index e07eb93c70..e5cc8498d1 100755 --- a/serials/lateissues-excel.pl +++ b/serials/lateissues-excel.pl @@ -1,6 +1,22 @@ #!/usr/bin/perl +# 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 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. + use strict; +use warnings; use CGI; use C4::Auth; use C4::Serials; @@ -28,40 +44,33 @@ my $csv = Text::CSV_XS->new( my $query = new CGI; my $supplierid = $query->param('supplierid'); my @serialid = $query->param('serialid'); -my $op = $query->param('op'); +my $op = $query->param('op') || q{}; my $serialidcount = @serialid; -my %supplierlist = GetSuppliersWithLateIssues; -my @select_supplier; - my @loop1; -my ($count, @lateissues); +my @lateissues; if($op ne 'claims'){ - ($count, @lateissues) = GetLateIssues($supplierid); - for (my $i=0;$i<@lateissues;$i++){ - my @rows1 = ($lateissues[$i]->{'name'}, # lets build up a row - $lateissues[$i]->{'title'}, - $lateissues[$i]->{'serialseq'}, - $lateissues[$i]->{'planneddate'}, - ); - push (@loop1, \@rows1); + @lateissues = GetLateIssues($supplierid); + for my $issue (@lateissues){ + push @loop1, + [ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},]; } } my $totalcount2 = 0; my @loop2; -my ($count2, @missingissues); +my @missingissues; for (my $k=0;$k<@serialid;$k++){ - ($count2, @missingissues) = GetMissingIssues($supplierid, $serialid[$k]); + @missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]); for (my $j=0;$j<@missingissues;$j++){ my @rows2 = ($missingissues[$j]->{'name'}, # lets build up a row - $missingissues[$j]->{'title'}, + $missingissues[$j]->{'title'}, $missingissues[$j]->{'serialseq'}, $missingissues[$j]->{'planneddate'}, ); push (@loop2, \@rows2); } - $totalcount2 = $totalcount2 + $count2; + $totalcount2 += scalar @missingissues; # update claim date to let one know they have looked at this missing item updateClaim($serialid[$k]); } @@ -72,7 +81,7 @@ if($supplierid){ if($missingissues[0]->{'name'}){ # if exists display supplier name in heading for neatness # not necessarily needed as the name will appear in supplier column also $heading = "FOR $missingissues[0]->{'name'}"; - $filename = "_$missingissues[0]->{'name'}"; + $filename = "_$missingissues[0]->{'name'}"; } } @@ -86,7 +95,7 @@ if($op ne 'claims'){ print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n"; for my $row ( @loop1 ) { - + $csv->combine(@$row); my $string = $csv->string; print $string, "\n"; @@ -102,7 +111,7 @@ if($serialidcount == 1){ print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n"; for my $row ( @loop2 ) { - + $csv->combine(@$row); my $string = $csv->string; print $string, "\n"; @@ -111,6 +120,7 @@ for my $row ( @loop2 ) { print ",,,,,,,\n"; print ",,,,,,,\n"; if($op ne 'claims'){ + my $count = scalar @lateissues; print ",,Total Number Late, $count\n"; } if($serialidcount == 1){