This topic is locked

Which event should I use?

10/1/2008 8:46:31 AM
PHPRunner General questions
T
thesofa author

When I click the link from a master table to a detail table for a specific record, I would like to update the master table record in one field 'dealt_with' to show that the link has been followed.

Which event will this be in the List Page?

Sergey Kornilov admin 10/1/2008

BeforeProcess event will work. In fact any list page event that occurs on every page load will work.

M
mmponline 10/2/2008

I need to use this event as well. Can you help me with an example code, please?

T
thesofa author 10/6/2008

I have got this working, do you need it still?

M
mmponline 10/7/2008

Yes Please!
Will it work in both version 4 and 5?

T
thesofa author 10/7/2008

This works in 4.2 final version with MySQL database.
No idea if it works in 5 yet, I shall update this as and when I feel the need to convert to 5
OK, this is what I have had to do, I run a detention system at school thta allows teachers to "grant" a detention to any of the kids.

Part of the legal bit is that there is a letter sent to the kid's parents telling them that the pupil will be on detention on the day etc.

So I had to be able to give a detention that does not clash with any others given for that kid.

Pupil is master table

Detention is slave table

find the kid using search and have ajax hints on, it works fine for 900 pupils

click the Detentions link next to the kid's name and use Inline Add to add a detention, so you can see all the latest detentions granted so you cannot have the excuse of not knowing whether the kid has been given a detention or not for that day.

Save it and a new page appears with the letter in it which is printed via File Print.

later, when the child has decided not to turn up, the head of department has to take over the detention and give out a new one, this needs to generate a new letter as well. So I have a page of missed detentions for Heads of Dept only, this shows which missed detentions have not been dealt with.

clicking the link next to the kids name takes you to the re-assign page and it carries the ID of the detention with it.

Of course, as the re-assign page is a slave page to the missed detention page, only the one detention is show, so I use the before SQL query to change the query to show all that kid's detentions.

Using Inline add to add a new detention, I pass the old detention ID via a session variable to the Add page, Before record Added page where it pulls all the details from the old record and uses them in the new letter which is generated as the new record is saved, then with an After Record Added event, I get the session variable of the original record ID and generate an update query that fills the Dealt With field in the record.

As the original SQL query for the Missed Detentions page has a condition of

`dealt_with`<>1

built in, it stops records from being shown once they are dealt with.
I know this takes you round the houses, but the code is fairly simple, I can post it if you want, but it will mean a big post.
HTH

M
mmponline 10/7/2008

You can e-mail it to me at mmp"at"mmponline.co.za if you feel it would be the easiest. Not urgent. I'll be out for 5 days from 2morrow.
Thanks for you assistance on this.

T
thesofa author 10/7/2008

You can e-mail it to me at mmp"at"mmponline.co.za if you feel it would be the easiest. Not urgent. I'll be out for 5 days from 2morrow.

Thanks for you assistance on this.



you will get the sql file and the script for 4.2

T
thesofa author 10/7/2008



you will get the sql file and the script for 4.2



done