For some reason the calendar is acting buggy. It doesn’t respond to form.clear() function and the dataprocessor generates some sort of error when handling requests. The following is client side code. After that there will be my serverside code. Then finally the error log.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Add Course</title>
<!-- dhtmlxForms -->
<link rel="stylesheet" type="text/css" href="../includes/dhtmlxSuite/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css" />
<script src="../includes/dhtmlxSuite/dhtmlxForm/codebase/dhtmlxcommon.js "></script>
<script src="../includes/dhtmlxSuite/dhtmlxForm/codebase/dhtmlxform.js "></script>
<!-- dhtmlxConnector & dhtmlxDataprocessor -->
<script src="../includes/dhtmlxSuite/dhtmlxConnector/codebase/connector.js"></script>
<script src="../includes/dhtmlxSuite/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
<!-- dhtmlxDataview -->
<script src="../includes/dhtmlxSuite/dhtmlxDataView/codebase/dhtmlxdataview.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../includes/dhtmlxSuite/dhtmlxDataView/codebase/dhtmlxdataview.css" />
<!-- dhtmlxCalendar -->
<script src="../includes/dhtmlxSuite/dhtmlxForm/codebase/ext/dhtmlxform_item_calendar.js"></script>
<script src="../includes/dhtmlxSuite/dhtmlxCalendar/codebase/dhtmlxcalendar.js"></script>
<link rel="stylesheet" type="text/css" href="../includes/dhtmlxSuite/dhtmlxCalendar/codebase/dhtmlxcalendar.css" />
<link rel="stylesheet" type="text/css" href="../includes/dhtmlxSuite/dhtmlxCalendar/codebase/skins/dhtmlxcalendar_dhx_skyblue.css" />
<!-- Initialization of dhtmlxComponents -->
<script type="text/javascript">
function doOnLoad(){
fc_addCourse = [
{type:"settings",position:"label-top"},
{type: "fieldset",name:"fldstAddCourse", label: "Add Course", list:[
{type: "input", name: "name", label:"Name of the course", validate: "NotEmpty"},
{type: "input", name: "points", label: "Credit point value", validate: "ValidNumeric"},
{type: "input", name: "hours", label: "Hours", validate: "ValidNumeric"},
{type: "calendar", dateFormat: "%Y-%m-%d", name: "start", label: "Start date", readonly: true, validate: "ValidDate", calendarPosition: "right"},
{type: "calendar", dateFormat: "%Y-%m-%d", name: "end", label: "End date", readonly: true, validate: "ValidDate", calendarPosition: "right"},
{type: "input", name: "interval", label: "interval"},
{type: "input", name: "type", label: "Type of studies", validate: "NotEmpty"},
{type: "input", name: "description", label: "Description of the course", validate: "NotEmpty"},
{type: "button", name: "save", value: "Save"},
{type: "button", name: "reset", value: "Reset"},
{type: "button", name: "cancel", value: "Cancel"}
]}
];
var formAddCourse = new dhtmlXForm("fc_formAddCourse", fc_addCourse);
var dpFormAddCourse = new dataProcessor("../control/ctrlAddCourse.php");
dpFormAddCourse.init(formAddCourse);
formAddCourse.attachEvent("onButtonClick", function(id){
if (id=="save"){
alert("Button "+id+" was pressed!!!");
formAddCourse.save();
} else if (id=="reset"){
formAddCourse.clear();
} else if (id=="cancel"){
alert("Button "+id+" was pressed!!!");
}
});
var viewAddCourse = new dhtmlXDataView({
container:"data_container",
drag: true,
type:{
template:"<b>Name: </b>#name#
<b>Description: </b>#description#",
height: 35
}
});
viewAddCourse.load("../control/ctrlAddCourse.php");
}
</script>
</head>
<body onload="doOnLoad()">
<div id="fc_formAddCourse"></div>
<p>
</p>
<div id="data_container" style="width:596px;height:396px;"></div>
</body>
</html>
now the server side code (note: the code executed when is_select_mode() returns true. does not have “start” or “end”. If it did the dataview would not load.
<?php
session_start();
require("../includes/dhtmlxSuite/dhtmlxConnector/codebase/dataview_connector.php");
require("../includes/dhtmlxSuite/dhtmlxConnector/codebase/form_connector.php");
$conn = mysql_connect("localhost","root","root");
mysql_select_db("db_users");
//Connect to the database
$dataCourse = new DataViewConnector($conn, "MySQL"); // replaced $data = new DataViewConnector($conn);
$dataCourse->enable_log("logDataCourse.txt", true); // create a log file
if ($dataCourse->is_select_mode()){
//code for loading data
$dataCourse->render_table("course", "id", "name, points, hours");//table name, ID, list of properties
}else{ //code for other operations - i.e. update/insert/delete
$dataCourse->render_table("course", "id", "name, points, hours, start, end, interval, type, description");//table name, ID, list of properties
}
?>
Finally here’s the error log. Notice that the dates are in long format?
[code]====================================
Log started, 06/09/2011 01:09:42
While there is no edit mode mark, POST parameters similar to edit mode detected. \n Switching to edit mode ( to disable behavior remove POST[ids]
While there is no edit mode mark, POST parameters similar to edit mode detected. \n Switching to edit mode ( to disable behavior remove POST[ids]
DataProcessor object initialized
1315302139582_name => Course 3
1315302139582_points => 12
1315302139582_hours => 8
1315302139582_start => Wed Sep 07 2011 13:13:00 GMT+0300 (EET)
1315302139582_end => Fri Sep 30 2011 13:13:00 GMT+0300 (EET)
1315302139582_interval => some interval
1315302139582_type => some typ
1315302139582_description => new description
1315302139582_!nativeeditor_status => inserted
ids => 1315302139582
Row data [1315302139582]
name => Course 3
points => 12
hours => 8
start => Wed Sep 07 2011 13:13:00 GMT+0300 (EET)
end => Fri Sep 30 2011 13:13:00 GMT+0300 (EET)
interval => some interval
type => some typ
description => new description
!nativeeditor_status => inserted
INSERT INTO course(name,points,hours,start,end,interval,type,description) VALUES (‘Course 3’,‘12’,‘8’,‘Wed Sep 07 2011 13:13:00 GMT+0300 (EET)’,‘Fri Sep 30 2011 13:13:00 GMT+0300 (EET)’,‘some interval’,‘some typ’,‘new description’)
Edit operation finished
0 => action:error; sid:1315302139582; tid:1315302139582;
Done in 0.0074620246887207s
[/code]
I know that it’s a lot of code to look at but I any help that you could lend would be great!!!