Disable projects from being selected if closed

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
mihaadzic
Posts: 5
Joined: 2016-07-27 07:41

Disable projects from being selected if closed

Post by mihaadzic » 2016-07-27 08:04

Hi!

For starters - Nice app! Thank you!

So to my question.

I have 3 tables: projects, statuses and orders.
The projects table has a list of projects with a lookup field to the statuses table.
The statuses table has a field with options active and closed.
When entering a new record into orders one of the fields is a lookup to the projects.

First, I would like to enable, that when a project has a status of:
- active it can be selected from the dropdown,
- closed it can no longer be selected from the dropdown.

Second, if the date for te status of the project has been set to closed on today I should still have an option of selecting the project if i'm enetring an order on yesterdays date.

To complete the second, it would maybe be easier if I would add the start and end dates of the projects into the projects table itself? I really have no idea on how to go about this. Can anyone point me in the right direction?

Using latest version of AppGini.

Thank you!

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: Disable projects from being selected if closed

Post by shasta59 » 2016-07-31 14:40

You can do this easily by writing a hook. You should be able to put it in tablename_before_insert() hook or even write as js script and put that in the same folder and when the lookup is done to populate the field you would tell it to not display/retrieve the records for those where it is no longer active as a project.

This should not be hard to do.

There is another place where it could be done. In the ajax_combo.php file. This is where the drop down configs are done. You would add in code to look at the closed setting and have it only display those records which show they are active.

Hope this helps. It should be as simple as writing the correct selection criteria statement. I have not tested this but cannot see why it would not work. Personally I would try more than one method. The hooks folder is best in that if you update it is easy to keep the code. If you put code in other files you have to remember to add it back in if you regenerate the entire app.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Disable projects from being selected if closed

Post by grimblefritz » 2016-07-31 20:56

Have a look at your orders table, for the lookup field into project. You'll see a button named "Advanced" there. This is so you can modify the SQL used to populate the lookup. You might be able to do what you need there, without resorting to hooks or customizing core files.

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Disable projects from being selected if closed

Post by peebee » 2016-08-01 00:45

Further to grimblefritz's reply above - here's a tutorial to achieve what you are after:

https://bigprof.com/appgini/screencasts ... -sql-query

mihaadzic
Posts: 5
Joined: 2016-07-27 07:41

Re: Disable projects from being selected if closed

Post by mihaadzic » 2016-08-04 12:10

Thank you!

The Advanced button and SQL did the trick.

Have a nice day! :D

Post Reply