Hello,
I have started a project and I ran into a brick wall as I don’t know enough coding. The first thing I need
Help on is, I need to create a logic hook or similar that will calculate some data before saving.
I have 2 tables in mysql:
1. Stat_daily,
This table contains the following fields:
a. date: this is the date representing the day for which this value belongs to.
b. Value: this represent a numerical value.
c. Stat_Code: This code represent and ID for the statistical entry for that week.
2. Weekly:
This table contain the following fields:
a. Ween_ending_date: this is the date representing the end of the working week, usually a Thursday
b. Value: this represent a numerical value.
c. Stat_Code: This code represent and ID for the statistical entry for that week.
d. Automatic_Calculation: yes/no
I need a logic hook or similar that will do the following when the Automatic_Calculation field is set to” yes”.
When I entered the date, Value and stat_code in the Stat_daily table and save the date i want the system to automatically add this
Values and save the data in the weekly table:
Lets say I entered on stats_daily for Friday, the first day of the working week.
Date: 07/05/2010 Value: 55 stat_code:DP1
Click save:
The code will automatically take that value and added to the weekly table that contains the week _ending_date: 13/05/2010 because Friday 7/05/2010 is consider to be the first day of the week into the stat_code DP1
Then when I enter the send day of the week which is Monday
Date:10/05/2010 Value: 75 stat_code DP1
The code will then take the value 75 and added to the weekly table containing week_edning_date: 13/05/20110 under the stat_code:DP1, so the new value will be 130.
And repeat the same operation when I entered Tuesday, Wednesday and Thursday. So at the end of the week Thursday I will have all the individual values added up together and saved in the table weekly for the stat_code DP1
When the new week starts again on Friday, the system will start again from "0", for the new weekly values based on the new week ending date which should be 20/05/2010 .
If the automatic-Calculation field is set to “no” nothings happend and the values in Weekly table have to be entered manually once a week as we do not have stat_code link in the Stat_daily that will represent that code on the weekly table.
Is there anyone in this forum skill enough to help with this code?
Sincerely,
Derek P