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 <jmf@liblime.com>
This commit is contained in:
Ryan Higgins 2008-04-22 17:46:50 -05:00 committed by Joshua Ferraro
parent f4f840da2c
commit 12a3217bfe
3 changed files with 59 additions and 30 deletions

View File

@ -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<issues> row to C<old_issues> and
setting C<returndate> to the current date.
setting C<returndate> to the current date, or
yesterday if C<dropbox> is true. Assumes you've
already checked that yesterday > issuedate.
Ideally, this function would be internal to C<C4::Circulation>,
not exported, but it is currently needed by one
@ -1369,14 +1377,22 @@ routine in C<C4::Accounts>.
=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 = ?");

View File

@ -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,
);

View File

@ -226,13 +226,16 @@ function Dopop(link) {
<div id="exemptfines" class="dialog message" style="display:none;">
<p>Fines for returned items are forgiven.</p>
</div>
<div id="dropboxmode" class="dialog message" style="display:none;">
<p>Dropbox Mode. (Effective checkin date is <!-- TMPL_VAR NAME="yesterdaysdate" --> ).</p>
</div>
<div class="details">
<form method="post" action="/cgi-bin/koha/circ/returns.pl" >
<fieldset><legend>Check In</legend>
<label for="barcode">Enter item barcode: </label>
<!-- TMPL_IF NAME="overduecharges" -->
<input name="barcode" id="barcode" size="14" class="focus" onfocus="if(this.form.exemptcheck.checked == true) {this.className='alert'} else {this.className='focus'};" onblur="this.className='unfocus';" />
<input name="barcode" id="barcode" size="14" class="focus" onfocus="if( (this.form.exemptcheck.checked == true) || (this.form.dropboxcheck.checked == true ) ) {this.className='alert'} else {this.className='focus'};" onblur="this.className='unfocus';" />
<!-- TMPL_ELSE -->
<input name="barcode" id="barcode" size="14" class="focus" />
<!-- /TMPL_IF -->
@ -243,20 +246,26 @@ function Dopop(link) {
<input type="hidden" name="dd-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
<input type="hidden" name="bn-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
<!-- /TMPL_LOOP -->
<fieldset id="checkin_options">
<legend>Options</legend>
<!-- TMPL_IF NAME="overduecharges" -->
<!-- TMPL_IF NAME="exemptfine" -->
<label for="exemptcheck" class="error" >Forgive Overdue charges on this item</label>
<!-- TMPL_ELSE -->
<label for="exemptcheck">Forgive Overdue charges on this item</label>
<!-- /TMPL_IF -->
<label for="exemptcheck">Forgive Overdue charges on this item</label>
<!-- TMPL_IF NAME="exemptfine" -->
<input type="checkbox" id="exemptcheck" name="exemptfine" value="exemptfine" checked="checked" onchange=" if (this.checked == true) { this.form.barcode.className='alert'; document.getElementById('exemptfines').style.display='block';} else { this.form.barcode.className='unfocus';document.getElementById('exemptfines').style.display='none'; } this.form.barcode.focus(); return false;" />
<!-- TMPL_ELSE -->
<input type="checkbox" id="exemptcheck" name="exemptfine" value="exemptfine" onchange=" if (this.checked == true) { this.form.barcode.className='alert'; document.getElementById('exemptfines').style.display='block';} else { this.form.barcode.className='unfocus';document.getElementById('exemptfines').style.display='none'; } this.form.barcode.focus(); return false;" />
<!-- /TMPL_IF -->
<br /><!-- (fixme) -->
<label for="dropboxcheck">Dropbox mode </label>
<!-- TMPL_IF NAME="dropboxmode" -->
<input type="checkbox" id="dropboxcheck" name="dropboxmode" value="dropboxmode" checked="checked" onchange=" if (this.checked == true) { this.form.barcode.className='alert'; document.getElementById('dropboxmode').style.display='block';} else { this.form.barcode.className='unfocus';document.getElementById('dropboxmode').style.display='none'; } this.form.barcode.focus(); return false;" />
<!-- TMPL_ELSE -->
<input type="checkbox" id="dropboxcheck" name="dropboxmode" value="dropboxmode" onchange=" if (this.checked == true) { this.form.barcode.className='alert'; document.getElementById('dropboxmode').style.display='block';} else { this.form.barcode.className='unfocus';document.getElementById('dropboxmode').style.display='none'; } this.form.barcode.focus(); return false;" />
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- /TMPL_IF --> <!-- overduecharges -->
</fieldset>
</fieldset>
</form>