Used php to filter min days for off canvas booking form
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 2 Nov 2015 17:34:24 +0000 (12:34 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 2 Nov 2015 17:34:24 +0000 (12:34 -0500)
js/app.js
js/custom/pageSetup.js
parts/off-canvas-menu.php

index ea89e1d..9d6bb6d 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -76,10 +76,17 @@ $(document).ready(function () {
     m = today.getMonth() + 1;
     y = today.getFullYear();
     requiredDate = y + '-' + m + '-' + d;
-    $("#dateOff1").attr("min", requiredDate);
+   // $("#dateOff1").attr("min", requiredDate);
     
     $("#dateOff1").change(function () {
         currentDate = this.value;
+        today = new Date(currentDate);
+        d = today.getDate() + 2;
+        m = today.getMonth() + 1;
+        y = today.getFullYear();
+        requiredDate = y + '-' + m + '-' + d;
+        alert(requiredDate);
+
     });
    // $("#date1").val(requiredDate);
     $("#date1").datepicker({
index d97de7b..d60f8f4 100644 (file)
@@ -67,10 +67,17 @@ $(document).ready(function () {
     m = today.getMonth() + 1;
     y = today.getFullYear();
     requiredDate = y + '-' + m + '-' + d;
-    $("#dateOff1").attr("min", requiredDate);
+   // $("#dateOff1").attr("min", requiredDate);
     
     $("#dateOff1").change(function () {
         currentDate = this.value;
+        today = new Date(currentDate);
+        d = today.getDate() + 2;
+        m = today.getMonth() + 1;
+        y = today.getFullYear();
+        requiredDate = y + '-' + m + '-' + d;
+        alert(requiredDate);
+
     });
    // $("#date1").val(requiredDate);
     $("#date1").datepicker({
index f7a5bcb..803fd70 100644 (file)
             <span>Book Now</span>
         </div>
     </div>
+    <?php $requiredDate = date('Y-m-d', strtotime("+2 days")); ?>
+    <?php $minStay = date('Y-m-d', strtotime($requiredDate. "+2 days" )); ?>
     <form method="post" action="<?php echo get_permalink(150); ?>">
         <div class="row">
             <div class="small-12 res-search columns">
                 <input type="text" placeholder="Search by property" name="s">
             </div>
             <div class="small-6 res-date columns">
-                <input id="dateOff1" type="date" placeholder="Arrive" name="ArrivalDate" required="required">
+                <input id="dateOff1" type="date" min="<?php echo $requiredDate ?>" placeholder="Arrive" name="ArrivalDate" required="required">
                 <img id = "offCal1" src="<?php echo get_template_directory_uri(); ?>/assets/calendar-icon.jpg">
             </div>
             <div class="small-6 res-date columns">
-                <input id="dateOff2" type="date" min="<?php date("Y/m/d", strtotime("+2 days")); ?>" placeholder="Depart" name="DepartureDate" required="required"><img id ="offCal2" src="<?php echo get_template_directory_uri(); ?>/assets/calendar-icon.jpg">
+                <input id="dateOff2" type="date" min="<?php echo $minStay ?>" placeholder="Depart" name="DepartureDate" required="required"><img id ="offCal2" src="<?php echo get_template_directory_uri(); ?>/assets/calendar-icon.jpg">
             </div>
             <div class="small-6 guest columns">
                 <!--<input id="offGuests" type="text" placeholder="Guests" > -->