Update field after insert

Here’s my events.php code:

 if ($scheduler->is_select_mode()){ // ' code for loading data
	
$SQL = "SELECT event_id,start_date,end_date, CONCAT(contacts.First, ' ' , contacts.Last) AS Patient, text,rec_type,event_pid,event_length,events_rec.office_ID,reason,events_rec.patient_ID,name,howheard_ID,promo_ID,events_rec.company_ID, appt_status,saw_by, previsit_categories.color, previsit_categories.textColor FROM events_rec LEFT JOIN previsit_categories ON previsit_categories.ID = events_rec.reason LEFT JOIN contacts ON contacts.Patient_ID =events_rec.patient_ID WHERE events_rec.office_ID IN ($office_id) AND appt_status IN ($appt_progress) AND saw_by IN ($provider) AND events_rec.company_ID = '" . addslashes($_SESSION['Company_ID']) . "'"; 
$scheduler->render_sql($SQL,"event_id","start_date,end_date,text,rec_type,event_pid,event_length,office_ID,reason,patient_ID,name,howheard_ID, Patient, promo_ID,company_ID,appt_status,saw_by, previsit_categories.color(color), previsit_categories.textColor(textColor)", "", "");
}
else {	 // code for other operations - i.e. update/insert/delete

      function afterProcessing($action){
     $res = mysql_query("SELECT color, textColor FROM previsit_categories WHERE previsit_categories.ID='".$action->get_value("reason")."' AND Company_ID= '" . addslashes($_SESSION['Company_ID']) . "'");
	 $row_color= mysql_fetch_assoc($res);
     $some_value = $row_color['color'];
	 $some_value2 = $row_color['textColor'];     
     $action->set_response_attribute("color", $some_value);
	 $action->set_response_attribute("textColor", $some_value2);
		};
$scheduler->event->attach("afterProcessing", afterProcessing);
$scheduler->render_table("events_rec","event_id","start_date,end_date,text,rec_type,event_pid,event_length,office_ID,reason,patient_ID,name,howheard_ID,promo_ID,company_ID,appt_status,saw_by");

}

My event text and tooltip in scheduler.php:

scheduler.templates.tooltip_text = function(start,end,event) {
		return "<b>Name:</b> "+event.Patient+"<br/><b>Comments:</b> "+event.text+"<br/><b>Office:</b> "+scheduler.getLabel("office_ID", event.office_ID) + "<br/><b>Reason:</b> " +scheduler.getLabel("reason", event.reason)+ "<br/><b>Status:</b> " +scheduler.getLabel("appt_status", event.appt_status);
		}

scheduler.templates.event_text = function(start, end, event) {
			var result = "<b>Name:</b> " + "<a href='apptinformation.php?Calendar_Id="+event.id+"' + target='_blank'>"+event.Patient+"</a>" + "<br/><b>Reason:</b> " +scheduler.getLabel("reason", event.reason)+ "<br/><b>Status:</b> " +scheduler.getLabel("appt_status", event.appt_status);
			return result;
		
		}

The Name comes from event.Patient -> which is from the loading data part of my events.php

The Name shows properly when the scheduler is loaded, naturally, however when I add an event to the scheduler, the Name doesn’t populate in the tooltip and event. It says undefined.

Upon insert, how can I return the updated event.Patient information to the tooltip and event field without having to manually refresh the page?

a) you can add some kind of select control to scheduler’s form and set Pacient on client side

b) you can add code to afterProcessing on server side

$action->set_response_attribute(“patient”, $some_value);

and on client side use

dp.attachEvent("onAfterUpdate", function(sid, action, id, tag){ scheduler.getEvent(id).Patient = tag.getAttribute("patient"); scheduler.updateEvent(id); });

Thanks, I am going for route B.

Here’s my schedluer code:

dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
    scheduler.getEvent(tid).color = tag.getAttribute("color"); 
	scheduler.getEvent(tid).textColor = tag.getAttribute("textColor"); 
	scheduler.getEvent(tid).Patient = tag.getAttribute("Patient");
	scheduler.updateEvent(tid);

Here’s server side code:

else {	 // code for other operations - i.e. update/insert/delete

     function afterProcessing($action){
     $res = mysql_query("SELECT color, textColor FROM previsit_categories WHERE previsit_categories.ID='".$action->get_value("reason")."' AND Company_ID= '" . addslashes($_SESSION['Company_ID']) . "'");
	 
	 $name = mysql_query("SELECT CONCAT(contacts.First, ' ' , contacts.Last) AS Patient FROM contacts WHERE Patient_ID= NEEDED_Patient_ID AND Company_ID= '" . addslashes($_SESSION['Company_ID']) . "'");
	 
	 $row_color= mysql_fetch_assoc($res);
	 $row_name= mysql_fetch_assoc($name);
         $some_color = $row_color['color'];
	 $some_textcolor = $row_color['textColor'];  
	 $some_name = $row_name['Patient'];     	 
         $action->set_response_attribute("color", $some_color);
	 $action->set_response_attribute("textColor", $some_textcolor);
	 $action->set_response_attribute("Patient", $some_name);
		};
$scheduler->event->attach("afterProcessing", afterProcessing);
$scheduler->render_table("events_rec","event_id","start_date,end_date,text,rec_type,event_pid,event_length,office_ID,reason,patient_ID,name,howheard_ID,promo_ID,company_ID,appt_status,saw_by");

I need to pass the event.Patient_ID information to the server code where the line reads:

$name = mysql_query("SELECT CONCAT(contacts.First, ' ' , contacts.Last) AS Patient FROM contacts WHERE Patient_ID= NEEDED_Patient_ID AND Company_ID= '" . addslashes($_SESSION['Company_ID']) . "'");

… in order for it to work. How can I pass that information per updated event in order for the afterupdate query to return the correct name?

I am constantly impressed with this extension, by the way.

I got it!

$action->get_value(“patient_ID”)

Thanks!