Hi all.
My question is:
In the example samples/06_timeline/01_slots.html there is a var sections.
There is a possibility of get value from DB ?.
I use the connector.
Thank you.
Sondra
Hi all.
My question is:
In the example samples/06_timeline/01_slots.html there is a var sections.
There is a possibility of get value from DB ?.
I use the connector.
Thank you.
Sondra
Hello,
Sure it’s possible.
Check out “samples/06_timeline/04_tree_db.html” sample. Although it’s a different view, it’s very similar in initialization to “01_slots.html” and uses database to get list of sections.
Hope this helps.
Best regards,
Ilya
Hi, thank you for your answer.
And now I have this situation:
var sections=[
{key:1, label:"Section A"},
{key:2, label:"Section B"},
{key:3, label:"Section C"},
{key:4, label:"Section D"}
];
scheduler.createTimelineView({
name: "matrix",
x_unit: "day",
x_date: "%d %M",
x_step: 1,
x_size: 15,
y_unit: sections,
y_property: "section_id",
section_autoheight: false,
dy: 20,
dx:110
});
in my events.php I add this SELECT for get “SECTIONS” value from another table of my DB.
$list = new OptionsConnector($res);
$list->render_sql("SELECT id,custom as value, custom as label FROM my_table","id","custom(value),custom(label)");
$list->render_table("my_table","id","custom(value),custom(label)");
//$scheduler->set_options("my_table", $list);
$scheduler = new schedulerConnector($res);
$scheduler->enable_log("log.txt",true);
$scheduler->render_table("events","event_id","start_date,end_date,event_name,section_id");
Can you help me ?
Thank you.
Sondra
Hello,
I am sorry, it seems ‘04_tree_db.html’ sample was not quite what you wanted.
Here is the correct listing according to which you should edit your files.
PHP file:
<?php
include ('../../../codebase/connector/scheduler_connector.php');
include ('../../common/config.php');
$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);
$scheduler = new schedulerConnector($res);
$sections = new OptionsConnector($res); // creating new options connector
$sections->render_table("sections","section_id","section_id (value), section_name (label)"); // rendering table with sections
$scheduler->set_options("sections", $sections); // serverlist will be available on client with the name 'sections'
$scheduler->render_table("events_units","event_id","start_date,end_date,text,section_id"); // rendering table with events
?>
Html file:
...
var sections = scheduler.serverList("sections"); // now sections variable contains all the sections fetched from the DB
scheduler.createTimelineView({
name: "matrix",
x_unit: "day",
x_date: "%d %M",
x_step: 1,
x_size: 15,
y_unit: sections,
y_property: "section_id"
});
...
scheduler.config.lightbox.sections=[
{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
{name:"custom", height:23, type:"select", options:sections, map_to:"section_id" },
{name:"time", height:72, type:"time", map_to:"auto"}
]
scheduler.init('scheduler_here', new Date(2010, 5, 30), "matrix");
scheduler.load("php/events_tree_db.php"); // link to your php file
var dp = new dataProcessor("php/events_tree_db.php");
dp.init(scheduler);
...
Hope this helps.
Best regards,
Ilya
Thank you for answer.
Your code don’t work.
XML error.
I must include some particular JS files?
Thank you.
Sondra.
Hello,
Please post contents of your current php and html file.
Best regards,
Ilya
Hi.
If I try to open my scheduler_connector.php in the browser and I see a blank page.
My events.php:
$sections = new OptionsConnector($res); // creating new options connector
$sections->render_table("sections","section_id","section_id (value), section_name (label)"); // rendering table with sections
$scheduler->set_options("sections", $sections); // serverlist will be available on client with the name 'sections'
$scheduler = new schedulerConnector($res);
$scheduler->enable_log("log.txt",true);
$scheduler->render_table("events","event_id","start_date,end_date,event_name,section_id");
My DB table “sections” have 2 fields, “section_id” and “section_name”.
javascript:
<script type="text/javascript" charset="utf-8">
function init() {
scheduler.locale.labels.section_custom="Section";
scheduler.locale.labels.matrix_tab = "Planning";
brief_mode = true;
var d2s1 = scheduler.date.date_to_str("%d-%m-%Y");
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.details_on_dblclick=true;
scheduler.config.prevent_cache = true;
scheduler.config.show_loading=true;
scheduler.config.details_on_create = true;
scheduler.config.first_hour=08;
scheduler.config.last_hour=20;
scheduler.config.multi_day = true;
scheduler.init('scheduler_here',null,"week");
scheduler.load("php/events.php?uid="+scheduler.uid());
var dp = new dataProcessor("php/events.php");
dp.init(scheduler);
}
var html=function(id){ return document.getElementById(id); }; //just a helper
scheduler.showLightbox = function(id){
var ev = scheduler.getEvent(id);
scheduler.startLightbox(id, html("my_form") );
var d2s = scheduler.date.date_to_str("%Y-%m-%d %H:%i");
html("description").value = ev.text;
html("custom1").value = ev.custom1||"";
html("datetime6").value = d2s(ev.start_date)||"";
html("datetime7").value = d2s(ev.end_date)||"";
html("section_id").value = ev.section_id||"";
}
function save_form() {
var ev = scheduler.getEvent(scheduler.getState().lightbox_id);
//converto date
var s2d = scheduler.date.str_to_date("%Y-%m-%d %H:%i");
ev.text = html("description").value;
ev.custom1 = html("custom1").value;
ev.start_date = s2d(html("datetime6").value);
ev.end_date = s2d(html("datetime7").value);
ev.section_id = html("section_id").value;
scheduler.endLightbox(true, html("my_form"));
}
function close_form(argument) {
scheduler.endLightbox(false, html("my_form"));
}
var sections = scheduler.serverList("sections"); // now sections variable contains all the sections fetched from the DB
scheduler.createTimelineView({
name: "matrix",
x_unit: "day",
x_date: "%d %M",
x_step: 1,
x_size: 15,
y_unit: sections,
y_property: "section_id"
});
//===============
//Customization
//===============
scheduler.templates.matrix_cell_class = function(evs,x,y){
if (!evs) {
var day = x.getDay();
return (day==0 || day == 6) ? "yellow_cell" : "white_cell";
}
if (evs.length<3) return "green_cell";
if (evs.length<5) return "yellow_cell";
return "red_cell";
};
scheduler.templates.matrix_scalex_class = function(date){
if (date.getDay()==0 || date.getDay()==6) return "yellow_cell";
return "";
}
</script>
HTML simple and sample:
<body onload="init();">
<div id="my_form">
<table>
<label for="description">Event text </label><input type="text" name="description" value="" id="description"><br> <tr>
<td>Custom</td>
<td><select id="custom1" name="custom1" >
<option value="">Select</option>
<option value="aa">AA</option>
<option value="bb">BB</option>
<option value="cc">CC</option>
</select></td>
</tr>
</table>
<table>
<tr>
<td>Start</td>
<td><input type="text" name="datetime6" id="datetime6"></td>
</tr>
<tr>
<td>End</td>
<td><input type="text" name="datetime7" id="datetime7"></td>
</tr>
</table>
<input type="button" name="save" value="Save" id="save" style='width:100px;' onclick="save_form()">
<input type="button" name="close" value="Cancel" id="close" style='width:100px;' onclick="close_form()">
</div>
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:244px;padding:0.2em 1em;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:160px;padding:0.2em 1em;"></div>
<div class="dhx_cal_tab" name="matrix_tab" style="right:330px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;padding:0.2em 1em;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>
</body>
Edit you php file:
[code]
$scheduler = new schedulerConnector($res); // should be first one
$sections = new OptionsConnector($res); // creating new options connector
$sections->render_table(“sections”,“section_id”,“section_id (value), section_name (label)”); // rendering table with sections
$scheduler->set_options(“sections”, $sections); // serverlist will be available on client with the name ‘sections’
$scheduler->enable_log(“log.txt”,true);
$scheduler->render_table(“events”,“event_id”,“start_date,end_date,event_name,section_id”);[/code]
I don’t see
[code] include (’…/…/…/codebase/connector/scheduler_connector.php’);
include (’…/…/common/config.php’);
$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);[/code]
You simply skipped them?
scheduler.load("php/events.php?uid="+scheduler.uid());
var dp = new dataProcessor("php/events.php");
2. Try opening it not as local file but from a web server, e.g. localhost/scheduler/samples/06_t … events.php
Best regards,
Ilya
Hi, sorry Ilya.
I simply skip the first part of events.php, and I try to open the events.php NOT scheduler.php.
Now The sections from DB seems to work but I have an error:
Message: ‘undefined’ is null or isn’t a object
IN, dhtmlxscheduler_timeline.js
Can you help me ?
Thank you
Sondra
If that won’t help then can you please create sample and attach here?
Best regards,
Ilya
Hi Ilya, I try all your suggestion.
Maybe the problem is in dhtmlxscheduler_timeline.js 2.3 version
because with dhtmlxscheduler_timeline.js 2.2 version seems to work.(without some options).
Is possible?
Thank you
Sondra
Hello,
Locally everything is working correctly with 2.3 version.
I have made sample with options and events being loaded from the database, check the attachment.
How to use it:
Best regards,
Ilya
slots_options_from_db_sample.zip (7.15 KB)
Hi , thank you.
The same problem in your example.
My browser = FF ver. 3.6 or IE 8.0.
My S.O Client is WIN VISTA
My O.S Server is CentOs 5 or Debian
Scheduler version 2.3
The error in Browser is = translate in english
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; .NET4.0C)
Timestamp: Wed, 20 Oct 2010 14:50:59 UTC
Message: ‘undefined’ is null or not object
Line: 9
Character: 12641
Code 0
URI: dhtmlxscheduler_timeline.js
NOTE: When I open the default page I see the matrix tab as attach image.
and after, If I click on the matrix tab I view correctly.
If you enable
scheduler.config.show_loading=true;
in your example, you can see the drawback.
Thank you.
Sondra
Hello,
//$sections->enable_log("sections_log.txt",true);
//$scheduler->enable_log("events_log.txt",true);
Now try loading scheduler again and check log files.
Thank you.
Best regards,
Ilya
Hello.
I have verify all condition and the configuration is OK.
My scheduler_connector.php
$str="<event id='".$this->get_id()."' >";
$str.="<start_date><![CDATA[".$this->data[$this->config->text[0]["name"]]."]]></start_date>";
$str.="<end_date><![CDATA[".$this->data[$this->config->text[1]["name"]]."]]></end_date>";
$str.="<text><![CDATA[".$this->data[$this->config->text[2]["name"]]."]]></text>";
$str.="<section_id><![CDATA[".$this->data[$this->config->text[3]["name"]]."]]></section_id>";
XML Output after some insertion:
[code] <?xml version="1.0" encoding="utf-8" ?>
SECTION_ID is duplicate.
I try comment out the last line of scheduler_connector.php (<section_id>) and XML OUTPUT render correctly one time section_id.
But I have the same errors.
In attach the logs
Thank you.
Sondra
log.zip (1.07 KB)
Hello,
Have you edited your scheduler_connector.php as it differs from the one available in the package? Try replacing it with the default one.
Best regards,
Ilya
Hello.
I replace scheduler_connector.php
I replace dhtmlxscheduler.js
I replace dhtmlxscheduler_timeline.js
… with your linked package.
Now all seems to work.
Strange, because my previuos installation was with a fresh package version scheduler 2.3.
Your linked package is an modified package?
I thank you very very much.
Sondra