How can I detect collision with a custom lightbox?
I tried it with scheduler.collision_check(ev); but this doesn’t work.
Regards,
Michiel Klaver
How can I detect collision with a custom lightbox?
I tried it with scheduler.collision_check(ev); but this doesn’t work.
Regards,
Michiel Klaver
When saving data from custom form you can call
var check = scheduler.callEvent(“onEventSave”, ["", event_object]);
where event_object - object with new start_date and end_date values
it will trigger collision detection and will return false if collision is detected.
[code]When saving data from custom form you can call
var check = scheduler.callEvent(“onEventSave”, ["", event_object]);
where event_object - object with new start_date and end_date values
it will trigger collision detection and will return false if collision is detected.[/code]
When I do this, it’s always returning true? I’m using the timelineview, can this be the problem?
In case of timeline or units view scheduler will trigger collision only if events in the same unit|timeline section conflicts. ( events can occupy the same time, while they are in the different time slots )
Also, you can try to use
scheduler.callEvent("onBeforeEventChanged", [event_object]);
instead of onEventSave
Thanks, that did it!
I’m it isn’t working, with a new event I get the following error:
a is undefined
This is the command I use:
var checkColl = scheduler.callEvent("onBeforeEventChanged",[scheduler.getEvent(event_id)]);
You are calling this line after addEvent (or some other similar command), right?
If issue still occurs - we need a sample where problem can be reconstructed to investigate reasons.
No before the adding the event, this is my code:
[code] scheduler.showLightbox = function(id){
var ev = scheduler.getEvent(id);
var fromdate = scheduler.getEvent(id).start_date.toGMTString();
var tilldate = scheduler.getEvent(id).end_date.toGMTString();
var room = scheduler.getEvent(id).room_id;
if(!dhxWins.isWindow(“eventwindow”)){
dhxWins.createWindow(“eventwindow”, 0, 0, 550, 450);
}
dhxWins.window(“eventwindow”).setModal(true);
dhxWins.window(“eventwindow”).center();
dhxWins.window(“eventwindow”).setText(“Reserveer ruimte”);
dhxTabbar = dhxWins.window("eventwindow").attachTabbar();
dhxTabbar.setSkin("custom");
dhxTabbar.setSkinColors("<? echo inactivetab;?>","<? echo activetab;?>");
dhxTabbar.enableScroll(false);
dhxTabbar.setImagePath("/cmspanel/js/dhtmlx/tabbar/codebase/imgs/");
dhxTabbar.addTab("a1","Reserveer",100);
dhxTabbar.setTabActive("a1");
dhxTabbar.setHrefMode("iframes");
dhxTabbar.enableAutoReSize(true);
dhxTabbar.attachEvent("onSelect",function(id,last_id){return true;});
dhxTabbar.setContentHref("a1","/cmspanel/frames/?reservation&eid="+id+"&room="+room+"&from="+fromdate+"&to="+tilldate);
dhxToolbar = dhxWins.window("eventwindow").attachToolbar();
dhxToolbar.setAlign("right");
dhxToolbar.setIconsPath("/cmspanel/js/dhtmlx/filemanager/imgs/toolbar/");
dhxToolbar.addButton("deletebtn",1,"Verwijder","","");
dhxToolbar.addButton("savebtn",1,"OK","","");
dhxToolbar.attachEvent("onClick",function(id){
switch(id){
case "savebtn": saveReservation(); break;
case "deletebtn": deleteReservation(); break;
}
});
scheduler._edit_stop_event(ev, false);
}
function saveReservation(){
var formatdate = scheduler.date.str_to_date("%d/%m/%Y %H:%i")
var tab1 = dhxTabbar.tabWindow("a1").document;
var action = $("#action",tab1).val();
var event_id = $("#event_id",tab1).val();
var date = $("#date",tab1).val();
var stime = $("#stime",tab1).val();
var etime = $("#etime",tab1).val();
var room_id = $("#room_id",tab1).val();
var relation_id = $("#relation_id",tab1).val();
var relation_name = $("#relation_name",tab1).val();
var contactperson = $("#contactperson",tab1).val();
var email = $("#email",tab1).val();
var telephone = $("#telephone",tab1).val();
var amountofpersons = $("#amountofpersons",tab1).val();
var catering = $("#catering",tab1).val();
var comments = $("#comments",tab1).val();
var sdate = formatdate(date+" "+stime);
var edate = formatdate(date+" "+etime);
var checkColl = scheduler.callEvent("onBeforeEventChanged",[scheduler.getEvent(event_id)]);
if(checkColl==false){
if(!isNaN(parseInt(relation_id)) && parseInt(relation_id)>0 && relation_name.length>0){
if(edate>sdate){
//nieuwe reservering
if(action=="insert"){
scheduler.addEvent({
start_date: sdate,
end_date: edate,
text: comments,
room_id: room_id,
relation_id: relation_id,
contactperson: contactperson,
email: email,
telephone: telephone,
amountofpersons: amountofpersons,
catering: catering
});
}
//bestaande reservering
else if(action=="update"){
scheduler.getEvent(event_id).start_date = sdate;
scheduler.getEvent(event_id).end_date = edate;
scheduler.getEvent(event_id).text = comments;
scheduler.getEvent(event_id).room_id = room_id;
scheduler.getEvent(event_id).relation_id = relation_id;
scheduler.getEvent(event_id).contactperson = contactperson;
scheduler.getEvent(event_id).email = email;
scheduler.getEvent(event_id).telephone = telephone;
scheduler.getEvent(event_id).amountofpersons = amountofpersons;
scheduler.getEvent(event_id).catering = catering;
scheduler.updateEvent(event_id);
dp.setUpdated(event_id,true,"updated");
}
dhxWins.window("eventwindow").close();
} else {
window.alert("De eindtijd dient later te zijn dan de begintijd");
}
} else {
window.alert("Vul de bedrijfsnaam in.");
}
} else {
window.alert("Op dit tijdstip is er al een ruimte gereserveerd");
}
}
[/code]
Not quite sure, but I think that correct code will be something like
var checkColl = scheduler.callEvent("onBeforeEventChanged",[{
start_date: sdate,
end_date: edate,
text: comments,
room_id: room_id,
relation_id: relation_id,
contactperson: contactperson,
email: email,
telephone: telephone,
amountofpersons: amountofpersons,
catering: catering
}]);
This is working for new events but not for existing events.