use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable);
use C4::Members::Attributes qw(SearchIdMatchingAttribute);
use C4::NewsChannels; #get slip news
+use DateTime;
+use DateTime::Format::DateParse;
+use Koha::DateUtils;
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
&GetMessagesCount
&IssueSlip
+ GetBorrowersWithEmail
);
#Modify data
$flaginfo{'message'} = $patroninformation->{'borrowernotes'};
$flags{'NOTES'} = \%flaginfo;
}
- my ( $odues, $itemsoverdue ) = checkoverdues($patroninformation->{'borrowernumber'});
+ my ( $odues, $itemsoverdue ) = C4::Overdues::checkoverdues($patroninformation->{'borrowernumber'});
if ( $odues && $odues > 0 ) {
my %flaginfo;
$flaginfo{'message'} = "Yes";
"SELECT COUNT(*) as latedocs
FROM issues
WHERE borrowernumber = ?
- AND date_due < curdate()"
+ AND date_due < now()"
);
$sth->execute($borrowernumber);
my $latedocs = $sth->fetchrow_hashref->{'latedocs'};
$sth = $dbh->prepare(
"SELECT COUNT(*) FROM issues
WHERE borrowernumber = ?
- AND date_due < curdate()"
+ AND date_due < now()"
);
$sth->execute($borrowernumber);
my $overdue_count = $sth->fetchrow_arrayref->[0];
return ($overdue_count, $issue_count, $total_fines);
}
-sub columns(;$) {
- return @{C4::Context->dbh->selectcol_arrayref("SHOW columns from borrowers")};
-}
-
=head2 ModMember
my $success = ModMember(borrowernumber => $borrowernumber,
my $sth = C4::Context->dbh->prepare($query);
$sth->execute(@borrowernumbers);
my $data = $sth->fetchall_arrayref({});
- my $today = C4::Dates->new->output('iso');
+ my $tz = C4::Context->tz();
+ my $today = DateTime->now( time_zone => $tz);
foreach (@{$data}) {
- if ($_->{date_due} and $_->{date_due} lt $today) {
+ if ($_->{issuedate}) {
+ $_->{issuedate} = dt_from_string($_->{issuedate}, 'sql');
+ }
+ $_->{date_due} or next;
+ $_->{date_due} = DateTime::Format::DateParse->parse_datetime($_->{date_due}, $tz->name());
+ if ( DateTime->compare($_->{date_due}, $today) == -1 ) {
$_->{overdue} = 1;
}
}
);
}
+=head2 GetBorrowersWithEmail
+
+ ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
+
+This gets a list of users and their basic details from their email address.
+As it's possible for multiple user to have the same email address, it provides
+you with all of them. If there is no userid for the user, there will be an
+C<undef> there. An empty list will be returned if there are no matches.
+
+=cut
+
+sub GetBorrowersWithEmail {
+ my $email = shift;
+
+ my $dbh = C4::Context->dbh;
+
+ my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
+ my $sth=$dbh->prepare($query);
+ $sth->execute($email);
+ my @result = ();
+ while (my $ref = $sth->fetch) {
+ push @result, $ref;
+ }
+ die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
+ return @result;
+}
+
+
+END { } # module clean-up code here (global destructor)
+
1;
__END__