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

(-)a/Koha/Template/Plugin/Borrowers.pm (+58 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Borrowers;
2
3
# Copyright ByWater Solutions 2013
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use base qw( Template::Plugin );
23
24
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
25
26
use C4::Koha;
27
28
=pod
29
30
This plugin is a home for various patron related Template Toolkit functions
31
to help streamline Koha and to move logic from the Perl code into the
32
Templates when it makes sense to do so.
33
34
To use, first, include the line '[% USE Borrowers %]' at the top
35
of the template to enable the plugin.
36
37
For example: [% IF Borrowers.IsDebarred( borrower.borrowernumber ) %]
38
removes the necessity of setting a template variable in Perl code to
39
find out if a patron is restricted even if that variable is not evaluated
40
in any way in the script.
41
42
=cut
43
44
sub IsDebarred {
45
    my ( $self, $borrower ) = @_;
46
47
    return unless $borrower;
48
49
    if ( $borrower->{'debarred'} && check_date( split( /-/, $borrower->{'debarred'} ) ) ) {
50
        if ( Date_to_Days(Date::Calc::Today) < Date_to_Days( split( /-/, $borrower->{'debarred'} ) ) ) {
51
            return 1;
52
        }
53
    }
54
55
    return 0;
56
}
57
58
1;
(-)a/circ/returns.pl (-1 / +2 lines)
Lines 268-274 if ($barcode) { Link Here
268
        itemtype         => $biblio->{'itemtype'},
268
        itemtype         => $biblio->{'itemtype'},
269
        ccode            => $biblio->{'ccode'},
269
        ccode            => $biblio->{'ccode'},
270
        itembiblionumber => $biblio->{'biblionumber'},    
270
        itembiblionumber => $biblio->{'biblionumber'},    
271
	additional_materials => $biblio->{'materials'}
271
        borrower         => $borrower,
272
        additional_materials => $biblio->{'materials'},
272
    );
273
    );
273
274
274
    my %input = (
275
    my %input = (
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +1 lines)
Lines 8062-8068 if ( CheckVersion($DBversion) ) { Link Here
8062
        INSERT INTO systempreferences
8062
        INSERT INTO systempreferences
8063
            (variable,value,explanation,options,type)
8063
            (variable,value,explanation,options,type)
8064
        VALUES
8064
        VALUES
8065
            ('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
8065
            ('SpecifyReturnDate',0,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
8066
    });
8066
    });
8067
    print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
8067
    print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
8068
    SetVersion($DBversion);
8068
    SetVersion($DBversion);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (+28 lines)
Lines 21-26 function Date_from_syspref(dstring) { Link Here
21
        }
21
        }
22
}
22
}
23
23
24
function DateTime_from_syspref(date_time) {
25
        var parts = date_time.split(" ");
26
        var date = parts[0];
27
        var time = parts[1];
28
        parts = time.split(":");
29
        var hour = parts[0];
30
        var minute = parts[1];
31
32
        if ( hour < 0 || hour > 23 ) {
33
            return 0;
34
        }
35
        if ( minute < 0 || minute > 59 ) {
36
            return 0;
37
        }
38
39
        var datetime = Date_from_syspref( date );
40
41
        if ( isNaN( datetime.getTime() ) ) {
42
            return 0;
43
        }
44
45
        datetime.setHours( hour );
46
        datetime.setMinutes( minute );
47
48
        return datetime;
49
}
50
51
24
/* Instead of including multiple localization files as you would normally see with
52
/* Instead of including multiple localization files as you would normally see with
25
   jQueryUI we expose the localization strings in the default configuration */
53
   jQueryUI we expose the localization strings in the default configuration */
26
jQuery(function($){
54
jQuery(function($){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-5 / +40 lines)
Lines 1-13 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE Borrowers %]
4
5
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Circulation &rsaquo; Check in [% title |html %]</title>
7
<title>Koha &rsaquo; Circulation &rsaquo; Check in [% title |html %]</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
8
9
9
[% INCLUDE 'calendar.inc' %]
10
[% INCLUDE 'calendar.inc' %]
10
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
11
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
11
12
12
<script type="text/javascript">
13
<script type="text/javascript">
13
//<![CDATA[
14
//<![CDATA[
Lines 18-26 function Dopop(link) { Link Here
18
$(document).ready(function () {
19
$(document).ready(function () {
19
    $("#return_date_override").datetimepicker({
20
    $("#return_date_override").datetimepicker({
20
        onClose: function(dateText, inst) { $("#barcode").focus(); },
21
        onClose: function(dateText, inst) { $("#barcode").focus(); },
22
        defaultDate: -1,
21
        hour: 23,
23
        hour: 23,
22
        minute: 59
24
        minute: 59,
25
        maxDate: 0
23
    });
26
    });
27
    $("#return_date_override").on("blur", function() {
28
            check_valid_return_date();
29
    });
30
    $("#checkin-form").submit(function( event ) {
31
        if ( !check_valid_return_date() ) {
32
            event.preventDefault();
33
        }
34
    });
35
36
    function check_valid_return_date() {
37
        if ( $("#return_date_override").val() ) {
38
            var datetime = DateTime_from_syspref( $("#return_date_override").val() );
39
            var now = new Date();
40
            if ( !datetime || datetime > now ) {
41
                alert("Invalid return date/time!");
42
                $("#return_date_override").val("")
43
                return false;
44
            }
45
        }
46
        return true;
47
    }
48
24
    $("#exemptcheck").change(function () {
49
    $("#exemptcheck").change(function () {
25
        if (this.checked == true) {
50
        if (this.checked == true) {
26
            $("#barcode").addClass("alert");
51
            $("#barcode").addClass("alert");
Lines 102-107 $(document).ready(function () { Link Here
102
    </div>
127
    </div>
103
[% END %]
128
[% END %]
104
129
130
<!-- Patron is restricted and checkin was backdated -->
131
[% IF return_date_override && Borrowers.IsDebarred( borrower ) %]
132
    <div id="restricted_backdated" class="dialog message">
133
        <h3>
134
            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">
135
                [% borrower.firstname %] [% borrower.surname %]
136
            </a>
137
            is retricted. Please verify this patron should still be restricted.
138
        </h3>
139
    </div>
140
[% END %]
105
141
106
[% IF ( wrongbranch ) %]
142
[% IF ( wrongbranch ) %]
107
<div class="dialog alert"><h3>Cannot check in</h3><p>This item must be checked in at its home library. <strong>NOT CHECKED IN</strong></p>
143
<div class="dialog alert"><h3>Cannot check in</h3><p>This item must be checked in at its home library. <strong>NOT CHECKED IN</strong></p>
Lines 395-401 $(document).ready(function () { Link Here
395
    </div>
431
    </div>
396
</div>
432
</div>
397
	<div class="yui-g">
433
	<div class="yui-g">
398
    <form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
434
    <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
399
    <div class="yui-u first">
435
    <div class="yui-u first">
400
            <fieldset>
436
            <fieldset>
401
	<legend>Check in</legend>
437
	<legend>Check in</legend>
Lines 413-419 $(document).ready(function () { Link Here
413
                <div class="date-select" id="return_date_override_fields">
449
                <div class="date-select" id="return_date_override_fields">
414
                    <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div>
450
                    <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div>
415
451
416
                    <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" readonly="readonly" />
452
                    <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" />
417
453
418
                    <label for="return_date_override_remember"> Remember for next check in:</label>
454
                    <label for="return_date_override_remember"> Remember for next check in:</label>
419
                    [% IF ( return_date_override_remember ) %]
455
                    [% IF ( return_date_override_remember ) %]
420
- 

Return to bug 10694