From 00bf7cc7744d75f1c33d798b1a6f02aab727a396 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 14 Jun 2011 15:32:27 +0100 Subject: [PATCH] Bug 5549 : Get basic 24 Hr loan working --- C4/Members.pm | 9 +++++++-- Koha/Calendar.pm | 10 ++++++++++ Koha/DateUtils.pm | 8 ++++---- circ/circulation.pl | 6 ++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 4aa689f63c..513819ee38 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -35,6 +35,8 @@ 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; our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug); @@ -1032,9 +1034,12 @@ 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) { + $_->{date_due} or next; + $_->{date_due} = DateTime::Format::DateParse->parse_datetime($_->{date_due}, $tz->name()); + if ( DateTime->compare($_->{date_due}, $today) == -1 ) { $_->{overdue} = 1; } } diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index db1c7f779f..5270f86228 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -98,6 +98,15 @@ sub addDate { } return $dt; } elsif ( $days_mode eq 'Calendar' ) { + if ($unit eq 'hours' ) { + $base_date->add_duration($add_duration); + while ($self->is_holiday($base_date)) { + $base_date->add_duration( $day_dur ); + + } + + } + else { my $days = $add_duration->in_units('days'); while ($days) { $base_date->add_duration( $day_dur ); @@ -107,6 +116,7 @@ sub addDate { --$days; } } + } if ( $unit eq 'hours' ) { my $dt = $base_date->clone()->subtract( days => 1 ); if ( $self->is_holiday($dt) ) { diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 06ef7c8ef5..fb9e2133a8 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -91,16 +91,16 @@ sub output_pref { my $pref = C4::Context->preference('dateformat'); given ($pref) { when (/^iso/) { - return $dt->strftime('%Y-%m-%d $H:%M'); + return $dt->strftime('%Y-%m-%d %H:%M'); } when (/^metric/) { - return $dt->strftime('%d/%m/%Y $H:%M'); + return $dt->strftime('%d/%m/%Y %H:%M'); } when (/^us/) { - return $dt->strftime('%m/%d/%Y $H:%M'); + return $dt->strftime('%m/%d/%Y %H:%M'); } default { - return $dt->strftime('%Y-%m-%d $H:%M'); + return $dt->strftime('%Y-%m-%d %H:%M'); } } diff --git a/circ/circulation.pl b/circ/circulation.pl index 11b40a4132..4c8a52a7ad 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -36,6 +36,7 @@ use C4::Reserves; use C4::Context; use CGI::Session; use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::DateUtils; use Date::Calc qw( Today @@ -445,9 +446,10 @@ sub build_issue_data { $totalprice += $it->{'replacementprice'}; $it->{'itemtype'} = $itemtypeinfo->{'description'}; $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'}; - $it->{'dd'} = format_date($it->{'date_due'}); + $it->{'dd'} = output_pref($it->{'date_due'}); $it->{'displaydate'} = format_date($it->{'issuedate'}); - $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ; + #$it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ; + $it->{'od'} = $it->{'overdue'}; ($it->{'author'} eq '') and $it->{'author'} = ' '; $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}}; -- 2.39.5