Bug 24008: Remove minus sign when displaying credit value
[koha-ffzg.git] / patron_lists / list.pl
index 91e6370..71bfa38 100755 (executable)
@@ -41,12 +41,25 @@ my ( $template, $logged_in_user, $cookie ) = get_template_and_user(
 my ($list) =
   GetPatronLists( { patron_list_id => scalar $cgi->param('patron_list_id') } );
 
+my @existing = $list->patron_list_patrons;
+
 my $cardnumbers = $cgi->param('patrons_by_barcode');
 my @patrons_by_barcode;
 
 if ( $cardnumbers ){
     push my @patrons_by_barcode, uniq( split(/\s\n/, $cardnumbers) );
-    AddPatronsToList( { list => $list, cardnumbers => \@patrons_by_barcode } );
+    my @results = AddPatronsToList( { list => $list, cardnumbers => \@patrons_by_barcode } );
+    my %found = map { $_->borrowernumber->cardnumber => 1 } @results;
+    my %exist = map { $_->borrowernumber->cardnumber => 1 } @existing;
+    my (@not_found, @existed);
+    foreach my $barcode ( @patrons_by_barcode ){
+        push (@not_found, $barcode) unless defined $found{$barcode};
+        push (@existed, $barcode) if defined $exist{$barcode};
+    }
+    $template->param(
+        not_found => \@not_found,
+        existed   => \@existed,
+    );
 }
 
 my @patrons_to_add = $cgi->multi_param('patrons_to_add');