From 42ef8c7e98a7785de46ade8cc88bc904bbf6149e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 11 Nov 2015 08:54:12 +0000 Subject: [PATCH] Bug 15168: Remove C4:Serials::ItemizeSerials MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This subroutine has been introduced in 2006, when C4::Serials has been added to the codebase. If you checkout this commit commit 18d2cd099085e443d713a1546e029faa81481814 Date: Fri Jul 7 08:45:47 2006 +0000 this file replace C4/Bull.pm You won't find any occurrences of this subroutine neither. Interesting module's name by the way. Test plan: git grep ItemizeSerials should not return any result Followed test plan, no results found. Signed-off-by: Marc Véron Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Serials.pm | 137 +-------------------------------------- t/db_dependent/Serials.t | 4 +- 2 files changed, 2 insertions(+), 139 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 7e977df238..5f348ce0a4 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -69,7 +69,7 @@ BEGIN { &HasSubscriptionStrictlyExpired &HasSubscriptionExpired &GetExpirationDate &abouttoexpire &GetSubscriptionHistoryFromSubscriptionId - &GetNextSeq &GetSeq &NewIssue &ItemizeSerials &GetSerials + &GetNextSeq &GetSeq &NewIssue &GetSerials &GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2 &ReNewSubscription &GetLateOrMissingIssues &GetSerialInformation &AddItem2Serial @@ -1588,141 +1588,6 @@ sub NewIssue { return $serialid; } -=head2 ItemizeSerials - -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 otherwise. @error containts the list of errors found. - -=cut - -sub ItemizeSerials { - my ( $serialid, $info ) = @_; - - return unless ($serialid); - - my $now = POSIX::strftime( "%Y-%m-%d", localtime ); - - my $dbh = C4::Context->dbh; - my $query = qq| - SELECT * - FROM serial - WHERE serialid=? - |; - my $sth = $dbh->prepare($query); - $sth->execute($serialid); - my $data = $sth->fetchrow_hashref; - if ( C4::Context->preference("RoutingSerials") ) { - - # check for existing biblioitem relating to serial issue - my ( $count, @results ) = GetBiblioItemByBiblioNumber( $data->{'biblionumber'} ); - my $bibitemno = 0; - for ( my $i = 0 ; $i < $count ; $i++ ) { - if ( $results[$i]->{'volumeddesc'} eq $data->{'serialseq'} . ' (' . $data->{'planneddate'} . ')' ) { - $bibitemno = $results[$i]->{'biblioitemnumber'}; - last; - } - } - if ( $bibitemno == 0 ) { - my $sth = $dbh->prepare( "SELECT * FROM biblioitems WHERE biblionumber = ? ORDER BY biblioitemnumber DESC" ); - $sth->execute( $data->{'biblionumber'} ); - my $biblioitem = $sth->fetchrow_hashref; - $biblioitem->{'volumedate'} = $data->{planneddate}; - $biblioitem->{'volumeddesc'} = $data->{serialseq} . ' (' . format_date( $data->{'planneddate'} ) . ')'; - $biblioitem->{'dewey'} = $info->{itemcallnumber}; - } - } - - my $fwk = GetFrameworkCode( $data->{'biblionumber'} ); - if ( $info->{barcode} ) { - my @errors; - if ( is_barcode_in_use( $info->{barcode} ) ) { - push @errors, 'barcode_not_unique'; - } else { - my $marcrecord = MARC::Record->new(); - my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk ); - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} ); - $marcrecord->insert_fields_ordered($newField); - if ( $info->{branch} ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( "items.homebranch", $fwk ); - - #warn "items.homebranch : $tag , $subfield"; - if ( $marcrecord->field($tag) ) { - $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{branch} ); - } else { - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{branch} ); - $marcrecord->insert_fields_ordered($newField); - } - ( $tag, $subfield ) = GetMarcFromKohaField( "items.holdingbranch", $fwk ); - - #warn "items.holdingbranch : $tag , $subfield"; - if ( $marcrecord->field($tag) ) { - $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{branch} ); - } else { - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{branch} ); - $marcrecord->insert_fields_ordered($newField); - } - } - if ( $info->{itemcallnumber} ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( "items.itemcallnumber", $fwk ); - - 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 ) = GetMarcFromKohaField( "items.itemnotes", $fwk ); - - if ( $marcrecord->field($tag) ) { - $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{notes} ); - } else { - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{notes} ); - $marcrecord->insert_fields_ordered($newField); - } - } - if ( $info->{location} ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( "items.location", $fwk ); - - if ( $marcrecord->field($tag) ) { - $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{location} ); - } else { - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{location} ); - $marcrecord->insert_fields_ordered($newField); - } - } - if ( $info->{status} ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( "items.notforloan", $fwk ); - - if ( $marcrecord->field($tag) ) { - $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{status} ); - } else { - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{status} ); - $marcrecord->insert_fields_ordered($newField); - } - } - if ( C4::Context->preference("RoutingSerials") ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( "items.dateaccessioned", $fwk ); - if ( $marcrecord->field($tag) ) { - $marcrecord->field($tag)->add_subfields( "$subfield" => $now ); - } else { - my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $now ); - $marcrecord->insert_fields_ordered($newField); - } - } - require C4::Items; - C4::Items::AddItemFromMarc( $marcrecord, $data->{'biblionumber'} ); - return 1; - } - return ( 0, @errors ); - } -} - =head2 HasSubscriptionStrictlyExpired 1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 3a4942dcfc..1f3ebb0e86 100644 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -15,7 +15,7 @@ use C4::Bookseller; use C4::Biblio; use C4::Budgets; use Koha::DateUtils; -use Test::More tests => 46; +use Test::More tests => 45; BEGIN { use_ok('C4::Serials'); @@ -175,8 +175,6 @@ is(C4::Serials::ModSerialStatus(),undef, 'test modding serials'); is(C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered'); -is(C4::Serials::ItemizeSerials(),undef, 'test getting nothing when nothing is entered'); - is(C4::Serials::HasSubscriptionStrictlyExpired(), undef, 'test if the subscriptions has expired'); is(C4::Serials::HasSubscriptionExpired(), undef, 'test if the subscriptions has expired'); -- 2.39.5