jo-ka
Member
Hello.
Please help me find the best way to do the following:
First, I have a table and form that stores member annual membership fees.
Table 1
id | member | value | in_debt | status (1, 2, 3)
For the status field, 1,2,3 are the values for unpaid, partially paid, fully paid.
So after I have a second table and form where all the movements are being stored
Table 2
id | member (dbjoin T1_member) | debt_value (calc from T1_value) (for info) | paid_value
So, as sometimes the paid value might be less than the debt_value, here's what I'm trying to achieve.
- If T2___paid_value = T1___in_debt then update T1___in_debt to 0 and T1___status to 3 (fully paid).
- If T2___paid_value < T1___in_debt then subtract (T1___in_debt - T2___paid_value) and update T1___in_debt with subtraction result, and, update T1___status to 2 (partially paid).
Is it possible to use the upsert plugin? If so, can you suggest some code for PHP?
Or the only option is to use the PHP form plugin?
Thank's in advance.
Please help me find the best way to do the following:
First, I have a table and form that stores member annual membership fees.
Table 1
id | member | value | in_debt | status (1, 2, 3)
For the status field, 1,2,3 are the values for unpaid, partially paid, fully paid.
So after I have a second table and form where all the movements are being stored
Table 2
id | member (dbjoin T1_member) | debt_value (calc from T1_value) (for info) | paid_value
So, as sometimes the paid value might be less than the debt_value, here's what I'm trying to achieve.
- If T2___paid_value = T1___in_debt then update T1___in_debt to 0 and T1___status to 3 (fully paid).
- If T2___paid_value < T1___in_debt then subtract (T1___in_debt - T2___paid_value) and update T1___in_debt with subtraction result, and, update T1___status to 2 (partially paid).
Is it possible to use the upsert plugin? If so, can you suggest some code for PHP?
Or the only option is to use the PHP form plugin?
Thank's in advance.