Bug 12759: Use a list (shelf) for batch record modification and deletion
[koha.git] / tools / batch_delete_records.pl
index 0194c5d..c8d0566 100755 (executable)
@@ -27,6 +27,7 @@ use C4::Auth;
 use C4::Output;
 use C4::AuthoritiesMarc;
 use C4::Biblio;
+use Koha::Virtualshelves;
 
 use Koha::Authorities;
 use Koha::Biblios;
@@ -44,6 +45,9 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({
         flagsrequired => { tools => 'records_batchdel' },
 });
 
+my @lists = Koha::Virtualshelves->search({});
+$template->param( lists => \@lists );
+
 my @records;
 my @messages;
 if ( $op eq 'form' ) {
@@ -64,6 +68,13 @@ if ( $op eq 'form' ) {
             $content =~ s/[\r\n]*$//;
             push @record_ids, $content if $content;
         }
+    } elsif ( my $shelf_number = $input->param('shelf_number') ) {
+        my $shelf = Koha::Virtualshelves->find($shelf_number);
+        my $contents = $shelf->get_contents;
+        while ( my $content = $contents->next ) {
+            my $biblionumber = $content->biblionumber;
+            push @record_ids, $biblionumber;
+        }
     } else {
         # The user enters manually the list of id
         push @record_ids, split( /\s\n/, $input->param('recordnumber_list') );