|
Lines 36-42
my $borrower_number;
Link Here
|
| 36 |
|
36 |
|
| 37 |
#errors |
37 |
#errors |
| 38 |
my $hasError; |
38 |
my $hasError; |
| 39 |
my $resultCount; |
|
|
| 40 |
|
39 |
|
| 41 |
#email form error |
40 |
#email form error |
| 42 |
my $errNoBorrowerFound; |
41 |
my $errNoBorrowerFound; |
|
Lines 56-86
if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
Link Here
|
| 56 |
#try with the main email |
55 |
#try with the main email |
| 57 |
$email ||= ''; # avoid undef |
56 |
$email ||= ''; # avoid undef |
| 58 |
my $borrower; |
57 |
my $borrower; |
| 59 |
my $search_results = []; |
58 |
my $search_results; |
| 60 |
|
59 |
|
| 61 |
# Find the borrower by his userid or email |
60 |
# Find the borrower by his userid or email |
| 62 |
if ($username) { |
61 |
if ($username) { |
| 63 |
$search_results = [ Koha::Patrons->search( { userid => $username } ) ]; |
62 |
$search_results = Koha::Patrons->search( { userid => $username } ); |
| 64 |
$resultCount = Koha::Patrons->search( { userid => $username } ) -> count |
|
|
| 65 |
} |
63 |
} |
| 66 |
elsif ($email) { |
64 |
elsif ($email) { |
| 67 |
$search_results = [ Koha::Patrons->search( { -or => { email => $email, emailpro => $email, B_email => $email } } ) ]; |
65 |
$search_results = Koha::Patrons->search( { -or => { email => $email, emailpro => $email, B_email => $email } } ); |
| 68 |
$resultCount = Koha::Patrons->search( { -or => { email => $email, emailpro => $email, B_email => $email } } ) -> count; |
|
|
| 69 |
} |
66 |
} |
| 70 |
|
67 |
|
| 71 |
if ( not $search_results || $resultCount < 1) { |
68 |
if ( not $search_results || $search_results->count < 1) { |
| 72 |
$hasError = 1; |
69 |
$hasError = 1; |
| 73 |
$errNoBorrowerFound = 1; |
70 |
$errNoBorrowerFound = 1; |
| 74 |
} |
71 |
} |
| 75 |
elsif ( $username && scalar $resultCount > 1) { # Multiple accounts for username |
72 |
elsif ( $username && $search_results->count > 1) { # Multiple accounts for username |
| 76 |
$hasError = 1; |
73 |
$hasError = 1; |
| 77 |
$errNoBorrowerFound = 1; |
74 |
$errNoBorrowerFound = 1; |
| 78 |
} |
75 |
} |
| 79 |
elsif ( $email && scalar $resultCount > 1) { # Muliple accounts for E-Mail |
76 |
elsif ( $email && $search_results->count > 1) { # Muliple accounts for E-Mail |
| 80 |
$hasError = 1; |
77 |
$hasError = 1; |
| 81 |
$errMultipleAccountsForEmail = 1; |
78 |
$errMultipleAccountsForEmail = 1; |
| 82 |
} |
79 |
} |
| 83 |
elsif ( $borrower = shift @$search_results ) { # One matching borrower |
80 |
elsif ( $borrower = $search_results->next() ) { # One matching borrower |
| 84 |
$username ||= $borrower->userid; |
81 |
$username ||= $borrower->userid; |
| 85 |
my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email ); |
82 |
my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email ); |
| 86 |
|
83 |
|
| 87 |
- |
|
|