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

(-)a/C4/Circulation.pm (-12 / +24 lines)
Lines 1781-1787 sub AddReturn { Link Here
1781
    # case of a return of document (deal with issues and holdingbranch)
1781
    # case of a return of document (deal with issues and holdingbranch)
1782
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1782
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1783
    if ($doreturn) {
1783
    if ($doreturn) {
1784
    my $datedue = $issue->{date_due};
1784
        my $datedue = $issue->{date_due};
1785
        $borrower or warn "AddReturn without current borrower";
1785
        $borrower or warn "AddReturn without current borrower";
1786
		my $circControlBranch;
1786
		my $circControlBranch;
1787
        if ($dropbox) {
1787
        if ($dropbox) {
Lines 1790-1820 sub AddReturn { Link Here
1790
            # FIXME: check issuedate > returndate, factoring in holidays
1790
            # FIXME: check issuedate > returndate, factoring in holidays
1791
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1791
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1792
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1792
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1793
        $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
1793
            $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0;
1794
        }
1794
        }
1795
1795
1796
        if ($borrowernumber) {
1796
        if ($borrowernumber) {
1797
            if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){
1797
            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
1798
                # we only need to calculate and change the fines if we want to do that on return
1799
            # Should be on for hourly loans
1799
                # Should be on for hourly loans
1800
                my $control = C4::Context->preference('CircControl');
1800
                my $control = C4::Context->preference('CircControl');
1801
                my $control_branchcode =
1801
                my $control_branchcode =
1802
                    ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
1802
                    ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch}
1803
                  : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
1803
                  : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
1804
                  :                                     $issue->{branchcode};
1804
                  :                                     $issue->{branchcode};
1805
1805
1806
                my $date_returned =
1807
                  $return_date ? dt_from_string($return_date) : $today;
1808
1806
                my ( $amount, $type, $unitcounttotal ) =
1809
                my ( $amount, $type, $unitcounttotal ) =
1807
                  C4::Overdues::CalcFine( $item, $borrower->{categorycode},
1810
                  C4::Overdues::CalcFine( $item, $borrower->{categorycode},
1808
                    $control_branchcode, $datedue, $today );
1811
                    $control_branchcode, $datedue, $date_returned );
1809
1812
1810
                $type ||= q{};
1813
                $type ||= q{};
1811
1814
1812
                if ( $amount > 0
1815
                if ( C4::Context->preference('finesMode') eq 'production' ) {
1813
                    && C4::Context->preference('finesMode') eq 'production' )
1816
                    if ( $amount > 0 ) {
1814
                {
1817
                        C4::Overdues::UpdateFine( $issue->{itemnumber},
1815
                    C4::Overdues::UpdateFine( $issue->{itemnumber},
1818
                            $issue->{borrowernumber},
1816
                        $issue->{borrowernumber},
1819
                            $amount, $type, output_pref($datedue) );
1817
                        $amount, $type, output_pref($datedue) );
1820
                    }
1821
                    elsif ($return_date) {
1822
1823
                       # Backdated returns may have fines that shouldn't exist,
1824
                       # so in this case, we need to drop those fines to 0
1825
1826
                        C4::Overdues::UpdateFine( $issue->{itemnumber},
1827
                            $issue->{borrowernumber},
1828
                            0, $type, output_pref($datedue) );
1829
                    }
1818
                }
1830
                }
1819
            }
1831
            }
1820
1832
(-)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 430-432 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V Link Here
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
433
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+12 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "3.13.00.XXX";
7071
if ( CheckVersion($DBversion) ) {
7072
    $dbh->do(q{
7073
        INSERT INTO systempreferences 
7074
            (variable,value,explanation,options,type) 
7075
        VALUES
7076
            ('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
7077
    });
7078
    print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
7079
    SetVersion($DBversion);
7080
}
7081
7070
=head1 FUNCTIONS
7082
=head1 FUNCTIONS
7071
7083
7072
=head2 TableExists($table)
7084
=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 383-388 $(document).ready(function () { Link Here
383
			<input name="barcode" id="barcode" size="14" class="focus"/>
399
			<input name="barcode" id="barcode" size="14" class="focus"/>
384
			[% END %]
400
			[% END %]
385
            <input type="submit" class="submit" value="Submit" />
401
            <input type="submit" class="submit" value="Submit" />
402
403
            [% IF Koha.Preference('SpecifyReturnDate') %]
404
                <div class="date-select" id="return_date_override_fields">
405
                    <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div>
406
407
                    <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" readonly="readonly" />
408
409
                    <label for="return_date_override_remember"> Remember for next check in:</label>
410
                    [% IF ( return_date_override_remember ) %]
411
                        <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" checked="checked" />
412
                    [% ELSE %]
413
                        <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" />
414
                    [% END %]
415
416
                    <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;" />
417
            </div>
418
        [% END %]
386
            [% FOREACH inputloo IN inputloop %]
419
            [% FOREACH inputloo IN inputloop %]
387
                <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
420
                <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" />
388
                <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />
421
                <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" />
389
- 

Return to bug 10694