Hi,
maybe you will find this for a good start and a foundation to build upon.
I've built a form where you submit results for the arrival and the departure. The dates selected previously by the users get disabled. This way you get a availability overview and a somewhat of a base system for a serious booking application.
You can go right ahead and integrate this form with ContentBuilder and create a availability/bookers overview as you wish. Your users could then edit submissions, you could limit their permissions to a number of edits/submits...and much more.
The form definitely needs more work if it's going to be used on real projects... There are a few crucial parts missing, such as few validations to keep the user data valid...Maybe even a Administration system... A confirmation process would be a must. I think this could be done easily with CB also.
The whole code is in the forms
before form piece:$db = JFactory::getDBO();
$sql = "SELECT value FROM #__facileforms_subrecords WHERE name='bookingIn' OR name='bookingOut' ORDER BY id ASC";
$db->setQuery($sql);
$rows = $db->loadObjectList();
$size = count($rows);
for ($i = 0; $i < $size; $i++)
{
$string = $rows[$i]->value;
$pieces = explode("-", $string);
$pieces[1]-=1;
$string = implode(",", $pieces);
if (!($i % 2)) $result .= '{ from: ['.$string.'],';
else $result .= ' to: ['.$string.'] },';
}
echo '<script type="text/javascript">
JQuery(document).ready(function () {
JQuery("#ff_elem15965_calendarButton").pickadate({
format: "yyyy-mm-dd",
selectYears: 60,
disable: ['.$result.'],
min: true,
selectMonths: true,
editable: true,
firstDay: 1,
onSet: function() {JQuery("#ff_elem15965").val(this.get("value"));}
});
JQuery("#ff_elem15966_calendarButton").pickadate({
format: "yyyy-mm-dd",
selectYears: 60,
disable: ['.$result.'],
min: true,
selectMonths: true,
editable: true,
firstDay: 1,
onSet: function() {JQuery("#ff_elem15966").val(this.get("value"));}
});
});
</script>';
so we're basically checking the DB to see previous submissions and build up a string to pass to the calendar disable parameter.
I've attached a form to the post... Just download, unzip and install to your BFs, it should work out of the box.
If you need some help/hints on how to get this to the next level do not hesitate to ask.
EDIT: Unfortunately the form doesn't work out of the box... You will need to get your calendar elements' HTML ID's from the frontend and replace them in the code...you need to replace the: ff_elemXXXX_calendarButton AND ff_elemXXX because BFs assigns new ids to elements on an install.
Regards,
Lovre
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===========================================
Need to renew Pro Support?
Buy Here!
===========================================
Satisfied?
Consider a membership!
===========================================
Like us on
Facebook
===========================================