X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=cataloguing%2Fmerge.pl;h=fca94ca4d54b5939f0be04175073347240f43016;hb=2ab8f50835acb06a115f00119b88e6f5053472c1;hp=7b1f81635cfaa1ea53c086cffbf46df3bf29bdc1;hpb=96cc447045f3f1d3702a3c69b36f596d88f38eda;p=koha-ffzg.git diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl index 7b1f81635c..fca94ca4d5 100755 --- a/cataloguing/merge.pl +++ b/cataloguing/merge.pl @@ -21,16 +21,24 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use C4::Output; -use C4::Auth; -use C4::Items; -use C4::Biblio; -use C4::Serials; -use C4::Koha; -use C4::Reserves qw/MergeHolds/; -use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); +use C4::Biblio qw( + DelBiblio + GetBiblioData + GetFrameworkCode + GetMarcBiblio + GetMarcFromKohaField + GetMarcStructure + ModBiblio + TransformHtmlToMarc +); +use C4::Serials qw( CountSubscriptionFromBiblionumber ); +use C4::Reserves qw( MergeHolds ); +use C4::Acquisition qw( ModOrder GetOrdersByBiblionumber ); use Koha::BiblioFrameworks; +use Koha::Biblios; use Koha::Items; use Koha::MetadataRecord; @@ -80,25 +88,16 @@ if ($merge) { $record->leader(GetMarcBiblio({ biblionumber => $ref_biblionumber })->leader()); my $frameworkcode = $input->param('frameworkcode'); - my @notmoveditems; # Modifying the reference record ModBiblio($record, $ref_biblionumber, $frameworkcode); - # Moving items from the other record to the reference record + # Moving items and article requests from the other record to the reference record + my $biblio = Koha::Biblios->find($ref_biblionumber); foreach my $biblionumber (@biblionumbers) { - my $items = Koha::Items->search({ biblionumber => $biblionumber }); - while ( my $item = $items->next) { - my $res = MoveItemFromBiblio( $item->itemnumber, $biblionumber, $ref_biblionumber ); - if ( not defined $res ) { - push @notmoveditems, $item->itemnumber; - } - } - } - # If some items could not be moved : - if (scalar(@notmoveditems) > 0) { - my $itemlist = join(' ',@notmoveditems); - push @errors, { code => "CANNOT_MOVE", value => $itemlist }; + my $from_biblio = Koha::Biblios->find($biblionumber); + $from_biblio->items->move_to_biblio($biblio); + $from_biblio->article_requests->update({ biblionumber => $ref_biblionumber }, { no_triggers => 1 }); } my $sth_subscription = $dbh->prepare(" @@ -162,7 +161,7 @@ if ($merge) { # Moving suggestions $sth_suggestions->execute($ref_biblionumber, $biblionumber); - # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio) + # Moving orders (orders linked to items of frombiblio have already been moved by move_to_biblio) my @allorders = GetOrdersByBiblionumber($biblionumber); foreach my $myorder (@allorders) { $myorder->{'biblionumber'} = $ref_biblionumber;