From: Anthony Talarico Date: Tue, 10 Nov 2015 16:28:52 +0000 (-0500) Subject: fixing auto populated min night stay field X-Git-Tag: v1.0.0^2~307 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=79dd8b26bd5ad009aa423cec83222f16b70210fa;p=WP-Themes%2Fstaffords.git fixing auto populated min night stay field --- diff --git a/js/app.js b/js/app.js index 98e44bd..619865a 100644 --- a/js/app.js +++ b/js/app.js @@ -30,7 +30,7 @@ $(document).ready(function () { } // }); - var start, end, arrival, currentDate, requiredDate, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', + var start, end, arrival, currentDate, currentDate2, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&', adults, kids, @@ -78,28 +78,28 @@ $(document).ready(function () { requiredDate = y + '-' + m + '-' + d; //$("#departOff").val(requiredDate); } - + requiredDate = y + '-' + m + '-' + dd; }); // restrict departure date /////////////////////////////// $(document).on('change', '#departOff', function () { - currentDate = $("#departOff").val(); - currentDate = new Date(currentDate); - currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate()); - currentDate.setDate(currentDate.getDate()); - dd = currentDate.getDate() + 1; + currentDate2 = $("#departOff").val(); + currentDate2 = new Date(currentDate2); + currentDate2 = new Date(currentDate2.getUTCFullYear(), currentDate2.getUTCMonth(), currentDate2.getUTCDate()); + currentDate2.setDate(currentDate2.getDate()); + dd = currentDate2.getDate() + 1; if (dd <= 9) { dd = '0' + dd; } - d = currentDate.getDate(); + d = currentDate2.getDate(); if (d <= 9) { d = '0' + d; } - m = currentDate.getMonth() + 1; + m = currentDate2.getMonth() + 1; if (m <= 9) { m = '0' + m; } - y = currentDate.getFullYear(); - requiredDate = y + '-' + m + '-' + d; + y = currentDate2.getFullYear(); + requiredDate1 = y + '-' + m + '-' + dd; departure = d + '-' + m + '-' + y; departure.toString(); departure = departure.replace(/\//g, ""); @@ -108,6 +108,7 @@ $(document).ready(function () { stay = 'stay_nights=' + (departure - arrival) + '&'; if ($("#departOff").val() < $('#departOff').attr("min")) { $("#departOff").val(requiredDate); + alert(requiredDate); } }); ///// end of canvas datepicker logic ^ ////////////////////////////////////////////// diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 52fee86..1a33598 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -21,7 +21,7 @@ $(document).ready(function () { } // }); - var start, end, arrival, currentDate, requiredDate, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', + var start, end, arrival, currentDate, currentDate2, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&', adults, kids, @@ -69,28 +69,28 @@ $(document).ready(function () { requiredDate = y + '-' + m + '-' + d; //$("#departOff").val(requiredDate); } - + requiredDate = y + '-' + m + '-' + dd; }); // restrict departure date /////////////////////////////// $(document).on('change', '#departOff', function () { - currentDate = $("#departOff").val(); - currentDate = new Date(currentDate); - currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate()); - currentDate.setDate(currentDate.getDate()); - dd = currentDate.getDate() + 1; + currentDate2 = $("#departOff").val(); + currentDate2 = new Date(currentDate2); + currentDate2 = new Date(currentDate2.getUTCFullYear(), currentDate2.getUTCMonth(), currentDate2.getUTCDate()); + currentDate2.setDate(currentDate2.getDate()); + dd = currentDate2.getDate() + 1; if (dd <= 9) { dd = '0' + dd; } - d = currentDate.getDate(); + d = currentDate2.getDate(); if (d <= 9) { d = '0' + d; } - m = currentDate.getMonth() + 1; + m = currentDate2.getMonth() + 1; if (m <= 9) { m = '0' + m; } - y = currentDate.getFullYear(); - requiredDate = y + '-' + m + '-' + d; + y = currentDate2.getFullYear(); + requiredDate1 = y + '-' + m + '-' + dd; departure = d + '-' + m + '-' + y; departure.toString(); departure = departure.replace(/\//g, ""); @@ -99,6 +99,7 @@ $(document).ready(function () { stay = 'stay_nights=' + (departure - arrival) + '&'; if ($("#departOff").val() < $('#departOff').attr("min")) { $("#departOff").val(requiredDate); + alert(requiredDate); } }); ///// end of canvas datepicker logic ^ ////////////////////////////////////////////// diff --git a/parts/reservation-form-off-canvas.php b/parts/reservation-form-off-canvas.php index 2ff8c06..9067057 100644 --- a/parts/reservation-form-off-canvas.php +++ b/parts/reservation-form-off-canvas.php @@ -15,7 +15,7 @@
- +