how to save recurring events as individual events?


#21

Hello,

The error is fixed, but with the function scheduler.getRecDates(event_id); I still get sundays back, but the start and endtime is correct.

Can you tell me how this is possible?

Regards,
Michiel Klaver


#22

Can you provide some scenario , how issue can be reconstructed ( which event was created, and which data is incorrectly returnted by getRecDates call )


#23

Hello,

This is my complete script:

[code]window.dhx_globalImgPath=“js/dhtmlx/combo/codebase/imgs/”;
function debtorAdd()
{
var tb_url = “frames/?debtor-add&scheduler=true&keepThis=true&TB_iframe=true&height=450&width=800”;
var tb_caption = “Debiteur toevoegen”
var tb_rel = “”
TB_show(tb_caption, tb_url, tb_rel);
}
scheduler._click.dhx_cal_prevmonth_button = function(e){
scheduler.setCurrentView(scheduler.date.add(scheduler._date,-28,scheduler._mode));
}
scheduler._click.dhx_cal_prevweek_button = function(e){
scheduler.setCurrentView(scheduler.date.add(scheduler._date,-7,scheduler._mode));
}
scheduler._click.dhx_cal_nextweek_button = function(e){
scheduler.setCurrentView(scheduler.date.add(scheduler._date,7,scheduler._mode));
}
scheduler._click.dhx_cal_nextmonth_button = function(e){
scheduler.setCurrentView(scheduler.date.add(scheduler._date,28,scheduler._mode));
}

			var markers = {};
			var format 	= scheduler.date.date_to_str("%Y-%m-%d");
			var Tomorrow= new Date(2010,10,22,00,00,00);
			Tomorrow.setDate(Tomorrow.getDate() - 0);
			scheduler.attachEvent("onEventLoading", function(ev){
				if (ev.event_billed=="nee" && ev.start_date<Tomorrow && ev.act_type!="2"){
					markers[format(ev.start_date)]=true;
				}
				return true;
			});
			
			var cur_viewmode,curr_viewdate;;
			scheduler.attachEvent("onViewChange", function (mode , date){
				cur_viewmode = mode;
				curr_viewdate = date;
			});
			scheduler.attachEvent("onXLE", function (){
				scheduler.setCurrentView(curr_viewdate,cur_viewmode);
			});
			
			
			scheduler.templates.week_date_class=function(date){
				if (scheduler._mode == "unit") return "";
				if (markers[format(date)]){
					 return "notclosedevent";
				}
			}
			
	scheduler.attachEvent("onEventAdded", function(event_id,event_object){
		if(event_id!="" && scheduler.getEvent(event_id).rec_type){
							
			var eventText             = event_object.text;       
			var eventReminder         = event_object.event_reminder;       
			var eventCustom_1         = event_object.event_custom_1;       
			var eventCustom_2         = event_object.event_custom_2;       
			var eventLocation         = event_object.event_location;       
			var eventProject_id       = event_object.project_id;       
			var eventDebtor_id        = event_object.debtor_id;       
			var eventEmployee_id      = event_object.employee_id;       
			var eventAct_id           = event_object.act_id;       
			var eventRoom_id          = event_object.room_id;       
			var eventEquip_id         = event_object.equip_id;       
			var eventRec_type         = "";   
			var eventRec_pattern      = "";     
			var eventShared_employees = event_object.event_shared_employees;       
			var eventSendmail         = event_object.sendmail;       
			var eventKm_start         = event_object.event_km_start;       
			var eventKm_end           = event_object.event_km_end;       
			
			var repeatArray = new Array();
			var repeatArray = scheduler.getRecDates(event_id);
			var repeatCount = repeatArray.length;
			var new_id      = scheduler.uid();

			for (var i = 0; i < repeatCount; i++){
				var start_date = repeatArray[i]["start_date"];
				var end_date = repeatArray[i]["end_date"];
				
				scheduler.addEvent({
					id:					   new_id,
					start_date:            start_date,
					end_date:              end_date,
					text:                  eventText,
					event_reminder:        eventReminder,
					event_custom_1:        eventCustom_1,
					event_custom_2:        eventCustom_2,
					event_location:        eventLocation,
					project_id:            eventProject_id,
					debtor_id:             eventDebtor_id,
					employee_id:           eventEmployee_id,
					act_id:                eventAct_id,
					room_id:               eventRoom_id,
					equip_id:              eventEquip_id,
					event_pid:             event_id,
					event_length:          start_date.valueOf()/1000,
					rec_type:              "",
					event_shared_employees:eventShared_employees,
					event_km_start:        eventKm_start,
					event_km_end:          eventKm_end,
					sendmail:              eventSendmail
				});
				scheduler._add_rec_marker(scheduler.getEvent(new_id),start_date);
				if (new_id!=event_id){
					dp.setUpdated(new_id, true, "inserted");
					new_id = scheduler.uid();
				}
			}
			
		}
		else return true;
		
	});

var dp;function init() { 

var employees = [{key:1458, label:“Michiel”}];
var projects = [{key:3, label:“JEROE1001 - “},{key:4, label:“JEROE1001_01 - “},{key:5, label:“MICHI1001 - “},{key:6, label:“MICHI1001_01 - “}];
var rooms = [{key:54, label:“Bespreking huiskamer”},{key:55, label:“Bespreking kraamkamer”},{key:56, label:“Bespreking stiltekamer”},{key:57, label:“Bespreking vergaderkamer”},{key:53, label:“Buiten”}];
var equipments = [{key:36, label:“camera blauw”},{key:38, label:“camera rood”},{key:39, label:“camera zwart”},{key:35, label:“canon eos”},{key:41, label:“scanner”},{key:33, label:“scherm”},{key:32, label:“Test apparatuur”}];
scheduler.form_blocks[“combo”]={
render:function(sns){
var height=(sns.height||“23”)+“px”;
var html=”

”;
return html;
},
set_value:function(node,value,ev){
var isreadonly = ev.readonly;
if(value==“0”) {value=””;}
if(value==“p0”){value=””;}
if(value==“s0”){value=””;}
if(value==“d0”){value="";}
if(value==“c0”){value="";}
if (!node.combo){
node.combo = new dhtmlXCombo(node.id,“dummy”,“553px”);
node.combo.enableFilteringMode(true);
node.combo.loadXML(node.getAttribute(“data”),function(){
node.combo.attachEvent(“onKeyPressed”, function(keyCode){if(keyCode == 13){var selIndex=node.combo.getSelectedIndex();node.combo.selectOption(selIndex);}});node.combo.attachEvent(“onBlur”, function(){var selIndex=node.combo.getSelectedIndex();node.combo.selectOption(selIndex);});var checkedID = node.getAttribute(“checked”);node.combo.setComboValue(value||checkedID);
});
return;
}
var checkedID = node.getAttribute(“checked”);node.combo.setComboValue(value||checkedID);
},
get_value:function(node,ev){
return node.combo.getActualValue();
},
focus:function(node){
node.combo.DOMelem_input.focus();
}
}
scheduler.form_blocks[“emptytext”]={
render:function(sns){
var height=(sns.height||“23”)+“px”;
var html="
";
return html;
}, set_value:function(node,value,ev){
var textvalue=value||"";
node.childNodes[0].value=textvalue;
if(textvalue==""){document.getElementById(‘emptytext’).style.display=‘none’;node.previousSibling.style.display=‘none’;}else{document.getElementById(‘emptytext’).style.display=‘block’;node.previousSibling.style.display=‘block’;};
},
get_value:function(node,ev){
return node.childNodes[0].value;
},
focus:function(node){
var a=node.firstChild; a.select(); a.focus();
}
}
scheduler.form_blocks[“checkable”]={
render:function(sns){
var height=(sns.height||“23”)+“px”;
var html="
";
return html;
},
set_value:function(node,value,ev){
if(value==“0”){value="";}
if(value==“p0”){value="";}
if(value==“s0”){value="";}
if(value==“d0”){value="";}
if(value==“c0”){value="";}
if (!node.combo){
node.combo = new dhtmlXCombo(node.id,“dummy”,“553px”,“checkbox”);
node.combo.enableFilteringMode(true);
node.combo.enableOptionAutoHeight(true,200);
node.combo.loadXML(node.getAttribute(“data”),function(){
if(value && value!=0)
{
var selemps =value.split(",");
for(var j=0;j<selemps.length;j++)
{
var nmbr = node.combo.getIndexByValue(selemps[j]);
node.combo.setChecked(nmbr,true);
}
}
});
return;
}
if(value && value!=0)
{
var res = new String(value);
var selemps =res.split(",");
for(var j=0;j<selemps.length;j++)
{
var nmbr = node.combo.getIndexByValue(selemps[j]);
node.combo.setChecked(nmbr,true);
}
}
else
{
var selecteditems = node.combo.getChecked()
for(j=0;j<selecteditems.length;j++){
var nmbr = node.combo.getIndexByValue(selecteditems[j]);
node.combo.setChecked(nmbr,false);
}
}
},
get_value:function(node,ev){
return node.combo.getChecked();
},
focus:function(node){
node.combo.DOMelem_input.focus();
}
}
scheduler.form_blocks[“hidden”]={
render:function(sns){
var html="
";
return html;
}, set_value:function(node,value,ev){
node.childNodes[0].value=value||"";
},
get_value:function(node,ev){
return node.childNodes[0].value;
},
focus:function(node){
var a=node.firstChild; a.select(); a.focus();
}
}
scheduler.form_blocks[“textinput”]={
render:function(sns){
var html="
";
return html;
}, set_value:function(node,value,ev){
node.childNodes[0].value=value||"";
},
get_value:function(node,ev){
return node.childNodes[0].value;
},
focus:function(node){
var a=node.firstChild; a.select(); a.focus();
}
}
scheduler.config.api_date = “%d/%m/%Y %H:%i”;
scheduler.config.xml_date = “%Y-%m-%d %H:%i”;
scheduler.config.default_date = “%D %d/%m/%Y”;
scheduler.config.month_date = “%M %Y”;
scheduler.config.week_date = “%D %d %M”;
scheduler.config.day_date = “%D %d %M %Y”;
scheduler.config.unit_date = “%D %d %M”;
scheduler.config.lightbox.sections=[
{name:“project”, map_to:“project_id”, type:“combo”, xml:“js/dhtmlx/combo/projects.php”, focus:true, checked:""}, {name:“description”, height:35, map_to:“text”, type:“textarea”, focus:false},
{name:“custom1”,map_to:“event_custom_1”, type:“textinput” },{name:“custom2”,map_to:“event_custom_2”, type:“textinput” }, {name:“company”, height:0, map_to:“company_id”, type:“hidden”},
{name:“debname”, height:0, map_to:“deb_name”, type:“hidden”},
{name:“debtor”, map_to:“debtor_id”, type:“combo”, xml:“js/dhtmlx/combo/debtors.php”, checked:"" },
{name:“employee”, map_to:“employee_id”, type:“combo”, xml:“js/dhtmlx/combo/employees.php”, checked:"" },
{name:“activity”, map_to:“act_id”, type:“combo”, xml:“js/dhtmlx/combo/activities.php”, checked:"" },
{name:“rooms”, map_to:“room_id”, type:“combo”, xml:“js/dhtmlx/combo/rooms.php”, checked:"" },
{name:“equipment”, map_to:“equip_id”, type:“combo”, xml:“js/dhtmlx/combo/equipment.php”, checked:"" },
{name:“time”, height:72, type:“time”, map_to:“auto”}
]
scheduler.xy.nav_height = 55;scheduler.xy.scale_height = 14;scheduler.config.repeat_date = “%d/%m/%Y”;
scheduler.config.scroll_hour = “8”;
scheduler.config.first_hour = “0”;
scheduler.config.last_hour = “24”;
scheduler.config.hour_size_px = 84;
scheduler.config.time_step = 15;
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.multi_day = false;
scheduler.config.drag_move = true;
scheduler.config.drag_resize = true;
scheduler.config.show_loading = true;
scheduler.locale.labels.new_event = “”;
scheduler.locale.labels.unit_tab = “Medewerkers”
scheduler.locale.labels.date = “Date”;
scheduler.locale.labels.description = “Description”;
scheduler.locale.labels.section_custom1 = “Doelstelling”;
scheduler.locale.labels.section_custom2 = “Resultaat”;
scheduler.locale.labels.section_company = “”;
scheduler.locale.labels.section_debname = “”;
scheduler.locale.labels.section_debtor = “Debiteur”;
scheduler.locale.labels.section_project = “Project”;
scheduler.locale.labels.section_employee = “Medewerker”;
scheduler.locale.labels.section_activity = “Uursoort”;
scheduler.locale.labels.section_equipment = “Apparatuur”;
scheduler.locale.labels.section_rooms = “Ruimte”;
function getIso8601Week(date) {var checkDate = new Date(date.getTime());checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));var time = checkDate.getTime();checkDate.setMonth(0);checkDate.setDate(1);return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;}var weekformat = scheduler.date.date_to_str("%D %d/%m/%Y");scheduler.templates.day_date=function(date){var weeknr = getIso8601Week(date); var fulldate = weekformat(date)+" - week “+weeknr; return fulldate;};scheduler.templates.week_date=function(start,end){var weeknr = getIso8601Week(start); var fulldate = “week “+weeknr+” | Michiel Klaver”; return fulldate;};scheduler.createUnitsView(“unit”,“employee_id”,employees);
scheduler.init(‘scheduler_here’,null,“unit”);
scheduler.setLoadMode(“week”);
scheduler.load([“js/dhtmlx/scheduler2.3/php/loader.php?user=1458&uid=”+scheduler.uid()+”&ran="+Math.random]);
dp = new dataProcessor(“js/dhtmlx/scheduler2.3/php/processor.php?employees=1458&uid=”+scheduler.uid()+"&ran="+Math.random);
dp.init(scheduler);
dp.attachEvent(“onAfterUpdate”,function(sid,action,tid, tag){if(action==“updated” || action==“inserted”){var debtor_bedrijf = tag.getAttribute(“debtor_bedrijf”); scheduler.getEvent(sid).debtor_bedrijf = debtor_bedrijf; var debtor_voornaam = tag.getAttribute(“debtor_voornaam”); scheduler.getEvent(sid).debtor_voornaam = debtor_voornaam; var debtor_tussenvoegsel = tag.getAttribute(“debtor_tussenvoegsel”); scheduler.getEvent(sid).debtor_tussenvoegsel = debtor_tussenvoegsel; var debtor_achternaam = tag.getAttribute(“debtor_achternaam”); scheduler.getEvent(sid).debtor_achternaam = debtor_achternaam; var debtor_telprive = tag.getAttribute(“debtor_telprive”); scheduler.getEvent(sid).debtor_telprive = debtor_telprive; var part_nr = tag.getAttribute(“part_nr”); scheduler.getEvent(sid).part_nr = part_nr; var part_name = tag.getAttribute(“part_name”); scheduler.getEvent(sid).part_name = part_name; scheduler.updateEvent(sid); }});
dp.attachEvent(“onRowMark”,function(id,state,mode,is_invalid){if(is_invalid==“invalid”){window.alert(“Niet toegestaan”); document.location.reload();}});scheduler.templates.event_text=function(start,end,event)
{
var partnr = " “+event.part_nr;
var partname = " “+event.part_name;
if(event.sub_nr!=””){partnr = " “+event.sub_nr; partname = " “+event.sub_name;}
var bedrijf = " “+event.debtor_bedrijf;
var naam = event.debtor_voornaam+” “+event.debtor_tussenvoegsel+” “+event.debtor_achternaam;
if(bedrijf==” undefined”){bedrijf=”";}
if(partnr==" undefined"){partnr="";}
if(partname==" undefined"){partname="";}
if(naam==“undefined undefined undefined”){naam="";}
if(naam.length>2){var fullname = bedrijf+" ("+naam+")
“;}else{var fullname = bedrijf+”
“;}
if(partname.length>2){var projectname = “<span style=“font-family:AvenirLTCom-Heavy;”>”+partname+”
“;var fullname = “”; var eventdescription=event.text;}else{var projectname = “”; var eventdescription=”<span style=“font-family:AvenirLTCom-Heavy;”>"+event.text+"";}
if(partnr.length>2){var project = “<span style=“font-family:AvenirLTCom-Heavy;”>”+partnr+"
“;}else{var project = “”;}
var employeename = “(undefined)”;if(fullname==“undefined”){fullname=”";}
if(project==“undefined”) {project ="";}
if(projectname==“undefined”) {projectname ="";}
if(employeename=="(undefined)") {employeename ="";}
var html = " “+project+” “+projectname+” “+eventdescription+” “+employeename+”
“+fullname+”";
return html;
}
scheduler.templates.event_class=function(start,end,event){
if(event.parent_id){parent_id=event.parent_id;}else{parent_id="";}if(parseInt(parent_id)>0 && event.event_invitedaccept==“nee”){ return “isshared”;} else { return “rooms_”+event.room_id;
}}
dhtmlXTooltip.config.className = “dhtmlXTooltip tooltip”;dhtmlXTooltip.config.timeout_to_display = 50;dhtmlXTooltip.config.delta_x = 10;dhtmlXTooltip.config.delta_y = 60;scheduler.templates.tooltip_time_format=scheduler.date.date_to_str("%H:%i");scheduler.templates.tooltip_date_format=scheduler.date.date_to_str("%d/%m/%Y");scheduler.templates.tooltip_text = function(start,end,event) {var partnr = " “+event.part_nr;
var partname = " “+event.part_name;
if(event.sub_nr!=””){partnr = " “+event.sub_nr; partname = " “+event.sub_name;}
var bedrijf = " “+event.debtor_bedrijf;
var naam = event.debtor_voornaam+” “+event.debtor_tussenvoegsel+” “+event.debtor_achternaam;
if(bedrijf==” undefined”){bedrijf=”";}
if(partnr==" undefined"){partnr="";}
if(partname==" undefined"){partname="";}
if(naam==“undefined undefined undefined”){naam="";}
if(naam.length>2){var fullname = bedrijf+" ("+naam+")
“;}else{var fullname = bedrijf;}
if(partname.length>2){var projectname = partname;var fullname = “”; }else{var projectname = “”;}
if(partnr.length>2){var project = partnr;}else{var project = “”;}
var employeename = “undefined”;if(fullname==“undefined”){fullname=”";}
if(project==“undefined”) {project ="";}
if(projectname==“undefined”) {projectname ="";}
if(employeename==“undefined”) {employeename ="";}
var tt_content = “”;if(project!=""){tt_content += “Project: “+project+” - “+projectname+”
”;}if(fullname!=""){tt_content += “Debiteur: “+fullname+”
”;}tt_content += “Beschrijving: “+event.text+”
”;tt_content += “Begintijd: “+scheduler.templates.tooltip_time_format(start)+”
”;tt_content += “Eindtijd: “+scheduler.templates.tooltip_time_format(end)+”
”;if(employeename!=""){tt_content += “Medewerker: “+employeename;}return tt_content;};function CheckRecurring(id){if(id){if(parseInt(this.getEvent(id).event_length)==0){return true;}else{window.alert(“Herhalende item kunnen niet versleept worden.”);return false;}}else{return true;}if(id){block_readonly(id);}}function block_readonly(id){
return true;
}
scheduler.attachEvent(“onClick”,block_readonly);
scheduler.attachEvent(“onBeforeDrag”,CheckRecurring);
scheduler.attachEvent(“onEventSave”,function(id,ev){
if(ev.employee_id==””){ev.employee_id="—";}
if(isNaN(ev.employee_id))
{
window.alert(“Geen medewerker geselecteerd”);
return false;
}
if(ev.debtor_id==""){ev.debtor_id="—";}
if(ev.project_id==""){ev.project_id="—";}
if(isNaN(ev.debtor_id.substr(1,10)) && isNaN(ev.project_id.substr(1,10)))
{
window.alert(“Geen debiteur en/of project geselecteerd”);
return false;
}
if(!ev.debtor_id && !ev.project_id)
{
window.alert(“Geen debiteur en/of project geselecteerd”);
return false;
}
if(ev.act_id==""){ev.act_id="—";}
if(isNaN(ev.act_id))
{
window.alert(“Geen uursoort geselecteerd”);
return false;
}
return true;
});
}
scheduler.showLightbox_rec = function(id){
var ev = scheduler.getEvent(id);
var startdate = scheduler.getEvent(id).start_date.toGMTString();
var enddate = scheduler.getEvent(id).end_date.toGMTString();
var employee = scheduler.getEvent(id).employee_id;
var rec_type = scheduler.getEvent(id).rec_type;
eventPopup(id,startdate,enddate,employee,rec_type);
scheduler._edit_stop_event(ev, false);
}
var dhxTabbar;
function eventPopup(id,startDateFinal,endDateFinal,employee,rec_type){
if(!dhxWins.isWindow(“eventwindow”)){dhxWins.createWindow(“eventwindow”, 0, 0, 550, 450);
}
dhxWins.window(“eventwindow”).button(“close”).disable();
dhxWins.window(“eventwindow”).setModal(true);
dhxWins.window(“eventwindow”).center();
dhxWins.window(“eventwindow”).setText(“Nieuwe afspraak”);
dhxTabbar = dhxWins.window(“eventwindow”).attachTabbar();
dhxTabbar.setSkin(“custom”);
dhxTabbar.setSkinColors("#ca2c91","#e5e5e5");
dhxTabbar.enableScroll(false);
dhxTabbar.setImagePath("/cmspanel/js/dhtmlx/tabbar/codebase/imgs/");
dhxTabbar.addTab(“a1”,“Afspraak”,100);
dhxTabbar.addTab(“a2”,“Uitnodigen”,100);
dhxTabbar.addTab(“a3”,“Herhalen”,100);
dhxTabbar.setTabActive(“a1”);
dhxTabbar.setHrefMode(“iframes”);
dhxTabbar.addTab(“a4”,“Reizen”,100);
dhxTabbar.setContentHref(“a4”,"/cmspanel/frames/?eventwindow&tab=travel&eid="+id+"&sdate="+startDateFinal+"&edate="+endDateFinal+"&employee="+employee+"&rec_type="+rec_type);
dhxTabbar.enableAutoReSize(true);
dhxTabbar.setContentHref(“a1”,"/cmspanel/frames/?eventwindow&tab=appointment&eid="+id+"&sdate="+startDateFinal+"&edate="+endDateFinal+"&employee="+employee+"&rec_type="+rec_type);
dhxTabbar.setContentHref(“a2”,"/cmspanel/frames/?eventwindow&tab=invite&eid="+id+"&sdate="+startDateFinal+"&edate="+endDateFinal+"&employee="+employee+"&rec_type="+rec_type);
dhxTabbar.setContentHref(“a3”,"/cmspanel/frames/?eventwindow&tab=recurring&eid="+id+"&sdate="+startDateFinal+"&edate="+endDateFinal+"&employee="+employee+"&rec_type="+rec_type);
dhxTabbar.attachEvent(“onSelect”,function(id,last_id){return true;});
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”: saveEvent(); break; case “deletebtn”: deleteEvent(); break;}});
}var showtraveltab = 0;showtraveltab = 1;
		function agendaOpenShared() 
		{
			dhxWins.createWindow("sharedwindow", 0, 0, 550, 450);
			dhxWins.window("sharedwindow").setModal(true);
			dhxWins.window("sharedwindow").center();
			dhxWins.window("sharedwindow").setText("Agenda delen");
			dhxWins.window("sharedwindow").attachURL("/cmspanel/frames/?agenda-open-shared");
		}
		
		
		function agendaSetOk(ayear,amonth,aday,aview)
		{
			dhxWins.createWindow("okwindow", 0, 0, 300, 150);
			dhxWins.window("okwindow").setModal(true);
			dhxWins.window("okwindow").center();
			dhxWins.window("okwindow").setText("Boek uren");
			dhxWins.window("okwindow").attachURL("frames/?agenda-set-ok&year="+ayear+"&month="+amonth+"&day="+aday+"&view="+aview);
			
		}
		


		function deleteEvent()
		{
			var event_id							= dhxTabbar.tabWindow("a1").document.getElementById("event_id").value;
			var sendmail							= dhxTabbar.tabWindow("a1").document.getElementById("sendmail").value;
			scheduler.getEvent(event_id).sendmail 	= sendmail;
			scheduler.deleteEvent(event_id);
			dp.setUpdated(event_id,true);
			
			dhxWins.window("eventwindow").close();
			setTimeout(function(){
			scheduler.clearAll();
			scheduler.load(["js/dhtmlx/scheduler2.3/php/loader.php?user=1458&uid="+scheduler.uid()+"&ran="+Math.random]);
			},500);
		}
		
		function saveEvent()
		{
			var event_id		= dhxTabbar.tabWindow("a1").document.getElementById("event_id").value;
			var newevent		= dhxTabbar.tabWindow("a1").document.getElementById("newevent").value;
			var dates			= new String(dhxTabbar.tabWindow("a1").document.getElementById("date").value);
			dates				= dates.split("/");
			var sdate			= dhxTabbar.tabWindow("a1").document.getElementById("date").value+" "+dhxTabbar.tabWindow("a1").document.getElementById("stime").value;
			var edate			= dhxTabbar.tabWindow("a1").document.getElementById("date").value+" "+dhxTabbar.tabWindow("a1").document.getElementById("etime").value;
			var event_name		= dhxTabbar.tabWindow("a1").document.getElementById("event_name").value;
			var reminder		= dhxTabbar.tabWindow("a1").document.getElementById("event_reminder").value;
			var custom_1		= dhxTabbar.tabWindow("a1").document.getElementById("event_custom_1").value;
			var custom_2		= dhxTabbar.tabWindow("a1").document.getElementById("event_custom_2").value;
			var event_location	= dhxTabbar.tabWindow("a1").document.getElementById("event_location").value;
			var project			= dhxTabbar.tabWindow("a1").z1.getSelectedValue();
			var debtor			= dhxTabbar.tabWindow("a1").z2.getSelectedValue();
			var employee		= dhxTabbar.tabWindow("a1").z3.getSelectedValue();
			var act				= dhxTabbar.tabWindow("a1").z4.getSelectedValue();
			var room			= dhxTabbar.tabWindow("a1").z5.getSelectedValue();
			var equip			= dhxTabbar.tabWindow("a1").z6.getSelectedValue();
			var sendmail		= dhxTabbar.tabWindow("a1").document.getElementById("sendmail").value;
			if(showtraveltab==1){
				var km_start		= dhxTabbar.tabWindow("a4").document.getElementById("event_km_start").value;
				var km_end			= dhxTabbar.tabWindow("a4").document.getElementById("event_km_end").value;
			} else {
				var km_start		= 0;
				var km_end			= 0;
			}
			              	
			event_rectype 		= "";
			event_length		= "";
			if(dhxTabbar.tabWindow("a3").document.getElementById("recurring").checked==true)
			{
				var rec_type="";
				var rec_count="";
				var rec_count2="";
				var rec_day="";
				var rec_days="";
				var rec_extra="";
				
				var rec_types	= dhxTabbar.tabWindow("a3").document.getElementsByName("rec_type[]");
				var day_types	= dhxTabbar.tabWindow("a3").document.getElementsByName("day_type[]");
				var month_types	= dhxTabbar.tabWindow("a3").document.getElementsByName("month_type[]");
				var year_types	= dhxTabbar.tabWindow("a3").document.getElementsByName("year_type[]");
				var week_days	= dhxTabbar.tabWindow("a3").document.getElementsByName("week_day[]");
				var j			= 0;
				var week_day	= new Array();
				for(i=0;i<rec_types.length;i++)		{if(rec_types[i].checked==true)		{rec_type 	= rec_types[i].value;}}
				for(i=0;i<day_types.length;i++)		{if(day_types[i].checked==true)		{day_type 	= day_types[i].value;}}
				for(i=0;i<month_types.length;i++)	{if(month_types[i].checked==true)	{month_type = month_types[i].value;}}
				for(i=0;i<year_types.length;i++)	{if(year_types[i].checked==true)	{year_type 	= year_types[i].value;}}
				for(i=0;i<week_days.length;i++)		{if(week_days[i].checked==true)		{week_day[j]= week_days[i].value;j++;}}

								
				formatdate	= scheduler.date.str_to_date("%d/%m/%Y %H:%i");
				stime		= formatdate(sdate);
				etime		= formatdate(edate);
				event_length= (etime-stime)/1000;
				
				
				switch(rec_type)
				{
					case "day":		
						rec_count 	= dhxTabbar.tabWindow("a3").document.getElementById("day_count").value;	
						if(day_type=="w")
						{
							rec_type = "week";
							rec_days = "1,2,3,4,5";
						}
					break;
					case "week":	
						rec_count	= dhxTabbar.tabWindow("a3").document.getElementById("week_count").value;	
						rec_days 	= week_day.join(",");
					break;
					case "month":	
						if(month_type=="d")
						{
							var dates	= new String(dhxTabbar.tabWindow("a1").document.getElementById("date").value);
							dates		= dates.split("/");
							datesday	= dhxTabbar.tabWindow("a3").document.getElementById("month_day").value;
							sdate		= datesday+"/"+dates[1]+"/"+dates[2]+" "+dhxTabbar.tabWindow("a1").document.getElementById("stime").value;
							rec_count 	= dhxTabbar.tabWindow("a3").document.getElementById("month_count").value;					
						}
						else if(month_type=="w")
						{
							rec_day		= dhxTabbar.tabWindow("a3").document.getElementById("month_week2").value;	
							rec_count2 	= dhxTabbar.tabWindow("a3").document.getElementById("month_day2").value;	
							rec_count 	= dhxTabbar.tabWindow("a3").document.getElementById("month_count2").value;					
						}		
					break;
					case "year":	
						if(year_type=="d")
						{
							var dates	= new String(dhxTabbar.tabWindow("a1").document.getElementById("date").value);
							dates		= dates.split("/");
							datesday	= dhxTabbar.tabWindow("a3").document.getElementById("year_count").value;;
							rec_count 	= dhxTabbar.tabWindow("a3").document.getElementById("year_month").value;	
							sdate		= datesday+"/"+rec_count+"/"+dates[2]+" "+dhxTabbar.tabWindow("a1").document.getElementById("stime").value;
							rec_count	= "1";
						}
						else if(year_type=="w")
						{
							emonth		= dhxTabbar.tabWindow("a3").document.getElementById("year_month2").value;
							var dates	= new String(dhxTabbar.tabWindow("a1").document.getElementById("date").value);
							dates		= dates.split("/");
							sdate		= dates[0]+"/"+emonth+"/"+dates[2]+" "+dhxTabbar.tabWindow("a1").document.getElementById("stime").value;
							
							rec_count 	= "1";
							rec_day 	= dhxTabbar.tabWindow("a3").document.getElementById("year_week2").value;
							rec_count2	= dhxTabbar.tabWindow("a3").document.getElementById("year_day2").value;
							
						}
					break;
				}
				
				event_rectype	= rec_type+"_"+rec_count+"_"+rec_count2+"_"+rec_day+"_"+rec_days+"#"+rec_extra;
				
				if(dhxTabbar.tabWindow("a3").document.getElementById("rec_end_1").checked==true)
				{
					
				}
				else if(dhxTabbar.tabWindow("a3").document.getElementById("rec_end_2").checked==true)
				{
					edate	= dhxTabbar.tabWindow("a3").document.getElementById("date_of_end").value+" "+dhxTabbar.tabWindow("a1").document.getElementById("etime").value;
				}
			}
			
			
			var d 			= 0;
			var shared		= dhxTabbar.tabWindow("a2").document.getElementsByName("invite[]");
			var invitations = new Array();
			for(j=0;j<shared.length;j++)
			{
				if(shared[j].checked==true)
				{
					invitations[d] = shared[j].value;
					d++;
				}
			}
			shared_employees = ","+invitations.join(",")+",";
			
			event_pid	= "";
			if(dhxTabbar.tabWindow("a3").document.getElementById("single_rec_edit").value.length>1)
			{
				var single_rec_edit	= dhxTabbar.tabWindow("a3").document.getElementById("single_rec_edit").value;
				var single_rec		= decodeURI(single_rec_edit.toString());
				single_rec			= single_rec.split("&");
				formatdate			= scheduler.date.str_to_date("%d/%m/%Y %H:%i");
				formatdate2			= scheduler.date.date_to_str("%d/%m/%Y");
				event_length		= single_rec[0].substr(1,25);
				sdates				= new Date(single_rec[1].substr(6,100));
				sdate				= formatdate2(sdates)+" "+dhxTabbar.tabWindow("a1").document.getElementById("stime").value;
				edates				= new Date(single_rec[2].substr(6,100));
				edate				= formatdate2(edates)+" "+dhxTabbar.tabWindow("a1").document.getElementById("etime").value;
				employee			= single_rec[3].substr(9,100);
				event_rectype		= "";
				event_pid			= event_id;
				newevent			= "1";
				shared_employees	= "";
			}
			
			if(project==null)	{project= "";}
			if(debtor==null)	{debtor	= "";}
			
			if(!isNaN(parseInt(employee)))
			{
				if(!isNaN(parseInt(act)))
				{
					if(!isNaN(parseInt(project.substr(1))) || !isNaN(parseInt(debtor.substr(1))))
					{
						if(newevent=="1")
						{
							scheduler.addEvent({
								id: event_id,
								start_date: sdate,
								end_date: edate,
								text: event_name,
								event_reminder: reminder,
								event_custom_1: custom_1,
								event_custom_2: custom_2,
								event_location: event_location,
								project_id: project,
								debtor_id: debtor,
								employee_id: employee,
								act_id: act,
								room_id: room,
								equip_id: equip,
								rec_type: event_rectype,
								rec_pattern: event_rectype,
								event_length: event_length,
								event_pid: event_pid,
								event_shared_employees: shared_employees,
								event_km_start: km_start,
								event_km_end: km_end,
								sendmail: sendmail
							});
							dp.setUpdated(event_id, true, "inserted");
							
						}
						else
						{
							formatdate	= scheduler.date.str_to_date("%d/%m/%Y %H:%i");
							scheduler.getEvent(event_id).start_date 			= formatdate(sdate);
							scheduler.getEvent(event_id).end_date 				= formatdate(edate);
							scheduler.getEvent(event_id).text 					= event_name;
							scheduler.getEvent(event_id).event_reminder 		= reminder;
							scheduler.getEvent(event_id).event_custom_1 		= custom_1;
							scheduler.getEvent(event_id).event_custom_2			= custom_2;
							scheduler.getEvent(event_id).event_location			= event_location;
							scheduler.getEvent(event_id).project_id 			= project;
							scheduler.getEvent(event_id).debtor_id 				= debtor;
							scheduler.getEvent(event_id).employee_id 			= employee;
							scheduler.getEvent(event_id).act_id 				= act;
							scheduler.getEvent(event_id).room_id 				= room;
							scheduler.getEvent(event_id).equip_id 				= equip;
							scheduler.getEvent(event_id).rec_type 				= event_rectype;
							scheduler.getEvent(event_id).rec_pattern			= event_rectype;
							scheduler.getEvent(event_id).event_shared_employees = shared_employees;
							scheduler.getEvent(event_id).sendmail 				= sendmail;
							scheduler.getEvent(event_id).event_km_start 		= km_start;
							scheduler.getEvent(event_id).event_km_end 			= km_end;

							if(event_length!=""){scheduler.getEvent(event_id).event_length 	= event_length;}
							scheduler.updateEvent(event_id);
							dp.setUpdated(event_id,true);
						}
						dhxWins.window("eventwindow").close();
						setTimeout(function(){
						scheduler.clearAll();
						scheduler.load(["js/dhtmlx/scheduler2.3/php/loader.php?user=1458&uid="+scheduler.uid()+"&ran="+Math.random]);
						},500);
					}
					else
					{
						window.alert("Selecteer een debiteur of een project");
					}
				}
				else
				{
					window.alert("Selecteer een uursoort");
					dhxTabbar.tabWindow("a1").z4.DOMelem_input.focus();
				}
			}
			else
			{
				window.alert("Selecteer een medewerker");
				dhxTabbar.tabWindow("a1").z3.DOMelem_input.focus();
			}
		}

[/code]

Best regards,
Michiel Klaver


#24

Hello,

In the file: dhtmlxscheduler_recurring.js, the date changes after this code: scheduler.date["transpose_"+ev.rec_pattern](td, from); on line 547.

Regards,
Michiel Klaver


#25

Hi, I’m looking for some logic to maybe parse the rec_type value on the server side. I’m working in PHP.

$rec_type = ‘month_1_1_2_’;
$start_date = ‘19/12/2010 10:00’;
$end_date = ‘25/02/2011 11:00’;
$event_length = ‘3600’;

would output an array with the dates needed to create the events individually serverside.

this also would save the client from making a huge POST request.

any help really appreciated

ksr


#26

Attached php class is used in the scheduler plugin, and can do such task. Check get_dates method it takes event info from DB and get list of dates, on which recurring event will occur. You can change that code to use info from incoming POST.
SchedulerHelper.zip (2.13 KB)


#27

Hello,

I am also creating sub events when a recurring event is created and replacing what is displayed on the calendar with those new sub events. So the dhtmlxScheduler recurring event is only being used as a parent reference for the event_pid field, but not being loaded into the calendar (see onEventAdded below).

The problem I run into is when I double click on these newly created events, it asks me if I want to edit the whole series (presumably because event_pid is not null). If I say yes, nothing happens. If I click cancel, it opens a non-recurring version of the event. I haven’t tried to edit that event yet to see what happens, but I’d like to prevent the “edit whole series” alert and create my own similar alert to let me handle editing of events in a series…any suggestions?

Thanks.

        scheduler.attachEvent("onEventAdded", 
            function(event_id,event_object) {
                if (event_object.event_pid == null || event_object.event_pid == '') {
                    $("#working_message").show();
                    var start_dt = convert(event_object.start_date);
                    var end_dt = convert(event_object.end_date);
                    var rec_type = event_object.rec_type;
                    var rec_dates = '';
                    var temp_rec_dates;
                    var temp_lenght;
                    if (rec_type != null && rec_type != '') {
                        rec_type = event_object.rec_type.replace('#', '');
                        temp_rec_dates = scheduler.getRecDates(event_id); //calculates dates and times for each recurring instance of event.
                        temp_length = temp_rec_dates.length;
                        for (var i = 0; i < temp_length; i++) {
                            rec_dates += '&start[' + i + ']=' + convert(temp_rec_dates[i]['start_date']) + '&end[' + i + ']=' + convert(temp_rec_dates[i]['end_date']);
                        }
                    } 
                    var urlparts = $.wiengine.getUrl();
                    var data = $.wiengine.removeParam(urlparts.params, '_display');
                    data = $.wiengine.removeParam(data, '_hist_id');
                    $.ajax({
                        type: "POST",
                        url: urlparts.url_naked+'?'+data+'&_handle_only=1&_panel_id=<{insert name="get_panel_id"}>&_handle_only_display=1',
                        data: '&insert=1&event_id=' + event_id + '&start_dt=' + start_dt + '&end_dt=' + end_dt + 
                            '&text=' + event_object.text + '&instr=' + event_object.instrument_id +
                            '&discount=' + event_object.discount + '&is_assisted=' + event_object.is_assisted +   
                            '&event_length=' + length + '&event_pid=' + event_object.event_pid + 
                            rec_dates + '&rec_type=' + rec_type, 
                        success: function(response) {
                            var instr;
                            for (var i = 0; i < sections.length; i++) {
                                if (event_object.instrument_id == sections[i].key) {
                                    instr = sections[i].label;
                                }
                            }
                            temp = jQuery.parseJSON(response); //response includes new event_id(s), cost, status, and pid.
                            if (rec_type != null && rec_type != '') {
                                for (var i = 0; i < temp_length; i++) {
                                    scheduler.addEvent(temp_rec_dates[i]['start_date'],temp_rec_dates[i]['start_date'],event_object.text,temp.new_id[i], //start date, end_date, text, event_id
                                                {person_id: <{$person_id}>,
                                                name: "<{$name}>",
                                                instrument_id: event_object.instrument_id,
                                                instrument_name: instr,
                                                discount: event_object.discount,
                                                is_assisted: event_object.is_assisted,
                                                status: temp.status, 
                                                cost: temp.cost,
                                                rec_type: '',
                                                event_length: 0,
                                                event_pid: temp.pid}
                                    );  
                                }
                                delete scheduler._events[event_id];
                                scheduler.unselect(event_id);
                                scheduler.event_updated(event_object);
                            } else {
                                scheduler.changeEventId(event_id, temp.new_id);
                                var ev = scheduler.getEvent(temp.new_id);
                                ev.person_id = <{$person_id}>;
                                ev.name = "<{$name}>";
                                ev.cost = temp.cost;
                                ev.status = temp.status;
                                scheduler.getEvent(event_id).instrument_name = instr;
                                scheduler.updateEvent(temp.new_id);
                            }
                        }
                    });
                    $("#working_message").hide();
                }
            }
        );

#28

Hello,

I believe you will have to edit source code to achieve that.

  1. codebase\ext\dhtmlxscheduler_recurring.js renamte to codebase\ext\old_dhtmlxscheduler_recurring.js
  2. Copy sorces/recurring.js to codebase\ext\ and rename it to dhtmlxscheduler_recurring.js
  3. In that file locate following part:

scheduler.showLightbox=function(id){ var pid=this.getEvent(id).event_pid; if (id.toString().indexOf("#")!=-1) pid = id.split("#")[0]; /* if there are no pid or user doesn't want to edit whole series when we need just to open lightbox for id or else - make some preparations and open 'main' event which represent whole series */ if (!pid || pid == 0 || (!this.locale.labels.confirm_recurring || !confirm(this.locale.labels.confirm_recurring))) return this.showLightbox_rec(id); pid = this.getEvent(pid); pid._end_date = pid.end_date; pid.end_date = new Date(pid.start_date.valueOf()+pid.event_length*1000); return this.showLightbox_rec(pid.id); };
Best regards,
Ilya


#29

Thanks, Ilya. I will give this a try - have not made any changes yet.

I am having a related, but separate issue. Events added as below are not visible in my timeline view:
scheduler.addEvent("<{$event.3}>","<{$event.4}>","<{$event.5}>",<{$event.0}>,
{person_id: <{$event.1}>,
name: “<{$event.2}>”,
instrument_id:"<{$event.6}>",
instrument_name:"<{$event.7}>",
discount:"<{$event.8}>",
is_assisted:"<{$event.9}>",
status:"<{$event.10}>",
cost:<{$event.11}>,
event_pid:<{$event.12}>}
);

Thanks.


#30

I copied over recurring.js from the sources folder, but now I am getting additional errors (see attached screen shots).

What is the id in function(id) in the recurring.js file?

Thanks.



#31

In addition to

change the includes on the page as

so both , old and new js files are included ( old first )


#32

that gives me an error for “too much recursion” in the old js file…here are my includes

'microscopy_core/js/dhtmlxscheduler_recurring.js', //for recurring events in details form
'microscopy_core/js/recurring.js', //added to modify recurring behavior

#33

To expand on how I plan to handle recurring events - I am saving the recurring instance created by the scheduler only to use getRecDates and to have a master id for the event_pid field. I want to include the following to replace your “edit recurring series” alert:

        //Prior to opening details form
        scheduler.attachEvent("onBeforeLightbox", 
            function (event_id) {
                if (scheduler.getEvent(event_id).event_pid > 0) {
                    update_recurring = confirm("Would you like to make changes to all events in the series?");
                }
                return true;
            }
        );

If update_recurring is set to true, then I will handle the database update accordingly…etc.


#34

Version of dhtmlxscheduler_rec.js with proposed modification is added.
You need to replace the old file and use only that include ( old_dhtmlxscheduler_recurring.js is not necessary )
dhtmlxscheduler_recurring.zip (5.63 KB)


#35

Hi,

I didn’t see a change in the showLightboxFunction in the attached recurring file. The behavior is the same - still recognizes events with an event_pid as recurring and asks if I want to edit the whole series. If I cancel, it’s a non-recurring form, if I say ok, I get “pid is undefined” on line 386.

I only want the recurring feature to be available on new events. I will handle changes and deletion of recurring events without relying on the recurring functionality of the Scheduler…

Thanks.


#36

Hello,

In your dhtmlxscheduler_recurring.js file locate the following string:

if (!pid || pid == 0 || (!this.locale.labels.confirm_recurring || !confirm(this.locale.labels.confirm_recurring))) return this.showLightbox_rec(id);

Replace it with:

if (!scheduler._new_event || !pid || pid == 0 || (!this.locale.labels.confirm_recurring || !confirm(this.locale.labels.confirm_recurring))) return this.showLightbox_rec(id);

As you see we have added check if this event is new or not. For old events there won’t by any confirmation message and the lightbox for just only this event will be displayed.

Now you can add your code which will display it’s own confirmation message:

scheduler.attachEvent("onBeforeLightbox", function (event_id) { if (scheduler.getEvent(event_id).event_pid > 0) { update_recurring = confirm("Would you like to make changes to all events in the series?"); } return true; } );
Best regards,
Ilya


#37

Thank you! That is working. I need to do additional testing, but this is what I needed.


#38

I am adding events as below, but in my “onEventSave” and ‘onEventUpdated’ functions, event_object.event_pid is undefined. Does this have to do with changes to my recurring.js file?

scheduler.addEvent(“18-01-2011 00:00”,“18-01-2011 00:30”,“sub: New event”,240,
{person_id: 8714989,
name: “ELIKA MOLAYI”,
instrument_id:“20”,
instrument_name:“Deltavision Deconvolution Microscope ---- test”,
discount:“0”,
is_assisted:“N”,
status:“maintenance”,
cost:0,
event_pid:237}

Thanks.


#39

I mentioned this issue in another discussion, but those same events that have event_pid = undefined are not visible in the Timeline view…not sure if these issues are related.


#40

Hello,

I believe there is no ‘onEventUpdated’ function.
As for ‘onEventSave’: event_object holds data which can be read from the lightbox (for example text, start_date, end_date and so on). it does not contain ‘internal’ properties of events which are modified by some other means (event_pid in this case). To access them:

scheduler.attachEvent("onEventSave",function(id,data,is_new_event){ var ev = scheduler.getEvent(id); // now you can access and modify 'internal' properties ... }
Best regards,
Ilya