Bug 10694: (follow-up) fix various issues
- new TT plugin for Borrowers, that at present supplies a method for determining if the patron is restricted - setting the default value of SpecifyReturnDate to false during upgrade to avoid an unwelcome surprise - validate the return date on the client side before allowing the form to be submitted. Signed-off-by: Petter Goksoyr Asen <boutrosboutrosboutros@gmail.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
1b618cac3d
commit
892111c84d
|
|
@ -0,0 +1,58 @@
|
|||
package Koha::Template::Plugin::Borrowers;
|
||||
|
||||
# Copyright ByWater Solutions 2013
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use base qw( Template::Plugin );
|
||||
|
||||
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
|
||||
|
||||
use C4::Koha;
|
||||
|
||||
=pod
|
||||
|
||||
This plugin is a home for various patron related Template Toolkit functions
|
||||
to help streamline Koha and to move logic from the Perl code into the
|
||||
Templates when it makes sense to do so.
|
||||
|
||||
To use, first, include the line '[% USE Borrowers %]' at the top
|
||||
of the template to enable the plugin.
|
||||
|
||||
For example: [% IF Borrowers.IsDebarred( borrower.borrowernumber ) %]
|
||||
removes the necessity of setting a template variable in Perl code to
|
||||
find out if a patron is restricted even if that variable is not evaluated
|
||||
in any way in the script.
|
||||
|
||||
=cut
|
||||
|
||||
sub IsDebarred {
|
||||
my ( $self, $borrower ) = @_;
|
||||
|
||||
return unless $borrower;
|
||||
|
||||
if ( $borrower->{'debarred'} && check_date( split( /-/, $borrower->{'debarred'} ) ) ) {
|
||||
if ( Date_to_Days(Date::Calc::Today) < Date_to_Days( split( /-/, $borrower->{'debarred'} ) ) ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -274,7 +274,8 @@ if ($barcode) {
|
|||
itemtype => $biblio->{'itemtype'},
|
||||
ccode => $biblio->{'ccode'},
|
||||
itembiblionumber => $biblio->{'biblionumber'},
|
||||
additional_materials => $biblio->{'materials'}
|
||||
borrower => $borrower,
|
||||
additional_materials => $biblio->{'materials'},
|
||||
);
|
||||
|
||||
my %input = (
|
||||
|
|
|
|||
|
|
@ -8350,7 +8350,7 @@ if ( CheckVersion($DBversion) ) {
|
|||
INSERT INTO systempreferences
|
||||
(variable,value,explanation,options,type)
|
||||
VALUES
|
||||
('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
|
||||
('SpecifyReturnDate',0,'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);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,34 @@ function Date_from_syspref(dstring) {
|
|||
}
|
||||
}
|
||||
|
||||
function DateTime_from_syspref(date_time) {
|
||||
var parts = date_time.split(" ");
|
||||
var date = parts[0];
|
||||
var time = parts[1];
|
||||
parts = time.split(":");
|
||||
var hour = parts[0];
|
||||
var minute = parts[1];
|
||||
|
||||
if ( hour < 0 || hour > 23 ) {
|
||||
return 0;
|
||||
}
|
||||
if ( minute < 0 || minute > 59 ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var datetime = Date_from_syspref( date );
|
||||
|
||||
if ( isNaN( datetime.getTime() ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
datetime.setHours( hour );
|
||||
datetime.setMinutes( minute );
|
||||
|
||||
return datetime;
|
||||
}
|
||||
|
||||
|
||||
/* Instead of including multiple localization files as you would normally see with
|
||||
jQueryUI we expose the localization strings in the default configuration */
|
||||
jQuery(function($){
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
[% USE KohaDates %]
|
||||
[% USE Branches %]
|
||||
[% USE Koha %]
|
||||
[% USE Borrowers %]
|
||||
|
||||
[% 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" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
|
@ -18,9 +19,33 @@ function Dopop(link) {
|
|||
$(document).ready(function () {
|
||||
$("#return_date_override").datetimepicker({
|
||||
onClose: function(dateText, inst) { $("#barcode").focus(); },
|
||||
defaultDate: -1,
|
||||
hour: 23,
|
||||
minute: 59
|
||||
minute: 59,
|
||||
maxDate: 0
|
||||
});
|
||||
$("#return_date_override").on("blur", function() {
|
||||
check_valid_return_date();
|
||||
});
|
||||
$("#checkin-form").submit(function( event ) {
|
||||
if ( !check_valid_return_date() ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
function check_valid_return_date() {
|
||||
if ( $("#return_date_override").val() ) {
|
||||
var datetime = DateTime_from_syspref( $("#return_date_override").val() );
|
||||
var now = new Date();
|
||||
if ( !datetime || datetime > now ) {
|
||||
alert("Invalid return date/time!");
|
||||
$("#return_date_override").val("")
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$("#exemptcheck").change(function () {
|
||||
if (this.checked == true) {
|
||||
$("#barcode").addClass("alert");
|
||||
|
|
@ -102,6 +127,17 @@ $(document).ready(function () {
|
|||
</div>
|
||||
[% END %]
|
||||
|
||||
<!-- Patron is restricted and checkin was backdated -->
|
||||
[% IF return_date_override && Borrowers.IsDebarred( borrower ) %]
|
||||
<div id="restricted_backdated" class="dialog message">
|
||||
<h3>
|
||||
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">
|
||||
[% borrower.firstname %] [% borrower.surname %]
|
||||
</a>
|
||||
is retricted. Please verify this patron should still be restricted.
|
||||
</h3>
|
||||
</div>
|
||||
[% END %]
|
||||
|
||||
[% IF ( wrongbranch ) %]
|
||||
<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>
|
||||
|
|
@ -395,7 +431,7 @@ $(document).ready(function () {
|
|||
</div>
|
||||
</div>
|
||||
<div class="yui-g">
|
||||
<form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
|
||||
<form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
|
||||
<div class="yui-u first">
|
||||
<fieldset>
|
||||
<legend>Check in</legend>
|
||||
|
|
@ -413,7 +449,7 @@ $(document).ready(function () {
|
|||
<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" />
|
||||
<input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" />
|
||||
|
||||
<label for="return_date_override_remember"> Remember for next check in:</label>
|
||||
[% IF ( return_date_override_remember ) %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue