From 20fb798f51ed707bcd4fb7b882313f6cfaac5123 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 12:46:06 +0100 Subject: [PATCH 1/9] Remove unused or unnecessary variables in claims processing Also cleaned the interface to the claims related functions in C4::Serials so they do not return an extra count variable moved generation of dropdown to template instead of inline code --- C4/Serials.pm | 40 ++++++------------- .../prog/en/modules/serials/claims.tmpl | 10 ++--- serials/claims.pl | 40 +++++++++---------- serials/lateissues-excel.pl | 13 +++--- 4 files changed, 43 insertions(+), 60 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index ad6f1e711e..c9b8246308 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -84,9 +84,8 @@ Give all XYZ functions this function get all suppliers with late issues. return : -the supplierlist into a hash. this hash containts id & name of the supplier -Only valid suppliers are returned. Late subscriptions lacking a supplier are -ignored. +an array_ref of suppliers each entry is a hash_ref containing id and name +the array is in name order =back @@ -103,14 +102,7 @@ sub GetSuppliersWithLateIssues { AND (planneddate < now() OR serial.STATUS = 3 OR serial.STATUS = 4) ORDER BY name |; - my $sth = $dbh->prepare($query); - $sth->execute; - my %supplierlist; - while ( my ( $id, $name ) = $sth->fetchrow ) { - next if !defined $id; - $supplierlist{$id} = $name; - } - return %supplierlist; + return $dbh->selectall_arrayref($query, { Slice => {} }); } =head2 GetLateIssues @@ -161,16 +153,14 @@ sub GetLateIssues { my @issuelist; my $last_title; my $odd = 0; - my $count = 0; while ( my $line = $sth->fetchrow_hashref ) { $odd++ unless $line->{title} eq $last_title; $line->{title} = "" if $line->{title} eq $last_title; $last_title = $line->{title} if ( $line->{title} ); $line->{planneddate} = format_date( $line->{planneddate} ); - $count++; push @issuelist, $line; } - return $count, @issuelist; + return @issuelist; } =head2 GetSubscriptionHistoryFromSubscriptionId @@ -1845,12 +1835,11 @@ sub DelIssue { =over 4 -($count,@issuelist) = &GetLateMissingIssues($supplierid,$serialid) +@issuelist = &GetLateMissingIssues($supplierid,$serialid) this function select missing issues on database - where serial.status = 4 or serial.status=3 or planneddateexecute; my @issuelist; - my $last_title; - my $odd = 0; - my $count = 0; while ( my $line = $sth->fetchrow_hashref ) { - $odd++ unless $line->{title} eq $last_title; - $last_title = $line->{title} if ( $line->{title} ); - $line->{planneddate} = format_date( $line->{planneddate} ); - $line->{claimdate} = format_date( $line->{claimdate} ); - $line->{ "status" . $line->{status} } = 1; - $line->{'odd'} = 1 if $odd % 2; - $count++; + if ($line->{planneddate}) { + $line->{planneddate} = format_date( $line->{planneddate} ); + } + if ($line->{claimdate}) { + $line->{claimdate} = format_date( $line->{claimdate} ); + } + $line->{"status".$line->{status}} = 1; push @issuelist, $line; } - return $count, @issuelist; + return @issuelist; } =head2 removeMissingIssue diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl index 16511acb1e..ae09e48c74 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl @@ -167,10 +167,10 @@
Phone: @@ -306,9 +306,9 @@
+
-
diff --git a/serials/claims.pl b/serials/claims.pl index 8ff672f5d6..5b73d8bd3a 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -18,7 +18,7 @@ my $claimletter = $input->param('claimletter'); my $supplierid = $input->param('supplierid'); my $suppliername = $input->param('suppliername'); my $order = $input->param('order'); -my %supplierlist = GetSuppliersWithLateIssues(); +my $supplierlist = GetSuppliersWithLateIssues; # open template first (security & userenv set here) my ($template, $loggedinuser, $cookie) @@ -29,14 +29,14 @@ my ($template, $loggedinuser, $cookie) flagsrequired => {serials => 1}, debug => 1, }); -my $supplier_loop = []; -foreach my $s_id (sort {$supplierlist{$a} cmp $supplierlist{$b} } keys %supplierlist){ - my ($count) = GetLateOrMissingIssues($s_id,q{},$order); - push @{$supplier_loop}, { - id => $s_id, - name => $supplierlist{$s_id} . "($count)", - selected => ( $supplierid && $supplierid == $s_id ), - }; + +for my $supplier ( @{$supplierlist} ) { + my @dummy = GetLateOrMissingIssues($supplier->{id},q{},$order); + my $counting = scalar @dummy; + $supplier->{name} .= " ($counting)"; + if ($supplierid && $supplierid == $supplier->{id}) { + $supplier->{selected} = 1; + } } my $letters = GetLetters('claimissues'); @@ -46,9 +46,9 @@ foreach (keys %{$letters}){ } my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code})); -my ($count2, @missingissues); +my @missingissues; if ($supplierid) { - ($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order); + @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order); } my ($singlesupplier,@supplierinfo); @@ -63,20 +63,18 @@ if($supplierid){ my $preview=0; if($op && $op eq 'preview'){ $preview = 1; +} else { + my @serialnums=$input->param('serialid'); + if (@serialnums) { # i.e. they have been flagged to generate claims + SendAlerts('claimissues',\@serialnums,$input->param("letter_code")); + my $cntupdate=UpdateClaimdateIssues(\@serialnums); + ### $cntupdate SHOULD be equal to scalar(@$serialnums) + } } -if ($op eq "send_alert"){ - my @serialnums=$input->param("serialid"); - SendAlerts('claimissues',\@serialnums,$input->param("letter_code")); - my $cntupdate=UpdateClaimdateIssues(\@serialnums); - ### $cntupdate SHOULD be equal to scalar(@$serialnums) - $template->param('SHOWCONFIRMATION' => 1); - $template->param('suppliername' => $suppliername); -} - $template->param('letters'=>\@letters,'letter'=>$letter); $template->param( order =>$order, - supplier_loop => $supplier_loop, + supplier_loop => $supplierlist, phone => $supplierinfo[0]->{phone}, booksellerfax => $supplierinfo[0]->{booksellerfax}, bookselleremail => $supplierinfo[0]->{bookselleremail}, diff --git a/serials/lateissues-excel.pl b/serials/lateissues-excel.pl index ea0f503311..47ce51a478 100755 --- a/serials/lateissues-excel.pl +++ b/serials/lateissues-excel.pl @@ -32,12 +32,10 @@ my @serialid = $query->param('serialid'); my $op = $query->param('op') || q{}; my $serialidcount = @serialid; -my %supplierlist = GetSuppliersWithLateIssues; - my @loop1; -my ($count, @lateissues); +my @lateissues; if($op ne 'claims'){ - ($count, @lateissues) = GetLateIssues($supplierid); + @lateissues = GetLateIssues($supplierid); for my $issue (@lateissues){ push @loop1, [ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},]; @@ -45,9 +43,9 @@ if($op ne 'claims'){ } my $totalcount2 = 0; my @loop2; -my ($count2, @missingissues); +my @missingissues; for (my $k=0;$k<@serialid;$k++){ - ($count2, @missingissues) = GetLateOrMissingIssues($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 @@ -57,7 +55,7 @@ for (my $k=0;$k<@serialid;$k++){ ); 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]); } @@ -107,6 +105,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){ From f75cca228a9149b6b1b5cb04f7037879cb465cf1 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 13:16:31 +0100 Subject: [PATCH 2/9] Basic refactoring of serials-edit.pm Removed some useless counts from serials-edit / Serials interfaces Removed old commented out code. Unrequired variables Reformatted some code so that improving logic can be done more easily --- C4/Serials.pm | 15 +- serials/serials-edit.pl | 452 +++++++++++++++++++++++----------------- 2 files changed, 260 insertions(+), 207 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index c9b8246308..32c6cbe2f0 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -742,8 +742,8 @@ sub GetSerials { =over 4 -($totalissues,@serials) = GetSerials2($subscriptionid,$status); -this function get every serial waited for a given subscription +@serials = GetSerials2($subscriptionid,$status); +this function gets every serial waited for a given subscription as well as the number of issues registered in the database (all types) this number is used to see if a subscription can be deleted (=it must have only 1 issue) @@ -771,8 +771,7 @@ sub GetSerials2 { $line->{"publisheddate"} = format_date( $line->{"publisheddate"} ); push @serials, $line; } - my ($totalissues) = scalar(@serials); - return ( $totalissues, @serials ); + return @serials; } =head2 GetLatestSerials @@ -808,14 +807,6 @@ sub GetLatestSerials { push @serials, $line; } - # my $query = qq| - # SELECT count(*) - # FROM serial - # WHERE subscriptionid=? - # |; - # $sth=$dbh->prepare($query); - # $sth->execute($subscriptionid); - # my ($totalissues) = $sth->fetchrow; return \@serials; } diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 528ecb39cc..1ee831da23 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -17,7 +17,6 @@ # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - =head1 NAME serials-recieve.pl @@ -61,7 +60,6 @@ op can be : =cut - use strict; use warnings; use CGI; @@ -74,232 +72,296 @@ use C4::Output; use C4::Context; use C4::Serials; -#use Smart::Comments; - -my $query = new CGI; -my $dbh = C4::Context->dbh; -my @serialids = $query->param('serialid'); -my @serialseqs = $query->param('serialseq'); -my @planneddates = $query->param('planneddate'); -my @publisheddates = $query->param('publisheddate'); -my @status = $query->param('status'); -my @notes = $query->param('notes'); +my $query = CGI->new(); +my $dbh = C4::Context->dbh; +my @serialids = $query->param('serialid'); +my @serialseqs = $query->param('serialseq'); +my @planneddates = $query->param('planneddate'); +my @publisheddates = $query->param('publisheddate'); +my @status = $query->param('status'); +my @notes = $query->param('notes'); my @subscriptionids = $query->param('subscriptionid'); -my $op = $query->param('op'); -if (scalar(@subscriptionids)==1 && index($subscriptionids[0],",")>0){ - @subscriptionids =split (/,/,$subscriptionids[0]); +my $op = $query->param('op'); +if ( scalar(@subscriptionids) == 1 && index( $subscriptionids[0], q|,| ) > 0 ) { + @subscriptionids = split( /,/, $subscriptionids[0] ); } my @errors; my @errseq; + # If user comes from subscription details -unless (@serialids){ - foreach my $subscriptionid (@subscriptionids){ - my $serstatus=$query->param('serstatus'); - if ($serstatus){ - my ($count,@tmpser)=GetSerials2($subscriptionid,$serstatus); - foreach (@tmpser) { - push @serialids, $_->{'serialid'}; - } +unless (@serialids) { + foreach my $subscriptionid (@subscriptionids) { + my $serstatus = $query->param('serstatus'); + if ($serstatus) { + my @tmpser = GetSerials2( $subscriptionid, $serstatus ); + foreach (@tmpser) { + push @serialids, $_->{'serialid'}; + } + } } - } } -unless (scalar(@serialids)){ - my $string="serials-collection.pl?subscriptionid=".join(",",@subscriptionids); - $string=~s/,$//; -# warn $string; - print $query->redirect($string); +unless ( scalar(@serialids) ) { + my $string = + "serials-collection.pl?subscriptionid=" . join( ",", @subscriptionids ); + $string =~ s/,$//; + + print $query->redirect($string); } -my ($template, $loggedinuser, $cookie) -= get_template_and_user({template_name => "serials/serials-edit.tmpl", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => {serials => 1}, - debug => 1, - }); +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "serials/serials-edit.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { serials => 1 }, + debug => 1, + } +); my @serialdatalist; my %processedserialid; -foreach my $tmpserialid (@serialids){ +foreach my $tmpserialid (@serialids) { + #filtering serialid for duplication #NEW serial should appear only once and are created afterwards - next unless (defined($tmpserialid) && $tmpserialid =~/^[0-9]+$/ && !$processedserialid{$tmpserialid}); - my $data=GetSerialInformation($tmpserialid); - $data->{publisheddate}=format_date($data->{publisheddate}); - $data->{planneddate}=format_date($data->{planneddate}); - $data->{'editdisable'}=((HasSubscriptionExpired($data->{subscriptionid})&& $data->{'status1'})||$data->{'cannotedit'}); - push @serialdatalist,$data; - $processedserialid{$tmpserialid}=1; + if ( defined($tmpserialid) + && $tmpserialid =~ /^[0-9]+$/ + && !$processedserialid{$tmpserialid} ) + { + my $data = GetSerialInformation($tmpserialid); + $data->{publisheddate} = format_date( $data->{publisheddate} ); + $data->{planneddate} = format_date( $data->{planneddate} ); + $data->{'editdisable'} = ( + ( + HasSubscriptionExpired( $data->{subscriptionid} ) + && $data->{'status1'} + ) + || $data->{'cannotedit'} + ); + push @serialdatalist, $data; + $processedserialid{$tmpserialid} = 1; + } } -my $bibdata=GetBiblioData($serialdatalist[0]->{'biblionumber'}); +my $bibdata = GetBiblioData( $serialdatalist[0]->{'biblionumber'} ); my @newserialloop; my @subscriptionloop; + # check, for each subscription edited, that we have an empty item line if applicable for the subscription my %processedsubscriptionid; -foreach my $subscriptionid (@subscriptionids){ - #Donot process subscriptionid twice if it was already processed. - my $subscriptiondetail = GetSubscription($subscriptionid); - next unless (defined($subscriptionid) && !$processedsubscriptionid{$subscriptionid}); - my $cell; - if ($serialdatalist[0]->{'serialsadditems'}){ - #Create New empty item - $cell = - PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'},'', $subscriptiondetail); - $cell->{serialsadditems} = 1; +foreach my $subscriptionid (@subscriptionids) { + + #Do not process subscriptionid twice if it was already processed. + if ( defined($subscriptionid) + && !$processedsubscriptionid{$subscriptionid} ) + { + my $cell; + if ( $serialdatalist[0]->{'serialsadditems'} ) { + + #Create New empty item + $cell = + PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'}, + '', GetSubscription($subscriptionid) ); + $cell->{serialsadditems} = 1; + } + $cell->{'subscriptionid'} = $subscriptionid; + $cell->{'itemid'} = "NNEW"; + $cell->{'serialid'} = "NEW"; + $cell->{'issuesatonce'} = 1; + push @newserialloop, $cell; + push @subscriptionloop, + { + 'subscriptionid' => $subscriptionid, + 'abouttoexpire' => abouttoexpire($subscriptionid), + 'subscriptionexpired' => HasSubscriptionExpired($subscriptionid), + }; + $processedsubscriptionid{$subscriptionid} = 1; } - $cell->{'subscriptionid'}=$subscriptionid; - $cell->{'itemid'} = "NNEW"; - $cell->{'serialid'} = "NEW"; - $cell->{'issuesatonce'} = 1; - push @newserialloop,$cell; - push @subscriptionloop, {'subscriptionid'=>$subscriptionid, - 'abouttoexpire'=>abouttoexpire($subscriptionid), - 'subscriptionexpired'=>HasSubscriptionExpired($subscriptionid), - }; - $processedsubscriptionid{$subscriptionid}=1; - $template->param(bibliotitle => $subscriptiondetail->{'bibliotitle'}, - callnumber => $subscriptiondetail->{'callnumber'}, - ); - } -$template->param(newserialloop=>\@newserialloop); -$template->param(subscriptions=>\@subscriptionloop); +$template->param( newserialloop => \@newserialloop ); +$template->param( subscriptions => \@subscriptionloop ); + +if ( $op and $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++) { -# $sth->execute($serialids[$i]); -# my ($oldstatus) = $sth->fetchrow; - if ($serialids[$i] && $serialids[$i] eq "NEW") { - if ($serialseqs[$i]){ + for ( my $i = 0 ; $i <= $#serialids ; $i++ ) { + + if ( $serialids[$i] && $serialids[$i] eq "NEW" ) { + if ( $serialseqs[$i] ) { + #IF newserial was provided a name Then we have to create a newSerial - ### FIXME if NewIssue is modified to use subscription biblionumber, then biblionumber would not be useful. - $newserial = NewIssue( $serialseqs[$i],$subscriptionids[$i],$serialdatalist[0]->{'biblionumber'}, - $status[$i], - format_date_in_iso($planneddates[$i]), - format_date_in_iso($publisheddates[$i]), - $notes[$i]); - } - }elsif ($serialids[$i]){ - ModSerialStatus($serialids[$i], - $serialseqs[$i], - format_date_in_iso($planneddates[$i]), - format_date_in_iso($publisheddates[$i]), - $status[$i], - $notes[$i]); + ### FIXME if NewIssue is modified to use subscription biblionumber, then biblionumber would not be useful. + $newserial = NewIssue( + $serialseqs[$i], + $subscriptionids[$i], + $serialdatalist[0]->{'biblionumber'}, + $status[$i], + format_date_in_iso( $planneddates[$i] ), + format_date_in_iso( $publisheddates[$i] ), + $notes[$i] + ); + } + } + elsif ( $serialids[$i] ) { + ModSerialStatus( + $serialids[$i], + $serialseqs[$i], + format_date_in_iso( $planneddates[$i] ), + format_date_in_iso( $publisheddates[$i] ), + $status[$i], + $notes[$i] + ); } } my @moditems = $query->param('moditem'); - if (scalar(@moditems)){ - my @tags = $query->param('tag'); - my @subfields = $query->param('subfield'); - my @field_values = $query->param('field_value'); - my @serials = $query->param('serial'); - my @bibnums = $query->param('bibnum'); - my @itemid = $query->param('itemid'); - my @ind_tag = $query->param('ind_tag'); - my @indicator = $query->param('indicator'); - #Rebuilding ALL the data for items into a hash - # parting them on $itemid. - my %itemhash; - my $countdistinct; - my $range=scalar(@itemid); - for (my $i=0; $i<$range; $i++){ - unless ($itemhash{$itemid[$i]}){ - if ($serials[$countdistinct] && $serials[$countdistinct] ne "NEW"){ - $itemhash{$itemid[$i]}->{'serial'}=$serials[$countdistinct]; - } else { - $itemhash{$itemid[$i]}->{'serial'}=$newserial; - } - $itemhash{$itemid[$i]}->{'bibnum'}=$bibnums[$countdistinct]; - $countdistinct++; - } - push @{$itemhash{$itemid[$i]}->{'tags'}},$tags[$i]; - push @{$itemhash{$itemid[$i]}->{'subfields'}},$subfields[$i]; - push @{$itemhash{$itemid[$i]}->{'field_values'}},$field_values[$i]; - push @{$itemhash{$itemid[$i]}->{'ind_tag'}},$ind_tag[$i]; - push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i]; - } - foreach my $item (keys %itemhash){ - # Verify Itemization is "Valid", i.e. serial status is Arrived or Missing - my $index=-1; - for (my $i=0; $i{'serial'} eq $serialids[$i] || ($itemhash{$item}->{'serial'} == $newserial && $serialids[$i] eq "NEW")); - } - if ($index>=0 && $status[$index]==2){ - my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'}, - $itemhash{$item}->{'subfields'}, - $itemhash{$item}->{'field_values'}, - $itemhash{$item}->{'indicator'}, - $itemhash{$item}->{'ind_tag'}); - # warn $xml; - my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); - if ($item=~/^N/){ - #New Item - - # if autoBarcode is set to 'incremental', calculate barcode... - my ($barcodetagfield,$barcodetagsubfield) = &GetMarcFromKohaField("items.barcode", GetFrameworkCode($serialdatalist[0]->{'biblionumber'})); - if (C4::Context->preference("autoBarcode") eq 'incremental' ) { - if (!$record->field($barcodetagfield)->subfield($barcodetagsubfield)) { - my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items"); - $sth_barcode->execute; - my ($newbarcode) = $sth_barcode->fetchrow; - # OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here. - $record->field($barcodetagfield)->update( $barcodetagsubfield => ++$newbarcode ); - } - } - # check for item barcode # being unique - 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]}; - } else { - my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$itemhash{$item}->{'bibnum'}); - AddItem2Serial($itemhash{$item}->{'serial'},$itemnumber); - } - } else { - #modify item - my ($oldbiblionumber,$oldbibnum,$itemnumber) = ModItemFromMarc($record,$itemhash{$item}->{'bibnum'},$item); - } - } - } - } -# ### 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); -# $redirect.="&".join("&",map{"publisheddate=".$_} @publisheddates); -# $redirect.="&".join("&",map{"status=".$_} @status); -# $redirect.="&".join("&",map{"notes=".$_} @notes); + if ( scalar(@moditems) ) { + my @tags = $query->param('tag'); + my @subfields = $query->param('subfield'); + my @field_values = $query->param('field_value'); + my @serials = $query->param('serial'); + my @bibnums = $query->param('bibnum'); + my @itemid = $query->param('itemid'); + my @ind_tag = $query->param('ind_tag'); + my @indicator = $query->param('indicator'); - if (scalar(@errors)>0){ - $template->param("Errors" => 1); - if (scalar(@errseq)>0){ - $template->param("barcode_not_unique" => 1); - $template->param('errseq'=>\@errseq); + #Rebuilding ALL the data for items into a hash + # parting them on $itemid. + my %itemhash; + my $countdistinct; + my $range = scalar(@itemid); + for ( my $i = 0 ; $i < $range ; $i++ ) { + unless ( $itemhash{ $itemid[$i] } ) { + if ( $serials[$countdistinct] + && $serials[$countdistinct] ne "NEW" ) + { + $itemhash{ $itemid[$i] }->{'serial'} = + $serials[$countdistinct]; + } + else { + $itemhash{ $itemid[$i] }->{'serial'} = $newserial; + } + $itemhash{ $itemid[$i] }->{'bibnum'} = $bibnums[$countdistinct]; + $countdistinct++; + } + push @{ $itemhash{ $itemid[$i] }->{'tags'} }, $tags[$i]; + push @{ $itemhash{ $itemid[$i] }->{'subfields'} }, $subfields[$i]; + push @{ $itemhash{ $itemid[$i] }->{'field_values'} }, + $field_values[$i]; + push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} }, $ind_tag[$i]; + push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i]; } - } else { - my $redirect ="serials-collection.pl?"; - my %hashsubscription; - foreach (@subscriptionids) { - $hashsubscription{$_}=1; - } - $redirect.=join("&",map{"subscriptionid=".$_} sort keys %hashsubscription); - print $query->redirect("$redirect"); - } + foreach my $item ( keys %itemhash ) { + + # Verify Itemization is "Valid", i.e. serial status is Arrived or Missing + my $index = -1; + for ( my $i = 0 ; $i < scalar(@serialids) ; $i++ ) { + if ( + $itemhash{$item}->{serial} eq $serialids[$i] + || ( $itemhash{$item}->{serial} == $newserial + && $serialids[$i] eq 'NEW' ) + ) { + $index = $i + } + } + if ( $index >= 0 && $status[$index] == 2 ) { + my $xml = TransformHtmlToXml( + $itemhash{$item}->{'tags'}, + $itemhash{$item}->{'subfields'}, + $itemhash{$item}->{'field_values'}, + $itemhash{$item}->{'indicator'}, + $itemhash{$item}->{'ind_tag'} + ); + + # warn $xml; + my $bib_record = MARC::Record::new_from_xml( $xml, 'UTF-8' ); + if ( $item =~ /^N/ ) { + + #New Item + + # if autoBarcode is set to 'incremental', calculate barcode... + my ( $barcodetagfield, $barcodetagsubfield ) = + GetMarcFromKohaField( + 'items.barcode', + GetFrameworkCode( + $serialdatalist[0]->{'biblionumber'} + ) + ); + if ( C4::Context->preference("autoBarcode") eq + 'incremental' ) + { + if ( !$bib_record->field($barcodetagfield) + ->subfield($barcodetagsubfield) ) + { + my $sth_barcode = $dbh->prepare( + "select max(abs(barcode)) from items"); + $sth_barcode->execute; + my ($newbarcode) = $sth_barcode->fetchrow; + +# OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here. + $bib_record->field($barcodetagfield) + ->update( $barcodetagsubfield => ++$newbarcode ); + } + } + + # check for item barcode # being unique + my $exists; + if ( + $bib_record->subfield( + $barcodetagfield, $barcodetagsubfield + ) + ) + { + $exists = GetItemnumberFromBarcode( + $bib_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'; + push @errseq, { serialseq => $serialseqs[$index] }; + } + else { + my ( $biblionumber, $bibitemnum, $itemnumber ) = + AddItemFromMarc( $bib_record, + $itemhash{$item}->{bibnum} ); + AddItem2Serial( $itemhash{$item}->{serial}, + $itemnumber ); + } + } + else { + + #modify item + my ( $oldbiblionumber, $oldbibnum, $itemnumber ) = + ModItemFromMarc( $bib_record, + $itemhash{$item}->{'bibnum'}, $item ); + } + } + } + } + + + if ( @errors ) { + $template->param( Errors => 1 ); + if ( @errseq ) { + $template->param( barcode_not_unique => 1, errseq => \@errseq ); + } + } + else { + my $redirect = "serials-collection.pl?"; + $redirect .= join( '&', map { "subscriptionid=" . $_ } sort @subscriptionids );# ID The sort necessary + print $query->redirect($redirect); + } } $template->param( serialsadditems => $serialdatalist[0]->{'serialsadditems'}, - biblionumber => $serialdatalist[0]->{'biblionumber'}, - serialslist => \@serialdatalist, + bibliotitle => $bibdata->{'title'}, + biblionumber => $serialdatalist[0]->{'biblionumber'}, + serialslist => \@serialdatalist, ); output_html_with_http_headers $query, $cookie, $template->output; From 3b137922a06e735036b31728e2905f3c3bed0da4 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 21 Jan 2010 15:27:02 +0000 Subject: [PATCH 3/9] Add Text to claim date column's header --- koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl index ae09e48c74..1e5c8b0fb9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl @@ -253,7 +253,7 @@ Issue number Status Since -   + Claim Date Begin Claim From d027e4dcd6264c908ffbf2b5e170e813ab48e081 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 13:28:40 +0100 Subject: [PATCH 4/9] add warnings to Serials.pm Change obvious warning generators: ( use of string comparisons in numeric comparison) ( declaration of variable in comnditional ) also some errors caused by undefined values: abouttoexpire was not checking for undef values Pass a valid planneddate in generation of next expected (undef here causes odd results) Add a basic test script test is minimal but I fell over a bug this would have caught --- C4/Serials.pm | 134 ++++++++++++++++++++++++-------------------------- t/Serials.t | 8 +++ 2 files changed, 73 insertions(+), 69 deletions(-) create mode 100644 t/Serials.t diff --git a/C4/Serials.pm b/C4/Serials.pm index 32c6cbe2f0..9c90cc6dab 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1,4 +1,4 @@ -package C4::Serials; #assumes C4/Serials.pm +package C4::Serials; # Copyright 2000-2002 Katipo Communications # @@ -18,7 +18,8 @@ package C4::Serials; #assumes C4/Serials.pm # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -use C4::Dates qw(format_date); +use warnings; +use C4::Dates qw(format_date format_date_in_iso); use Date::Calc qw(:all); use POSIX qw(strftime); use C4::Suggestions; @@ -61,8 +62,6 @@ BEGIN { ); } -=head2 GetSuppliersWithLateIssues - =head1 NAME C4::Serials - Give functions for serializing. @@ -77,6 +76,8 @@ Give all XYZ functions =head1 FUNCTIONS +=head2 GetSuppliersWithLateIssues + =over 4 %supplierlist = &GetSuppliersWithLateIssues @@ -1090,10 +1091,12 @@ sub ModSerialStatus { # change status & update subscriptionhistory my $val; - if ( $status eq 6 ) { - DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } ); - } else { - my $query = "UPDATE serial SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? WHERE serialid = ?"; + if ( $status == 6 ) { + DelIssue( {'serialid'=>$serialid, 'subscriptionid'=>$subscriptionid,'serialseq'=>$serialseq} ); + } + else { + my $query = +'UPDATE serial SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? WHERE serialid = ?'; $sth = $dbh->prepare($query); $sth->execute( $serialseq, $publisheddate, $planneddate, $status, $notes, $serialid ); $query = "SELECT * FROM subscription WHERE subscriptionid = ?"; @@ -1105,7 +1108,7 @@ sub ModSerialStatus { $sth = $dbh->prepare($query); $sth->execute($subscriptionid); my ( $missinglist, $recievedlist ) = $sth->fetchrow; - if ( $status eq 2 ) { + if ( $status == 2 ) { $recievedlist .= "; $serialseq" unless ( index( "$recievedlist", "$serialseq" ) >= 0 ); @@ -1113,10 +1116,10 @@ sub ModSerialStatus { # warn "missinglist : $missinglist serialseq :$serialseq, ".index("$missinglist","$serialseq"); $missinglist .= "; $serialseq" - if ( $status eq 4 + if ( $status == 4 and not index( "$missinglist", "$serialseq" ) >= 0 ); - $missinglist .= "; $serialseq" - if ( $status eq 5 + $missinglist .= "; not issued $serialseq" + if ( $status == 5 and index( "$missinglist", "$serialseq" ) >= 0 ); $query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE subscriptionid=?"; $sth = $dbh->prepare($query); @@ -1127,20 +1130,19 @@ sub ModSerialStatus { } # create new waited entry if needed (ie : was a "waited" and has changed) - if ( $oldstatus eq 1 && $status ne 1 ) { + if ( $oldstatus == 1 && $status != 1 ) { my $query = "SELECT * FROM subscription WHERE subscriptionid = ?"; $sth = $dbh->prepare($query); $sth->execute($subscriptionid); my $val = $sth->fetchrow_hashref; # next issue number - # warn "Next Seq"; - my ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq($val); - - # warn "Next Seq End"; + my ( + $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, + $newinnerloop1, $newinnerloop2, $newinnerloop3 + ) = GetNextSeq($val); # next date (calculated from actual date & frequency parameters) - # warn "publisheddate :$publisheddate "; my $nextpublisheddate = GetNextDate( $publisheddate, $val ); NewIssue( $newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextpublisheddate, $nextpublisheddate ); $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? @@ -1148,8 +1150,8 @@ sub ModSerialStatus { $sth = $dbh->prepare($query); $sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid ); - # check if an alert must be sent... (= a letter is defined & status became "arrived" - if ( $val->{letter} && $status eq 2 && $oldstatus ne 2 ) { +# check if an alert must be sent... (= a letter is defined & status became "arrived" + if ( $val->{letter} && $status == 2 && $oldstatus != 2 ) { SendAlerts( 'issue', $val->{subscriptionid}, $val->{letter} ); } } @@ -1181,13 +1183,17 @@ sub GetNextExpected($) { # Each subscription has only one 'expected' issue, with serial.status==1. $sth->execute( $subscriptionid, 1 ); - my ($nextissue) = $sth->fetchrow_hashref; - if ( not $nextissue ) { - $sth = $dbh->prepare('SELECT serialid,planneddate FROM serial WHERE subscriptionid = ? ORDER BY planneddate DESC LIMIT 1'); - $sth->execute($subscriptionid); - $nextissue = $sth->fetchrow_hashref; + my ( $nextissue ) = $sth->fetchrow_hashref; + if( !$nextissue){ + $sth = $dbh->prepare('SELECT serialid,planneddate FROM serial WHERE subscriptionid = ? ORDER BY planneddate DESC LIMIT 1'); + $sth->execute( $subscriptionid ); + $nextissue = $sth->fetchrow_hashref; } - $nextissue->{planneddate} = C4::Dates->new( $nextissue->{planneddate}, 'iso' ); + if (!defined $nextissue->{planneddate}) { + # or should this default to 1st Jan ??? + $nextissue->{planneddate} = strftime('%Y-%m-%d',localtime); + } + $nextissue->{planneddate} = C4::Dates->new($nextissue->{planneddate},'iso'); return $nextissue; } @@ -1477,14 +1483,14 @@ sub NewIssue { $sth->execute($subscriptionid); my ( $missinglist, $recievedlist ) = $sth->fetchrow; - if ( $status eq 2 ) { - ### TODO Add a feature that improves recognition and description. - ### As such count (serialseq) i.e. : N18,2(N19),N20 - ### Would use substr and index But be careful to previous presence of () - $recievedlist .= "; $serialseq" unless ( index( $recievedlist, $serialseq ) > 0 ); + if ( $status == 2 ) { + ### TODO Add a feature that improves recognition and description. + ### As such count (serialseq) i.e. : N18,2(N19),N20 + ### Would use substr and index But be careful to previous presence of () + $recievedlist .= "; $serialseq" unless (index($recievedlist,$serialseq)>0); } - if ( $status eq 4 ) { - $missinglist .= "; $serialseq" unless ( index( $missinglist, $serialseq ) > 0 ); + if ( $status == 4 ) { + $missinglist .= "; $serialseq" unless (index($missinglist,$serialseq)>0); } $query = qq| UPDATE subscriptionhistory @@ -2265,44 +2271,34 @@ sub abouttoexpire { my ($subscriptionid) = @_; my $dbh = C4::Context->dbh; my $subscription = GetSubscription($subscriptionid); - my $per = $subscription->{'periodicity'}; - if ( $per % 16 > 0 ) { - my $expirationdate = $subscription->{enddate}; - my $sth = $dbh->prepare("select max(planneddate) from serial where subscriptionid=?"); - $sth->execute($subscriptionid); - my ($res) = $sth->fetchrow; - my @res = split( /-/, $res ); - @res = Date::Calc::Today if ( $res[0] * $res[1] == 0 ); - my @endofsubscriptiondate = split( /-/, $expirationdate ); - my $x; - if ( $per == 1 ) { $x = 7; } - if ( $per == 2 ) { $x = 7; } - if ( $per == 3 ) { $x = 14; } - if ( $per == 4 ) { $x = 21; } - if ( $per == 5 ) { $x = 31; } - if ( $per == 6 ) { $x = 62; } - if ( $per == 7 || $per == 8 ) { $x = 93; } - if ( $per == 9 ) { $x = 190; } - if ( $per == 10 ) { $x = 365; } - if ( $per == 11 ) { $x = 730; } - my @datebeforeend = Add_Delta_Days( $endofsubscriptiondate[0], $endofsubscriptiondate[1], $endofsubscriptiondate[2], -( 3 * $x ) ) - if ( @endofsubscriptiondate && $endofsubscriptiondate[0] * $endofsubscriptiondate[1] * $endofsubscriptiondate[2] ); - - # warn "DATE BEFORE END: $datebeforeend"; - return 1 - if ( - @res - && ( @datebeforeend - && Delta_Days( $res[0], $res[1], $res[2], $datebeforeend[0], $datebeforeend[1], $datebeforeend[2] ) <= 0 ) - && ( @endofsubscriptiondate - && Delta_Days( $res[0], $res[1], $res[2], $endofsubscriptiondate[0], $endofsubscriptiondate[1], $endofsubscriptiondate[2] ) >= 0 ) - ); - return 0; - } elsif ( $subscription->{numberlength} > 0 ) { - return ( countissuesfrom( $subscriptionid, $subscription->{'startdate'} ) >= $subscription->{numberlength} - 1 ); - } else { + my $per = $subscription->{'periodicity'}; + if ($per && $per % 16 > 0){ + my $expirationdate = GetExpirationDate($subscriptionid); + my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid); + my @res; + if (defined $res) { + @res=split (/-/,$res); + @res=Date::Calc::Today if ($res[0]*$res[1]==0); + } else { # default an undefined value + @res=Date::Calc::Today; + } + my @endofsubscriptiondate=split(/-/,$expirationdate); + my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 0, 0, 0); + my @datebeforeend; + @datebeforeend = Add_Delta_Days( $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2], + - (3 * $per_list[$per])) if (@endofsubscriptiondate && $endofsubscriptiondate[0]*$endofsubscriptiondate[1]*$endofsubscriptiondate[2]); + return 1 if ( @res && + (@datebeforeend && + Delta_Days($res[0],$res[1],$res[2], + $datebeforeend[0],$datebeforeend[1],$datebeforeend[2]) <= 0) && + (@endofsubscriptiondate && + Delta_Days($res[0],$res[1],$res[2], + $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2]) >= 0) ); return 0; + } elsif ($subscription->{numberlength}>0) { + return (countissuesfrom($subscriptionid,$subscription->{'startdate'}) >=$subscription->{numberlength}-1); } + return 0; } =head2 GetNextDate diff --git a/t/Serials.t b/t/Serials.t new file mode 100644 index 0000000000..ff8e5e1b71 --- /dev/null +++ b/t/Serials.t @@ -0,0 +1,8 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test::More tests => 1; + +use_ok('C4::Serials'); + From bf0eed8d3137c489a15e49bbfdabb86d6cf12bc5 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 14:44:39 +0100 Subject: [PATCH 5/9] Clean up Pod Documentation Ensured returns were documented Fixed some language issues Removed the host of podchecker warnings about missing lists added a couple of explicit returns when subroutines 'fell off the end' to remove any ambiguity --- C4/Serials.pm | 332 +++++++++++++------------------------------------- 1 file changed, 82 insertions(+), 250 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 9c90cc6dab..7b42465f38 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -64,7 +64,7 @@ BEGIN { =head1 NAME -C4::Serials - Give functions for serializing. +C4::Serials - Serials Module Functions =head1 SYNOPSIS @@ -72,15 +72,14 @@ C4::Serials - Give functions for serializing. =head1 DESCRIPTION -Give all XYZ functions +Functions for handling subscriptions, claims routing etc. -=head1 FUNCTIONS + +=head1 SUBROUTINES =head2 GetSuppliersWithLateIssues -=over 4 - -%supplierlist = &GetSuppliersWithLateIssues +$supplierlist = GetSuppliersWithLateIssues() this function get all suppliers with late issues. @@ -88,8 +87,6 @@ return : an array_ref of suppliers each entry is a hash_ref containing id and name the array is in name order -=back - =cut sub GetSuppliersWithLateIssues { @@ -108,18 +105,14 @@ sub GetSuppliersWithLateIssues { =head2 GetLateIssues -=over 4 +@issuelist = GetLateIssues($supplierid) -@issuelist = &GetLateIssues($supplierid) - -this function select late issues on database +this function selects late issues from the database return : -the issuelist into an table. Each line of this table containts a ref to a hash which it containts +the issuelist as an array. Each element of this array contains a hashi_ref containing name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio -=back - =cut sub GetLateIssues { @@ -166,15 +159,9 @@ sub GetLateIssues { =head2 GetSubscriptionHistoryFromSubscriptionId -=over 4 - $sth = GetSubscriptionHistoryFromSubscriptionId() -this function just prepare the SQL request. +this function prepares the SQL request and returns the statement handle After this function, don't forget to execute it by using $sth->execute($subscriptionid) -return : -$sth = $dbh->prepare($query). - -=back =cut @@ -190,16 +177,12 @@ sub GetSubscriptionHistoryFromSubscriptionId() { =head2 GetSerialStatusFromSerialId -=over 4 - $sth = GetSerialStatusFromSerialId(); -this function just prepare the SQL request. +this function returns a statement handle After this function, don't forget to execute it by using $sth->execute($serialid) return : $sth = $dbh->prepare($query). -=back - =cut sub GetSerialStatusFromSerialId() { @@ -214,16 +197,13 @@ sub GetSerialStatusFromSerialId() { =head2 GetSerialInformation -=over 4 $data = GetSerialInformation($serialid); -returns a hash containing : +returns a hash_ref containing : items : items marcrecord (can be an array) serial table field subscription table field + information about subscription expiration - -=back =cut @@ -282,12 +262,9 @@ sub GetSerialInformation { =head2 AddItem2Serial -=over 4 - -$data = AddItem2Serial($serialid,$itemnumber); +$rows = AddItem2Serial($serialid,$itemnumber); Adds an itemnumber to Serial record - -=back +returns the number of rows affected =cut @@ -301,15 +278,11 @@ sub AddItem2Serial { =head2 UpdateClaimdateIssues -=over 4 - UpdateClaimdateIssues($serialids,[$date]); -Update Claimdate for issues in @$serialids list with date $date +Update Claimdate for issues in @$serialids list with date $date (Take Today if none) -=back - =cut sub UpdateClaimdateIssues { @@ -326,16 +299,12 @@ sub UpdateClaimdateIssues { =head2 GetSubscription -=over 4 - $subs = GetSubscription($subscriptionid) -this function get the subscription which has $subscriptionid as id. +this function returns the subscription which has $subscriptionid as id. return : a hashref. This hash containts subscription, subscriptionhistory, aqbudget.bookfundid, biblio.title -=back - =cut sub GetSubscription { @@ -376,12 +345,8 @@ sub GetSubscription { =head2 GetFullSubscription -=over 4 - - \@res = GetFullSubscription($subscriptionid) - this function read on serial table. - -=back + $array_ref = GetFullSubscription($subscriptionid) + this function reads the serial table. =cut @@ -426,13 +391,9 @@ sub GetFullSubscription { =head2 PrepareSerialsData -=over 4 - - \@res = PrepareSerialsData($serialinfomation) + $array_ref = PrepareSerialsData($serialinfomation) where serialinformation is a hashref array -=back - =cut sub PrepareSerialsData { @@ -484,11 +445,11 @@ sub PrepareSerialsData { =head2 GetSubscriptionsFromBiblionumber -\@res = GetSubscriptionsFromBiblionumber($biblionumber) -this function get the subscription list. it reads on subscription table. +$array_ref = GetSubscriptionsFromBiblionumber($biblionumber) +this function get the subscription list. it reads the subscription table. return : -table of subscription which has the biblionumber given on input arg. -each line of this table is a hashref. All hashes containt +reference to an array of subscriptions which have the biblionumber given on input arg. +each element of this array is a hashref containing startdate, histstartdate,opacnote,missinglist,recievedlist,periodicity,status & enddate =cut @@ -544,12 +505,8 @@ sub GetSubscriptionsFromBiblionumber { =head2 GetFullSubscriptionsFromBiblionumber -=over 4 - - \@res = GetFullSubscriptionsFromBiblionumber($biblionumber) - this function read on serial table. - -=back + $array_ref = GetFullSubscriptionsFromBiblionumber($biblionumber) + this function reads the serial table. =cut @@ -593,15 +550,11 @@ sub GetFullSubscriptionsFromBiblionumber { =head2 GetSubscriptions -=over 4 - @results = GetSubscriptions($title,$ISSN,$biblionumber); -this function get all subscriptions which has title like $title,ISSN like $ISSN and biblionumber like $biblionumber. +this function gets all subscriptions which have title like $title,ISSN like $ISSN and biblionumber like $biblionumber. return: a table of hashref. Each hash containt the subscription. -=back - =cut sub GetSubscriptions { @@ -680,17 +633,13 @@ sub GetSubscriptions { =head2 GetSerials -=over 4 - ($totalissues,@serials) = GetSerials($subscriptionid); -this function get every serial not arrived for a given subscription +this function gets every serial not arrived for a given subscription as well as the number of issues registered in the database (all types) this number is used to see if a subscription can be deleted (=it must have only 1 issue) FIXME: We should return \@serials. -=back - =cut sub GetSerials { @@ -741,15 +690,11 @@ sub GetSerials { =head2 GetSerials2 -=over 4 - @serials = GetSerials2($subscriptionid,$status); -this function gets every serial waited for a given subscription +this function returns every serial waited for a given subscription as well as the number of issues registered in the database (all types) this number is used to see if a subscription can be deleted (=it must have only 1 issue) -=back - =cut sub GetSerials2 { @@ -777,14 +722,10 @@ sub GetSerials2 { =head2 GetLatestSerials -=over 4 - \@serials = GetLatestSerials($subscriptionid,$limit) get the $limit's latest serials arrived or missing for a given subscription return : -a ref to a table which it containts all of the latest serials stored into a hash. - -=back +a ref to an array which contains all of the latest serials stored into a hash. =cut @@ -813,12 +754,8 @@ sub GetLatestSerials { =head2 GetDistributedTo -=over 4 - $distributedto=GetDistributedTo($subscriptionid) -This function select the old previous value of distributedto in the database. - -=back +This function returns the field distributedto for the subscription matching subscriptionid =cut @@ -834,15 +771,11 @@ sub GetDistributedTo { =head2 GetNextSeq -=over 4 - GetNextSeq($val) $val is a hashref containing all the attributes of the table 'subscription' This function get the next issue for the subscription given on input arg return: -all the input params updated. - -=back +a list containing all the input params updated. =cut @@ -929,16 +862,12 @@ sub GetNextSeq { =head2 GetSeq -=over 4 - $calculated = GetSeq($val) $val is a hashref containing all the attributes of the table 'subscription' this function transforms {X},{Y},{Z} to 150,0,0 for example. return: the sequence in integer format -=back - =cut sub GetSeq { @@ -969,12 +898,12 @@ sub GetSeq { =head2 GetExpirationDate -$sensddate = GetExpirationDate($subscriptionid) +$sensddate = GetExpirationDate($subscriptionid, [$startdate]) this function return the next expiration date for a subscription given on input args. return -the enddate +the enddate or undef =cut @@ -1017,14 +946,10 @@ sub GetExpirationDate { =head2 CountSubscriptionFromBiblionumber -=over 4 - $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber) -this count the number of subscription for a biblionumber given. +this returns a count of the subscriptions for a given biblionumber return : -the number of subscriptions with biblionumber given on input arg. - -=back +the number of subscriptions =cut @@ -1040,13 +965,10 @@ sub CountSubscriptionFromBiblionumber { =head2 ModSubscriptionHistory -=over 4 - ModSubscriptionHistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote); -this function modify the history of a subscription. Put your new values on input arg. - -=back +this function modifies the history of a subscription. Put your new values on input arg. +returns the number of rows affected =cut @@ -1067,15 +989,11 @@ sub ModSubscriptionHistory { =head2 ModSerialStatus -=over 4 - ModSerialStatus($serialid,$serialseq, $planneddate,$publisheddate,$status,$notes) This function modify the serial status. Serial status is a number.(eg 2 is "arrived") Note : if we change from "waited" to something else,then we will have to create a new "waited" entry -=back - =cut sub ModSerialStatus { @@ -1155,12 +1073,11 @@ sub ModSerialStatus { SendAlerts( 'issue', $val->{subscriptionid}, $val->{letter} ); } } + return; } =head2 GetNextExpected -=over 4 - $nextexpected = GetNextExpected($subscriptionid) Get the planneddate for the current expected issue of the subscription. @@ -1172,8 +1089,6 @@ $nextexepected = { planneddate => C4::Dates object } -=back - =cut sub GetNextExpected($) { @@ -1200,8 +1115,6 @@ sub GetNextExpected($) { =head2 ModNextExpected -=over 4 - ModNextExpected($subscriptionid,$date) Update the planneddate for the current expected issue of the subscription. @@ -1209,7 +1122,7 @@ This will modify all future prediction results. C<$date> is a C4::Dates object. -=back +returns 0 =cut @@ -1228,11 +1141,8 @@ sub ModNextExpected($$) { =head2 ModSubscription -=over 4 - -this function modify a subscription. Put all new values on input args. - -=back +this function modifies a subscription. Put all new values on input args. +returns the number of rows affected =cut @@ -1276,7 +1186,6 @@ sub ModSubscription { $graceperiod, $location, $enddate, $subscriptionid ); my $rows = $sth->rows; - $sth->finish; logaction( "SERIAL", "MODIFY", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog"); return $rows; @@ -1284,8 +1193,6 @@ sub ModSubscription { =head2 NewSubscription -=over 4 - $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, @@ -1299,8 +1206,6 @@ Create a new subscription with value given on input args. return : the id of this new subscription -=back - =cut sub NewSubscription { @@ -1383,14 +1288,10 @@ sub NewSubscription { =head2 ReNewSubscription -=over 4 - ReNewSubscription($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note) this function renew a subscription with values given on input args. -=back - =cut sub ReNewSubscription { @@ -1446,18 +1347,16 @@ sub ReNewSubscription { $sth->execute( $enddate, $subscriptionid ); logaction( "SERIAL", "RENEW", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog"); + return; } =head2 NewIssue -=over 4 - NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes) Create a new issue stored on the database. Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription. - -=back +returns the serial id =cut @@ -1506,16 +1405,12 @@ sub NewIssue { =head2 ItemizeSerials -=over 4 - ItemizeSerials($serialid, $info); $info is a hashref containing barcode branch, itemcallnumber, status, location $serialid the serialid return : 1 if the itemize is a succes. -0 and @error else. @error containts the list of errors found. - -=back +0 and @error otherwise. @error containts the list of errors found. =cut @@ -1641,8 +1536,6 @@ sub ItemizeSerials { =head2 HasSubscriptionStrictlyExpired -=over 4 - 1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) the subscription has stricly expired when today > the end subscription date @@ -1650,8 +1543,6 @@ the subscription has stricly expired when today > the end subscription date return : 1 if true, 0 if false, -1 if the expiration date is not set. -=back - =cut sub HasSubscriptionStrictlyExpired { @@ -1686,8 +1577,6 @@ sub HasSubscriptionStrictlyExpired { =head2 HasSubscriptionExpired -=over 4 - $has_expired = HasSubscriptionExpired($subscriptionid) the subscription has expired when the next issue to arrive is out of subscription limit. @@ -1697,8 +1586,6 @@ return : 1 if the subscription has expired 2 if has subscription does not have a valid expiration date set -=back - =cut sub HasSubscriptionExpired { @@ -1737,13 +1624,9 @@ sub HasSubscriptionExpired { =head2 SetDistributedto -=over 4 - SetDistributedto($distributedto,$subscriptionid); This function update the value of distributedto for a subscription given on input arg. -=back - =cut sub SetDistributedto { @@ -1756,16 +1639,13 @@ sub SetDistributedto { |; my $sth = $dbh->prepare($query); $sth->execute( $distributedto, $subscriptionid ); + return; } =head2 DelSubscription -=over 4 - DelSubscription($subscriptionid) -this function delete the subscription which has $subscriptionid as id. - -=back +this function deletes subscription which has $subscriptionid as id. =cut @@ -1782,12 +1662,10 @@ sub DelSubscription { =head2 DelIssue -=over 4 - DelIssue($serialseq,$subscriptionid) -this function delete an issue which has $serialseq and $subscriptionid given on input arg. +this function deletes an issue which has $serialseq and $subscriptionid given on input arg. -=back +returns the number of rows affected =cut @@ -1830,18 +1708,14 @@ sub DelIssue { =head2 GetLateOrMissingIssues -=over 4 - @issuelist = &GetLateMissingIssues($supplierid,$serialid) -this function select missing issues on database - where serial.status = 4 or serial.status=3 or planneddateexecute( $missinglist, $subscriptionid ); } + return; } =head2 updateClaim -=over 4 - &updateClaim($serialid) this function updates the time when a claim is issued for late/missing items called from claims.pl file -=back - =cut sub updateClaim { @@ -1968,21 +1835,18 @@ sub updateClaim { " ); $sth->execute($serialid); + return; } =head2 getsupplierbyserialid -=over 4 - -($result) = &getsupplierbyserialid($serialid) +$result = getsupplierbyserialid($serialid) this function is used to find the supplier id given a serial id return : hashref containing serialid, subscriptionid, and aqbooksellerid -=back - =cut sub getsupplierbyserialid { @@ -2003,15 +1867,11 @@ sub getsupplierbyserialid { =head2 check_routing -=over 4 - -($result) = &check_routing($subscriptionid) +$result = &check_routing($subscriptionid) this function checks to see if a serial has a routing list and returns the count of routingid used to show either an 'add' or 'edit' link -=back - =cut sub check_routing { @@ -2031,16 +1891,12 @@ sub check_routing { =head2 addroutingmember -=over 4 +addroutingmember($borrowernumber,$subscriptionid) -&addroutingmember($borrowernumber,$subscriptionid) - -this function takes a borrowernumber and subscriptionid and add the member to the +this function takes a borrowernumber and subscriptionid and adds the member to the routing list for that serial subscription and gives them a rank on the list of either 1 or highest current rank + 1 -=back - =cut sub addroutingmember { @@ -2062,9 +1918,7 @@ sub addroutingmember { =head2 reorder_members -=over 4 - -&reorder_members($subscriptionid,$routingid,$rank) +reorder_members($subscriptionid,$routingid,$rank) this function is used to reorder the routing list @@ -2074,8 +1928,6 @@ it takes the routingid of the member one wants to re-rank and the rank it is to - then reinjects $routingid at point indicated by $rank - then update the database with the routingids in the new order -=back - =cut sub reorder_members { @@ -2108,19 +1960,16 @@ sub reorder_members { my $sth = $dbh->prepare( "UPDATE subscriptionroutinglist SET ranking = '" . ( $j + 1 ) . "' WHERE routingid = '" . $result[$j] . "'" ); $sth->execute; } + return; } =head2 delroutingmember -=over 4 - -&delroutingmember($routingid,$subscriptionid) +delroutingmember($routingid,$subscriptionid) this function either deletes one member from routing list if $routingid exists otherwise deletes all members from the routing list -=back - =cut sub delroutingmember { @@ -2136,23 +1985,20 @@ sub delroutingmember { my $sth = $dbh->prepare("DELETE FROM subscriptionroutinglist WHERE subscriptionid = ?"); $sth->execute($subscriptionid); } + return; } =head2 getroutinglist -=over 4 - -($count,@routinglist) = &getroutinglist($subscriptionid) +($count,@routinglist) = getroutinglist($subscriptionid) this gets the info from the subscriptionroutinglist for $subscriptionid return : a count of the number of members on routinglist -the routinglist into a table. Each line of this table containts a ref to a hash which containts +the routinglist as an array. Each element of the array contains a hash_ref containing routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription -=back - =cut sub getroutinglist { @@ -2177,12 +2023,10 @@ sub getroutinglist { =head2 countissuesfrom -=over 4 +$result = countissuesfrom($subscriptionid,$startdate) -$result = &countissuesfrom($subscriptionid,$startdate) - - -=back +Returns a count of serial rows matching the given subsctiptionid +with published date greater than startdate =cut @@ -2203,12 +2047,9 @@ sub countissuesfrom { =head2 CountIssues -=over 4 +$result = CountIssues($subscriptionid) -$result = &CountIssues($subscriptionid) - - -=back +Returns a count of serial rows matching the given subsctiptionid =cut @@ -2228,12 +2069,9 @@ sub CountIssues { =head2 HasItems -=over 4 +$result = HasItems($subscriptionid) -$result = &HasItems($subscriptionid) - - -=back +returns a count of items from serial matching the subscriptionid =cut @@ -2254,17 +2092,13 @@ sub HasItems { =head2 abouttoexpire -=over 4 - -$result = &abouttoexpire($subscriptionid) +$result = abouttoexpire($subscriptionid) this function alerts you to the penultimate issue for a serial subscription returns 1 - if this is the penultimate issue returns 0 - if not -=back - =cut sub abouttoexpire { @@ -2301,13 +2135,21 @@ sub abouttoexpire { return 0; } +sub in_array { # used in next sub down + my ( $val, @elements ) = @_; + foreach my $elem (@elements) { + if ( $val == $elem ) { + return 1; + } + } + return 0; +} + =head2 GetNextDate -($resultdate) = &GetNextDate($planneddate,$subscription) +$resultdate = GetNextDate($planneddate,$subscription) -this function is an extension of GetNextDate which allows for checking for irregularity - -it takes the planneddate and will return the next issue's date and will skip dates if there +this function it takes the planneddate and will return the next issue's date and will skip dates if there exists an irregularity - eg if periodicity is monthly and $planneddate is 2007-02-10 but if March and April is to be skipped then the returned date will be 2007-05-10 @@ -2319,16 +2161,6 @@ Return 0 if periodicity==0 =cut -sub in_array { # used in next sub down - my ( $val, @elements ) = @_; - foreach my $elem (@elements) { - if ( $val == $elem ) { - return 1; - } - } - return 0; -} - sub GetNextDate(@) { my ( $planneddate, $subscription ) = @_; my @irreg = split( /\,/, $subscription->{irregularity} ); @@ -2472,7 +2304,7 @@ sub GetNextDate(@) { =head2 itemdata - $item = &itemdata($barcode); + $item = itemdata($barcode); Looks up the item with the given barcode, and returns a reference-to-hash containing information about that item. The keys of From 5226371ea3e438c2ecf43ef18cbac090fe17c373 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 17:58:20 +0100 Subject: [PATCH 6/9] Remove bottleneck making claims page unuseable While the idea of showing the number of late serials against the vendor name was nice it does not scale and on large sites selecting claims was just timing out. Improved the speed of the initial query but have removed the big query for each user just to get a count. Check for 0000-00-00 dates so that C4::Dates does not log error Removed a variable that was never set and the bit of template used if the impossible happened --- C4/Serials.pm | 22 ++++++------ .../prog/en/modules/serials/claims.tmpl | 4 --- serials/claims.pl | 36 ++++++++----------- 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 7b42465f38..a50d9038d1 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -91,15 +91,12 @@ the array is in name order sub GetSuppliersWithLateIssues { my $dbh = C4::Context->dbh; - my $query = qq| - SELECT DISTINCT id, name - FROM subscription - LEFT JOIN serial ON serial.subscriptionid=subscription.subscriptionid - LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id - WHERE subscription.subscriptionid = serial.subscriptionid - AND (planneddate < now() OR serial.STATUS = 3 OR serial.STATUS = 4) - ORDER BY name - |; + my $query = q| + SELECT DISTINCT aqbooksellerid as id, aqbooksellers.name as name + FROM subscription + LEFT JOIN serial ON serial.subscriptionid=subscription.subscriptionid + LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id + WHERE (planneddate < now() OR serial.STATUS = 3 OR serial.STATUS = 4) ORDER BY name|; return $dbh->selectall_arrayref($query, { Slice => {} }); } @@ -1708,7 +1705,7 @@ sub DelIssue { =head2 GetLateOrMissingIssues -@issuelist = &GetLateMissingIssues($supplierid,$serialid) +@issuelist = GetLateMissingIssues($supplierid,$serialid) this function selects missing issues on database - where serial.status = 4 or serial.status=3 or planneddateexecute; my @issuelist; while ( my $line = $sth->fetchrow_hashref ) { - if ($line->{planneddate}) { + + if ($line->{planneddate} && $line->{planneddate} !~/^0+\-/) { $line->{planneddate} = format_date( $line->{planneddate} ); } - if ($line->{claimdate}) { + if ($line->{claimdate} && $line->{claimdate} !~/^0+\-/) { $line->{claimdate} = format_date( $line->{claimdate} ); } $line->{"status".$line->{status}} = 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl index 1e5c8b0fb9..d678022486 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tmpl @@ -292,10 +292,6 @@

- - " /> - &op=preview" onclick="popup(,''); return false" class="button">Vendor Group Claim Notice

--> -
diff --git a/serials/claims.pl b/serials/claims.pl index 5b73d8bd3a..e39e350e9d 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -10,7 +10,7 @@ use C4::Output; use C4::Bookseller; use C4::Context; use C4::Letters; -my $input = new CGI; +my $input = CGI->new; my $serialid = $input->param('serialid'); my $op = $input->param('op'); @@ -18,26 +18,26 @@ my $claimletter = $input->param('claimletter'); my $supplierid = $input->param('supplierid'); my $suppliername = $input->param('suppliername'); my $order = $input->param('order'); -my $supplierlist = GetSuppliersWithLateIssues; +my $supplierlist = GetSuppliersWithLateIssues(); +if ($supplierid) { + foreach my $s ( @{$supplierlist} ) { + if ($s->{id} == $supplierid ) { + $s->{selected} = 1; + last; + } + } +} # open template first (security & userenv set here) my ($template, $loggedinuser, $cookie) -= get_template_and_user({template_name => "serials/claims.tmpl", += get_template_and_user({template_name => 'serials/claims.tmpl', query => $input, - type => "intranet", + type => 'intranet', authnotrequired => 0, flagsrequired => {serials => 1}, debug => 1, }); -for my $supplier ( @{$supplierlist} ) { - my @dummy = GetLateOrMissingIssues($supplier->{id},q{},$order); - my $counting = scalar @dummy; - $supplier->{name} .= " ($counting)"; - if ($supplierid && $supplierid == $supplier->{id}) { - $supplier->{selected} = 1; - } -} my $letters = GetLetters('claimissues'); my @letters; @@ -47,17 +47,10 @@ foreach (keys %{$letters}){ my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code})); my @missingissues; +my @supplierinfo; if ($supplierid) { @missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order); -} - -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 $mi (@missingissues){ - $mi->{supplierid} = getsupplierbyserialid($mi->{serialid}); - } + @supplierinfo=GetBookSeller($supplierid); } my $preview=0; @@ -82,7 +75,6 @@ $template->param( missingissues => \@missingissues, supplierid => $supplierid, claimletter => $claimletter, - singlesupplier => $singlesupplier, supplierloop => \@supplierinfo, dateformat => C4::Context->preference("dateformat"), DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), From ad3594fded5bc25d8f5e06b5487b1492884b32d8 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 20:04:24 +0100 Subject: [PATCH 7/9] Bug 4380 Use syspref to resolve which bib display is used Be consistent with elsewhere in cataloguing When switching there from serials TODO Duplicates Code Should be in a common routine --- .../prog/en/modules/serials/serials-edit.tmpl | 2 +- .../en/modules/serials/subscription-detail.tmpl | 2 +- serials/serials-edit.pl | 16 ++++++++++++++++ serials/subscription-detail.pl | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl index 56ffecec08..55499875ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl @@ -424,7 +424,7 @@ function CloneSubfield(index){ )">Renew -
  • " title="go to ">Show Biblio
  • +
  • " title="go to ">Show Biblio
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl index 6e7b982a0e..86c3efcf61 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl @@ -82,7 +82,7 @@ function popup(subscriptionid) {
  • Subscription ID:
  • Librarian identity:
  • Vendor: "> 
  • -
  • Biblio: () ">
  • +
  • Biblio: () ">
  • Library:  
  • Serial receipt creates an item record.
  • diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 1ee831da23..3e2a852071 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -357,11 +357,27 @@ if ( $op and $op eq 'serialchangestatus' ) { print $query->redirect($redirect); } } +my $default_bib_view = get_default_view(); $template->param( serialsadditems => $serialdatalist[0]->{'serialsadditems'}, bibliotitle => $bibdata->{'title'}, biblionumber => $serialdatalist[0]->{'biblionumber'}, serialslist => \@serialdatalist, + default_bib_view => $default_bib_view, ); output_html_with_http_headers $query, $cookie, $template->output; + +sub get_default_view { + my $defaultview = C4::Context->preference('IntranetBiblioDefaultView'); + my $views = { C4::Search::enabled_staff_search_views }; + if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) { + return 'ISBDdetail'; + } elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) { + return 'MARCdetail'; + } elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) { + return 'labeledMARCdetail'; + } else { + return 'detail'; + } +} diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 0b8e57975d..a2b1d0c09a 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -101,6 +101,7 @@ if (! $subs->{dow}) { if (! $subs->{periodicity}) { $subs->{periodicity} = '0'; } +my $default_bib_view = get_default_view(); $template->param( subscriptionid => $subscriptionid, serialslist => \@serialslist, @@ -118,6 +119,21 @@ $template->param( intranetstylesheet => C4::Context->preference('intranetstylesheet'), intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'), irregular_issues => scalar @irregular_issues, + default_bib_view => $default_bib_view, ); output_html_with_http_headers $query, $cookie, $template->output; + +sub get_default_view { + my $defaultview = C4::Context->preference('IntranetBiblioDefaultView'); + my $views = { C4::Search::enabled_staff_search_views }; + if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) { + return 'ISBDdetail'; + } elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) { + return 'MARCdetail'; + } elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) { + return 'labeledMARCdetail'; + } else { + return 'detail'; + } +} From 255362e3cfd1532f0d0a79d757b883123159d681 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 20:37:12 +0100 Subject: [PATCH 8/9] Fix FSF Address in directory serials/ Add License statement to those files lacking it --- serials/checkexpiration.pl | 6 +++--- serials/claims.pl | 15 +++++++++++++++ serials/lateissues-excel.pl | 15 +++++++++++++++ serials/member-search.pl | 6 +++--- serials/reorder_members.pl | 15 +++++++++++++++ serials/routing-preview.pl | 15 +++++++++++++++ serials/routing.pl | 6 +++--- serials/statecollection.pl | 6 +++--- serials/subscription-add.pl | 6 +++--- serials/subscription-detail.pl | 6 +++--- 10 files changed, 78 insertions(+), 18 deletions(-) diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl index c055d5d24a..16529b0a7a 100755 --- a/serials/checkexpiration.pl +++ b/serials/checkexpiration.pl @@ -12,9 +12,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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. =head1 NAME diff --git a/serials/claims.pl b/serials/claims.pl index e39e350e9d..af0143d6d0 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -1,5 +1,20 @@ #!/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; diff --git a/serials/lateissues-excel.pl b/serials/lateissues-excel.pl index 47ce51a478..e5cc8498d1 100755 --- a/serials/lateissues-excel.pl +++ b/serials/lateissues-excel.pl @@ -1,5 +1,20 @@ #!/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; diff --git a/serials/member-search.pl b/serials/member-search.pl index 549067a1dd..2d9a031f52 100755 --- a/serials/member-search.pl +++ b/serials/member-search.pl @@ -11,9 +11,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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. =head1 member-search.pl diff --git a/serials/reorder_members.pl b/serials/reorder_members.pl index d82f2d7a89..224a37af14 100755 --- a/serials/reorder_members.pl +++ b/serials/reorder_members.pl @@ -1,4 +1,19 @@ #!/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. + # Routing.pl script used to create a routing list for a serial subscription # In this instance it is in fact a setting up of a list of reserves for the item diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index 7fb471952d..716ccedbe2 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -1,5 +1,20 @@ #!/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. + # Routing Preview.pl script used to view a routing list after creation # lets one print out routing slip and create (in this instance) the heirarchy # of reserves for the serial diff --git a/serials/routing.pl b/serials/routing.pl index 3d2c5148d7..524c71ddcc 100755 --- a/serials/routing.pl +++ b/serials/routing.pl @@ -11,9 +11,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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. =head1 Routing.pl diff --git a/serials/statecollection.pl b/serials/statecollection.pl index 13960fbd66..bcbfbdabd4 100755 --- a/serials/statecollection.pl +++ b/serials/statecollection.pl @@ -11,9 +11,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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; diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index f7f23e76f4..242f7b41f1 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -11,9 +11,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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; diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index a2b1d0c09a..d8c44ee33f 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -11,9 +11,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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; From cfbd0c847eb20a6875a14a7f85b033cb22f0d8d8 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Apr 2010 22:36:16 +0100 Subject: [PATCH 9/9] Check value is defined before splitting it splitting an undef generates a warning --- C4/Serials.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C4/Serials.pm b/C4/Serials.pm index a50d9038d1..6cef7efea6 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1591,6 +1591,9 @@ sub HasSubscriptionExpired { my $subscription = GetSubscription($subscriptionid); if ( ( $subscription->{periodicity} % 16 ) > 0 ) { my $expirationdate = $subscription->{enddate}; + if (!defined $expirationdate) { + $expirationdate = q{}; + } my $query = qq| SELECT max(planneddate) FROM serial