I have a scheluder with timeline view : [code]
Scheduler<style type="text/css" media="screen">
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
</style>
<script type="text/javascript" charset="utf-8">
function init() {
scheduler.locale.labels.timeline_tab = "Timeline";
scheduler.locale.labels.section_room = "Room";
scheduler.locale.labels.section_hoso = "Hồ sơ";
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
dhtmlXTooltip.config.className = 'dhtmlXTooltip tooltip';
dhtmlXTooltip.config.timeout_to_display = 50;
scheduler.templates.tooltip_text = function(start,end,event) {
var i = event.hoso_id;
var label = scheduler.getLabel("hoso_id", i);
return label;
}
scheduler.templates.event_bar_text=function(start,end,event){
var i = event.hoso_id;
var label = scheduler.getLabel("hoso_id", i);
return label;
}
/*scheduler.filter_timeline = function(ev_id, event){
if(event.hoso_id < 4)
return false; // event will be filtered (not rendered)
//or
return true; // event will be rendered
}*/
//===============
//Configuration
//===============
var rooms = [
{key: "P01", label: "Phòng 1"},
{key: "P02", label: "Phòng 2"},
{key: "P03", label: "Phòng 3"},
{key: "P04", label: "Phòng 4"},
{key: "P05", label: "Phòng 5"},
{key: "P06", label: "Phòng 6"},
{key: "P07", label: "Phòng 7"},
{key: "P08", label: "Phòng 8"},
{key: "P09", label: "Phòng 9"},
{key: "P10", label: "Phòng 10"}
];
var hosos = [
{key: 1, label: "Lập trình căn bản A - Nguyễn Văn A"},
{key: 2, label: "Lập trình căn bản A - Trần Văn B"},
{key: 3, label: "Lập trình hướng đối tượng C++ - Trần Văn D"},
{key: 4, label: "Lập trình hướng đối tượng C++ - Nguyễn Văn C"},
{key: 5, label: "Phát triển phần mềm mã nguồn mở - Ngô Bá Hùng"},
{key: 6, label: "Lập trình cho các thiết bị di động - Đoàn Hòa Minh"}
];
var basicSort = function(a, b) {
if (+a.start_date == +b.start_date) {
return a.id > b.id ? 1 : -1;
}
return a.start_date > b.start_date ? 1 : -1;
};
var prioritySort = function(a, b) {
// here we can define sorting logic, what event should be displayed at the top
if (a.important && !b.important) {
// display a before b
return -1;
} else {
if (!a.important && b.important) {
// display a after b
return 1;
} else {
return basicSort(a, b);
}
}
};
// this function is not universal and should be changed depending on your timeline configuration
var timeframeSort = function(a, b) {
a_timeframe_start = scheduler.date.date_part(new Date(a.start_date));
a_timeframe_end = scheduler.date.date_part(new Date(a.end_date));
if (+a.end_date != +a_timeframe_end) {
a_timeframe_end = scheduler.date.add(a_timeframe_end, 1, "day");
}
b_timeframe_start = scheduler.date.date_part(new Date(b.start_date));
if (a_timeframe_start < b.end_date && a_timeframe_end > b.start_date && +a_timeframe_start == +b_timeframe_start) {
return prioritySort(a, b);
} else {
return (a_timeframe_start < b_timeframe_start) ? -1 : 1;
}
};
scheduler.createTimelineView({
name: "timeline",
x_unit: "day",
x_date: "%d %F %Y",
x_step: 1,
x_size: 7,
x_start: 1,
x_length: 7,
y_unit: rooms,
y_property: "room_id",
render: "bar",
round_position: true,
sort: timeframeSort
});
// Working week
scheduler.date.timeline_start = scheduler.date.week_start;
scheduler.date.add_timeline = function(date, step, something) {
return scheduler.date.add(date, step * 7, "day");
};
//===============
//Data loading
//===============
scheduler.config.lightbox.sections = [
{ name: "hoso", height: 23, type: "select", options: hosos, map_to: "hoso_id" },
//{ name: "description", height: 50, map_to: "text", type: "textarea", focus: true },
{ name: "room", height: 23, type: "select", options: rooms, map_to: "room_id" },
{ name: "time", height: 72, type: "time", map_to: "auto"}
];
scheduler.init('scheduler_here', new Date(), "timeline");
scheduler.load("http://localhost/QLPTH/index.php/scheduler/data");
var dp = new dataProcessor("http://localhost/QLPTH/index.php/scheduler/data");
dp.action_param ="dhx_editor_status";
dp.init(scheduler);
/*scheduler.parse([
{ start_date: "2013-03-06 10:00", end_date: "2013-03-06 12:10", hoso_id: 1, room_id: "P01" },
{ start_date: "2013-03-06 10:00", end_date: "2013-03-06 16:00", hoso_id: 2, room_id: "P06" },
{ start_date: "2013-03-06 10:00", end_date: "2013-03-06 14:00", hoso_id: 3, room_id: "P07" },
{ start_date: "2013-03-06 16:05", end_date: "2013-03-06 17:00", hoso_id: 4, room_id: "P08"},
{ start_date: "2013-03-08 12:05", end_date: "2013-03-08 17:45", hoso_id: 5, room_id: "P02"},
{ start_date: "2013-03-08 05:05", end_date: "2013-03-08 07:45", hoso_id: 6, room_id: "P03"},
{ start_date: "2013-03-30 16:30", end_date: "2013-03-30 18:00", hoso_id: 6, room_id: "P04"},
{ start_date: "2013-03-30 18:30", end_date: "2013-03-30 20:00", hoso_id: 5, room_id: "P05"},
{ start_date: "2013-03-07 10:00", end_date: "2013-03-07 12:10", hoso_id: 4, room_id: "P09" },
{ start_date: "2013-03-07 10:00", end_date: "2013-03-07 16:00", hoso_id: 3, room_id: "P10"},
{ start_date: "2013-03-07 10:00", end_date: "2013-03-07 14:00", hoso_id: 2, room_id: "P05" },
{ start_date: "2013-03-07 16:05", end_date: "2013-03-07 17:00", hoso_id: 1, room_id: "P03"}
], "json");*/
}
</script>
class Scheduler extends CI_Controller {
public function index()
{
$this->load->view(‘scheduler’);// loads the view
}
public function data()
{
//data feed
$this->load->database();
//$this->load->model(“event_model”);
$connector = new SchedulerConnector($this->db, “PHPCI”);
$connector->configure(“chi_tiet_hs”, “id”, “start_date, end_date, room_id, hoso_id”);
//$connector->useModel($this->event_model);
$connector->render();
}
}[/code]
My event(chi_tiet_hs) can display in month, week and day view but in timeline view i can’t see it.
I use codeigniter framework.
Can anybody help me?