Last active
October 22, 2022 00:41
-
-
Save rafiahmedd/da73856c7c9e326ad71d3052746f5f95 to your computer and use it in GitHub Desktop.
FF Booking system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_footer', 'booking', 999999999); | |
function booking(){ | |
$formId = 43; //Target a specific form here by id | |
$fields = wpFluent()->table('fluentform_submissions') | |
->where('form_id', $formId) | |
->get(); | |
$toDisable = []; | |
foreach ($fields as $key=>$value) { | |
$response = json_decode($value->response); | |
$toDisable[]= $response->datetime; | |
} | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
function initPicker() { | |
var toDisable = []; | |
<?php foreach ($toDisable as $date){?> | |
toDisable.push("<?php echo $date?>"); | |
<?php }?> | |
if(typeof flatpickr == 'undefined') { | |
return; | |
} | |
flatpickr.localize(window.fluentFormVars.date_i18n); | |
var config = {"dateFormat":"d\/m\/Y","enableTime":false,"noCalendar":false,"disableMobile":true,"time_24hr":false}; | |
try { | |
var customConfig = { | |
disable: toDisable, | |
}; | |
} catch (e) { | |
var customConfig = {}; | |
} | |
var config = $.extend({}, config, customConfig); | |
if (!config.locale) { | |
config.locale = 'default'; | |
} | |
/** | |
* jQuery('#ff_<?php echo $formId?>_datetime') | |
* date field id, so please use the right field id here | |
* it will return jQuery('#ff_43_datetime') | |
*/ | |
if(jQuery('#ff_<?php echo $formId?>_datetime').length) { | |
flatpickr('#ff_<?php echo $formId?>_datetime', config); | |
} | |
} | |
initPicker(); | |
$(document).on('reInitExtras', '.ff_form_instance_<?php echo $formId?>_1', function () { | |
initPicker(); | |
}); | |
}) | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment