X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=tools%2Fbatch_delete_records.pl;h=2ec14ef653795373b2834dd2339a15c1b904080f;hb=f0108f4ff70bc351a2129ee670e07c8f79ae023e;hp=9eba7354a4b7357916a847057a9d8e666802c4d0;hpb=4ea26c0a697fcd8e4f88feb9a4f43a8b02c06650;p=koha-ffzg.git diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl index 9eba7354a4..2ec14ef653 100755 --- a/tools/batch_delete_records.pl +++ b/tools/batch_delete_records.pl @@ -23,17 +23,17 @@ use Modern::Perl; use CGI; use List::MoreUtils qw( uniq ); -use C4::Auth; -use C4::Output; -use C4::AuthoritiesMarc; -use C4::Biblio; +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); +use C4::Biblio qw( GetMarcBiblio ); use Koha::Virtualshelves; use Koha::Authorities; use Koha::Biblios; use Koha::Items; -my $input = new CGI; +my $input = CGI->new; my $op = $input->param('op') // q|form|; my $recordtype = $input->param('recordtype') // 'biblio'; @@ -41,7 +41,6 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ template_name => 'tools/batch_delete_records.tt', query => $input, type => "intranet", - authnotrequired => 0, flagsrequired => { tools => 'records_batchdel' }, }); @@ -94,7 +93,6 @@ if ( $op eq 'form' ) { my $holds_count = $biblio->holds->count; $biblio = $biblio->unblessed; my $record = &GetMarcBiblio({ biblionumber => $record_id }); - $biblio->{subtitle} = C4::Biblio::SplitSubtitle( $biblio->{subtitle} ); $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')]; $biblio->{holds_count} = $holds_count; $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); @@ -176,15 +174,15 @@ if ( $op eq 'form' ) { } # Delete items - my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber })->get_column('itemnumber'); - ITEMNUMBER: for my $itemnumber ( @itemnumbers ) { - my $error = eval { C4::Items::DelItemCheck( $biblionumber, $itemnumber ) }; - if ( $error != 1 or $@ ) { + my $items = Koha::Items->search({ biblionumber => $biblionumber }); + while ( my $item = $items->next ) { + my $deleted_item = eval { $item->safe_delete }; + if ( !ref($deleted_item) or $@ ) { push @messages, { type => 'error', code => 'item_not_deleted', biblionumber => $biblionumber, - itemnumber => $itemnumber, + itemnumber => $item->itemnumber, error => ($@ ? $@ : $error), }; $schema->storage->txn_rollback;