View | Details | Raw Unified | Return to bug 10694
Collapse All | Expand All

(-)a/C4/Circulation.pm (-15 / +30 lines)
Lines 1635-1641 sub GetBranchItemRule { Link Here
1635
=head2 AddReturn
1635
=head2 AddReturn
1636
1636
1637
  ($doreturn, $messages, $iteminformation, $borrower) =
1637
  ($doreturn, $messages, $iteminformation, $borrower) =
1638
      &AddReturn($barcode, $branch, $exemptfine, $dropbox);
1638
      &AddReturn($barcode, $branch, $exemptfine, $dropbox, $returndate);
1639
1639
1640
Returns a book.
1640
Returns a book.
1641
1641
Lines 1654-1659 overdue charges are applied and C<$dropbox> is true, the last charge Link Here
1654
will be removed.  This assumes that the fines accrual script has run
1654
will be removed.  This assumes that the fines accrual script has run
1655
for _today_.
1655
for _today_.
1656
1656
1657
=item C<$return_date> allows the default return date to be overridden
1658
by the given return date.
1659
1657
=back
1660
=back
1658
1661
1659
C<&AddReturn> returns a list of four items:
1662
C<&AddReturn> returns a list of four items:
Lines 1707-1713 patron who last borrowed the book. Link Here
1707
=cut
1710
=cut
1708
1711
1709
sub AddReturn {
1712
sub AddReturn {
1710
    my ( $barcode, $branch, $exemptfine, $dropbox ) = @_;
1713
    my ( $barcode, $branch, $exemptfine, $dropbox, $return_date ) = @_;
1711
1714
1712
    if ($branch and not GetBranchDetail($branch)) {
1715
    if ($branch and not GetBranchDetail($branch)) {
1713
        warn "AddReturn error: branch '$branch' not found.  Reverting to " . C4::Context->userenv->{'branch'};
1716
        warn "AddReturn error: branch '$branch' not found.  Reverting to " . C4::Context->userenv->{'branch'};
Lines 1780-1786 sub AddReturn { Link Here
1780
    # case of a return of document (deal with issues and holdingbranch)
1783
    # case of a return of document (deal with issues and holdingbranch)
1781
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1784
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1782
    if ($doreturn) {
1785
    if ($doreturn) {
1783
    my $datedue = $issue->{date_due};
1786
        my $datedue = $issue->{date_due};
1784
        $borrower or warn "AddReturn without current borrower";
1787
        $borrower or warn "AddReturn without current borrower";
1785
		my $circControlBranch;
1788
		my $circControlBranch;
1786
        if ($dropbox) {
1789
        if ($dropbox) {
Lines 1789-1824 sub AddReturn { Link Here
1789
            # FIXME: check issuedate > returndate, factoring in holidays
1792
            # FIXME: check issuedate > returndate, factoring in holidays
1790
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1793
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1791
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1794
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1792
        $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
1795
            $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
1793
        }
1796
        }
1794
1797
1795
        if ($borrowernumber) {
1798
        if ($borrowernumber) {
1796
            if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){
1799
            if ( ( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'} ) || $return_date ) {
1797
            # we only need to calculate and change the fines if we want to do that on return
1800
                # we only need to calculate and change the fines if we want to do that on return
1798
            # Should be on for hourly loans
1801
                # Should be on for hourly loans
1799
                my $control = C4::Context->preference('CircControl');
1802
                my $control = C4::Context->preference('CircControl');
1800
                my $control_branchcode =
1803
                my $control_branchcode =
1801
                    ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
1804
                    ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
1802
                  : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
1805
                  : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
1803
                  :                                     $issue->{branchcode};
1806
                  :                                     $issue->{branchcode};
1804
1807
1808
                my $date_returned =
1809
                  $return_date ? dt_from_string($return_date) : $today;
1810
1805
                my ( $amount, $type, $unitcounttotal ) =
1811
                my ( $amount, $type, $unitcounttotal ) =
1806
                  C4::Overdues::CalcFine( $item, $borrower->{categorycode},
1812
                  C4::Overdues::CalcFine( $item, $borrower->{categorycode},
1807
                    $control_branchcode, $datedue, $today );
1813
                    $control_branchcode, $datedue, $date_returned );
1808
1814
1809
                $type ||= q{};
1815
                $type ||= q{};
1810
1816
1811
                if ( $amount > 0
1817
                if ( C4::Context->preference('finesMode') eq 'production' ) {
1812
                    && C4::Context->preference('finesMode') eq 'production' )
1818
                    if ( $amount > 0 ) {
1813
                {
1819
                        C4::Overdues::UpdateFine( $issue->{itemnumber},
1814
                    C4::Overdues::UpdateFine( $issue->{itemnumber},
1820
                            $issue->{borrowernumber},
1815
                        $issue->{borrowernumber},
1821
                            $amount, $type, output_pref($datedue) );
1816
                        $amount, $type, output_pref($datedue) );
1822
                    }
1823
                    elsif ($return_date) {
1824
1825
                       # Backdated returns may have fines that shouldn't exist,
1826
                       # so in this case, we need to drop those fines to 0
1827
1828
                        C4::Overdues::UpdateFine( $issue->{itemnumber},
1829
                            $issue->{borrowernumber},
1830
                            0, $type, output_pref($datedue) );
1831
                    }
1817
                }
1832
                }
1818
            }
1833
            }
1819
1834
1820
            MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
1835
            MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
1821
                $circControlBranch, '', $borrower->{'privacy'} );
1836
                $circControlBranch, $return_date, $borrower->{'privacy'} );
1822
1837
1823
            # FIXME is the "= 1" right?  This could be the borrower hash.
1838
            # FIXME is the "= 1" right?  This could be the borrower hash.
1824
            $messages->{'WasReturned'} = 1;
1839
            $messages->{'WasReturned'} = 1;
(-)a/circ/returns.pl (-1 / +25 lines)
Lines 180-185 my $calendar = Koha::Calendar->new( branchcode => $userenv_branch ); Link Here
180
#dropbox: get last open day (today - 1)
180
#dropbox: get last open day (today - 1)
181
my $today       = DateTime->now( time_zone => C4::Context->tz());
181
my $today       = DateTime->now( time_zone => C4::Context->tz());
182
my $dropboxdate = $calendar->addDate($today, -1);
182
my $dropboxdate = $calendar->addDate($today, -1);
183
184
my $return_date_override = $query->param('return_date_override');
185
my $return_date_override_remember =
186
  $query->param('return_date_override_remember');
187
if ($return_date_override) {
188
    if ( C4::Context->preference('SpecifyReturnDate') ) {
189
        if ( $return_date_override =~ C4::Dates->regexp('syspref') ) {
190
191
            # Save the original format if we are remembering for this series
192
            $template->param(
193
                return_date_override          => $return_date_override,
194
                return_date_override_remember => 1
195
            ) if ($return_date_override_remember);
196
197
            my $dt = dt_from_string($return_date_override);
198
            $return_date_override =
199
              DateTime::Format::MySQL->format_datetime($dt);
200
        }
201
    }
202
    else {
203
        $return_date_override = q{};
204
    }
205
}
206
183
if ($dotransfer){
207
if ($dotransfer){
184
# An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
208
# An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
185
    my $transferitem = $query->param('transferitem');
209
    my $transferitem = $query->param('transferitem');
Lines 216-222 if ($barcode) { Link Here
216
# save the return
240
# save the return
217
#
241
#
218
    ( $returned, $messages, $issueinformation, $borrower ) =
242
    ( $returned, $messages, $issueinformation, $borrower ) =
219
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
243
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override );
220
    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
244
    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
221
    $homeorholdingbranchreturn ||= 'homebranch';
245
    $homeorholdingbranchreturn ||= 'homebranch';
222
246
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 342-347 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
342
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
342
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
343
('soundon','0','','Enable circulation sounds during checkin and checkout in the staff interface.  Not supported by all web browsers yet.','YesNo'),
343
('soundon','0','','Enable circulation sounds during checkin and checkout in the staff interface.  Not supported by all web browsers yet.','YesNo'),
344
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
344
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
345
('SpecifyReturnDate',1,'','Define whether to display \"Specify Return Date\" form in Circulation','YesNo'),
345
('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'),
346
('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'),
346
('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'),
347
('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'),
347
('SpineLabelShowPrintOnBibDetails','0','','If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.','YesNo'),
348
('SpineLabelShowPrintOnBibDetails','0','','If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.','YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+12 lines)
Lines 7104-7109 if ( CheckVersion($DBversion) ) { Link Here
7104
    SetVersion($DBversion);
7104
    SetVersion($DBversion);
7105
}
7105
}
7106
7106
7107
$DBversion = "3.13.00.XXX";
7108
if ( CheckVersion($DBversion) ) {
7109
    $dbh->do(q{
7110
        INSERT INTO systempreferences
7111
            (variable,value,explanation,options,type)
7112
        VALUES
7113
            ('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
7114
    });
7115
    print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
7116
    SetVersion($DBversion);
7117
}
7118
7107
=head1 FUNCTIONS
7119
=head1 FUNCTIONS
7108
7120
7109
=head2 TableExists($table)
7121
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 58-63 Circulation: Link Here
58
                  no: "Don't allow"
58
                  no: "Don't allow"
59
            - staff to specify a due date for a checkout.
59
            - staff to specify a due date for a checkout.
60
        -
60
        -
61
            - pref: SpecifyReturnDate
62
              choices:
63
                  yes: Allow
64
                  no: "Don't allow"
65
            - staff to specify a return date for a check in.
66
        -
61
            - Set the default start date for the Holds to pull list to
67
            - Set the default start date for the Holds to pull list to
62
            - pref: HoldsToPullStartDate
68
            - pref: HoldsToPullStartDate
63
              class: integer
69
              class: integer
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +33 lines)
Lines 1-9 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE KohaBranchName %]
2
[% USE KohaBranchName %]
3
[% USE Koha %]
3
4
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Circulation &rsaquo; Check in [% title |html %]</title>
6
<title>Koha &rsaquo; Circulation &rsaquo; Check in [% title |html %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
8
9
[% INCLUDE 'calendar.inc' %]
10
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
11
7
<script type="text/javascript">
12
<script type="text/javascript">
8
//<![CDATA[
13
//<![CDATA[
9
function Dopop(link) {
14
function Dopop(link) {
Lines 11-16 function Dopop(link) { Link Here
11
    $("#barcode").focus();
16
    $("#barcode").focus();
12
}
17
}
13
$(document).ready(function () {
18
$(document).ready(function () {
19
    $("#return_date_override").datetimepicker({
20
        onClose: function(dateText, inst) { $("#barcode").focus(); },
21
        hour: 23,
22
        minute: 59
23
    });
14
    $("#exemptcheck").change(function () {
24
    $("#exemptcheck").change(function () {
15
        if (this.checked == true) {
25
        if (this.checked == true) {
16
            $("#barcode").addClass("alert");
26
            $("#barcode").addClass("alert");
Lines 25-33 $(document).ready(function () { Link Here
25
        if (this.checked == true) {
35
        if (this.checked == true) {
26
            $("#barcode").addClass("alert");
36
            $("#barcode").addClass("alert");
27
            $("#dropboxmode").show();
37
            $("#dropboxmode").show();
38
39
            $("#return_date_override_fields :input").attr("disabled", true);
40
            $("#return_date_override").datetimepicker("disable");
28
        } else {
41
        } else {
29
            $("#barcode").removeClass("alert");
42
            $("#barcode").removeClass("alert");
30
            $("#dropboxmode").hide();
43
            $("#dropboxmode").hide();
44
45
            $("#return_date_override_fields :input").attr("disabled", false);
46
            $("#return_date_override").datetimepicker("enable");
31
        }
47
        }
32
        $("#barcode").focus();
48
        $("#barcode").focus();
33
    });
49
    });
Lines 382-387 $(document).ready(function () { Link Here
382
			<input name="barcode" id="barcode" size="14" class="focus"/>
398
			<input name="barcode" id="barcode" size="14" class="focus"/>
383
			[% END %]
399
			[% END %]
384
            <input type="submit" class="submit" value="Submit" />
400
            <input type="submit" class="submit" value="Submit" />
401
402
            [% IF Koha.Preference('SpecifyReturnDate') %]
403
                <div class="date-select" id="return_date_override_fields">
404
                    <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div>
405
406
                    <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" readonly="readonly" />
407
408
                    <label for="return_date_override_remember"> Remember for next check in:</label>
409
                    [% IF ( return_date_override_remember ) %]
410
                        <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" checked="checked" />
411
                    [% ELSE %]
412
                        <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" />
413
                    [% END %]
414
415
                    <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;" />
416
            </div>
417
        [% END %]
385
            [% FOREACH inputloo IN inputloop %]
418
            [% FOREACH inputloo IN inputloop %]
386
                <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
419
                <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
387
                <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />
420
                <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />
388
- 

Return to bug 10694