Problem with Database / Scroll Units

Hey

i have 2 problems with the “Scroll Units”.

  1. For the moment the units are loading manually:
var sections=[
  {key:1, label:"Tab 1"},
  {key:2, label:"Tab 2"},
  {key:3, label:"Tab 3"},
  {key:4, label:"Tab 4"},
  {key:5, label:"Tab 5"},
  {key:6, label:"Tab 6"},
];

Is there a way that i can load the numbers of the keys and the Label-Caption directly out of a database table?

  1. In which table of the Demo-Database does the Script save? When i add events it saves always in the first Tab. The event never refers to the Tab where i put it before.

I hope you understand what i mean :frowning:

greets

Hmm … i try to ask again.

Can anyone explain me how the “SCROLL UNIT” saves in the database?
How the database know that i wrote an event in TAB3 for example …

please help me :frowning:

Hello,

Check the following code:

scheduler.createUnitsView({ name:"unit", property:"section_id", list:sections, size:20, step:1 });
Please note the ‘property: “section_id”’ line. That means that units view will differentiate events based on their ‘section_id’ property. And you need to store and fetch from the database.

Yes, please check scheduler\samples\03_extensions\17_connector_units.html sample for example and ./php/types.php server side script it uses.

Kind regards,
Ilya

Thank you. Is exactly what i was searching for.

This is the types.php:

<?php
	include ('../../../codebase/connector/scheduler_connector.php');
	include ('../../common/config.php');
	
	$res=mysql_connect($server, $user, $pass);
	mysql_select_db($db_name);
	
	$list = new OptionsConnector($res);
	$list->render_table("types","typeid","typeid(value),name(label)");
	
	$scheduler = new schedulerConnector($res);
	//$scheduler->enable_log("log.txt",true);
	
	$scheduler->set_options("type", $list);
	$scheduler->render_table("tevents","event_id","start_date,end_date,event_name,type");
?>

for me this means that he is looking in tevents for the events of the type. But how i can write in “tevents” ?

I started to analize this script yesterday and it’s still really complex to me :frowning:

Hello,

In this sample two tables are used: ‘types’ and ‘tevents’.
Types is a simple table with key(id) and label of sections. Connectors simply fetches with information and includes in xml. This happens during initial loading. After that we don’t use this table at all.
Tevents - table with all information about events: their start/end dates, text and so on.
We are using this table during initial loading, when event is updated or deleted.

Connectors do the job for you. Then you create new event AJAX request is send to the server where he parses it, generates correct SQL and adds record to the database. Same thing for the update and delete operations.

Kind regards,
Ilya

This i understand but why he doesn’t write in the database when i create a new event? I tried with the demo (17_connector_units.html) but nothing.

I tried the same with Map-View and works really fine. In the next step i would like to put these 2 tabs together but first i would like to know why the connector doesn’t write in “tevents”.

thanks for your help

Just in case that i don’t have a problem with my source code:

   <script type="text/javascript" charset="utf-8">
		function init() {
			var sections = scheduler.serverList("type");
			var dp2 = new dataProcessor("php/events_map_view.php");
			   dp2.init(scheduler);
			
			scheduler.config.xml_date="%Y-%m-%d %H:%i";
			scheduler.config.prevent_cache = true;
			scheduler.config.details_on_create = true;
		   scheduler.config.details_on_dblclick = true;
			scheduler.config.multi_day = true;
			
			scheduler.locale.labels.unit_tab = "Techniker"
			scheduler.locale.labels.map_tab = "Google Map";
			scheduler.locale.labels.year_tab = "Jahresansicht";
			scheduler.locale.labels.section_custom = "Techniker";
			scheduler.locale.labels.section_location = "Adresse";
			scheduler.locale.labels.section_time = "Zeit";
									
			scheduler.xy.map_date_width = 180; // date column width
			scheduler.xy.map_description_width = 400; // description column width

         // updating dates to display on before view change
         scheduler.attachEvent("onBeforeViewChange", function(old_mode, old_date, new_mode, new_date) {
             scheduler.config.map_start = scheduler.date.month_start(new Date((new_date||old_date).valueOf()));
             scheduler.config.map_end = scheduler.date.add(scheduler.config.map_start, 1, "month");
             return true;
          });

         // defining add function for prev/next arrows
         scheduler.date.add_map = function(date, inc) {
             return scheduler.date.add(date, inc, "month");
         };

         // defining date header 
         var format = scheduler.date.date_to_str("%Y-%m-%d");
         scheduler.templates.map_date = function(start, end, mode){
             return format(start)+" — "+format(end);
         };
			
			scheduler.config.map_inital_zoom = 10;
			
			scheduler.config.lightbox.sections=[	
	 		  {name:"description", height:130, map_to:"text", type:"textarea" , focus:true}, 			    
				{name:"location", height:43, map_to:"event_location", type:"textarea" },
				{name:"custom", height:23, type:"select", options:sections, map_to:"type" },
			/  {name:"recurring", height:115, type:"recurring", map_to:"rec_type", button:"recurring"},
			   {name:"time", height:72, type:"time", map_to:"auto"}
		   ]	
			
			scheduler.createUnitsView({name:"unit",property:"type",list:sections,size:9,step:5});	
			
			scheduler.init('scheduler_here',new Date(2011,9,1),"unit");
			scheduler.load("php/types.php");
			scheduler.load("php/events_map_view.php");	
		}	
		
		function show_minical(){
		if (scheduler.isCalendarVisible())
			scheduler.destroyCalendar();
		else
			scheduler.renderCalendar({
				position:"dhx_minical_icon",
				date:scheduler._date,
				navigation:true,
				handler:function(date,calendar){
					scheduler.setCurrentView(date);
					scheduler.destroyCalendar()
				}
			});
	     }
    </script>	
</head>

<body onload="init();" >
	<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
		<div class="dhx_cal_navline">
			<div class="dhx_cal_prev_button">&nbsp;</div>
			<div class="dhx_cal_next_button">&nbsp;</div>
			<div class="dhx_cal_today_button"></div>
			<div class="dhx_cal_date"></div>
         <div class="dhx_minical_icon" id="dhx_minical_icon" onclick="show_minical()">&nbsp;</div>
         <div class="dhx_cal_tab" name="unit_tab" style="right:542px;"></div>
         <div class="dhx_cal_tab" name="map_tab" style="right:450px;"></div>
	      <div class="dhx_cal_tab" name="day_tab" style="right:316px;"></div>
	      <div class="dhx_cal_tab" name="week_tab" style="right:224px;"></div>			
	      <div class="dhx_cal_tab" name="month_tab" style="right:132px;"></div>
         <div class="dhx_cal_tab" name="year_tab" style="right:40px;"></div>
		</div>
		<div class="dhx_cal_header"></div>
		<div class="dhx_cal_data"></div>		
	</div>
</body>

You are loading data from
php/types.php
But dataprocessor is linked to the different url
var dp2 = new dataProcessor(“php/events_map_view.php”);

Thank you. I changed the source code in:

function init() {
			var sections = scheduler.serverList("type");
			var dp2 = new dataProcessor("php/events_map_view.php");
			var dp3 = new dataProcessor("php/types.php");
			dp2.init(scheduler);
			dp3.init(scheduler);

If i create a new event, he is saving correctly in both tables :smiley:
But … if i make changes in Map-View-Tab he just changes the Map-View-Table and NOT the Types-Table. Why?

Best regards and thank you for all your help