Hi all.
Calendar plugin is really very nice.
But i dont know, how i can to do reservation time.
For default i can to do many same periods, but i want restrict reservation time, if same time in same day was reserved some time ago.
It is possible?
Calendar plugin - how to do reservation
Re: Calendar plugin - how to do reservation
Hi,
I do have the plugin, but I have not used it yet.
As the calendar is simply a way of displaying data, I would think you probably need to make the checks you want in advance.
You can check in the /hooks/tablename.php -> _before_update (and before_insert) function if that condition is met and if it is return FALSE from the function. The update/insert will not take place. You can take a look on my custom error messages (in my footer) which would allow you to inform the user why saving was canceled
The code you could use looks probably like this (pseudo code!) in _before_update and before_insert:
Or, not so elegant, set a constraint UNIQUE on both fields date and time in your database.
Olaf
I do have the plugin, but I have not used it yet.
As the calendar is simply a way of displaying data, I would think you probably need to make the checks you want in advance.
You can check in the /hooks/tablename.php -> _before_update (and before_insert) function if that condition is met and if it is return FALSE from the function. The update/insert will not take place. You can take a look on my custom error messages (in my footer) which would allow you to inform the user why saving was canceled
The code you could use looks probably like this (pseudo code!) in _before_update and before_insert:
Code: Select all
$myReturnValue = TRUE;
$sql = "select count(primarykey) as c from calendartable WHERE yourDATEField=`" . $data['yourDate'] . "` and yourTimeField = `" . $data['yourTime'] . "`;" ;
$result = sqlValue($sql);
if ($result > 0){
$myReturnValue = FALSE;
}
return $myReturnValue;
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Calendar plugin - how to do reservation
I thou
Example:
1-st people put in calendar event 15.02.2021 from 10.00 - 11.00
2-nd people put in calendar event 15.02.2021 from 10.30 - 11.15
Thats events time not unique, but time from 10.30 - 11.00 is same ...
Code for this solutions should be harder. My PHP skills is not so good.
I thought about it, but thats soultions have problems.onoehring wrote: ↑2021-01-31 08:41Hi,
I do have the plugin, but I have not used it yet.
As the calendar is simply a way of displaying data, I would think you probably need to make the checks you want in advance.
You can check in the /hooks/tablename.php -> _before_update (and before_insert) function if that condition is met and if it is return FALSE from the function. The update/insert will not take place. You can take a look on my custom error messages (in my footer) which would allow you to inform the user why saving was canceled
The code you could use looks probably like this (pseudo code!) in _before_update and before_insert:Or, not so elegant, set a constraint UNIQUE on both fields date and time in your database.Code: Select all
$myReturnValue = TRUE; $sql = "select count(primarykey) as c from calendartable WHERE yourDATEField=`" . $data['yourDate'] . "` and yourTimeField = `" . $data['yourTime'] . "`;" ; $result = sqlValue($sql); if ($result > 0){ $myReturnValue = FALSE; } return $myReturnValue;
Olaf
Example:
1-st people put in calendar event 15.02.2021 from 10.00 - 11.00
2-nd people put in calendar event 15.02.2021 from 10.30 - 11.15
Thats events time not unique, but time from 10.30 - 11.00 is same ...
Code for this solutions should be harder. My PHP skills is not so good.
Re: Calendar plugin - how to do reservation
Hi,
I am not trying to give you ready-to-implement-code but an idea how to do it.
A:
There is an overlap in time (which you want to prevent) if:
I am not sure, if these are all possibilities ... make yourself a drawing - this helps.
Olaf
I am not trying to give you ready-to-implement-code but an idea how to do it.
A:
B:1-st people put in calendar event 15.02.2021 from 10.00 - 11.00
Code should test:2-nd people put in calendar event 15.02.2021 from 10.30 - 11.15
There is an overlap in time (which you want to prevent) if:
Code: Select all
(starttimeB > starttimeA AND starttimeB < endtimeA)
OR
(endtimeB > starttimeA AND endtimeB < endttimeA)
OR
(starttimeB > starttimeA AND endtimeB < endtimeA)
OR
(starttimeA > starttimeB AND endtimeA < endtimeB)
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view