I’m trying to edit the behaviuor of the scheduler to make it save three events per day when the user clicks the save button of the lightbox (month view).
This is the code snippet for this function
scheduler.attachEvent("onEventSave", function(id,ev){
var inizioPausa = scheduler.date.add(ev.start_date, 4, 'hour');
var finePausa = scheduler.date.add(ev.start_date, 5, 'hour');
scheduler.addEvent({
start_date: ev.start_date,
end_date: inizioPausa,
text: " ",
userId: ev.userId,
type: "presenza"
});
scheduler.addEvent({
start_date: inizioPausa,
end_date: finePausa,
text: " ",
userId: ev.userId,
type: "pausa"
})
scheduler.addEvent({
start_date: finePausa,
end_date: ev.end_date,
text: " ",
userId: ev.userId,
type: "pausa"
})
});
The problem is that the events created by this function look good in the scheduler, but not so good in the database: some records are doubled. Moreover I get an IllegalStateException in the consolle and I’m not sure what causes that.
I’m using a Java backend, with a servlet connector.java (see below)
package tts.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.servlet.annotation.WebServlet;
import com.dhtmlx.connector.*;
@WebServlet(name="Connector", urlPatterns={"/connector.action"})
public class Connector extends ConnectorServlet {
private static final long serialVersionUID = -8819552090653981282L;
@Override
protected void configure() {
//obtain DB connection
Connection conn=null;
try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection("jdbc:mysql://localhost/youtime", "root", "root");
} catch (Throwable e) {
e.printStackTrace();
}
//Initializes connector
SchedulerConnector c = new SchedulerConnector(conn);
//configures the used table and fields
c.render_table("events","id","start_date,end_date,text,userId,type");
}
}
Any idea on where is the problem? Any suggestion for implementing this functionality (save multiple custom events in a single day)?
Thanks!!!