X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FMembers.pm;h=1f0ac3f99516479873233b0e3eee4586d47b2c58;hb=39d1b7e61b4e11d76e443f7755aba96e3cf13ab6;hp=7def77e80bdcabf928389921bc7ee133bb4d6d49;hpb=a9ded4fa008668df8c485fbbc76efa3cc9cc00d7;p=koha_gimpoz diff --git a/C4/Members.pm b/C4/Members.pm index 7def77e80b..1f0ac3f995 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -35,6 +35,9 @@ use C4::Letters; 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); @@ -95,6 +98,7 @@ BEGIN { &GetMessagesCount &IssueSlip + GetBorrowersWithEmail ); #Modify data @@ -472,7 +476,7 @@ sub patronflags { $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"; @@ -638,7 +642,7 @@ sub IsMemberBlocked { "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'}; @@ -676,7 +680,7 @@ sub GetMemberIssuesAndFines { $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]; @@ -1031,9 +1035,15 @@ sub GetPendingIssues { 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; } } @@ -2308,6 +2318,36 @@ sub IssueSlip { ); } +=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 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__