Collision detection on save event in lightbox

Hi, on my lightbox, I have custom fields Rooms and Photographers. The data is coming from database. I want to be able to have an alert or something like it on save the even if the photographer or the room is in use on the selected date/time.
Is it possible to accomplish this. If yes, could you please guide me or have example to check with database before saving and have an alert.
tks
seby

hi again, any idea on how to accomplish that
tks
Seby

Hi,

the most versatile way to do this is to use build-in dataProcessor with server-side dataConnector :
docs.dhtmlx.com/scheduler/server … ation.html
We use it in our projects.

On the server-side you can check with database and return any answer (for ex., “error_update”), then handle it on the client-side using the “defineAction” method:
docs.dhtmlx.com/doku.php?id=dhtm … fineaction

Hi Serge, I think that if you had a little coding example to put me on the right track, that would help me. do you think it would be possible to have so example of the method you are talking to me about?
Thanks in adavance for your help
Seby

Hi again Serge, here’s the code that I already use in my application.
tks
seby

html file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title></title>
</head>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>	
	<script src="../../codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_year_view.js"></script>
	<script src='../../codebase/ext/dhtmlxscheduler_minical.js' type="text/javascript" charset="utf-8"></script>
   <link rel="stylesheet" href="../../codebase/ext/dhtmlxscheduler_ext.css" type="text/css">
   <link rel="stylesheet" href="../../codebase/dhtmlxscheduler.css" type="text/css">
   <script src="../../codebase/ext/dhtmlxscheduler_editors.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxcombo/codebase/dhtmlxcombo.css">
	<script  src="../../codebase/dhtmlxcombo/codebase/dhtmlxcommon.js"></script>
	<script  src="../../codebase/dhtmlxcombo/codebase/dhtmlxcombo.js"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_tooltip.js"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_timeline.js	"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_treetimeline.js	"></script>

<style type="text/css" media="screen">
	html, body{
		margin:0px;
		padding:0px;
		height:100%;
		overflow:hidden;
	}	
</style>

<script type="text/javascript" charset="utf-8">


function mycheckfun(rd)
{
//alert("hello");
//alert(rd);
}

   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()
            }
         });
   }
   



	function init() {
	


	
	
	///////////////////-------------added by sushma ////////////////
		
		var sections=[
			{key:'Business', label:"Business"},
			{key:'Quote', label:"Quote"},
			{key:'Personal', label:"Personal"}
			
		];
		
		scheduler.locale.labels.unit_tab = "Unit"
		scheduler.locale.labels.section_custom="Select";
		scheduler.config.multi_day = true;
		scheduler.config.auto_end_date = true;
		scheduler.config.event_duration = 60;
		scheduler.config.first_hour=4;

		scheduler.config.details_on_create=true;
		scheduler.config.details_on_dblclick=true;


		
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		scheduler.config.prevent_cache = true;
		
		
		
		
		/////////////////////////////////////////////////////////////
		
		scheduler.config.lightbox.sections=[
			{name:"session", height:20, map_to:"session_name", type:"textarea" , focus:true},
			{name:"type", height:20, type:"combo" , image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", options:sections, map_to:"type" },
		    {name:"subtype", height:20, type:"combo",  image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", map_to:"session_type",options:scheduler.serverList("session_type") },
		    {name:"photographers", height:20, type:"combo" , image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", map_to:"photographers_id",options:scheduler.serverList("photographers") },
		    {name:"rooms", height:20, type:"combo" , image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", map_to:"rooms_id",options:scheduler.serverList("rooms") },
			{name:"clients", map_to:"client_id", type:"combo", image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", filtering: true, script_path: "php/complete.php", cache: true },
			{name:"place", height:20, type:"textarea", map_to:"session_location" },

			{name:"time", height:70, type:"calendar_time", map_to:"auto"},
				
			{name:"notes", height:60, type:"textarea", map_to:"session_notes" }
			
		]
		
		
		scheduler.locale.labels.section_session="Event Name";
		scheduler.locale.labels.section_notes="Notes";
		scheduler.locale.labels.section_type="Type";
        scheduler.locale.labels.section_subtype="Sub Type";
		scheduler.locale.labels.section_place="Place";
		scheduler.locale.labels.section_clients="Clients";
		scheduler.locale.labels.section_photographers="Photographe";
		scheduler.locale.labels.section_rooms="Pièce";
		scheduler.locale.labels.timeline_tab ="Photographe";
		scheduler.config.year_x = 4;
		scheduler.config.year_y = 3;
		
		
		
		
scheduler.createTimelineView({
			section_autoheight: false,
			name:	"timeline",
			x_unit:	"minute",
			x_date:	"%H:%i",
			x_step:	30,
			x_size: 24,
			x_start: 16,
			x_length:	48,

			render: "tree",
			folder_events_available: true,
			dy:60,
     y_unit: scheduler.serverList("photographers"),        //sections of the view (titles of Y-Axis)
        
     y_property:"photographers_id", //mapped data property
     render:"tree"             //view mode
});		



		
scheduler.config.start_on_monday = false;
	
	
		//top label of calendar
scheduler.templates.calendar_month =  scheduler.date.date_to_str("%F %Y");

//week label of calendar
scheduler.templates.calendar_scale_date =  scheduler.date.date_to_str("%D");
//date value on the event's details form
scheduler.templates.calendar_time = scheduler.date.date_to_str("%d-%m-%Y");
	
	
	
scheduler.templates.event_class = function(s,e,ev){
if (ev.type == 'Personal') return "Personal";
if (ev.type == 'Business') return "Business";
if (ev.type == 'Quote') return "Quote";
return "";
}	
	
	
		//scheduler.locale.labels.section_radiotype="Select";
		//scheduler.config.details_on_create=true;
		//scheduler.config.details_on_dblclick=true;
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();


		
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		
		scheduler.init('scheduler_here',new Date(curr_year,curr_month,curr_date),"year");
		
		
		scheduler.setLoadMode("year");
		
		
		
		scheduler.load("php/events.php");
		
		
		var dp = new dataProcessor("php/events.php");
		
		dp.init(scheduler);
		
		
		

	}
	

</script>

<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="day_tab" style="right:204px;"></div>
			<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
			<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
			<div class="dhx_cal_tab" name="year_tab" style="right:12px;"></div>
			<div class="dhx_cal_tab" name="timeline_tab"  style="width:auto; right:268px;"></div>
		</div>
		<div class="dhx_cal_header">
		</div>
		<div class="dhx_cal_data">
		</div>		
	</div>
</body>

PHP file event.php

<?php
session_start();
   include ('../../../codebase/connector/scheduler_connector.php');
   include ('../../common/config.php');
   
   $res=mysql_connect($server, $user, $pass);
   mysql_select_db($db_name);
   mysql_query("SET NAMES utf8");
   $scheduler = new schedulerConnector($res);
   /*$list = new OptionsConnector($res);
   $list->render_table("types","typeid","typeid(value),name(label)");*/
   
   
   //-------------Sub Type dropdown ..........................
   
   $OtherDropdown = new OptionsConnector($res);
   $OtherDropdown->render_sql("select id as value, session_type as label from session_type where user_id = '".$_SESSION['user_id']."'","","value,label");
   //$OtherDropdown->render_table("session_type","session_type","id(value),session_type(label)");
    $scheduler->set_options("session_type",$OtherDropdown);
   
   //------------- Eof Sub Type dropdown ..........................
   
   
   
   
   //-------------Photographers dropdown ..........................
   
   $OtherDropdown2 = new OptionsConnector($res);
   $OtherDropdown2->render_sql("select id as value, full_name as label from photographers where user_id = '".$_SESSION['user_id']."'","","value,label");
    $scheduler->set_options("photographers",$OtherDropdown2);
   
   //------------- Eof Photographers dropdown ..........................
   
   
   
   
   //-------------Rooms dropdown ..........................
   
   $OtherDropdown2 = new OptionsConnector($res);
   $OtherDropdown2->render_sql("select id as value, room_name as label from rooms where user_id = '".$_SESSION['user_id']."'","","value,label");
    $scheduler->set_options("rooms",$OtherDropdown2);
   
   //------------- Eof Rooms dropdown ..........................
   
   
   
   
   
   $clients = new OptionsConnector($res);
   
   $clients->render_sql("select id as value, full_name as label from clients where user_id = '".$_SESSION['user_id']."'","","value,label");
   
   $scheduler->set_options("clients",$clients);
      //$scheduler->enable_log("log.txt",true);
      
function mycode($action){
     $action->set_value("user_id", $_SESSION['user_id']);
}
$scheduler->event->attach("beforeProcessing", "mycode");



   
   
   
   //$scheduler->enable_log("log.txt",true);
   //$scheduler = new schedulerConnector($res);
   //$scheduler->render_table("events","event_id","start_date,end_date,event_name,details,types,clients");
   

   if ($scheduler->is_select_mode()){ // ' code for loading data
$SQL = "SELECT * from sessions WHERE user_id='".$_SESSION['user_id']."' "; 
$scheduler->render_sql($SQL,"id","start_date,end_date,session_name,session_name,session_notes,session_type,session_location,type,photographers_id,rooms_id,client_id", "", "");


}
else {    // code for other operations - i.e. update/insert/delete
$scheduler->render_table("sessions","id","start_date,end_date,session_name,session_notes,session_type,session_location,type,photographers_id,rooms_id,client_id,user_id");
}  
 
   
?>

Any example on how to do that pease?
tks
Seby

Hi,

your project is almost ready, you need to add some lines:
Server

[code]$scheduler = new SchedulerConnector($res);

function validate($data){
if($data->get_value(“start_date”) …) { // your condition
$data->set_response_text(“message”);
$data->invalid();
}
}
$scheduler->event->attach(“beforeInsert”,“validate”);[/code]

Client

[code]var dp = new dataProcessor(“php/events.php”);
dp.init(scheduler);

dp.defineAction(“invalid”,function(response){
var message = response.textContent;
alert(message);
return false;// return false to cancel default data processing at all
})[/code]

You can find more info about server-side validation here:
docs.dhtmlx.com/doku.php?id=dhtm … tom_status

Hi Serge, tks for the answer, here’s what my programmer tried. What is wrong, nothing seems to happen. I’m sure he is close lol
tks
Seby

PHP:

<?php
session_start();
   include ('../../../codebase/connector/scheduler_connector.php');
   include ('../../common/config.php');
   
   $res=mysql_connect($server, $user, $pass);
   mysql_select_db($db_name);
   mysql_query("SET NAMES utf8");
   
   
   function validate($data){
	   $start_date=$data->get_value("start_date");
	   if($data->get_value("start_date")) {
		  
		 $photographers_id=$data->get_value("photographers");
		 $rooms_id=$data->get_value("rooms");
		 $user_id=$data->get_value("user_id");
		  if($photographers_id!=0 && $photographers_id!="")
			{
				$sql_chk_photo = mysql_query("select id from sessions where id!='".$id."' AND user_id='".$user_id."' AND photographers_id = '".$photographers_id."' AND '".$start_date."' between start_date  AND end_date");
				if(mysql_num_rows($sql_chk_photo))
				{
					$error=2;
				}
			}
			if($rooms_id!=0 && $rooms_id!="")
			{
				$sql_chk_room = mysql_query("select id from sessions where id!='".$id."' AND user_id='".$user_id."' AND rooms_id = '".$rooms_id."' AND '".$start_date."' between start_date  AND end_date");
				if(mysql_num_rows($sql_chk_room))
				{
					$error=3;
				}
			}
			if($error==2  || $error==3)
			{
			  $data->set_response_text("message");
			  $data->invalid();
			  }
	   }
	}
   
   $scheduler = new schedulerConnector($res);
   /*$list = new OptionsConnector($res);
   $list->render_table("types","typeid","typeid(value),name(label)");*/
   
	
	
	
   //-------------Sub Type dropdown ..........................
   
   $OtherDropdown = new OptionsConnector($res);
   $OtherDropdown->render_sql("select id as value, session_type as label from session_type where user_id = '".$_SESSION['user_id']."'","","value,label");
   //$OtherDropdown->render_table("session_type","session_type","id(value),session_type(label)");
    $scheduler->set_options("session_type",$OtherDropdown);
   
   //------------- Eof Sub Type dropdown ..........................
   
   
   
   
   //-------------Photographers dropdown ..........................
   
   $OtherDropdown2 = new OptionsConnector($res);
   $OtherDropdown2->render_sql("select id as value, full_name as label from photographers where user_id = '".$_SESSION['user_id']."'","","value,label");
    $scheduler->set_options("photographers",$OtherDropdown2);
   
   //------------- Eof Photographers dropdown ..........................
   
   
   
   
   //-------------Rooms dropdown ..........................
   
   $OtherDropdown2 = new OptionsConnector($res);
   $OtherDropdown2->render_sql("select id as value, room_name as label from rooms where user_id = '".$_SESSION['user_id']."'","","value,label");
    $scheduler->set_options("rooms",$OtherDropdown2);
   
   //------------- Eof Rooms dropdown ..........................
   
   
   
   
   
   $clients = new OptionsConnector($res);
   
   $clients->render_sql("select id as value, full_name as label from clients where user_id = '".$_SESSION['user_id']."'","","value,label");
   
   $scheduler->set_options("clients",$clients);
      //$scheduler->enable_log("log.txt",true);
      
function mycode($action){
     $action->set_value("user_id", $_SESSION['user_id']);
}
$scheduler->event->attach("beforeProcessing", "mycode");



   $scheduler->event->attach("beforeInsert","validate");
   
   
   //$scheduler->enable_log("log.txt",true);
   //$scheduler = new schedulerConnector($res);
   //$scheduler->render_table("events","event_id","start_date,end_date,event_name,details,types,clients");
   

   if ($scheduler->is_select_mode()){ // ' code for loading data
$SQL = "SELECT * from sessions WHERE user_id='".$_SESSION['user_id']."' "; 
$scheduler->render_sql($SQL,"id","start_date,end_date,session_name,session_name,session_notes,session_type,session_location,type,photographers_id,rooms_id,client_id", "", "");


}
else {    // code for other operations - i.e. update/insert/delete
$scheduler->render_table("sessions","id","start_date,end_date,session_name,session_notes,session_type,session_location,type,photographers_id,rooms_id,client_id,user_id");
}


   
 
   
?>

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title></title>
</head>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>	
	<script src="../../codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_year_view.js"></script>
	<script src='../../codebase/ext/dhtmlxscheduler_minical.js' type="text/javascript" charset="utf-8"></script>
   <link rel="stylesheet" href="../../codebase/ext/dhtmlxscheduler_ext.css" type="text/css">
   <link rel="stylesheet" href="../../codebase/dhtmlxscheduler.css" type="text/css">
   <script src="../../codebase/ext/dhtmlxscheduler_editors.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxcombo/codebase/dhtmlxcombo.css">
	<script  src="../../codebase/dhtmlxcombo/codebase/dhtmlxcommon.js"></script>
	<script  src="../../codebase/dhtmlxcombo/codebase/dhtmlxcombo.js"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_tooltip.js"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_timeline.js	"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_treetimeline.js	"></script>

<style type="text/css" media="screen">
	html, body{
		margin:0px;
		padding:0px;
		height:100%;
		overflow:hidden;
	}	
</style>

<script type="text/javascript" charset="utf-8">


function mycheckfun(rd)
{
//alert("hello");
//alert(rd);
}

   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()
            }
         });
   }
   



	function init() {
	


	
	
	///////////////////-------------added by sushma ////////////////
		
		var sections=[
			{key:'Business', label:"Business"},
			{key:'Quote', label:"Quote"},
			{key:'Personal', label:"Personal"}
			
		];
		
		scheduler.locale.labels.unit_tab = "Unit"
		scheduler.locale.labels.section_custom="Select";
		scheduler.config.multi_day = true;
		scheduler.config.auto_end_date = true;
		scheduler.config.event_duration = 60;
		scheduler.config.first_hour=4;

		scheduler.config.details_on_create=true;
		scheduler.config.details_on_dblclick=true;


		
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		scheduler.config.prevent_cache = true;
		
		
		
		
		/////////////////////////////////////////////////////////////
		
		scheduler.config.lightbox.sections=[
			{name:"session", height:20, map_to:"session_name", type:"textarea" , focus:true},
			{name:"type", height:20, type:"combo" , image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", options:sections, map_to:"type" },
		    {name:"subtype", height:20, type:"combo",  image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", map_to:"session_type",options:scheduler.serverList("session_type") },
		    {name:"photographers", height:20, type:"combo" , image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", map_to:"photographers_id",options:scheduler.serverList("photographers") },
		    {name:"rooms", height:20, type:"combo" , image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", map_to:"rooms_id",options:scheduler.serverList("rooms") },
			{name:"clients", map_to:"client_id", type:"combo", image_path: "../../codebase/dhtmlxcombo/codebase/imgs/", filtering: true, script_path: "php/complete.php", cache: true },
			{name:"place", height:20, type:"textarea", map_to:"session_location" },

			{name:"time", height:70, type:"calendar_time", map_to:"auto"},
				
			{name:"notes", height:60, type:"textarea", map_to:"session_notes" }
			
		]
		
		
		scheduler.locale.labels.section_session="Event Name";
		scheduler.locale.labels.section_notes="Notes";
		scheduler.locale.labels.section_type="Type";
        scheduler.locale.labels.section_subtype="Sub Type";
		scheduler.locale.labels.section_place="Place";
		scheduler.locale.labels.section_clients="Clients";
		scheduler.locale.labels.section_photographers="Photographe";
		scheduler.locale.labels.section_rooms="Pièce";
		scheduler.locale.labels.timeline_tab ="Photographe";
		scheduler.config.year_x = 4;
		scheduler.config.year_y = 3;
		
		
		
		
scheduler.createTimelineView({
			section_autoheight: false,
			name:	"timeline",
			x_unit:	"minute",
			x_date:	"%H:%i",
			x_step:	30,
			x_size: 24,
			x_start: 16,
			x_length:	48,

			render: "tree",
			folder_events_available: true,
			dy:60,
     y_unit: scheduler.serverList("photographers"),        //sections of the view (titles of Y-Axis)
        
     y_property:"photographers_id", //mapped data property
     render:"tree"             //view mode
});		



		
scheduler.config.start_on_monday = false;
	
	
		//top label of calendar
scheduler.templates.calendar_month =  scheduler.date.date_to_str("%F %Y");

//week label of calendar
scheduler.templates.calendar_scale_date =  scheduler.date.date_to_str("%D");
//date value on the event's details form
scheduler.templates.calendar_time = scheduler.date.date_to_str("%d-%m-%Y");
	
	
	
scheduler.templates.event_class = function(s,e,ev){
if (ev.type == 'Personal') return "Personal";
if (ev.type == 'Business') return "Business";
if (ev.type == 'Quote') return "Quote";
return "";
}	
	
	
		//scheduler.locale.labels.section_radiotype="Select";
		//scheduler.config.details_on_create=true;
		//scheduler.config.details_on_dblclick=true;
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();


		
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		
		scheduler.init('scheduler_here',new Date(curr_year,curr_month,curr_date),"year");
		
		
		scheduler.setLoadMode("year");
		
		
		
		scheduler.load("php/events.php");
		
		
		var dp = new dataProcessor("php/events.php");
		
		dp.init(scheduler);
		
		dp.defineAction("invalid",function(response){
		   var message = response.textContent;
		   alert(message);
		   return false;// return false to cancel default data processing at all
		})
		

	}
	

</script>

<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="day_tab" style="right:204px;"></div>
			<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
			<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
			<div class="dhx_cal_tab" name="year_tab" style="right:12px;"></div>
			<div class="dhx_cal_tab" name="timeline_tab"  style="width:auto; right:268px;"></div>
		</div>
		<div class="dhx_cal_header">
		</div>
		<div class="dhx_cal_data">
		</div>		
	</div>
</body>

Hi Serge, why it is not triggered? The before insertion?
tks
Seby

Even the save function seems to fail now, I don’t know what we messed-up now. But I think we need your help serge
tks in advance
Seby

Hi everyones, is it because it’s not the right way or not even possible that I don’t have any answer yet? I’m still looking for some help on my problem
tks in advance
Seby

Anyones please?
tks
Seby

If issue is still actual - please open ticket at support system.

Hi, yes it’s still actual, but don’t know how to open a ticket, i’m not a registered member I guess.
I’m pretty sure we were close with the example we had. But something is missing
tks
Seby

Hi everyones. A week has passed and no ones seems to want to help out on this.
tks in adcance
seby

Hi again, still waiting for some help
tks
Seby

Hello,
Please check whether beforeInsert event is triggered. Put some debugging code into event handler function. Note that connector uses output buffering and clears buffer before rendering xml, so if you simply put ‘echo “something”’ it won’t give a visible result.
However, I’ve copied event attachment from your code and tested it locally, both “beforeProcessing” and “beforeInsert” events has been triggered, so this part must be working correctly.

Secondly, in your code, ‘function validate’, there is following sql query: $sql_chk_photo = mysql_query("select id from sessions where id!='".$id."' AND user_id='".$user_id."' AND photographers_id = '".$photographers_id."' AND '".$start_date."' between start_date AND end_date");

And particularly this condition: where id!='".$id."'
$id seems to be never defined, at least i can’t see its definition in the code above. It shouldn’t cause an error by itself, since id is compared for inequality with an empty string (which should always give true). But make sure that your code generates a valid sql queries and they return something from the database. Try executing generated queries in db console and see the response

Hi alexander, tks for your help.
Here’s what my programmer did, it seems to work well, the only problem we have is this. When we save the lightbox, now I get the alert saying there’s a collision in photographer field at that time range, but when I clic ok, I lost everything I had put in the lightbox and I have to re-enter everything. So is it possible to have the alert before closing the lightbox and be able to modify before saving?

html:

[code]

html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
 
 
 
[/code]

PHP:

[code]<?php
session_start();
include (’…/…/…/codebase/connector/scheduler_connector.php’);
include (’…/…/common/config.php’);

$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);
mysql_query(“SET NAMES utf8”);
$scheduler = new schedulerConnector($res);
/$list = new OptionsConnector($res);
$list->render_table(“types”,“typeid”,“typeid(value),name(label)”);
/

//-------------Sub Type dropdown …

$OtherDropdown = new OptionsConnector($res);
$OtherDropdown->render_sql(“select id as value, session_type as label from session_type where user_id = '”.$_SESSION[‘user_id’]."’","",“value,label”);
//$OtherDropdown->render_table(“session_type”,“session_type”,“id(value),session_type(label)”);
$scheduler->set_options(“session_type”,$OtherDropdown);

//------------- Eof Sub Type dropdown …

//-------------Photographers dropdown …

$OtherDropdown2 = new OptionsConnector($res);
$OtherDropdown2->render_sql(“select id as value, full_name as label from photographers where user_id = '”.$_SESSION[‘user_id’]."’","",“value,label”);
$scheduler->set_options(“photographers”,$OtherDropdown2);

//------------- Eof Photographers dropdown …

//-------------Rooms dropdown …

$OtherDropdown2 = new OptionsConnector($res);
$OtherDropdown2->render_sql(“select id as value, room_name as label from rooms where user_id = '”.$_SESSION[‘user_id’]."’","",“value,label”);
$scheduler->set_options(“rooms”,$OtherDropdown2);

//------------- Eof Rooms dropdown …

$clients = new OptionsConnector($res);

$clients->render_sql(“select id as value, full_name as label from clients where user_id = '”.$_SESSION[‘user_id’]."’","",“value,label”);

$scheduler->set_options(“clients”,$clients);
//$scheduler->enable_log(“log.txt”,true);

function mycode($action){
$action->set_value(“user_id”, $_SESSION[‘user_id’]);
}
$scheduler->event->attach(“beforeProcessing”, “mycode”);

//$scheduler->enable_log(“log.txt”,true);
//$scheduler = new schedulerConnector($res);
//$scheduler->render_table(“events”,“event_id”,“start_date,end_date,event_name,details,types,clients”);

if ($scheduler->is_select_mode()){ // ’ code for loading data
$SQL = “SELECT s.*, p.full_name, r.room_name from sessions as s left join rooms as r on r.id=s.rooms_id left join photographers as p on p.id=s.photographers_id WHERE s.user_id=’”.$_SESSION[‘user_id’]."’ ";
$scheduler->render_sql($SQL,“id”,“start_date,end_date,session_name,session_name,session_notes,session_type,session_location,type,photographers_id,rooms_id,client_id,full_name,room_name”, “”, “”);

}
else { // code for other operations - i.e. update/insert/delete
$scheduler->render_table(“sessions”,“id”,“start_date,end_date,session_name,session_notes,session_type,session_location,type,photographers_id,rooms_id,client_id,user_id”);
}

?>[/code]