Bug 5549 : fixed datetime issue so time is shown in output for circulation.pl and...
[koha_gimpoz] / C4 / Circulation.pm
index 41d60dd..6a9affa 100644 (file)
@@ -793,7 +793,7 @@ sub CanBookBeIssued {
     #
        my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item );
     # if TooMany max_loans_allowed returns 0 the user doesn't have permission to check out this book
-    if ($max_loans_allowed eq 0) {
+    if (defined $max_loans_allowed && $max_loans_allowed == 0) {
         $needsconfirmation{PATRON_CANT} = 1;
     } else {
         if($max_loans_allowed){
@@ -1735,10 +1735,10 @@ sub MarkIssueReturned {
     my $query = 'UPDATE issues SET returndate=';
     my @bind;
     if ($dropbox_branch) {
-        my $calendar = Koha->new( branchcode => $dropbox_branch );
+        my $calendar = Koha::Calendar->new( branchcode => $dropbox_branch );
         my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
         $query .= ' ? ';
-        push @bind, $dropboxdate->strftimei('%Y-%m-%d %H:%M');
+        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
     } elsif ($returndate) {
         $query .= ' ? ';
         push @bind, $returndate;
@@ -1794,7 +1794,7 @@ sub _FixFineDaysOnReturn {
     }
 
     my $branchcode = _GetCircControlBranch( $item, $borrower );
-    my $calendar = C4::Calendar->new( branchcode => $branchcode );
+    my $calendar = Koha::Calendar->new( branchcode => $branchcode );
     my $today = C4::Dates->new();
 
     my $deltadays = $calendar->daysBetween( $datedue, C4::Dates->new() );
@@ -2838,6 +2838,10 @@ sub CalcDateDue {
             }
             my $calendar = Koha::Calendar->new( branchcode => $branch );
             $datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} );
+            if ($loanlength->{lengthunit} eq 'days') {
+                $datedue->set_hour(23);
+                $datedue->set_minute(59);
+            }
         }
     }