From 1157ed9457849e7475c8bad48d48fe8cd9b93f58 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Tue, 15 Jul 2008 12:06:42 -0500 Subject: [PATCH] fix for bug 1551: Renewing doesn't move item... 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 --- C4/Circulation.pm | 2 +- circ/circulation.pl | 54 ++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6aac340448..ca52e2764b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -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=?" ); diff --git a/circ/circulation.pl b/circ/circulation.pl index 8c53bdc762..3f35aa6b2b 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -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 ; } } -- 2.39.5