- $(document).ready(function() {
- $("#exemptcheck").change(function(){
- if(this.checked == true) {
- $("#barcode").addClass("alert");
- $("#exemptfines").show();
- } else {
- $("#barcode").removeClass("alert");
- $("#exemptfines").hide();
- }
- $("#barcode").focus();
- });
- $("#dropboxcheck").change(function(){
- if (this.checked == true) {
- $("#barcode").addClass("alert");
- $("#dropboxmode").show();
- } else {
- $("#barcode").removeClass("alert");
- $("#dropboxmode").hide();
- }
- $("#barcode").focus();
- });
- [% IF ( overduecharges ) %]$("#barcode").focus(function(){
- if(($("#exemptcheck").attr("checked") == true)||($("#dropboxcheck").attr("checked") == true)){
- $("#barcode").addClass("alert");
- } else {
- $("#barcode").removeClass("alert");
- }
- });
- $("#barcode").blur(function(){
- $("#barcode").removeClass("alert");
- });[% END %]
- });
+$(document).ready(function () {
+ $("#return_date_override").datetimepicker({
+ onClose: function(dateText, inst) { $("#barcode").focus(); },
+ defaultDate: -1,
+ hour: 23,
+ 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");
+ $("#exemptfines").show();
+ } else {
+ $("#barcode").removeClass("alert");
+ $("#exemptfines").hide();
+ }
+ $("#barcode").focus();
+ });
+ $("#dropboxcheck").change(function () {
+ if (this.checked == true) {
+ $("#barcode").addClass("alert");
+ $("#dropboxmode").show();
+
+ $("#return_date_override_fields :input").attr("disabled", true);
+ $("#return_date_override").datetimepicker("disable");
+ } else {
+ $("#barcode").removeClass("alert");
+ $("#dropboxmode").hide();
+
+ $("#return_date_override_fields :input").attr("disabled", false);
+ $("#return_date_override").datetimepicker("enable");
+ }
+ $("#barcode").focus();
+ });
+ [% IF(overduecharges) %] $("#barcode").focus(function () {
+ if (($("#exemptcheck").attr("checked") == true) || ($("#dropboxcheck").attr("checked") == true)) {
+ $("#barcode").addClass("alert");
+ } else {
+ $("#barcode").removeClass("alert");
+ }
+ });
+ $("#barcode").blur(function () {
+ $("#barcode").removeClass("alert");
+ });
+ [% END %]
+});