fix for bug 1551: Renewing doesn't move item...
authorJesse Weaver <jesse.weaver@liblime.com>
Tue, 15 Jul 2008 17:06:42 +0000 (12:06 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 16 Jul 2008 23:26:16 +0000 (18:26 -0500)
This makes C4::Circulation::AddRenewal update lastreneweddate, then has circulation.pl check today's date against issuedate or lastreneweddate. It also cl
eans up a little parenthesis spacing.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Circulation.pm
circ/circulation.pl

index 6aac340..ca52e27 100644 (file)
@@ -1946,7 +1946,7 @@ sub AddRenewal {
     # Update the issues record to have the new due date, and a new count
     # of how many times it has been renewed.
     my $renews = $issuedata->{'renewals'} + 1;
-    $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?
+    $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = CURRENT_DATE
                             WHERE borrowernumber=? 
                             AND itemnumber=?"
     );
index 8c53bdc..3f35aa6 100755 (executable)
@@ -425,59 +425,59 @@ my $issued_itemtypes_flags;            #hashref that stores flags
 my @issued_itemtypes_count_loop;
 
 if ($borrower) {
-
 # get each issue of the borrower & separate them in todayissues & previous issues
     my ($countissues,$issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
 
     # split in 2 arrays for today & previous
     foreach my $it ( @$issueslist ) {
         # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
-        $it->{'itemtype'} = (C4::Context->preference('item-level_itypes')) ? $it->{'itype'} : $it->{'itemtype'};
+        $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
 
-    ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
+        ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
             $it->{'itemnumber'}, $borrower->{'borrowernumber'}
-    );
-    $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
+        );
+        $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
         my $can_renew_error;
         ($it->{'can_renew'}, $can_renew_error) = CanBookBeRenewed( 
             $borrower->{'borrowernumber'},$it->{'itemnumber'}
-    );
+        );
         $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
-    my ($restype, $reserves) = CheckReserves($it->{'itemnumber'});
-    ($restype) and $it->{'can_renew'} = 0;
+        my ( $restype, $reserves ) = CheckReserves( $it->{'itemnumber'} );
+        ( $restype ) and $it->{'can_renew'} = 0;
 
-    $it->{'dd'} = format_date($it->{'date_due'});
-    $it->{'od'} = ($it->{'date_due'} lt $todaysdate) ? 1 : 0 ;
+        $it->{'dd'} = format_date($it->{'date_due'});
+        $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
         ($it->{'author'} eq '') and $it->{'author'} = ' ';
         $it->{'renew_failed'} = $renew_failed[$it->{'itemnumber'}];
         # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
         $issued_itemtypes_count->{ $it->{'itemtype'} }++;
 
-        if ( $todaysdate == $it->{'issuedate'} ) {
+        warn "$todaysdate, $it->{'issuedate'}, $it->{'lastreneweddate'}, $it->{'barcode'}";
+        if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
             push @todaysissues, $it;
         } else {
             push @previousissues, $it;
         }
     }
-  if (C4::Context->preference("todaysIssuesDefaultSortOrder") eq 'asc'){
-    @todaysissues   = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
-  }
-  else {
-    @todaysissues   = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
-  }
-  if (C4::Context->preference("previousIssuesDefaultSortOrder") eq 'asc'){
-    @previousissues = sort { $a->{'date_due' } cmp $b->{'date_due' } } @previousissues;
-  }
-  else {
-    @previousissues = sort { $b->{'date_due' } cmp $a->{'date_due' } } @previousissues;
-  }
+    if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
+        @todaysissues   = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
+    }
+    else {
+        @todaysissues   = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
+    }
+    if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
+        @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
+    }
+    else {
+        @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
+    }
     my $i = 1;
-  foreach my $book (@todaysissues) {
-        $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
+    foreach my $book ( @todaysissues ) {
+        $book->{'togglecolor'} = ( ++$i % 2 ) ? 0 : 1 ;
     }
     $i = 1;
-  foreach my $book (@previousissues) {
-        $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
+    foreach my $book ( @previousissues ) {
+        $book->{'togglecolor'} = ( ++$i % 2 ) ? 0 : 1 ;
     }
 }