From 12a3217bfee83dd0c2c2c19def591baf675798b9 Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Tue, 22 Apr 2008 17:46:50 -0500 Subject: [PATCH] Add dropbox mode to return.pl. Small API change to allow setting returndate other than now(). Overdues will be handled in a forthcoming commit. Signed-off-by: Joshua Ferraro --- C4/Circulation.pm | 42 +++++++++++++------ circ/returns.pl | 24 ++++++----- .../prog/en/modules/circ/returns.tmpl | 23 ++++++---- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9586fc53d9..5a39d849fa 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1153,13 +1153,15 @@ sub GetIssuingRule { =head2 AddReturn ($doreturn, $messages, $iteminformation, $borrower) = - &AddReturn($barcode, $branch, $exemptfine); + &AddReturn($barcode, $branch, $exemptfine, $dropbox); Returns a book. C<$barcode> is the bar code of the book being returned. C<$branch> is the code of the branch where the book is being returned. C<$exemptfine> -indicates that overdue charges for the item will not be applied. +indicates that overdue charges for the item will be removed. C<$dropbox> +indicates that the check-in date is assumed to be yesterday. If overdue +charges are applied and C<$dropbox> is true, the last charge will be removed. C<&AddReturn> returns a list of four items: @@ -1202,7 +1204,7 @@ patron who last borrowed the book. =cut sub AddReturn { - my ( $barcode, $branch, $exemptfine ) = @_; + my ( $barcode, $branch, $exemptfine, $dropbox ) = @_; my $dbh = C4::Context->dbh; my $messages; my $doreturn = 1; @@ -1256,7 +1258,11 @@ sub AddReturn { # case of a return of document (deal with issues and holdingbranch) if ($doreturn) { - MarkIssueReturned($borrower->{'borrowernumber'}, $iteminformation->{'itemnumber'}); + if($dropbox) { + # don't allow dropbox mode to create an invalid entry in issues ( issuedate > returndate) + undef($dropbox) if ( $iteminformation->{'issuedate'} eq C4::Dates->today('iso') ); + } + MarkIssueReturned($borrower->{'borrowernumber'}, $iteminformation->{'itemnumber'},$dropbox); $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? } @@ -1310,7 +1316,7 @@ sub AddReturn { } # fix up the overdues in accounts... FixOverduesOnReturn( $borrower->{'borrowernumber'}, - $iteminformation->{'itemnumber'}, $exemptfine ); + $iteminformation->{'itemnumber'}, $exemptfine, $dropbox ); # find reserves..... # if we don't have a reserve with the status W, we launch the Checkreserves routine @@ -1360,7 +1366,9 @@ MarkIssueReturned($borrowernumber, $itemnumber); Unconditionally marks an issue as being returned by moving the C row to C and -setting C to the current date. +setting C to the current date, or +yesterday if C is true. Assumes you've +already checked that yesterday > issuedate. Ideally, this function would be internal to C, not exported, but it is currently needed by one @@ -1369,14 +1377,22 @@ routine in C. =cut sub MarkIssueReturned { - my ($borrowernumber, $itemnumber) = @_; - - my $dbh = C4::Context->dbh; + my ($borrowernumber, $itemnumber, $dropbox) = @_; + my $dbh = C4::Context->dbh; + my $query = "UPDATE issues SET returndate="; + my @bind = ($borrowernumber,$itemnumber); + if($dropbox) { + my @datearr = localtime( time() ); + my @yesterdayarr = Add_Delta_Days( $datearr[5] + 1900 , $datearr[4] + 1, $datearr[3] , -1 ); + unshift @bind, sprintf("%0.4d-%0.2d-%0.2d",@yesterdayarr) ; + $query .= " ? " + } else { + $query .= " now() "; + } + $query .= " WHERE borrowernumber = ? AND itemnumber = ?"; # FIXME transaction - my $sth_upd = $dbh->prepare("UPDATE issues SET returndate = now() - WHERE borrowernumber = ? - AND itemnumber = ?"); - $sth_upd->execute($borrowernumber, $itemnumber); + my $sth_upd = $dbh->prepare($query); + $sth_upd->execute(@bind); my $sth_copy = $dbh->prepare("INSERT INTO old_issues SELECT * FROM issues WHERE borrowernumber = ? AND itemnumber = ?"); diff --git a/circ/returns.pl b/circ/returns.pl index 262b009c75..fe1cfa56ba 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -32,6 +32,7 @@ use C4::Auth qw/:DEFAULT get_session/; use C4::Output; use C4::Circulation; use C4::Dates qw/format_date/; +use Date::Calc qw/Add_Delta_Days/; use C4::Print; use C4::Reserves; use C4::Biblio; @@ -169,7 +170,10 @@ my $barcode = $query->param('barcode'); # strip whitespace # $barcode =~ s/\s*//g; - use barcodedecode for this; whitespace is not invalid. my $exemptfine = $query->param('exemptfine'); - +my $dropboxmode= $query->param('dropboxmode'); +my @datearr = localtime( time() ); +my @yesterdayarr = Add_Delta_Days( $datearr[5] + 1900 , $datearr[4] + 1, $datearr[3] , -1 ); +my $yesterday= C4::Dates->new( sprintf("%0.4d-%0.2d-%0.2d",@yesterdayarr),'iso'); my $dotransfer = $query->param('dotransfer'); if ($dotransfer){ # An item has been returned to a branch other than the homebranch, and the librarian has choosen to initiate a transfer @@ -185,7 +189,7 @@ if ($barcode) { # save the return # ( $returned, $messages, $issueinformation, $borrower ) = - AddReturn( $barcode, C4::Context->userenv->{'branch'}, $exemptfine ); + AddReturn( $barcode, C4::Context->userenv->{'branch'}, $exemptfine, $dropboxmode); # get biblio description my $biblio = GetBiblioFromItemNumber($issueinformation->{'itemnumber'}); # fix up item type for display @@ -339,12 +343,9 @@ if ( $messages->{'ResFound'}) { } if ( $reserve->{'ResFound'} eq "Reserved" ) { - my @da = localtime( time() ); - my $todaysdate = - sprintf( "%0.2d", ( $da[3] + 1 ) ) . "/" - . sprintf( "%0.2d", ( $da[4] + 1 ) ) . "/" - . ( $da[5] + 1900 ); - + # my @da = localtime( time() ); + # my $todaysdate = sprintf( "%0.2d/%0.2d/%0.4d", ( $datearr[3] + 1 ),( $datearr[4] + 1 ),( $datearr[5] + 1900 ) ); + # FIXME - use Dates obj , locale. AND, why [4]+1 ?? if ( C4::Context->userenv->{'branch'} eq $reserve->{'branchcode'} ) { $template->param( intransit => 0 ); } @@ -361,7 +362,7 @@ if ( $messages->{'ResFound'}) { transfertodo => ( C4::Context->userenv->{'branch'} eq $reserve->{'branchcode'} ? 0 : 1 ), reserved => 1, resbarcode => $barcode, - today => $todaysdate, + # today => $todaysdate, itemnumber => $reserve->{'itemnumber'}, borsurname => $borr->{'surname'}, bortitle => $borr->{'title'}, @@ -529,11 +530,12 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { $ri{month} = $tempdate[1]; $ri{day} = $tempdate[2]; my $duedatenz = "$tempdate[2]/$tempdate[1]/$tempdate[0]"; - my @datearr = localtime( time() ); + # my @datearr = localtime( time() ); my $todaysdate = $datearr[5] . '-' . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-' . sprintf( "%0.2d", $datearr[3] ); + # FIXME - todaysdate isn't used, and what date _is_ it ? $ri{duedate} = format_date($duedate); my ($borrower) = GetMemberDetails( $riborrowernumber{$_}, 0 ); @@ -573,6 +575,8 @@ $template->param( printer => $printer, errmsgloop => \@errmsgloop, exemptfine => $exemptfine, + dropboxmode => $dropboxmode, + yesterdaysdate => $yesterday->output(), overduecharges => $overduecharges, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl index 399223a4f9..cf928d455a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl @@ -226,13 +226,16 @@ function Dopop(link) { +
Check In - + @@ -243,20 +246,26 @@ function Dopop(link) { " value="" /> " value="" /> +
+ Options - - - - - + + +
+ + + + + - + +
-- 2.39.5