ajax vs triggers

A place for users and developers of the Xataface to discuss and receive support.

ajax vs triggers

Postby Jean » Tue Oct 09, 2012 2:55 am

Hi Steve and all of you,
I am building a timetable for agents with different desks in a library.

To be able to add someone somewhere at some time, I need to remove him/her from an other desk (if so) at the same time so that nobody be in two spots at the same time ;=)
The timetable is built first , so any delete or add action of an agent is just an update on the table in the good box.

So every time someone is added on a desk I need to scan the same column of time and remove him/her from the other desks before with a beforeUpdate() method.
Besides a unique index on the database table prevents someone to be in two premisses at the same time.

The problem here is that ajax prevents me from doing any action like adding someone if this agent is yet on an other desk at the same time, ignoring my beforeUpdate action of removing from any other desk because the update action only is checked up.

Do you follow me ?

Thank you for any help

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: ajax vs triggers

Postby silma » Tue Oct 09, 2012 9:34 am

You could create a virtual user ?

BeforeUpdate :
Generate an unique Mister Virtual###
Look for your user old place in the same column of time, update it to "Mister Virtual###"
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm

Re: ajax vs triggers

Postby Jean » Wed Oct 10, 2012 1:04 am

Thank you Silma, unfortunately, the problem is that the whole operation is checked up by ajax before executing it and so it returns false because it cannot save data in the table.

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: ajax vs triggers

Postby silma » Wed Oct 10, 2012 1:52 am

Unless a technical solution from Steve to disable the ajax only fort this action, i can see nothing else to do but "to cheat " with the date.

=> add ten year to the date the user want with js

=> Save = Add the next one + 10 year
=> BeforeUpdate , update the old record (-10 year)
=> AfterUpdate, update the date - 10 year

I admit it is awful...
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm

Re: ajax vs triggers

Postby Jean » Wed Oct 10, 2012 5:13 am

smart! thank you. I keep your solution in mind.

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: ajax vs triggers

Postby Jean » Tue Oct 23, 2012 12:29 am

Steve,
I come back on this question. What would you do to delete a record in a column with a unique index before add it on an other line ? There is an opposition between ajax check-up and the beforeSave action.
Thank you

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: ajax vs triggers

Postby shannah » Fri Oct 26, 2012 8:52 am

Hi Jean,

Which ajax action is being used to perform the save? Is this the "Ajax inline editing" feature?
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: ajax vs triggers

Postby Jean » Tue Oct 30, 2012 7:24 am

Thank you Steve.
In fact I am building a timetable for librarians. I have a unique index on each time unit (30mns). To add someone at a desk at some time, I have to remove him/her of an other desk on the same time to be sure he/she is not at two spots at the same time.
I don't delete, I just update to add or remove.
I created a beforeUpdate trigger to remove the person from an other desk on the same time. In fact before executing the request, Ajax checks up the result which is false because each column has a unique index and cannot have the same data twice.
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: ajax vs triggers

Postby shannah » Tue Oct 30, 2012 9:03 am

Are you using a custom action for updating these values, or a Xataface built-in action? If Xataface, which action?
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: ajax vs triggers

Postby Jean » Wed Oct 31, 2012 7:03 am

Hi Steve,
I don't use a custom action but I use custom links in the list to access the edit form. I have a filter and had some problems with -skip and -cursor.
You think this could explain my problems ?

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: ajax vs triggers

Postby shannah » Wed Oct 31, 2012 7:44 am

So to be clear. You are linking to the edit record form. Then when you make changes on this edit record form, it fails because the validation refuses to let you continue?

Where does AJAX come in?
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: ajax vs triggers

Postby Jean » Wed Oct 31, 2012 8:24 am

ajax checks up the request and stops everything bacause the data is yet in the same column thant should be unique although my beforeUpdate remove it.

Code: Select all
function beforeUpdate(&$record){
$this->app =& Dataface_Application::getInstance();
$result= mysql_query("UPDATE quinzaines SET tranche12=NULL WHERE jour='$jour' AND tranche12='$tranche'" , $this->app->db());
}

Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 16 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved