Welcome,
Guest
|
|
I\'m modifying getEventFromFrom() function in the calendar.php to insert into the newly added items from the #customNewEventTemplate
The start and end varariables need to be converted to mysql\'s datetime friendly format however I can\'t seem to pass them to the parent method addMyEvent() method. Any ideas why its not happening? Below is my code: function addMyEvent()
{
newev = getEventFromForm()
//ical.addEvent(newev);
var str=\"?\";
str=str+\"eventName=\"+newev.name;
str=str+\"&desc=\"+newev.name;
str=str+\"&st=\"+newev.start;
str=str+\"&et=\"+newev.end;
str=str+\"&groupId=\"+newev.group.groupId;
str=str+\"&allDay=\"+((newev.allDay)?1:0);
str=str+\"&a1=\"+newev.a1;
str=str+\"&a2=\"+newev.a2;
ajaxObj.call(\"action=createevent\"+str, function(ev){ical.addEvent(newev);});
return false;
}
/**
Method to get event from the Form
*/
function getEventFromForm()
{
var newEventContainer = jQuery(\"#customNewEventTemplate\");
var name=newEventContainer.find(\"#eventName\").val();
var grp=newEventContainer.find(\"#eventGroup\").val();
var grpName=newEventContainer.find(\"#eventGroup option:selected\").text();
var strtTime=newEventContainer.find(\"#eventStartTime\").val();
var endTime=newEventContainer.find(\"#eventEndTime\").val();
var startDate=newEventContainer.find(\"#eventStartDate\").val();
var endDate=newEventContainer.find(\"#eventEndDate\").val();
var description=newEventContainer.find(\"#eventDescription\").val();
var movable=newEventContainer.find(\"#chkMovable\").val();
var resizable=newEventContainer.find(\"#chkResizable\").val();
var a1=newEventContainer.find(\"#attribute1\").val();
var a2=newEventContainer.find(\"#attribute2\").val();
if(name==\"\")
{
name=HtmlEncode(\"No Title\");
}
var alldaybox=jQuery(\"#allDayEvent\", newEventContainer).get(0);
var allday=alldaybox.checked;
//var start = getDateFromStrings(startDate, strtTime);
//var end = getDateFromStrings(endDate, endTime);
var sdat = new Date(startDate+\' \'+strtTime);
var edat = new Date(endDate+\' \'+strtTime);
var start = sdat.getFullYear() + \"-\" + zeroPad(sdat.getMonth(),2) + \"-\" + zeroPad(sdat.getDate(),2) + \" \" + zeroPad(sdat.getHours(),2) +\":\" + zeroPad(sdat.getMinutes(),2) + \":00\";
var end = edat.getFullYear() + \"-\" + edat.getMonth() + \"-\" + edat.getDate() + \" \" + edat.getHours() +\":\" + edat.getMinutes();
if(allday)
{
start.setHours(0,0,0);
end.setHours(0,0,0);
}
var newev={name:name, startTime:start, endTime:end
, allDay:allday
, group:{groupId:grp, name: grpName}
, eventId: Math.ceil(999*Math.random())
, description: description
, resizable: resizable
, movable: movable
, attribute1: attribute1
, attribute2: attribute2
};
//returns all form fields in var newev
return newev;
}
function zeroPad(num,count)
{
var numZeropad = num + \'\';
while(numZeropad.length < count) {
numZeropad = \"0\" + numZeropad;
}
return numZeropad;
} Here are my errors: Server Page: src/mybic_server.php
HTTP Method: POST
Encoding Format: JSON
Query String: action=createevent?eventName=2&desc=2&st=undefined&et=undefined&groupId=2&allDay=0&oid=undefined&rid=undefined
HTTP Server Response:
<blockquote><font face=arial size=2 color=ff0000><b>SQL/DB Error --</b> [<font color=000077>Incorrect datetime value: \'undefined\' for column \'start_time\' at row 1</font>]</font></blockquote>{\"eventName\":\"2\",\"eventDesc\":\"2\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"eventId\":0,\"startTime\":\"undefined\",\"endTime\":\"undefined\"}
thanks in advance
|
Please Log in to join the conversation.
phillipkuo.com
|
|
figured out why it wasn\'t inserting.
I am still having trouble figuring out why the ical.addEvent(newev); of the call: ajaxObj.call(\"action=createevent\"+str, function(newev){ical.addEvent(newev);}); isn\'t working. should the function always be function(ev)? thanks in advance |
Please Log in to join the conversation.
phillipkuo.com
|
|
Your newev does not have \"start\", it has \"startTime\"
var newev={name:name, startTime:start, endTime:end , allDay:allday , group:{groupId:grp, name: grpName} var str=\"?\"; str=str+\"eventName=\"+newev.name; str=str+\"&desc=\"+newev.name; str=str+\"&st=\"+newev.start; str=str+\"&et=\"+newev.end; , eventId: Math.ceil(999*Math.random()) , description: description , resizable: resizable , movable: movable , attribute1: attribute1 , attribute2: attribute2 }; But, in your Submit to PHP you are using start and end. That explains the \"undefined\" |
Please Log in to join the conversation. |
|
that fixed the insertion error, however the event doesn\'t \"stick\" on the calendar..
I\'m guessing it is because of this javascript action.. ajaxObj.call(\"action=createevent\"+str, function(newev){ical.addEvent(newev);}); Is the ical.addEvent(newev); |
Please Log in to join the conversation.
phillipkuo.com
|
|
here is my debug output.
Server Page: src/mybic_server.php
HTTP Method: POST
Encoding Format: JSON
Query String: action=getevents
HTTP Server Response:
{\"1\":{\"events\":{\"1\":{\"eventId\":\"2\",\"eventName\":\"test\",\"eventDesc\":\"test\",\"startTime\":\"2010-05-14 00:15:00\",\"endTime\":\"2010-05-14 00:15:00\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"oid\":null,\"rid\":null},\"2\":{\"eventId\":\"13\",\"eventName\":\"test\",\"eventDesc\":\"test\",\"startTime\":\"2010-06-15 00:15:00\",\"endTime\":\"2010-06-15 00:15:00\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"oid\":null,\"rid\":null},\"3\":{\"eventId\":\"14\",\"eventName\":\"test\",\"eventDesc\":\"test\",\"startTime\":\"2010-06-15 00:15:00\",\"endTime\":\"2010-06-15 00:15:00\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"oid\":null,\"rid\":null},\"4\":{\"eventId\":\"15\",\"eventName\":\"test\",\"eventDesc\":\"test\",\"startTime\":\"2010-06-15 01:00:00\",\"endTime\":\"2010-06-15 01:00:00\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"oid\":null,\"rid\":null}},\"groupId\":\"2\",\"name\":\"Jill\"}} |
Please Log in to join the conversation.
phillipkuo.com
|
|
Hi,
What is the error you see? In the JSON string, Events should be an array. You must have an example JSONString.html in your downloaded package, which describes the structure expected. I suggest follow that example. I did NOT test the following structure. Just found the error when I glanced through. Let us know how it goes. {\"1\":{\"events\":[{\"eventId\":\"2\",\"eventName\":\"test\",\"eventDesc\":\"test\",\"startTime\":\"2010-05-14 00:15:00\",\"endTime\":\"2010-05-14 00:15:00\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"oid\":null,\"rid\":null} ,{\"eventId\":\"13\",\"eventName\": \"test\",\"eventDesc\":\"test\",\"startTime\":\"2010-06-15 00:15:00\",\"endTime\":\"2010-06-15 00:15:00\",\"group\":{\"groupId\":\"2\"},\"allDay\":false,\"oid\":null,\"rid\":null}], groupName: \"group\", groupId: \"2\"} |
Please Log in to join the conversation. Team Web2Cal. |
|
Referencing the JSONString.html
I added the following to the addMyEvent() function addMyEvent()
{
newev = getEventFromForm()
eventStr = [{groupId:newev.group.groupId, name:newev.name, events: [{eventId:newev.group.groupId, eventName:newev.name, startTime: newev.startTime, endTime: newev.endTime}] }];
alert(eventStr);
var str=\"?\";
str=str+\"eventName=\"+newev.name;
str=str+\"&desc=\"+newev.name;
str=str+\"&st=\"+newev.startTime;
str=str+\"&et=\"+newev.endTime;
str=str+\"&groupId=\"+newev.group.groupId;
str=str+\"&allDay=\"+((newev.allDay)?1:0);
str=str+\"&oid=\"+newev.attribute1;
str=str+\"&rid=\"+newev.attribute2;
ajaxObj.call(\"action=createevent\"+str, function(eventStr){ ical.addEvent(eventStr);});
return false;
} It still doesn\'t seem to \"stick\" the added event to the calendar. It just inserts into the db but doesn\'t generate anything on the calendar. Once I hit save, the form just disappears. Is there another way to run a diag on how the event is registered? I also compared the HTTP Server Responses for my script and the original and the output formatting is also the same. thanks |
Please Log in to join the conversation.
phillipkuo.com
Last edit: by philltx.
|
|
I changed the jquery library to 1.3.2 and it didn\'t make a difference.
The events do not show up. I\'m thinking it has someething to do with the object received from getevents.php. |
Please Log in to join the conversation.
phillipkuo.com
|
|
I just checked your demo. It is saving and showing correctly. The issue is you date parse function. You are off by a month. All those events, are showing in may.
Let me know if u see the same. |
Please Log in to join the conversation. |
|
I updated the date month parsing and it is still not \'sticking\'.
I think there is something not loading correctly in the loadCalendarEvents method? |
Please Log in to join the conversation.
phillipkuo.com
|