Page 1 of 1

A simple calculation Example

Posted: 2018-03-31 14:17
by mwilliam
Could one of you wonderful people post a AppGini project that will do a calculation from fields:

ID
day1
day2
day3
total

I want to see how its done. and where to put the code.

Re: A simple calculation Example

Posted: 2018-04-10 22:33
by R Tammam
Hello mwilliam , will you put dates like 11/4/2018 or numbers like 5 days

Re: A simple calculation Example

Posted: 2018-04-11 06:08
by pbottcher
Hi mwilliam,

where would you like to see the total calculated? You have an option in AppGini "Show column sum" in the field definition.

Re: A simple calculation Example

Posted: 2018-04-11 18:02
by R Tammam
mwilliam , here's another idea , you can make the new project normally and just open the project folder
go to hooks file , then table name and put the following line in before inset and before update function , and it will sum them automatically

Code: Select all

$data['total'] = $data['day1'] + $data['day2'] + $data['day3'];

Re: A simple calculation Example

Posted: 2018-04-12 22:42
by Moh Youba
Hello guys, I have same question, please any one with help
I have 3 table
1 - clients
2 - credit (loan)
3- versement (payment)

it the table client, I want to display
- total of credit
- total of loan
- balance
sum_of_field.jpg
sum_of_field.jpg (89.13 KiB) Viewed 4487 times
Please any solution.
Thank you

Re: A simple calculation Example

Posted: 2018-04-17 23:08
by R Tammam
Hello Moh Youba,
i will explain the idea for you,
you will need to use after insert function in hook
after inserting in credit table ot after inserting in vestments table
you should first select sum of credits where customerid = logged customer and then use this value to update the credits field in cousomter table
and so on you can go through this logic for tota versement and for balance

Re: A simple calculation Example

Posted: 2018-04-18 06:42
by Moh Youba
Hello R Tammam

Thank you for your reply. I will try to follow your suggestions.

Re: A simple calculation Example

Posted: 2018-08-30 21:30
by AEmpeno
Were you able to make it work?

Re: A simple calculation Example

Posted: 2018-08-31 13:17
by Moh Youba
Yep...