From 5cc4d00a6f2c7644fa709865956ba8e33381560f Mon Sep 17 00:00:00 2001 From: hdl Date: Wed, 8 Feb 2006 09:20:11 +0000 Subject: [PATCH] Bug fixing statecollection itemization : status and itemcallnumbers were not taken into account. re writing some code in order to have only a few blocks for serialadditems. changing status to itemstatus in template wherever it was necessary for script to work -- itemstatus(notforloan) is not status(arrived missing)--. --- C4/Bull.pm | 21 +++++- bull/statecollection.pl | 69 ++++++++++--------- .../default/en/bull/statecollection.tmpl | 4 +- 3 files changed, 56 insertions(+), 38 deletions(-) diff --git a/C4/Bull.pm b/C4/Bull.pm index 9bbe792f1b..bdead27430 100755 --- a/C4/Bull.pm +++ b/C4/Bull.pm @@ -474,7 +474,7 @@ sub serialsitemize { unless ($exists){ my $marcrecord = MARC::Record->new(); my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.barcode",$fwk); - warn "items.barcode : $tag , $subfield"; +# warn "items.barcode : $tag , $subfield"; my $newField = MARC::Field->new( "$tag",'','', "$subfield" => $info->{barcode} @@ -482,7 +482,7 @@ sub serialsitemize { $marcrecord->insert_fields_ordered($newField); if ($info->{branch}){ my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.homebranch",$fwk); - warn "items.homebranch : $tag , $subfield"; +# warn "items.homebranch : $tag , $subfield"; if ($marcrecord->field($tag)) { $marcrecord->field($tag)->add_subfields("$subfield" => $info->{branch}) }else { @@ -493,6 +493,7 @@ sub serialsitemize { $marcrecord->insert_fields_ordered($newField); } my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$fwk); +# warn "items.holdingbranch : $tag , $subfield"; if ($marcrecord->field($tag)) { $marcrecord->field($tag)->add_subfields("$subfield" => $info->{branch}) }else { @@ -503,8 +504,22 @@ sub serialsitemize { $marcrecord->insert_fields_ordered($newField); } } + if ($info->{itemcallnumber}){ + my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.itemcallnumber",$fwk); +# warn "items.itemcallnumber : $tag , $subfield"; + if ($marcrecord->field($tag)) { + $marcrecord->field($tag)->add_subfields("$subfield" => $info->{itemcallnumber}) + }else { + my $newField = MARC::Field->new( + "$tag",'','', + "$subfield" => $info->{itemcallnumber} + ); + $marcrecord->insert_fields_ordered($newField); + } + } if ($info->{notes}){ my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.itemnotes",$fwk); +# warn "items.itemnotes : $tag , $subfield"; if ($marcrecord->field($tag)) { $marcrecord->field($tag)->add_subfields("$subfield" => $info->{notes}) }else { @@ -517,6 +532,7 @@ sub serialsitemize { } if ($info->{location}){ my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.location",$fwk); +# warn "items.location : $tag , $subfield"; if ($marcrecord->field($tag)) { $marcrecord->field($tag)->add_subfields("$subfield" => $info->{location}) }else { @@ -529,6 +545,7 @@ sub serialsitemize { } if ($info->{status}){ my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.notforloan",$fwk); +# warn "items.notforloan : $tag , $subfield"; if ($marcrecord->field($tag)) { $marcrecord->field($tag)->add_subfields("$subfield" => $info->{status}) }else { diff --git a/bull/statecollection.pl b/bull/statecollection.pl index 0fd00e91fa..adc622ee90 100755 --- a/bull/statecollection.pl +++ b/bull/statecollection.pl @@ -89,47 +89,43 @@ my ($template, $loggedinuser, $cookie) my $subs = &getsubscription($subscriptionid); my ($totalissues,@serialslist) = getserials($subscriptionid); -my $branches = getbranches; -my @branchloop; -foreach my $thisbranch (keys %$branches) { - my %row =(value => $thisbranch, - branchname => $branches->{$thisbranch}->{'branchname'}, - ); - push @branchloop, \%row; -} - -my $itemstatushash = getitemstatus; -my @itemstatusloop; -foreach my $thisitemstatus (keys %$itemstatushash) { - my %row =(itemval => $thisitemstatus, - itemlib => $itemstatushash->{$thisitemstatus}, - ); - warn "".$row{'itemval'}.", ". $row{"itemlib"}; - push @itemstatusloop, \%row; -} - -my $itemlocationhash = getitemlocation; -my @itemlocationloop; -foreach my $thisitemlocation (keys %$itemlocationhash) { - my %row =(value => $thisitemlocation, - itemlocationname => $itemlocationhash->{$thisitemlocation}, - ); - push @itemlocationloop, \%row; -} if (C4::Context->preference("serialsadditems")){ + my $bibid=MARCfind_MARCbibid_from_oldbiblionumber($dbh,$subscription->{biblionumber}); + my $fwk=MARCfind_frameworkcode($dbh,$bibid); + + my $branches = getbranches; + my @branchloop; + foreach my $thisbranch (keys %$branches) { + my %row =(value => $thisbranch, + branchname => $branches->{$thisbranch}->{'branchname'}, + ); + push @branchloop, \%row; + } + + my $itemstatushash = getitemstatus($fwk); + my @itemstatusloop; + foreach my $thisitemstatus (keys %$itemstatushash) { + my %row =(itemval => $thisitemstatus, + itemlib => $itemstatushash->{$thisitemstatus}, + ); + warn "".$row{'itemval'}.", ". $row{"itemlib"}; + push @itemstatusloop, \%row; + } + + my $itemlocationhash = getitemlocation($fwk); + my @itemlocationloop; + foreach my $thisitemlocation (keys %$itemlocationhash) { + my %row =(value => $thisitemlocation, + itemlocationname => $itemlocationhash->{$thisitemlocation}, + ); + push @itemlocationloop, \%row; + } foreach my $data (@serialslist){ $data->{"itemstatusloop"}=\@itemstatusloop if (scalar(@itemstatusloop)); $data->{"itemlocationloop"}=\@itemlocationloop if (scalar(@itemlocationloop)); $data->{"branchloop"}=\@branchloop ; } -} - -my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?"); -$sth->execute($subscriptionid); -my $solhistory = $sth->fetchrow_hashref; - -if (C4::Context->preference("serialsadditems")){ $template->param(serialadditems =>C4::Context->preference("serialsadditems"), branchloop => \@branchloop, ) ; @@ -139,6 +135,11 @@ if (C4::Context->preference("serialsadditems")){ $template->param(branchloop=>[],itemstatusloop=>[],itemlocationloop=>[]) ; } +my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?"); +$sth->execute($subscriptionid); +my $solhistory = $sth->fetchrow_hashref; + + $template->param( serialslist => \@serialslist, biblionumber => $subscription->{biblionumber}, diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl index d784b79c6b..7bc7561ec2 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl @@ -90,7 +90,7 @@ - @@ -148,7 +148,7 @@ -