<div class="yui-b">
<h1>[% list.name |html %]</h1>
+ [% IF ( not_found.size > 0 ) %]
+ <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
+ <table style="margin:auto;">
+ <thead>
+ <tr><th>Cardnumbers not found</th></tr>
+ </thead>
+ <tbody>
+ [% FOREACH nf IN not_found %]
+ <tr><td>[% nf |html %]</td></td>
+ [% END %]
+ </tbody>
+ </table>
+ [% END %]
+
+ [% IF ( existed.size > 0 ) %]
+ <div class="dialog alert"><p>Warning, the following cardnumbers were already in this list:</p></div>
+ <table style="margin:auto;">
+ <thead>
+ <tr><th>Cardnumbers already in list</th></tr>
+ </thead>
+ <tbody>
+ [% FOREACH ed IN existed %]
+ <tr><td>[% ed |html %]</td></td>
+ [% END %]
+ </tbody>
+ </table>
+ [% END %]
+
<form action="list.pl" id="add_patrons" method="post" class="clearfix">
<fieldset class="rows">
<legend>Add patrons</legend>
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');