Gossamer Forum
Home : Products : DBMan : Customization :

Re: Calculate field based on other fields

Quote Reply
Re: Calculate field based on other fields In reply to
It probably would be a good idea to have both a "Total" and a "Balance" field. Actually, you don't need a "Balance" field after all. Just a "Total" field and a "Paid" field. You can compute the balance at the time you print the record out.

To compute the "Total" field, in db.cgi, sub add_record, after

($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

add

Code:
if ($in{'USAF_mem'} eq ('Yes')) {
if ($in{'Attend_Sat'} eq 'Yes') {
if ($in{'Attend_Sun'} eq 'Yes') {
$in{'Total'} = $both_fee;
}
else {
$in{'Total'} = $sat_fee;
}
}
elsif ($in{'Attend_Sun'} eq 'Yes') {
$in{'Total'} = $sun_fee;
}
}
else {
if ($in{'Attend_Sat'} eq 'Yes') {
if ($in{'Attend_Sun'} eq 'Yes') {
$in{'Total'} = $both_Non_fee;
}
else {
$in{'Total'} = $sat_Non_fee;
}
}
elsif ($in{'Attend_Sun'} eq 'Yes') {
$in{'Total'} = $sun_Non_fee;
}
}

Add the same code to sub modify_record, after

my ($status, $line, @lines, @data, $output, $found, $restricted);

In sub html_record, you can add, after

my (%rec) = @_;

Code:
$balance = $rec{'Total'} - $rec{'Paid'};

and then use the $balance variable to print out what the user owes.

Does this make sense to you?


------------------
JPD





Subject Author Views Date
Thread Calculate field based on other fields bboru 1452 Oct 9, 1999, 12:35 PM
Post Re: Calculate field based on other fields
JPDeni 1357 Oct 9, 1999, 2:14 PM
Post Re: Calculate field based on other fields
bboru 1358 Oct 9, 1999, 4:49 PM
Post Re: Calculate field based on other fields
JPDeni 1351 Oct 9, 1999, 5:58 PM
Post Re: Calculate field based on other fields
bboru 1354 Oct 10, 1999, 4:38 AM