From c9f3ede16119935beb7895f06f230e82df8396f7 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Mon, 7 Sep 2009 13:03:10 +0100 Subject: [PATCH] Enable warnings in serial scripts Remove some superfluous variables Simplify some loops over lists Fix generated warnings Strip whitespace from line endings Signed-off-by: Galen Charlton --- serials/acqui-search-result.pl | 45 +++++++++++++++--------------- serials/acqui-search.pl | 28 +++++++++---------- serials/checkexpiration.pl | 1 + serials/claims.pl | 12 +++++--- serials/lateissues-excel.pl | 21 ++++++-------- serials/member-search.pl | 3 +- serials/routing-preview.pl | 20 ++++++------- serials/routing.pl | 29 +++++++++++++------ serials/serial-issues.pl | 6 ++-- serials/serials-collection.pl | 12 ++++---- serials/serials-edit.pl | 41 ++++++++++++++------------- serials/serials-home.pl | 21 +++++++------- serials/subscription-add.pl | 26 ++++++++--------- serials/subscription-bib-search.pl | 9 +++--- serials/subscription-detail.pl | 43 +++++++++++++++++----------- serials/subscription-renew.pl | 12 +++----- 16 files changed, 178 insertions(+), 151 deletions(-) diff --git a/serials/acqui-search-result.pl b/serials/acqui-search-result.pl index 4f410bd70c..df73738cb1 100755 --- a/serials/acqui-search-result.pl +++ b/serials/acqui-search-result.pl @@ -40,6 +40,7 @@ acqui-search-result.pl use strict; +use warnings; use C4::Auth; use C4::Biblio; use C4::Output; @@ -60,33 +61,33 @@ my ($template, $loggedinuser, $cookie) my $supplier=$query->param('supplier'); my @suppliers = GetBookSeller($supplier); -my $count = scalar @suppliers; +#my $count = scalar @suppliers; #build result page -my @loop_suppliers; -for (my $i=0; $i<$count; $i++) { - my $orders = GetPendingOrders($suppliers[$i]->{'id'}); - my $ordcount = scalar @$orders; +my $loop_suppliers = []; +for my $s (@suppliers) { + my $orders = GetPendingOrders($s->{'id'}); - my %line; - $line{aqbooksellerid} =$suppliers[$i]->{'id'}; - $line{name} = $suppliers[$i]->{'name'}; - $line{active} = $suppliers[$i]->{'active'}; - my @loop_basket; - for (my $i2=0;$i2<$ordcount;$i2++){ - my %inner_line; - $inner_line{basketno} =$orders->[$i2]->{'basketno'}; - $inner_line{total} =$orders->[$i2]->{'count(*)'}; - $inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'}; - $inner_line{creationdate} = format_date($orders->[$i2]->{'creationdate'}); - $inner_line{closedate} = format_date($orders->[$i2]->{'closedate'}); - push @loop_basket, \%inner_line; + my $loop_basket = []; + for my $ord ( @{$orders} ) { + push @{$loop_basket}, { + basketno => $ord->{'basketno'}, + total => $ord->{'count(*)'}, + authorisedby => $ord->{'authorisedby'}, + creationdate => format_date($ord->{'creationdate'}), + closedate => format_date($ord->{'closedate'}), + }; } - $line{loop_basket} = \@loop_basket; - push @loop_suppliers, \%line; + push @{$loop_suppliers}, { + loop_basket => $loop_basket, + aqbooksellerid => $s->{'id'}, + name => $s->{'name'}, + active => $s->{'active'}, + }; } -$template->param(loop_suppliers => \@loop_suppliers, + +$template->param(loop_suppliers => $loop_suppliers, supplier => $supplier, - count => $count); + count => scalar @suppliers); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/serials/acqui-search.pl b/serials/acqui-search.pl index 7461a8a139..408ac83740 100755 --- a/serials/acqui-search.pl +++ b/serials/acqui-search.pl @@ -19,6 +19,7 @@ use strict; +use warnings; use CGI; use C4::Auth; use C4::Output; @@ -53,18 +54,18 @@ my $totspent = 0; my $totcomtd = 0; my $totavail = 0; my @loop_budget = (); -for ( my $i = 0 ; $i < $count ; $i++ ) { +for my $r (@results) { my ( $spent, $comtd ) = - GetBookFundBreakdown( $results[$i]->{'bookfundid'} ); - my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd ); + GetBookFundBreakdown( $r->{'bookfundid'} ); + my $avail = $r->{'budgetamount'} - ( $spent + $comtd ); my %line; - $line{bookfundname} = $results[$i]->{'bookfundname'}; - $line{budgetamount} = $results[$i]->{'budgetamount'}; + $line{bookfundname} = $r->{'bookfundname'}; + $line{budgetamount} = $r->{'budgetamount'}; $line{spent} = sprintf( "%.2f", $spent ); $line{comtd} = sprintf( "%.2f", $comtd ); $line{avail} = sprintf( "%.2f", $avail ); push @loop_budget, \%line; - $total += $results[$i]->{'budgetamount'}; + $total += $r->{'budgetamount'}; $totspent += $spent; $totcomtd += $comtd; $totavail += $avail; @@ -72,20 +73,19 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { #currencies my @rates = GetCurrencies(); -$count = scalar @rates; -my @loop_currency = (); -for ( my $i = 0 ; $i < $count ; $i++ ) { - my %line; - $line{currency} = $rates[$i]->{'currency'}; - $line{rate} = $rates[$i]->{'rate'}; - push @loop_currency, \%line; +my $loop_currency = []; +for my $r (@rates) { + push @{$loop_currency}, { + currency => $r->{'currency'}, + rate => $r->{'rate'}, + }; } $template->param( classlist => $classlist, type => 'intranet', loop_budget => \@loop_budget, - loop_currency => \@loop_currency, + loop_currency => $loop_currency, total => sprintf( "%.2f", $total ), totspent => sprintf( "%.2f", $totspent ), totcomtd => sprintf( "%.2f", $totcomtd ), diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl index 5461aa6946..865e163a72 100755 --- a/serials/checkexpiration.pl +++ b/serials/checkexpiration.pl @@ -43,6 +43,7 @@ The date to filter on. =cut use strict; +use warnings; use CGI; use C4::Auth; use C4::Serials; # GetExpirationDate diff --git a/serials/claims.pl b/serials/claims.pl index 8fcea93ab6..cbb6fd686b 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; +use warnings; use CGI; use C4::Auth; use C4::Serials; @@ -44,7 +45,10 @@ foreach (keys %$letters){ } my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code})); -my ($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order) if $supplierid; +my ($count2, @missingissues); +if ($supplierid) { + ($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order); +} my $CGIsupplier=CGI::scrolling_list( -name => 'supplierid', -id => 'supplierid', @@ -58,13 +62,13 @@ my ($singlesupplier,@supplierinfo); if($supplierid){ (@supplierinfo)=GetBookSeller($supplierid); } else { # set up supplierid for the claim links out of main table if all suppliers is chosen - for(my $i=0; $i<@missingissues;$i++){ - $missingissues[$i]->{'supplierid'} = getsupplierbyserialid($missingissues[$i]->{'serialid'}); + for my $mi (@missingissues){ + $mi->{supplierid} = getsupplierbyserialid($mi->{serialid}); } } my $preview=0; -if($op eq 'preview'){ +if($op && $op eq 'preview'){ $preview = 1; } else { my @serialnums=$input->param('serialid'); diff --git a/serials/lateissues-excel.pl b/serials/lateissues-excel.pl index 7433a6711d..6110bcdda2 100755 --- a/serials/lateissues-excel.pl +++ b/serials/lateissues-excel.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; +use warnings; use CGI; use C4::Auth; use C4::Serials; @@ -28,7 +29,7 @@ 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; @@ -38,13 +39,9 @@ my @loop1; my ($count, @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); + for my $issue (@lateissues){ + push @loop1, + [ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},]; } } my $totalcount2 = 0; @@ -55,7 +52,7 @@ for (my $k=0;$k<@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'}, ); @@ -72,7 +69,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 +83,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 +99,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"; diff --git a/serials/member-search.pl b/serials/member-search.pl index fbb9a6fd93..a2063f8823 100755 --- a/serials/member-search.pl +++ b/serials/member-search.pl @@ -18,10 +18,11 @@ =head1 member-search.pl Member Search.pl script used to search for members to add to a routing list - + =cut use strict; +use warnings; use CGI; use C4::Auth; # get_template_and_user use C4::Output; diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index 9cac0aa05c..8e9add2ed3 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -4,6 +4,7 @@ # lets one print out routing slip and create (in this instance) the heirarchy # of reserves for the serial use strict; +use warnings; use CGI; use C4::Koha; use C4::Auth; @@ -31,14 +32,14 @@ my $dbh = C4::Context->dbh; if($delete){ delroutingmember($routingid,$subscriptionid); my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?"); - $sth->execute($subscriptionid); - print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new"); + $sth->execute($subscriptionid); + print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new"); } if($edit){ print $query->redirect("routing.pl?subscriptionid=$subscriptionid"); } - + my ($routing, @routinglist) = getroutinglist($subscriptionid); my $subs = GetSubscription($subscriptionid); my ($count,@serials) = GetSerials($subscriptionid); @@ -47,7 +48,7 @@ my ($template, $loggedinuser, $cookie); if($ok){ # get biblio information.... my $biblio = $subs->{'biblionumber'}; - + # get existing reserves ..... my ($count,$reserves) = GetReservesFromBiblionumber($biblio); my $totalcount = $count; @@ -74,8 +75,8 @@ if($ok){ AddReserve($branch,$routinglist[$i]->{'borrowernumber'},$biblio,$const,\@bibitems,$routinglist[$i]->{'ranking'},'',$notes,$title); } } - - + + ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "serials/routing-preview-slip.tmpl", query => $query, @@ -94,9 +95,8 @@ if($ok){ flagsrequired => {serials => 1}, debug => 1, }); -} +} -# my $firstdate = "$serials[0]->{'serialseq'} ($serials[0]->{'planneddate'})"; my @results; my $data; for(my $i=0;$i<$routing;$i++){ @@ -110,13 +110,13 @@ for(my $i=0;$i<$routing;$i++){ my $routingnotes = $serials[0]->{'routingnotes'}; $routingnotes =~ s/\n/\
/g; - + $template->param( title => $subs->{'bibliotitle'}, issue => $issue, issue_escaped => URI::Escape::uri_escape($issue), subscriptionid => $subscriptionid, - memberloop => \@results, + memberloop => \@results, routingnotes => $routingnotes, ); diff --git a/serials/routing.pl b/serials/routing.pl index 11fcf6c866..d49d450d4b 100755 --- a/serials/routing.pl +++ b/serials/routing.pl @@ -26,6 +26,7 @@ printed out =cut use strict; +use warnings; use CGI; use C4::Koha; use C4::Auth; @@ -46,7 +47,7 @@ my $serialseq = $query->param('serialseq'); my $routingid = $query->param('routingid'); my $borrowernumber = $query->param('borrowernumber'); my $notes = $query->param('notes'); -my $op = $query->param('op'); +my $op = $query->param('op') || q{}; my $date_selected = $query->param('date_selected'); my $dbh = C4::Context->dbh; @@ -63,7 +64,7 @@ if($op eq 'save'){ my $urldate = URI::Escape::uri_escape($date_selected); print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate"); } - + my ($routing, @routinglist) = getroutinglist($subscriptionid); my $subs = GetSubscription($subscriptionid); my ($count,@serials) = GetSerials($subscriptionid); @@ -104,26 +105,38 @@ my ($template, $loggedinuser, $cookie) # } # my $issue = "$serialseq ($date)"; - + my @results; my $data; for(my $i=0;$i<$routing;$i++){ $data=GetMember($routinglist[$i]->{'borrowernumber'},'borrowernumber'); $data->{'location'}=$data->{'branchcode'}; - $data->{'name'}="$data->{'firstname'} $data->{'surname'}"; + if ($data->{firstname} ) { + $data->{name} = $data->{firstname} . q| |; + } + else { + $data->{name} = q{}; + } + if ($data->{surname} ) { + $data->{name} .= $data->{surname}; + } $data->{'routingid'}=$routinglist[$i]->{'routingid'}; $data->{'subscriptionid'}=$subscriptionid; - my $rankingbox = ''; for(my $j=1; $j <= $routing; $j++) { $rankingbox .= ""; } $rankingbox .= ""; $data->{'routingbox'} = $rankingbox; - + push(@results, $data); } @@ -139,7 +152,7 @@ if ($op eq 'new') { $template->param( title => $subs->{'bibliotitle'}, subscriptionid => $subscriptionid, - memberloop => \@results, + memberloop => \@results, op => $new, dates => \@dates, routingnotes => $serials[0]->{'routingnotes'}, diff --git a/serials/serial-issues.pl b/serials/serial-issues.pl index 127d4c55c0..842876a688 100755 --- a/serials/serial-issues.pl +++ b/serials/serial-issues.pl @@ -42,6 +42,7 @@ the biblionumber this script has to give more infos. =cut use strict; +use warnings; use CGI; use C4::Auth; use C4::Koha; @@ -57,7 +58,6 @@ my $selectview = $query->param('selectview'); $selectview = C4::Context->preference("SubscriptionHistory") unless $selectview; my $sth; -# my $id; my ($template, $loggedinuser, $cookie); my $biblionumber = $query->param('biblionumber'); if ($selectview eq "full"){ @@ -75,10 +75,10 @@ if ($selectview eq "full"){ flagsrequired => {serials => 1}, debug => 1, }); - + # replace CR by
in librarian note # $subscription->{opacnote} =~ s/\n/\/g; - + $template->param( biblionumber => $query->param('biblionumber'), years => $subscriptions, diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index baef9b9d7c..c80886b3c0 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -19,6 +19,7 @@ use strict; +use warnings; use CGI; use C4::Auth; use C4::Koha; @@ -50,8 +51,9 @@ my @subscriptionid = $query->param('subscriptionid'); my $subscriptiondescs ; my $subscriptions; -if($op eq "gennext" && @subscriptionid){ - my $subscriptionid = @subscriptionid[0]; +$op ||= q{}; +if($op eq 'gennext' && @subscriptionid){ + my $subscriptionid = $subscriptionid[0]; my $subscription = GetSubscription($subscriptionid); my $sth = $dbh->prepare("SELECT publisheddate, serialid, serialseq, planneddate @@ -69,13 +71,13 @@ if($op eq "gennext" && @subscriptionid){ $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq($subscription); - + ## We generate the next publication date my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription ); ## Creating the new issue NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpublisheddate, $nextpublisheddate ); - + ## Updating the subscription seq status my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? WHERE subscriptionid = ?"; @@ -103,7 +105,7 @@ if (@subscriptionid){ $subs->{ "status" . $subs->{'status'} } = 1; $subs->{startdate} = format_date( $subs->{startdate} ); $subs->{histstartdate} = format_date( $subs->{histstartdate} ); - if ( $subs->{enddate} eq '0000-00-00' ) { + if ( !defined $subs->{enddate} || $subs->{enddate} eq '0000-00-00' ) { $subs->{enddate} = ''; } else { diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 9994e445b4..08eae33f88 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -28,7 +28,7 @@ serials-recieve.pl =item op op can be : - * modsubscriptionhistory :to modify the subscription history + * modsubscriptionhistory :to modify the subscription history * serialchangestatus :to modify the status of this subscription =item subscriptionid @@ -63,6 +63,7 @@ op can be : use strict; +use warnings; use CGI; use C4::Auth; use C4::Dates qw/format_date format_date_in_iso/; @@ -90,7 +91,6 @@ if (scalar(@subscriptionids)==1 && index($subscriptionids[0],",")>0){ } my @errors; my @errseq; -my $redirectstring; # If user comes from subscription details unless (@serialids){ foreach my $subscriptionid (@subscriptionids){ @@ -107,7 +107,7 @@ unless (@serialids){ unless (scalar(@serialids)){ my $string="serials-collection.pl?subscriptionid=".join(",",@subscriptionids); $string=~s/,$//; -# warn $string; +# warn $string; print $query->redirect($string); } my ($template, $loggedinuser, $cookie) @@ -130,7 +130,7 @@ foreach my $tmpserialid (@serialids){ $data->{planneddate}=format_date($data->{planneddate}); $data->{'editdisable'}=((HasSubscriptionExpired($data->{subscriptionid})&& $data->{'status1'})||$data->{'cannotedit'}); push @serialdatalist,$data; - $processedserialid{$tmpserialid}=1; + $processedserialid{$tmpserialid}=1; } my $bibdata=GetBiblioData($serialdatalist[0]->{'biblionumber'}); @@ -143,7 +143,7 @@ foreach my $subscriptionid (@subscriptionids){ next unless (defined($subscriptionid) && !$processedsubscriptionid{$subscriptionid}); my $cell; if ($serialdatalist[0]->{'serialsadditems'}){ - #Create New empty item + #Create New empty item $cell = PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'},'', GetSubscription($subscriptionid)); $cell->{serialsadditems} = 1; @@ -157,12 +157,12 @@ foreach my $subscriptionid (@subscriptionids){ 'abouttoexpire'=>abouttoexpire($subscriptionid), 'subscriptionexpired'=>HasSubscriptionExpired($subscriptionid), }; - $processedsubscriptionid{$subscriptionid}=1; + $processedsubscriptionid{$subscriptionid}=1; } $template->param(newserialloop=>\@newserialloop); $template->param(subscriptions=>\@subscriptionloop); -if ($op eq 'serialchangestatus') { +if ($op and $op eq 'serialchangestatus') { # my $sth = $dbh->prepare("select status from serial where serialid=?"); my $newserial; for (my $i=0;$i<=$#serialids;$i++) { @@ -247,15 +247,18 @@ if ($op eq 'serialchangestatus') { } } # check for item barcode # being unique - my $exists = GetItemnumberFromBarcode($record->subfield($barcodetagfield,$barcodetagsubfield)) if ($record->subfield($barcodetagfield,$barcodetagsubfield)); - # push @errors,"barcode_not_unique" if($exists); + my $exists; + if ($record->subfield($barcodetagfield,$barcodetagsubfield)) { + $exists = GetItemnumberFromBarcode($record->subfield($barcodetagfield,$barcodetagsubfield)); + } + # push @errors,"barcode_not_unique" if($exists); # if barcode exists, don't create, but report The problem. - if ($exists){ - push @errors,"barcode_not_unique" if($exists); - push @errseq,{"serialseq"=>$serialseqs[$index]}; + if ($exists){ + push @errors,"barcode_not_unique" if($exists); + push @errseq,{"serialseq"=>$serialseqs[$index]}; } else { - my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$itemhash{$item}->{'bibnum'}); - AddItem2Serial($itemhash{$item}->{'serial'},$itemnumber); + my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$itemhash{$item}->{'bibnum'}); + AddItem2Serial($itemhash{$item}->{'serial'},$itemnumber); } } else { #modify item @@ -264,7 +267,7 @@ if ($op eq 'serialchangestatus') { } } } -# ### FIXME this part of code is not very pretty. Nor is it very efficient... There MUST be a more perlish way to write it. But it works. +# ### FIXME this part of code is not very pretty. Nor is it very efficient... There MUST be a more perlish way to write it. But it works. # my $redirect ="serials-home.pl?"; # $redirect.=join("&",map{"serialseq=".$_} @serialseqs); # $redirect.="&".join("&",map{"planneddate=".$_} @planneddates); @@ -276,9 +279,9 @@ if ($op eq 'serialchangestatus') { $template->param("Errors" => 1); if (scalar(@errseq)>0){ $template->param("barcode_not_unique" => 1); - $template->param('errseq'=>\@errseq); - } - } else { + $template->param('errseq'=>\@errseq); + } + } else { my $redirect ="serials-collection.pl?"; my %hashsubscription; foreach (@subscriptionids) { @@ -286,7 +289,7 @@ if ($op eq 'serialchangestatus') { } $redirect.=join("&",map{"subscriptionid=".$_} sort keys %hashsubscription); print $query->redirect("$redirect"); - } + } } $template->param( diff --git a/serials/serials-home.pl b/serials/serials-home.pl index 7b0c464ac9..ec2ddee948 100755 --- a/serials/serials-home.pl +++ b/serials/serials-home.pl @@ -41,6 +41,7 @@ this script is the main page for serials/ =cut use strict; +use warnings; use CGI; use C4::Auth; use C4::Serials; @@ -79,14 +80,14 @@ if (@serialseqs){ ### FIXME This limitation that a serial must be given a title may not be very efficient for some library who do not update serials titles. push @information, { serialseq=>$seq, - publisheddate=>$publisheddates[$index], - planneddate=>$planneddates[$index], - notes=>$notes[$index], + publisheddate=>$publisheddates[$index], + planneddate=>$planneddates[$index], + notes=>$notes[$index], status=>$status[$index] - } - } - $index++; - } + } + } + $index++; + } $template->param('information'=>\@information); } my @subscriptions; @@ -96,10 +97,8 @@ if ($searched){ # to toggle between create or edit routing list options if ($routing) { - for ( my $i = 0 ; $i < @subscriptions ; $i++ ) { - my $checkrouting = - check_routing( $subscriptions[$i]->{'subscriptionid'} ); - $subscriptions[$i]->{'routingedit'} = $checkrouting; + for my $subscription ( @subscriptions) { + $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); } } diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index e6f9e83e67..4fbf8c2f12 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -41,7 +41,7 @@ my ($subscriptionid,$auser,$branchcode,$librarian,$cost,$aqbooksellerid, $aqbook $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $biblionumber, + $numberingmethod, $status, $biblionumber, $bibliotitle, $callnumber, $notes, $hemisphere, $letter, $manualhistory,$serialsadditems, $location); my @budgets; @@ -59,7 +59,7 @@ my ($template, $loggedinuser, $cookie) my $sub_on; my @subscription_types = ( 'issues', 'weeks', 'months' - ); + ); my @sub_type_data; my $subs; @@ -74,7 +74,7 @@ if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') { if ($subs->{'cannotedit'} && $op eq 'mod'){ warn "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); - } + } $firstissuedate = $subs->{firstacquidate}; # in iso format. for (qw(startdate firstacquidate histstartdate enddate histenddate)) { next unless defined $subs->{$_}; @@ -82,7 +82,7 @@ if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') { if ($subs->{$_} eq '0000-00-00') { $subs->{$_} = '' } else { - $subs->{$_} = format_date($subs->{$_}); + $subs->{$_} = format_date($subs->{$_}); } } $subs->{'letter'}='' unless($subs->{'letter'}); @@ -100,7 +100,7 @@ if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') { last; } } - + $template->param($subs); $template->param("dow".$subs->{'dow'} => 1) if defined $subs->{'dow'}; $template->param( @@ -115,9 +115,9 @@ if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') { } } -my $onlymine=C4::Context->preference('IndependantBranches') && - C4::Context->userenv && - C4::Context->userenv->{flags} % 2 !=1 && +my $onlymine=C4::Context->preference('IndependantBranches') && + C4::Context->userenv && + C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{branch}; my $branches = GetBranches($onlymine); my @branchloop; @@ -144,9 +144,9 @@ if ($op eq 'addsubscription') { my $branchcode = $query->param('branchcode'); my $aqbooksellerid = $query->param('aqbooksellerid'); my $cost = $query->param('cost'); - my $aqbudgetid = $query->param('aqbudgetid'); + my $aqbudgetid = $query->param('aqbudgetid'); my $startdate = $query->param('startdate'); - my $firstacquidate = $query->param('firstacquidate'); + my $firstacquidate = $query->param('firstacquidate'); my $periodicity = $query->param('periodicity'); my $dow = $query->param('dow'); my @irregularity = $query->param('irregularity_select'); @@ -281,7 +281,7 @@ if ($op eq 'addsubscription') { # if we have not received any issues yet, then we also must change the firstacquidate for the subs. $firstissuedate = $nextacquidate if($nextexpected->{isfirstissue}); } - + if ($history_only) { ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote); } else { @@ -311,7 +311,7 @@ if ($op eq 'addsubscription') { $row{'selected'} = ''; } push( @sub_type_data, \%row ); - } + } $template->param(subtype => \@sub_type_data, ); @@ -339,5 +339,5 @@ sub letter_loop { }; } $template->param(letterloop => \@letterloop) if @letterloop; + return; } - diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl index e486f0c5a4..fc70f09f94 100755 --- a/serials/subscription-bib-search.pl +++ b/serials/subscription-bib-search.pl @@ -48,6 +48,7 @@ to multipage gestion. use strict; +use warnings; use CGI; use C4::Koha; @@ -77,7 +78,7 @@ if ($op eq "do_search" && $query) { my $index = C4::Context->preference("item-level_itypes") ? 'itype' : 'itemtype'; $query .= " AND $index=$itemtypelimit"; } - + $resultsperpage= $input->param('resultsperpage'); $resultsperpage = 20 if(!defined $resultsperpage); @@ -91,7 +92,7 @@ if ($op eq "do_search" && $query) { exit; } my @results; - + for(my $i=0;$i<$total;$i++) { my %resultsloop; my $marcrecord = MARC::File::USMARC::decode($marcrecords->[$i]); @@ -108,7 +109,7 @@ if ($op eq "do_search" && $query) { push @results, \%resultsloop; } - + ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "serials/result.tmpl", query => $input, @@ -144,7 +145,7 @@ if ($op eq "do_search" && $query) { } } } - + my $from = 0; $from = $startfrom*$resultsperpage+1 if($total_hits > 0); my $to; diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index aa3179d012..131fdefc98 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -16,6 +16,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use warnings; use CGI; use C4::Auth; use C4::Koha; @@ -24,25 +25,23 @@ use C4::Serials; use C4::Output; use C4::Context; use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/; -#use Date::Manip; +use Carp; my $query = new CGI; my $op = $query->param('op'); my $dbh = C4::Context->dbh; -my $sth; -# my $id; my ($template, $loggedinuser, $cookie, $hemisphere); my $subscriptionid = $query->param('subscriptionid'); -my $subs = &GetSubscription($subscriptionid); +my $subs = GetSubscription($subscriptionid); $subs->{enddate} = GetExpirationDate($subscriptionid); -if ($op eq 'del') { +if ($op && $op eq 'del') { if ($subs->{'cannotedit'}){ - warn "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; + carp "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); - } - &DelSubscription($subscriptionid); + } + DelSubscription($subscriptionid); print "Content-Type: text/html\n\n"; exit; } @@ -75,24 +74,34 @@ $subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid}); $template->param($subs); $template->param(biblionumber_for_new_subscription => $subs->{bibnum}); +my @irregular_issues = split /,/, $subs->{irregularity}; +if (! $subs->{numberpattern}) { + $subs->{numberpattern} = q{}; +} +if (! $subs->{dow}) { + $subs->{dow} = q{}; +} +if (! $subs->{periodicity}) { + $subs->{periodicity} = '0'; +} $template->param( subscriptionid => $subscriptionid, routing => $routing, serialslist => \@serialslist, totalissues => $totalissues, hemisphere => $hemisphere, - cannotedit =>(C4::Context->preference('IndependantBranches') && - C4::Context->userenv && - C4::Context->userenv->{flags} % 2 !=1 && + cannotedit =>(C4::Context->preference('IndependantBranches') && + C4::Context->userenv && + C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{branch} && $subs->{branchcode} && (C4::Context->userenv->{branch} ne $subs->{branchcode})), - "periodicity".($subs->{periodicity}?$subs->{periodicity}:'0') => 1, - "arrival".$subs->{dow} => 1, - "numberpattern".$subs->{numberpattern} => 1, - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - irregular_issues => scalar(split(/,/,$subs->{irregularity})), + 'periodicity' . $subs->{periodicity} => 1, + 'arrival' . $subs->{dow} => 1, + 'numberpattern' . $subs->{numberpattern} => 1, + intranetstylesheet => C4::Context->preference('intranetstylesheet'), + intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'), + irregular_issues => scalar @irregular_issues, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index 10c1205d63..7402af70d6 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -1,5 +1,4 @@ #!/usr/bin/perl -# WARNING: 4-character tab stops here # Copyright 2000-2002 Katipo Communications # @@ -45,6 +44,7 @@ Id of the subscription this script has to renew =cut use strict; +use warnings; use CGI; use C4::Koha; @@ -79,14 +79,14 @@ if ( $op eq "renew" ) { $query->param('startdate'), $query->param('numberlength'), $query->param('weeklength'), $query->param('monthlength'), $query->param('note') - ); + ); } my $subscription = GetSubscription($subscriptionid); if ($subscription->{'cannotedit'}){ warn "Attempt to renew subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); -} +} $template->param( startdate => format_date( @@ -99,12 +99,8 @@ $template->param( subscriptionid => $subscriptionid, bibliotitle => $subscription->{bibliotitle}, $op => 1, - popup => ($query->param('mode')eq "popup"), + popup => ($query->param('mode')eq "popup"), ); # Print the page output_html_with_http_headers $query, $cookie, $template->output; - -# Local Variables: -# tab-width: 4 -# End: -- 2.39.5