I have 5 departments. Each department has its own calendar with its own table and connector. Now we want to have a 6. calendar that displays all the events from all the other 5 calendars.
is this possible?
if so how do I load the events from the different tables.
2a. do I make a new connector, that quires all the tables?
2b. or is it simply adding more parameters to the scheduler.load?
there is an example samples/03_extensions/13_multisource.html that seems to to this (2b) with xml:
var dp = new dataProcessor("<?php bloginfo('template_directory'); ?>/includes/dhtmlxScheduler_v30/connect_<?php echo $jai_current_calendar; ?>.php");
dp.init(scheduler);[/code]
where the PHP part simply gets the connector for the calendar in question ($jai_current_calendar)
I also see that the event_id in the tables for each calendar will no longer be unique if I manage to combine and load events from all departments into one view. IE. there will at least be two or more events with event_id = 1. Anyone has a suggestion how to handle this challenge?
so, I really hope someone can help me with this. Thanks for a great product!
2a. do I make a new connector, that quires all the tables?
Possible.
You can create a view in database which joins all tables and use this view in render_table command
2b. or is it simply adding more parameters to the scheduler.load?
Possible as well, you can use multisource extension
is there a PHP version of this? I load my single department calendars as such:
Will work the same, just use url of php files instead of xml
Beware that only scenario with view will support data saving, if you load data from multiple files you will not be able to save it by dataprocessor.
here will at least be two or more events with event_id = 1
If you need only show data, not edit - you can create a separate connector file, the same as normal , but with empty id field in render_table command. As result - ids will be autogenerated ( and unique )
To make the keys unique across several tables I am playing with extending the primary key for the department table as such:
function create_events_departments($scheduler_table_name) {
global $wpdb, $scheduler_prefix;
$query = "CREATE TABLE IF NOT EXISTS `".$scheduler_prefix.$scheduler_table_name."` (
`event_id` int(11) NOT NULL AUTO_INCREMENT,
`table_name` varchar(255) NOT NULL DEFAULT '{$scheduler_table_name}',
`start_date` datetime NOT NULL,
`end_date` datetime NOT NULL,
`text` varchar(255) NOT NULL,
`name_ungdom` varchar(255) NOT NULL,
`kategori_id` int(11) NOT NULL,
`event_pid` int(11) NOT NULL,
`event_length` int(11) NOT NULL,
PRIMARY KEY (`event_id`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$wpdb->query($query);
}
so the primary key is now ‘event_id’ and ‘table_name’. the latter is the table name/id for the department in question.
will this work? IE. does the function “render_table” who calls “configure” in “base_connector.php” handle the case where the Primary Key is built up of more than one field? Testing shows that it stores and retrieves the events (for the single calendar views) - but I want to be sure…
looking at render_table
public function render_table($table,$id="",$fields=false,$extra=false,$relation_id=false){
$this->configure($table,$id,$fields,$extra,$relation_id);
return $this->render();
}
a) it says that “@param id: name of id field” does this mean the primary key?
b) how then do I call render_table if (question 1 is true && question 2a is true) when I have two fields making the primary key?
I did some testing and I don’t think the system recognizes the key in a table where the primary key consists of two columns. It seems that the “ID” parameter can only take one elment. IE “event_id” and NOT “event_id,table_name” (where ‘table_name’ is the second key in the primary key (the name/id of each department))
would really be happy for some feedback on this
2 .Also, when creating a view combining the tables - the view still has rows with same IDs → saving data will not work. so I am wondering how to create the view so that saving is possible?
I created the view as follows (just testing with two departments wp_cal_grini and wp_cal_hagan)
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `wp_all_view` AS
select * from `wp_cal_grini`
union
select * from `wp_cal_hagan`
A screen shot of the view with values is attached below.
As for data saving - it possible to use beforeProcessing server side event to decompose id and get both id and table_name values, after which custom logic can be executed which will exec necessary operations
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan