Hello,
Im looking for some help.
Im working on some calendar where I want to be able to accept or decline bookings, just for learning.
So I want to attach a variable for every event, a status event.
If status = 1 then it will be shown as pending, if the status is 2 it will show as accepted, if it is 3 it will show as declined.
But I have no idea how to send this status variable data to my database. I want to try to connect an external app to the same database to retrieve this status variable so the “backend” app will get a notification if a new booking is made, and from that app i can either accept or decline.
How would I make a variable that is default 1 on event create (pending)?
I am also changing the event_bar_text depending on the status…
var svar = “1”
scheduler.templates.event_bar_text = function(start,end,event){
var text;
if(svar == "1"){
text = "Pending";
}
else if(svar =="2"){
text = "Accepted";
}
else {
text = " "
}
return text;
};
I want svar to be sent to my database, and i want svar to be loaded from my database also since i will be changing this value from another application so if i change from an external application to svar = 2, i want the scheduler to read that value and change the text to “accepted”. the text works and changes but im stuck on sending the value to the database…
Sorry if im being unclear,
Thank you for your time
Hi,
event objects can have any custom properties.
E.g. if you add a ‘status’ column to the events table and load it to the client, it can be used for templating and can be editable, like section property in this sample
docs.dhtmlx.com/scheduler/snippet/2875db1c
When event is modified, client-side sends all it’s properties to the backend, including custom ones.
Hey Aliaksandr,
I’m sorry if I sound rude but that did not really explain very much…
I do have a column in my table thats called status. Its also in the render->table call in my events.php file.
But how would I manipulate the value of the column?
When event is created the value should be 1. 1 = pending.
I will then connect this to a backend app where I will get a notification for a pending booking.
If I hit accept it will change the value in the db to 2. 2 = accepted.
Then in the scheduler the text of the event will be changed to “accepted”
I have an if statement for the eventtext that works, now instead of var svar = 1; if svar=1 text=pending blablabla I want to make var svar take its value from the db.
How would I do this?
The scheduler will show events that are both pending or accepted. Id love to maybe change colors depending on status.
Im stuck here, Ive been trying to solve this before moving on but I seem to be really stuck…
Hi,
if you have a column table and have added it to a connector config than it will be available on the client side as one of the properties of the event object and value of this property will be saved back to the db if modified on the client.
If you need a default value, you can use onEventCreated api event:
php:
$scheduler->render_table("events","event_id","start_date,end_date,event_name,status");
js:
scheduler.attachEvent("onEventCreated", function(id,e){
var event = scheduler.getEvent(id);
event.status = 1;
return true;
});
For colors and event text you’ll need to redefine related templates, please check these articles:
docs.dhtmlx.com/scheduler/custom … stoanevent
docs.dhtmlx.com/scheduler/custom … eventstext
An in order to modify the status value from the ui, you can add a selector control to the lightbox, check this article
docs.dhtmlx.com/scheduler/select.html - there is also instruction on how to setup loading of options from the db.
If it still doesn’t help, please clarify what you’ve tried to do or provide some kind of demo so i could better understand what kind of issues do you have