Hi All, I want to prevent the insertion of new event in the future based on my sql condition.
I have build an select options in lightbox with my sql query list of PERSONS.
My problem is:
When I add a new event in the future and assign to a PERSON I will control and prevent the insertion if the PERSON is unavalaible based on the date select.
If you are using connectors - you can attach your custom code to beforeProcessing event and block saving if some data do not confirm your requirements.
function my_validate($action){
if (some_custom_check($action->get_value("start_date"))
$action->invalid();
}
$scheduler->attachEvent("beforeProcessing", "my_validate");
Thank you.
Yes i use php and mysql.
But this code must add in which file and in which position?
I use connector file called scheduler_connector.php this is the right file?
Hi Stanislav, I have build this code for prevent the insertion of new Event in the future if the operator is not avalaible .
But don’t work.
function custom_upd_1($action){
$res = mysql_query("SELECT presence_start,name FROM operators WHERE name='{$action->get_value('operator')}'"); //get value when I open Lightbox
$data = mysql_fetch_array($res);
$presence_start = $data['presence_start'];
$date_start_event = $action->get_value("start_date"); // get value when I open Lightbox
if($date_start_event >= $presence_start)
$action->invalid();
}
$scheduler->event->attach("beforeInsert", "custom_upd_1");
This line can be replaced with your custom reaction. What do you want to be done, when some action returns “invalid” status from server side. Scheduler has not any predefined actions for such case - so you need to use a custom code here.