- $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
- $batch = C4::Patroncards::Batch->new(branch_code => $branch_code) if $batch == -2;
+if ($bor_num_list) {
+ my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a <cr> separated list
+ foreach my $number (@bor_nums_unchecked) {
+ $number =~ s/\r$//; # strip any naughty return chars
+ if ( Koha::Patrons->find( $number )) { # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm
+ my $borrower_number = $number;
+ push @borrower_numbers, $borrower_number;
+ }
+ }
+ }
+ if ($batch_id != 0) {$batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);}
+ if ($batch_id == 0 || $batch == -2) {$batch = C4::Patroncards::Batch->new(branch_code => $branch_code);}