Prevent open multiple form

deant

Active Member
I have notice that my users have open more forms at once which is not acceptable according to app workflow and change/delete data from repeat groupe in some point. I have to prevent users to open multiple forms.

So, I thing I can do it using js plugin and ajax. Here is the plan:
1. onLoad form/list: read session from browser then get user ID and session_id for this user from db and store session value in browser LocalStoreg and set flag
So if user open new tab -> session === session_id and flag === 1 -> window.close.

2. onUnload unset flag in LoacalStorage

Problem is if user close browser or tabs by clicking X in browser LocalStorage the flag stay set and user can not open any form. He must wait until session expires.

Is there another way to prevent open multiple forms?
 
I thing the lockrow wont work in my case. My workflow
I have list work order with repeat items. In the next step the user exam items, run some test and store values in exam table. When exam is saved I lock item in work order so user can not change/delete item (entire row) from workorder.

What users do: they open workorder form in one tab (at that point exam for item not exist, so no locking flag) in second tab user create exam and save form. Of course the flag to lock item row was writen to db but the workorder form is still open. Then user activate tab whit workorder form and can change/delete item in workorder.

And yes, I can tell users a million times you shouldn't do that, allways run app only in one tab etc. Nothing hleps. Maybe I should find new customer/user o_O
 
Do I understand correct that you have two separate tables and you need to lock some related record in another table when record in the first table is opened?

I think I have some similar "ready" solution working in one of my sites, but I'm not sure if it suits your case before I understand your setup better.
 
Table workorder is almost 'holly grail' an of course repeat items.
Exam can be done only if item from workorder exist. So if user delete item from workorder then we have a problem. Because we have an exam for item which not exist in workorder.
When we do report we don't have workoreder number.
 
I'm still not sure about your exact setup, but shortly one concept to solve it would be to add "record lock" element to work task table and update it to current unix datestamp on form load (with form php plugin). And when record in exams table is opened, update the timestamp in work order table again for the related record.

And then in work order form_xx.js you would have a code which retreives that "lock record" element data with ajax every few seconds. And if the record is changed (exam record is opened), corresponding open record in work order table is redirected.

I'm at my pc again tomorrow, so if needed I might be able to find the code snippet I once used.
 
Last edited:
And then in work order form_xx.js you would have a code which retreives that "lock record" element data with ajax every few seconds.

I don't like this...if user leaves open the form the code is triggering for ever....unless we set timeout.

Btw exam record is new record. When exam form is saved I set flag in db workorder item to prevent edit/delete item.

I'll try my luck using browser LocalStorage. I'll let you know if it works or not.

Thanks
 
Yes, you can set a timeout and redirect if needed. And I still think you could also use lockrow plugin. You just update the Work Task table's lockrow element from Exam table (with form php), so the open record in Work Task table can not be saved after that. But of course you can try different options and find out what best suits for you.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top