Gossamer Forum
Home : Products : DBMan : Customization :

Calculate field based on other fields

Quote Reply
Calculate field based on other fields
My knowlege of Perl is rudimentary, so I'm having a hard time trying to figure out how to base the value of a field on the entered values of 3 other fields. Below is my attempt at the sub, but I'm not even sure whether it should be incorporated in db.cgi or html.pl
(I have the commented variables, listed here at the end, declared in my db.cfg file)

sub balance {
#----------------------------------
#Calculate the balance based on single-day fee, weekend-fee, and
#member status.

while($rec{'USAF_mem'} eq ('yes')) {
($sat_fee - $rec{'Paid') if $rec{'Attend_Sat'} eq ('Yes') && $rec{'Attend_Sun'} eq ('') ;
($sun_fee - $rec{'Paid') if $rec{'Attend_Sun'} eq ('Yes') && $rec{'Attend_Sat'} eq ('') ;
($both_fee - $rec{'Paid') if $rec{'Attend_Sat'} eq ('Yes') && $rec{'Attend_Sun'} eq ('Yes') ;
{last}}

while($rec{'USAF_mem'} eq ('No')) {

($sat_Non_fee - $rec{'Paid') if $rec{'Attend_Sat'} eq ('Yes') && $rec{'Attend_Sun'} eq ('') ;
($sun_Non_fee - $rec{'Paid') if $rec{'Attend_Sun'} eq ('Yes') && $rec{'Attend_Sat'} eq ('') ;
($both_Non_fee - $rec{'Paid') if $rec{'Attend_Sat'} eq ('Yes') && $rec{'Attend_Sun'} eq ('Yes') ;
{last}}
}





# $sat_fee = 60.00;
# $sun_fee = 40.00;
# $both_fee = 80.00;
# $sat_Non_fee = 75.00;
# $sun_Non_fee = 55.00;
# $both_Non_fee = 100.00;

I'd appreciate any help.
Thanks.
-Brian
Subject Author Views Date
Thread Calculate field based on other fields bboru 1437 Oct 9, 1999, 12:35 PM
Post Re: Calculate field based on other fields
JPDeni 1342 Oct 9, 1999, 2:14 PM
Post Re: Calculate field based on other fields
bboru 1343 Oct 9, 1999, 4:49 PM
Post Re: Calculate field based on other fields
JPDeni 1335 Oct 9, 1999, 5:58 PM
Post Re: Calculate field based on other fields
bboru 1339 Oct 10, 1999, 4:38 AM