Page 1 of 1

I need a message on DB entry

Posted: Tue Oct 04, 2005 11:00 am
by MichaelMcCulley
I have an application where user1 is logged into his security groups section of the site, and user2 (user1's subordinate) is logged into his.

User2 makes an entry for an appointment into a table.

When User2 submits his entry, I want a popup to show on User1's computer so that he can confirm or reschedule the appointment.

Posted: Tue Oct 04, 2005 11:09 am
by feyd
Congratulations. You didn't ask a question.

I'm going to guess you want to know how to make the popup happen. The answer depends on how you want it to work. If by just sitting on the page the popup happens: XMLHTTP is pretty much the only way (iframes can do it too). If by navigating to a new page the popup should happen, then it's a "basic" trigger that you can set in the database, for instance.

#1 is more elegant, but difficult while #2 is fairly easy. I'd highly suggest not actually popping a window however, due to popup blocker restrictions some browsers have. Instead, I'd go with a floating div.

I'll take door #1 Bob

Posted: Tue Oct 04, 2005 11:55 am
by MichaelMcCulley
Sounds great. So lets say I want to go with option 1 and use iframes. How would that get the message across that an entry has been made into the database, AND give them the ability to confirm the entry ( which will change a field in the same record)

I kind of like the sound of the floating div, but a submission there might take them out of the page they are on( and I can't do that ).

the problem I face is not how to display the message, but the triggering process. Not sure if I want to do an auto refresh, because of the traffic involved (DB mostly, and this site has the potential for 1000's of users). I know there has to be a simple solution but I can't see it.

Posted: Tue Oct 04, 2005 12:00 pm
by feyd
with iframes, auto-refresh is the only path pretty much.. Basically, you have the source listed in the iframe to poll that person's event queue looking for things it needs to pop. It transports back the needed information and supplies the parent page with the details to pop.

Event Queue?

Posted: Tue Oct 04, 2005 12:10 pm
by MichaelMcCulley
How, what, Is this a db table, text file, server variable?

Posted: Tue Oct 04, 2005 12:13 pm
by feyd
it's probably easiest (and safest for concurrance) as a database table.

Posted: Tue Oct 04, 2005 1:58 pm
by MichaelMcCulley
Ok, so just for my own clarity,

I create a table for the event queue.

when the user does an update to one table, he also creates an entry in the queue for the other indiviual. Done with him.

The other user is crusing the site or camping on one page. All pages have a query for the event queue. If there is an entry....?

How would the iframe work? Javascript? Can I force them to click something that would do the confimation part, or what?

Sorry if I seem slow on the uptake. Thanks you for your help so far BTW.

Posted: Tue Oct 04, 2005 2:04 pm
by feyd
yep, you've got the idea. I'd set the iframe to simply auto-refresh. When an entry is there for the user, you can pop a confirm dialog box. Clicking okay (returns true) would reload the page telling the server to confirm the update or whatever you are wanting to do and the process starts all over again. I'd try to keep the iframe's code as small as possible..

Posted: Tue Oct 04, 2005 2:14 pm
by MichaelMcCulley
OK, that sounds like something I can do.

Thank you very much.

Posted: Tue Oct 04, 2005 2:38 pm
by MichaelMcCulley
Will this handle multiple alerts?

I am assuming that I will have to delete the event record after confirmation in order to avoid duplicate notification. But what if I have 2 or more users make the same data entries that create the alert? If one comes in before the other is confirmed and the iframe refreshes won't it cause a train wreck?

Posted: Tue Oct 04, 2005 2:40 pm
by feyd
multiple events handling would be apart of the code you need to write. As for multiple confirms, I believe browsers will only allow one at a time because they are modal in nature.