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

(-)a/C4/Circulation.pm (-15 / +30 lines)
Lines 1636-1642 sub GetBranchItemRule { Link Here
1636
=head2 AddReturn
1636
=head2 AddReturn
1637
1637
1638
  ($doreturn, $messages, $iteminformation, $borrower) =
1638
  ($doreturn, $messages, $iteminformation, $borrower) =
1639
      &AddReturn($barcode, $branch, $exemptfine, $dropbox);
1639
      &AddReturn($barcode, $branch, $exemptfine, $dropbox, $returndate);
1640
1640
1641
Returns a book.
1641
Returns a book.
1642
1642
Lines 1655-1660 overdue charges are applied and C<$dropbox> is true, the last charge Link Here
1655
will be removed.  This assumes that the fines accrual script has run
1655
will be removed.  This assumes that the fines accrual script has run
1656
for _today_.
1656
for _today_.
1657
1657
1658
=item C<$return_date> allows the default return date to be overridden
1659
by the given return date.
1660
1658
=back
1661
=back
1659
1662
1660
C<&AddReturn> returns a list of four items:
1663
C<&AddReturn> returns a list of four items:
Lines 1708-1714 patron who last borrowed the book. Link Here
1708
=cut
1711
=cut
1709
1712
1710
sub AddReturn {
1713
sub AddReturn {
1711
    my ( $barcode, $branch, $exemptfine, $dropbox ) = @_;
1714
    my ( $barcode, $branch, $exemptfine, $dropbox, $return_date ) = @_;
1712
1715
1713
    if ($branch and not GetBranchDetail($branch)) {
1716
    if ($branch and not GetBranchDetail($branch)) {
1714
        warn "AddReturn error: branch '$branch' not found.  Reverting to " . C4::Context->userenv->{'branch'};
1717
        warn "AddReturn error: branch '$branch' not found.  Reverting to " . C4::Context->userenv->{'branch'};
Lines 1781-1787 sub AddReturn { Link Here
1781
    # case of a return of document (deal with issues and holdingbranch)
1784
    # case of a return of document (deal with issues and holdingbranch)
1782
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1785
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1783
    if ($doreturn) {
1786
    if ($doreturn) {
1784
    my $datedue = $issue->{date_due};
1787
        my $datedue = $issue->{date_due};
1785
        $borrower or warn "AddReturn without current borrower";
1788
        $borrower or warn "AddReturn without current borrower";
1786
		my $circControlBranch;
1789
		my $circControlBranch;
1787
        if ($dropbox) {
1790
        if ($dropbox) {
Lines 1790-1825 sub AddReturn { Link Here
1790
            # FIXME: check issuedate > returndate, factoring in holidays
1793
            # FIXME: check issuedate > returndate, factoring in holidays
1791
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1794
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1792
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1795
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1793
        $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
1796
            $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
1794
        }
1797
        }
1795
1798
1796
        if ($borrowernumber) {
1799
        if ($borrowernumber) {
1797
            if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){
1800
            if ( ( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'} ) || $return_date ) {
1798
            # we only need to calculate and change the fines if we want to do that on return
1801
                # we only need to calculate and change the fines if we want to do that on return
1799
            # Should be on for hourly loans
1802
                # Should be on for hourly loans
1800
                my $control = C4::Context->preference('CircControl');
1803
                my $control = C4::Context->preference('CircControl');
1801
                my $control_branchcode =
1804
                my $control_branchcode =
1802
                    ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
1805
                    ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
1803
                  : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
1806
                  : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
1804
                  :                                     $issue->{branchcode};
1807
                  :                                     $issue->{branchcode};
1805
1808
1809
                my $date_returned =
1810
                  $return_date ? dt_from_string($return_date) : $today;
1811
1806
                my ( $amount, $type, $unitcounttotal ) =
1812
                my ( $amount, $type, $unitcounttotal ) =
1807
                  C4::Overdues::CalcFine( $item, $borrower->{categorycode},
1813
                  C4::Overdues::CalcFine( $item, $borrower->{categorycode},
1808
                    $control_branchcode, $datedue, $today );
1814
                    $control_branchcode, $datedue, $date_returned );
1809
1815
1810
                $type ||= q{};
1816
                $type ||= q{};
1811
1817
1812
                if ( $amount > 0
1818
                if ( C4::Context->preference('finesMode') eq 'production' ) {
1813
                    && C4::Context->preference('finesMode') eq 'production' )
1819
                    if ( $amount > 0 ) {
1814
                {
1820
                        C4::Overdues::UpdateFine( $issue->{itemnumber},
1815
                    C4::Overdues::UpdateFine( $issue->{itemnumber},
1821
                            $issue->{borrowernumber},
1816
                        $issue->{borrowernumber},
1822
                            $amount, $type, output_pref($datedue) );
1817
                        $amount, $type, output_pref($datedue) );
1823
                    }
1824
                    elsif ($return_date) {
1825
1826
                       # Backdated returns may have fines that shouldn't exist,
1827
                       # so in this case, we need to drop those fines to 0
1828
1829
                        C4::Overdues::UpdateFine( $issue->{itemnumber},
1830
                            $issue->{borrowernumber},
1831
                            0, $type, output_pref($datedue) );
1832
                    }
1818
                }
1833
                }
1819
            }
1834
            }
1820
1835
1821
            MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
1836
            MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
1822
                $circControlBranch, '', $borrower->{'privacy'} );
1837
                $circControlBranch, $return_date, $borrower->{'privacy'} );
1823
1838
1824
            # FIXME is the "= 1" right?  This could be the borrower hash.
1839
            # FIXME is the "= 1" right?  This could be the borrower hash.
1825
            $messages->{'WasReturned'} = 1;
1840
            $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 348-353 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
348
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
348
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
349
('soundon','0','','Enable circulation sounds during checkin and checkout in the staff interface.  Not supported by all web browsers yet.','YesNo'),
349
('soundon','0','','Enable circulation sounds during checkin and checkout in the staff interface.  Not supported by all web browsers yet.','YesNo'),
350
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
350
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
351
('SpecifyReturnDate',1,'','Define whether to display \"Specify Return Date\" form in Circulation','YesNo'),
351
('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'),
352
('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'),
352
('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'),
353
('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'),
353
('SpineLabelShowPrintOnBibDetails','0','','If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.','YesNo'),
354
('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 7853-7858 if ( CheckVersion($DBversion) ) { Link Here
7853
   SetVersion ($DBversion);
7853
   SetVersion ($DBversion);
7854
}
7854
}
7855
7855
7856
$DBversion = "3.13.00.XXX";
7857
if ( CheckVersion($DBversion) ) {
7858
    $dbh->do(q{
7859
        INSERT INTO systempreferences
7860
            (variable,value,explanation,options,type)
7861
        VALUES
7862
            ('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
7863
    });
7864
    print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
7865
    SetVersion($DBversion);
7866
}
7867
7856
=head1 FUNCTIONS
7868
=head1 FUNCTIONS
7857
7869
7858
=head2 TableExists($table)
7870
=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 Branches %]
2
[% USE Branches %]
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 392-397 $(document).ready(function () { Link Here
392
			<input name="barcode" id="barcode" size="14" class="focus"/>
408
			<input name="barcode" id="barcode" size="14" class="focus"/>
393
			[% END %]
409
			[% END %]
394
            <input type="submit" class="submit" value="Submit" />
410
            <input type="submit" class="submit" value="Submit" />
411
412
            [% IF Koha.Preference('SpecifyReturnDate') %]
413
                <div class="date-select" id="return_date_override_fields">
414
                    <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div>
415
416
                    <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" readonly="readonly" />
417
418
                    <label for="return_date_override_remember"> Remember for next check in:</label>
419
                    [% IF ( return_date_override_remember ) %]
420
                        <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" checked="checked" />
421
                    [% ELSE %]
422
                        <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" />
423
                    [% END %]
424
425
                    <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;" />
426
            </div>
427
        [% END %]
395
            [% FOREACH inputloo IN inputloop %]
428
            [% FOREACH inputloo IN inputloop %]
396
                <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
429
                <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
397
                <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />
430
                <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />
398
- 

Return to bug 10694