=head2 AddReturn
($doreturn, $messages, $iteminformation, $borrower) =
- &AddReturn($barcode, $branch, $exemptfine, $dropbox);
+ &AddReturn($barcode, $branch, $exemptfine, $dropbox, $returndate);
Returns a book.
will be removed. This assumes that the fines accrual script has run
for _today_.
+=item C<$return_date> allows the default return date to be overridden
+by the given return date.
+
=back
C<&AddReturn> returns a list of four items:
=cut
sub AddReturn {
- my ( $barcode, $branch, $exemptfine, $dropbox ) = @_;
+ my ( $barcode, $branch, $exemptfine, $dropbox, $return_date ) = @_;
if ($branch and not GetBranchDetail($branch)) {
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'};
# case of a return of document (deal with issues and holdingbranch)
my $today = DateTime->now( time_zone => C4::Context->tz() );
if ($doreturn) {
- my $datedue = $issue->{date_due};
+ my $datedue = $issue->{date_due};
$borrower or warn "AddReturn without current borrower";
my $circControlBranch;
if ($dropbox) {
# FIXME: check issuedate > returndate, factoring in holidays
#$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
$circControlBranch = _GetCircControlBranch($item,$borrower);
- $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
+ $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
}
if ($borrowernumber) {
- if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){
- # we only need to calculate and change the fines if we want to do that on return
- # Should be on for hourly loans
+ if ( ( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'} ) || $return_date ) {
+ # we only need to calculate and change the fines if we want to do that on return
+ # Should be on for hourly loans
my $control = C4::Context->preference('CircControl');
my $control_branchcode =
( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode}
: $issue->{branchcode};
+ my $date_returned =
+ $return_date ? dt_from_string($return_date) : $today;
+
my ( $amount, $type, $unitcounttotal ) =
C4::Overdues::CalcFine( $item, $borrower->{categorycode},
- $control_branchcode, $datedue, $today );
+ $control_branchcode, $datedue, $date_returned );
$type ||= q{};
- if ( $amount > 0
- && C4::Context->preference('finesMode') eq 'production' )
- {
- C4::Overdues::UpdateFine( $issue->{itemnumber},
- $issue->{borrowernumber},
- $amount, $type, output_pref($datedue) );
+ if ( C4::Context->preference('finesMode') eq 'production' ) {
+ if ( $amount > 0 ) {
+ C4::Overdues::UpdateFine( $issue->{itemnumber},
+ $issue->{borrowernumber},
+ $amount, $type, output_pref($datedue) );
+ }
+ elsif ($return_date) {
+
+ # Backdated returns may have fines that shouldn't exist,
+ # so in this case, we need to drop those fines to 0
+
+ C4::Overdues::UpdateFine( $issue->{itemnumber},
+ $issue->{borrowernumber},
+ 0, $type, output_pref($datedue) );
+ }
}
}
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
- $circControlBranch, '', $borrower->{'privacy'} );
+ $circControlBranch, $return_date, $borrower->{'privacy'} );
# FIXME is the "= 1" right? This could be the borrower hash.
$messages->{'WasReturned'} = 1;
#dropbox: get last open day (today - 1)
my $today = DateTime->now( time_zone => C4::Context->tz());
my $dropboxdate = $calendar->addDate($today, -1);
+
+my $return_date_override = $query->param('return_date_override');
+my $return_date_override_remember =
+ $query->param('return_date_override_remember');
+if ($return_date_override) {
+ if ( C4::Context->preference('SpecifyReturnDate') ) {
+ if ( $return_date_override =~ C4::Dates->regexp('syspref') ) {
+
+ # Save the original format if we are remembering for this series
+ $template->param(
+ return_date_override => $return_date_override,
+ return_date_override_remember => 1
+ ) if ($return_date_override_remember);
+
+ my $dt = dt_from_string($return_date_override);
+ $return_date_override =
+ DateTime::Format::MySQL->format_datetime($dt);
+ }
+ }
+ else {
+ $return_date_override = q{};
+ }
+}
+
if ($dotransfer){
# An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
my $transferitem = $query->param('transferitem');
# save the return
#
( $returned, $messages, $issueinformation, $borrower ) =
- AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode); # do the return
+ AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override );
my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
$homeorholdingbranchreturn ||= 'homebranch';
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
('soundon','0','','Enable circulation sounds during checkin and checkout in the staff interface. Not supported by all web browsers yet.','YesNo'),
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
+('SpecifyReturnDate',1,'','Define whether to display \"Specify Return Date\" form in Circulation','YesNo'),
('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'),
('SpineLabelFormat','<itemcallnumber><copynumber>','30|10','This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example <itemcallnumber>.','Textarea'),
('SpineLabelShowPrintOnBibDetails','0','','If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.','YesNo'),
SetVersion($DBversion);
}
+
+$DBversion = "3.13.00.XXX";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ INSERT INTO systempreferences
+ (variable,value,explanation,options,type)
+ VALUES
+ ('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
+ });
+ print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
+ SetVersion($DBversion);
+}
+
=head1 FUNCTIONS
=head2 TableExists($table)
no: "Don't allow"
- staff to specify a due date for a checkout.
-
+ - pref: SpecifyReturnDate
+ choices:
+ yes: Allow
+ no: "Don't allow"
+ - staff to specify a return date for a check in.
+ -
- Set the default start date for the Holds to pull list to
- pref: HoldsToPullStartDate
class: integer
[% USE KohaDates %]
[% USE Branches %]
+[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Circulation › Check in [% title |html %]</title>
[% INCLUDE 'doc-head-close.inc' %]
+
+[% INCLUDE 'calendar.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
+
<script type="text/javascript">
//<![CDATA[
function Dopop(link) {
$("#barcode").focus();
}
$(document).ready(function () {
+ $("#return_date_override").datetimepicker({
+ onClose: function(dateText, inst) { $("#barcode").focus(); },
+ hour: 23,
+ minute: 59
+ });
$("#exemptcheck").change(function () {
if (this.checked == true) {
$("#barcode").addClass("alert");
if (this.checked == true) {
$("#barcode").addClass("alert");
$("#dropboxmode").show();
+
+ $("#return_date_override_fields :input").attr("disabled", true);
+ $("#return_date_override").datetimepicker("disable");
} else {
$("#barcode").removeClass("alert");
$("#dropboxmode").hide();
+
+ $("#return_date_override_fields :input").attr("disabled", false);
+ $("#return_date_override").datetimepicker("enable");
}
$("#barcode").focus();
});
<input name="barcode" id="barcode" size="14" class="focus"/>
[% END %]
<input type="submit" class="submit" value="Submit" />
+
+ [% IF Koha.Preference('SpecifyReturnDate') %]
+ <div class="date-select" id="return_date_override_fields">
+ <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div>
+
+ <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" readonly="readonly" />
+
+ <label for="return_date_override_remember"> Remember for next check in:</label>
+ [% IF ( return_date_override_remember ) %]
+ <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" checked="checked" />
+ [% ELSE %]
+ <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" />
+ [% END %]
+
+ <input type="button" class="action" id="cleardate" value="Clear" name="cleardate" onclick="this.checked = false; this.form.return_date_override.value = ''; this.form.return_date_override_remember.checked = false; this.form.barcode.focus(); return false;" />
+ </div>
+ [% END %]
[% FOREACH inputloo IN inputloop %]
<input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
<input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />