Bug 5549 : Get basic 24 Hr loan working
authorColin Campbell <colin.campbell@ptfs-europe.com>
Tue, 14 Jun 2011 14:32:27 +0000 (15:32 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Mon, 19 Mar 2012 23:13:34 +0000 (12:13 +1300)
C4/Members.pm
Koha/Calendar.pm
Koha/DateUtils.pm
circ/circulation.pl

index 4aa689f..513819e 100644 (file)
@@ -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;
         }
     }
index db1c7f7..5270f86 100644 (file)
@@ -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) ) {
index 06ef7c8..fb9e213 100644 (file)
@@ -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');
         }
 
     }
index 11b40a4..4c8a52a 100755 (executable)
@@ -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'}};