From 28c9e2fc1bfa9260769bc8f5cb5923e7d2ad7334 Mon Sep 17 00:00:00 2001
From: Emmi <emmi.takkinen@outlook.com>
Date: Fri, 5 Jul 2019 11:46:15 +0300
Subject: [PATCH] Bug 23268:  "Suspend all holds" calendar allows... ...to
 select past date

This patch removes "circulation" and moremember" templates functions
for Datepicker plugin. They now use options common for all inputs with
"datepicker" class and get "minDate" option from id assigned function
in "calender.inc"

To test:
- Apply patch
- Add holds for patron
- Use "Suspend all holds" calendar
=>Calendar greys out dates past from today
---
 koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc    | 4 ++++
 .../intranet-tmpl/prog/en/modules/circ/circulation.tt    | 9 +--------
 .../intranet-tmpl/prog/en/modules/members/moremember.tt  | 8 --------
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
index e6f12ddce0..42175668f9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
@@ -173,6 +173,10 @@ $("#dateofbirth").datepicker({
         yearRange: "c-100:c"
     });
 
+$("#suspend_until").datepicker({
+    minDate: 1, // require that hold suspended until date is after today
+});
+
     $( ".datepicker" ).datepicker({
         onClose: function(dateText, inst) {
             validate_date(dateText, inst);
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
index 84c3833d71..d14439aa97 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -1098,14 +1098,7 @@
             $("#onsite_checkout").click(function(){
                 toggle_onsite_checkout();
             });
-
-            $("#suspend_until").datepicker({
-                onClose: function(dateText, inst) {
-                    validate_date(dateText, inst);
-                },
-                minDate: 1, // require that hold suspended until date is after today
-            });
-
+         
             [% IF HIGHHOLDS %]
                 [% IF !override_high_holds %]
                     $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate | html %]');
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
index 05cb6c9478..b3074559ac 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -903,14 +903,6 @@
                 "bPaginate": false
             }));
 
-            $("#suspend_until").datepicker({
-                onClose: function(dateText, inst) {
-                    validate_date(dateText, inst);
-                },
-                minDate: 1, // require that hold suspended until date is after today
-            }).on("change", function(e, value) {
-                if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
-            });
 
             $("#view_restrictions").on("click",function(){
                 $('#debarments-tab-link').click();
-- 
2.17.1