Help!..... Please.
Ok I have a quick and hopefully simple problem.
I need to have a way to show if an inspection is expired.
I have a date field in my app and if its been over a year since it was done according to todays date I need it to return a value of EXPIRED to another field.
How can I do this?? Directions very helpful.
Example
Date Inspected 1-1-2015 Should return a value from todays date of Expired.
Thanks
Clayton
Due date
Re: Due date
Create a field called ALERT in the same table (or any other name you choose) and use this code in the init hook of your table:
This should do the trick.
I use this code a lot to expire discounts, special prices for clients etc. etc.
Code: Select all
sql("update `YOUR_TABLE` set `Alert`= if(Date_Add(Date(`Inspection`), interval 365 day)<CurDate(),'Expired',null)",$eo);
I use this code a lot to expire discounts, special prices for clients etc. etc.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper
Re: Due date
Hello,
does not work. Probably something wrong.
How can I do ?
My table is called: 'Gestione_Ordini'
The names of the fields are these: 'Data_Consegna' e 'Alert'
I insert the code into the hook file '' Gestione_Ordini '' but exactly where to put it?
Thanks in advance for the help
Greetings
does not work. Probably something wrong.
How can I do ?
My table is called: 'Gestione_Ordini'
The names of the fields are these: 'Data_Consegna' e 'Alert'
Code: Select all
sql("update `Gestione_Ordini` set `Alert`= if(Date_Add(Date(`Data_Consegna`), interval 365 day)<CurDate(),'Alert',null)",$eo);
I insert the code into the hook file '' Gestione_Ordini '' but exactly where to put it?
Thanks in advance for the help
Greetings
Re: Due date
You should the code right after this line:
Code: Select all
function Gestione_Ordini_init(&$options, $memberInfo, &$args){
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper
Re: Due date
I have entered the code in your specified space but it does not work.
What should look like in the ALERT cell?
According to you, the code shown above has been modified by me correctly?
I attached the hook file
Thank you very much for your help.
What should look like in the ALERT cell?
According to you, the code shown above has been modified by me correctly?
I attached the hook file
Thank you very much for your help.
- Attachments
-
- Gestione_Ordini.zip
- (2.56 KiB) Downloaded 228 times
Re: Due date
The Code looks fine to me, check the following: Data Type your are using for Data_Consegna has to be DATE.
Check if you have expired dates, maybe all the dates are less than one year (use like 30 days to check if this is not the problem).
Check if you have expired dates, maybe all the dates are less than one year (use like 30 days to check if this is not the problem).
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper
Re: Due date
Hi, it was just a field size problem. It was not DATE.
Now works.
Thanks so much for help.
Good day
Now works.
Thanks so much for help.
Good day
Re: Due date
Glad it works
Have a nice day
Have a nice day
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper
Re: Due date
Sorry if it disturbs you again. The code works but I would need to put a warning on the lines that expire in the next 30 days (even previous ones compared to the date of the day of the display).
Example: today is 27.06.2017
I should mark the rows with date 20.06.2017 but also those with date 25.07.2017.
It is not necessary to indicate those with date 30.07.2017 because they are over 30 days.
How can I do ?
Example: today is 27.06.2017
I should mark the rows with date 20.06.2017 but also those with date 25.07.2017.
It is not necessary to indicate those with date 30.07.2017 because they are over 30 days.
How can I do ?
Code: Select all
sql("update `Gestione_Ordini` set `Alert`= if(Date_Add(Date(`Data_Consegna`), interval 30 day) >CurDate(),'ATTENZIONE!',null)",$eo);
Re: Due date
Maybe I've solved this way:
It seems to work.
Thanks again for everything.
Code: Select all
sql("update `Gestione_Ordini` set `Alert`= if((`Data_Consegna`) < (CurDate() + interval 30 day),'ATTENZIONE!',null)",$eo);
Thanks again for everything.
Re: Due date
Just a warning you could NULL other alerts this way.
You should COMBINE BOTH lines in one IF sql update.
In other words you should check for status of 30 days and 365 in same IF formula.
You should COMBINE BOTH lines in one IF sql update.
In other words you should check for status of 30 days and 365 in same IF formula.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper