sub print_pay_by_check{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal) = get_checkout_table($user_key, 1); my $account_table = get_account_table($user_key); print_steps(); print "
\n"; print "
Step 5 : Pay by Check
Please verify your registration prior to sending the check.

\n"; print $account_table . "

" . $user_table, "
"; print "
\n"; } sub print_pay_partial_complete{ #print "

\n"; my $session_id = get_cookie(); my $user_key = get_login_from_session($session_id); $active_id{"complete"} = "id=current"; print_steps(); $html = "
"; $html .= "
Step 6 : Order Complete
\n"; $html .= $pay_complete_message . "


\n"; if($org_id == 167){ # Plymouth required forms $html .= "Print Registration Confirmation and Player Forms\n"; } $html .= "\n"; $html .= "
\n"; print $html; } sub print_verify_pay_partial{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my $partial = param('partial_amount'); my $min_pay_message = ""; #################################### # Check if the partial payment is less than he min partial pay # if it is, set the message and change the payment to the min # If the min is greater then the balance, this will be handled # in the get_partial_checkout_table function #################################### if($partial < $min_partial_pay){ $partial = $min_partial_pay; $min_pay_message = "
The minimum partial payment is \$$min_partial_pay

"; } my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal, $balance) = get_partial_checkout_table($user_key, 2, $partial); print_steps(); #################################### # Set the min_pay_message to blank if balance is less than # min_partial_pay #################################### if($balance < $min_partial_pay){ $min_pay_message = ""; } $verify_form = "
\n"; $verify_form .= ""; $verify_form .= "\n"; $verify_form .= "
\n"; $pay_by_check_form = "
\n"; $pay_by_check_form .= ""; $pay_by_check_form .= "\n"; $pay_by_check_form .= "
\n"; print "\n"; print "
Step 5:Verify Partial Payment
Please enter the partial payment amount you wish to pay below.$min_pay_message

\n"; print "
\n"; print $user_table, "
"; print $verify_form; print $pay_by_check_form; print $pay_pal; print "
\n"; } sub print_pay_partial{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my $partial = param('partial_amount'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal, $balance) = get_partial_checkout_table($user_key, 0, $partial); print_steps(); $verify_form = "
\n"; $verify_form .= ""; $verify_form .= "\n"; $verify_form .= "
\n"; $pay_by_check_form = "
\n"; $pay_by_check_form .= ""; $pay_by_check_form .= "\n"; $pay_by_check_form .= "
\n"; print "\n"; print "
Step 5: Enter Partial Payment Amount
Please enter the partial payment amount you wish to pay below.

\n"; print "
\n"; print $user_table, "
"; print $verify_form; print $pay_by_check_form; print $pay_pal; print "
\n"; } sub print_pay{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal) = get_checkout_table($user_key, 0); print_steps(); $full_or_partial = <<__JSCRIPT__; __JSCRIPT__ $verify_form = "
\n"; $verify_form .= ""; $verify_form .= "\n"; $verify_form .= "
\n"; $pay_by_check_form = "
\n"; $pay_by_check_form .= ""; $pay_by_check_form .= "\n"; $pay_by_check_form .= "
\n"; print "$full_or_partial
\n"; print "
Step 5:Verify Order
Please verify your registration prior to checkout.

\n"; print $user_table, "
"; print $verify_form; print $pay_by_check_form; print $pay_pal; print "
\n"; } ################################################################ ### Get the HTML player table show in upper right corner ################################################################ sub get_player_table{ my $user_key = shift; my %player_info = get_player_info($user_key); my $user_table = "\n"; #$user_table .= "\n"; $user_table .= "\n"; my $player_number = 1; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $player_number++; $division_id = $player_info{$user_number}{"DIVISION"}; $player_key = $player_info{$user_number}{"KEY"}; $amount_paid = $player_info{$user_number}{"PAID"}; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; #$user_table .= "\n"; $last_user = $user_number; } $user_table .= "
Registered Players
NameDivisioneditremovePaid
NameEditRemove
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"}\$$amount_paid
\n"; return $user_table, $player_number; } ########################################### # Modify player info on main registration ########################################### sub print_modify_player{ my $user_key = param('userkey'); my $player_key = param('playerkey'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my %mod_player_info = get_player_info_by_key($player_key); my $account_table = get_account_table($user_key); my ($user_table, $player_num) = get_player_table($user_key); $active_id{"register"} = "id=current"; print_steps(); my $phone_validation = get_phone_validation(); %reg_form = get_reg_update_form($org_id, "$reg_year","create_player_account_form", $player_key); my $auto_reg_form = ""; my $first_compare = 1; foreach $form_row (sort{$a <=> $b}keys %reg_form){ if(defined($reg_form{"$form_row"}{"JSCRIPT_VARS"})){ $jscript_vars .= $reg_form{"$form_row"}{"JSCRIPT_VARS"}; } if(defined($reg_form{"$form_row"}{"JSCRIPT_COMPARE"})){ my $or = ""; if($first_compare == 1){ $first_compare = 0; }else{ $or = "||" } $jscript_compare .= $or . $reg_form{"$form_row"}{"JSCRIPT_COMPARE"} ; } $auto_reg_form .= $reg_form{"$form_row"}{"HTML"}; } my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; if($user_info{"ADDRESS2"} ne ""){ $address2 = "$user_info{\"ADDRESS2\"}
"; }else{ $address2 = ""; } my $html = <<__HTML__;
$account_table $user_table

Step 3:Update Registration
Please complete the information listed below...
    * Required Fields
$auto_reg_form
Player Information
Player First Name*
Player Last Name*


* Required Fields
__HTML__ print $html; } sub get_multiplayer_discount_description{ my $multiplayer_discount_id = shift; my $dbh = get_dbh(); my $query = "SELECT `Description` FROM `Reg_Multi_Player_Discount` WHERE `Key` = '$multiplayer_discount_id'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $description = "default discount"; while (my $hash_ref = $sth->fetchrow_hashref) { $description = $hash_ref->{Description}; } #print "PLAYER COUNT: $player_count
\n"; # disconnect from database $dbh->disconnect; $sth->finish(); return $description; } ################################################################ ### Print verify Player registration ################################################################ sub print_verify_register_programs{ my $player_key = shift; my $user_key = param(userkey); #my %user_info = get_account_info($user_key); my %player_info = get_player_info_by_key($player_key); $active_id{"verify"} = "id=current"; %reg_form = get_read_only_reg_form($org_id, "$reg_year","create_player_account_form", $player_key); my $auto_reg_form = ""; my $first_compare = 1; foreach $form_row (sort{$a <=> $b}keys %reg_form){ if(defined($reg_form{"$form_row"}{"JSCRIPT_VARS"})){ $jscript_vars .= $reg_form{"$form_row"}{"JSCRIPT_VARS"}; } if(defined($reg_form{"$form_row"}{"JSCRIPT_COMPARE"})){ my $or = ""; if($first_compare == 1){ $first_compare = 0; }else{ $or = "||" } $jscript_compare .= $or . $reg_form{"$form_row"}{"JSCRIPT_COMPARE"} ; } $auto_reg_form .= $reg_form{"$form_row"}{"HTML"}; } print_steps(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; \n"; $return_hash{"TOTAL_FEE_CELL"} = "\n"; $return_hash{"TOTAL_PAID_CELL"} = "\n"; $return_hash{"TOTAL_DUE_CELL"} = "\n"; $return_hash{"TOTAL_FEE"} = $total_fee; $return_hash{"TOTAL_PAID"} = $total_paid; $return_hash{"TOTAL_DUE"} = $total_due; $return_hash{"PAYPAL_STRING"} = $paypal_string; return %return_hash; } ############################################ # Get adjustment info for one player ############################################ sub get_adjustment_info{ my $player_key = shift; my $return_string = ""; my %return_hash = (); my $total = 0; my $total_fee = 0; my $total_paid = 0; my $count = 1; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key`, `Amount`, `Check_ID`, `Update_Account_ID`, `Date` FROM `Reg_All_Transaction` WHERE `Player_ID` = '$player_key' ORDER BY `Key`"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Amount, \$Check_ID, \$Update_Account_ID, \$Date); while($sth->fetch()) { $return_hash{$count}{"KEY"} = $Key; $return_hash{$count}{"AMOUNT"} = $Amount; $return_hash{$count}{"CHECK_ID"} = $Check_ID; $return_hash{$count}{"UPDATE_ID"} = $Update_Account_ID; $return_hash{$count}{"DATE"} = $Date; if(!(($Update_Account_ID == -2)||($Update_Account_ID == -3)||($Update_Account_ID == -5))){ if($Amount > 0){ $total_fee = $total_fee + $Amount; }else{ $total_paid = $total_paid + $Amount; } $total = $total + $Amount; }elsif($Update_Account_ID == -5){ $total_fee = $total_fee + $Amount; } $count++; } #if($player_key == 1409){ #print "TOTAL: $total
T_PAID: $total_paid
FEE: $total_fee
\n"; #} $sth->finish(); $dbh->disconnect; return $total, $total_fee, $total_paid, %return_hash; } ############################################ # Get reg definition info for one cell ############################################ sub get_specific_reg_definition{ my $org_id = shift; my $reg_year = shift; my $player_id = shift; my $reg_key = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key`,`Description_Text`,`Input_Type`,`Selection_Link`,`Validation_Link`,`Required`,`Order` FROM `Reg_Definition` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year' AND `Key` = '$reg_key';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Description_Text,\$Input_Type,\$Selection_Link,\$Validation_Link,\$Required,\$Order); while($sth->fetch()) { $return_hash{"DESCRIPTION_TEXT"} = $Description_Text; $return_hash{"INPUT_TYPE"} = $Input_Type; $return_hash{"SELECTION_LINK"} = $Selection_Link; $return_hash{"VALIDATION_LINK"} = $Validation_Link; $return_hash{"REQUIRED"} = $Required; $return_hash{"ORDER"} = $Order; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ############################################ # Return description text for multiplayer discount ############################################ sub get_multiplayer_discount_description{ my $multiplayer_discount_id = shift; my $dbh = get_dbh(); my $query = "SELECT `Description` FROM `Reg_Multi_Player_Discount` WHERE `Key` = '$multiplayer_discount_id'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $description = "default discount"; while (my $hash_ref = $sth->fetchrow_hashref) { $description = $hash_ref->{Description}; } #print "PLAYER COUNT: $player_count
\n"; # disconnect from database $dbh->disconnect; $sth->finish(); return $description; } ############################################ # Check to see if multiplayer discounts # Change because a player was removed ############################################ sub verify_multiplayer_discounts_after_remove_player{ my $user_key = shift; my $remove_player_key = shift; my $player_count = get_player_count($user_key); my $dbh = get_dbh(); my $query = "SELECT `Key`, `Description`, `Discount` FROM `Reg_Multi_Player_Discount` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year' AND `Number_Of_Reg_Players` > '$player_count'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); ############################################ # Loop through discounts that need to be removed ############################################ while (my $hash_ref = $sth->fetchrow_hashref) { my $description = $hash_ref->{Description}; my $discount = $hash_ref->{Discount}; my $key = $hash_ref->{Key}; check_for_discounts_that_need_to_be_removed($user_key, $key); #print "DESC: $description, DIS: $discount
\n"; #insert_adjustment($user_key, $player_key, $discount, $key, -5); #-5 just means that its a multiplayer discount } #print "PLAYER COUNT: $player_count
\n"; # disconnect from database $sth->finish(); $dbh->disconnect; ############################################ # Check for chance that the removed user # was part of an acitve discount and was not # the player that was discounted in which # case we need to remove on of the discount # from another player ############################################ my $dbh2 = get_dbh(); my $query2 = "SELECT `Key`, `Description`, `Discount` FROM `Reg_Multi_Player_Discount` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year' AND `Number_Of_Reg_Players` <= '$player_count'"; #print "QUERY: $query2
\n"; my $sth2 = $dbh2->prepare($query2); $sth2->execute(); ############################################ # Loop through discounts that need to be removed ############################################ while (my $hash_ref2 = $sth2->fetchrow_hashref) { my $description = $hash_ref2->{Description}; my $discount = $hash_ref2->{Discount}; my $key = $hash_ref2->{Key}; my ($amount, $player_discount_key) = get_player_discount($remove_player_key, $key); ############################################ # If there was no multiplayer discount # for the removed player, we have to remove # a discount for another player of the same # user (parent) ############################################ if($player_discount_key == 0){ remove_first_multi_player_discount($user_key, $key); } #print "DESC: $description, DIS: $discount
\n"; #insert_adjustment($user_key, $player_key, $discount, $key, -5); #-5 just means that its a multiplayer discount } #print "PLAYER COUNT: $player_count
\n"; # disconnect from database $sth2->finish(); $dbh2->disconnect; } ############################################ # Remove a multiplayer discount to compensate # for the removed player which should not have # been discounted ############################################ sub remove_first_multi_player_discount{ my $user_key = shift; my $discount_key = shift; my %player_info = get_player_info($user_key); my $removed_discount = 0; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ if($removed_discount == 0){ my $player_key = $player_info{$user_number}{"KEY"}; my ($amount, $player_discount_key) = get_player_discount($player_key, $discount_key); if($player_discount_key > 0){ my $option_change_amount = 0 - $amount; insert_adjustment($user_key, $player_key, $option_change_amount, "Multi Player Discount Removal", -2); #-2 just means that its an Option Change update_adjustment_account_to_show_change($player_discount_key); $removed_discount = 1; } } } } ############################################ # Get the discount for a speific player # and discount code ############################################ sub get_player_discount{ my $player_key = shift; my $discount_key = shift; my $dbh = get_dbh(); my $query = "SELECT `Key`, `Amount` FROM Reg_All_Transaction WHERE `Check_ID` = '$discount_key' AND `Update_Account_ID` = '-5' AND `Player_ID` = '$player_key'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $amount = 0; my $player_discount_key = 0; while (my $hash_ref = $sth->fetchrow_hashref) { $amount = $hash_ref->{Amount}; $player_discount_key = $hash_ref->{Key}; my $option_change_amount = 0 - $amount; insert_adjustment($user_key, $player_id, $option_change_amount, "ADJUST MP Discount", -2); #-2 just means that its an Option Change update_adjustment_account_to_show_change($key); #insert_adjustment($user_key, $player_key, $discount, $key, -5); #-5 just means that its a multiplayer discount } # disconnect from database $dbh->disconnect; $sth->finish(); return $amount, $player_discount_key; } ############################################ # Look for any discounts that do not # meet player requirement and adjust # them in db ############################################ sub check_for_discounts_that_need_to_be_removed{ my $user_key = shift; my $discount_key = shift; my $dbh = get_dbh(); my $query = "SELECT `Key`, `Player_ID`, `Amount` FROM Reg_All_Transaction WHERE `Check_ID` = '$discount_key' AND `Account_ID` = '$user_key' AND `Update_Account_ID` = '-5'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); while (my $hash_ref = $sth->fetchrow_hashref) { my $player_id = $hash_ref->{Player_ID}; my $amount = $hash_ref->{Amount}; my $key = $hash_ref->{Key}; my $option_change_amount = 0 - $amount; insert_adjustment($user_key, $player_id, $option_change_amount, "ADJUST MP Discount", -2); #-2 just means that its an Option Change update_adjustment_account_to_show_change($key); #insert_adjustment($user_key, $player_key, $discount, $key, -5); #-5 just means that its a multiplayer discount } #print "PLAYER COUNT: $player_count
\n"; # disconnect from database $dbh->disconnect; $sth->finish(); } ############################################ # Check for discount for user (parent) ############################################ sub check_for_multiplayer_discounts{ my $user_key = shift; my $player_key = shift; my $player_count = get_player_count($user_key); my $dbh = get_dbh(); my $query = "SELECT `Key`, `Description`, `Discount` FROM `Reg_Multi_Player_Discount` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year' AND `Number_Of_Reg_Players` <= '$player_count'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); while (my $hash_ref = $sth->fetchrow_hashref) { my $description = $hash_ref->{Description}; my $discount = $hash_ref->{Discount}; my $key = $hash_ref->{Key}; #print "DESC: $description, DIS: $discount
\n"; insert_adjustment($user_key, $player_key, $discount, $key, -5); #-5 just means that its a multiplayer discount } #print "PLAYER COUNT: $player_count
\n"; # disconnect from database $dbh->disconnect; $sth->finish(); } ############################################ # Get number of players per user(parent) ############################################ sub get_player_count{ my $user_key = shift; my $dbh = get_dbh(); my $query = "SELECT COUNT(*) FROM `Reg_Player_Link` WHERE `Account_ID` = '$user_key' AND `Active` = '1' AND `Reg_Year` = '$reg_year'"; my $sth = $dbh->prepare($query); #print "QUERY: $query
\n"; $sth->execute(); my $player_count = $sth->fetchrow_arrayref->[0]; # disconnect from database $dbh->disconnect; $sth->finish(); return $player_count; } ############################################ # Get player info ############################################ sub get_player_info{ my $user_key = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT * FROM `Reg_Player_Link` WHERE `Account_ID` = '$user_key' AND `Active` = '1' AND `Reg_Year` = '$reg_year' ORDER BY `Key`"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$Org_ID, \$Reg_Year, \$Firstname, \$Lastname, \$Account_ID, \$Paid, \$Active, \$Reg_Date); $user_number = 1; while($sth->fetch()) { $return_hash{$user_number}{"KEY"} = $Key; $return_hash{$user_number}{"ORG_ID"} = $Org_ID; $return_hash{$user_number}{"REG_YEAR"} = $Reg_Year; $return_hash{$user_number}{"FIRSTNAME"} = $Firstname; $return_hash{$user_number}{"LASTNAME"} = $Lastname; $return_hash{$user_number}{"ACCOUNT_ID"} = $Account_ID; $return_hash{$user_number}{"PAID"} = $Paid; $return_hash{$user_number}{"ACTIVE"} = $Active; $return_hash{$user_number}{"REG_DATE"} = $Reg_Date; $user_number++; } # disconnect from database $dbh->disconnect; $sth->finish(); return %return_hash; } ############################################ # Return html for checkout header ############################################ sub get_checkout_header{ my $header = shift; my $checkout_header = "

Step 4:Verify Program Registration
Please verify the player information listed below.

$auto_reg_form __HTML__ print $html; } ################################################################ ### Print Player registration form ################################################################ sub print_register_programs{ my $user_key = shift; my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my $account_table = get_account_table($user_key); my ($user_table, $player_number) = get_player_table($user_key); $active_id{"register"} = "id=current"; print_steps(); %reg_form = get_reg_form($org_id, "$reg_year","create_player_account_form", $user_key); my $auto_reg_form = ""; my $first_compare = 1; foreach $form_row (sort{$a <=> $b}keys %reg_form){ if(defined($reg_form{"$form_row"}{"JSCRIPT_VARS"})){ $jscript_vars .= $reg_form{"$form_row"}{"JSCRIPT_VARS"}; } if(defined($reg_form{"$form_row"}{"JSCRIPT_COMPARE"})){ my $or = ""; if($first_compare == 1){ $first_compare = 0; }else{ $or = "||" } $jscript_compare .= $or . $reg_form{"$form_row"}{"JSCRIPT_COMPARE"} ; } $auto_reg_form .= $reg_form{"$form_row"}{"HTML"}; } #print "
\n"; my $phone_validation = get_phone_validation(); $jscript_compare .= '||(lname.value == "")||(fname.value == "")'; $submit_to_pay = get_submit_to_pay($user_key); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; if($user_info{"ADDRESS2"} ne ""){ $address2 = "$user_info{\"ADDRESS2\"}
"; }else{ $address2 = ""; } my $player_header = "
"; my $form_first_name = ""; my $form_last_name = ""; my $html = <<__HTML__;
Player Information
Player First Name:$player_info{"FIRSTNAME"}
Player Last Name:$player_info{"LASTNAME"}

The above information is correct...

The above information is not correct...
Player #$player_number
Player First Name*
Player Last Name*
$account_table $user_table
$submit_to_pay

Step 3:Register for Programs
Please complete the information listed below...
    * Required Fields
$player_header $form_first_name $form_last_name $auto_reg_form __HTML__ $html .= <<__HTML__;


* Required Fields
__HTML__ print $html; } sub get_reg_setup{ my $org_id = shift; my $reg_year = shift; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Secure_URL`, `Org_Dir`, `Reg_File`, `Reg_Admin_File`, `Org_Caps`, `Home_Page_URL`, `Default_State`, `Min_Partial_Pay`, `Reply_To`, `From`, `Org_Full_Name_For_Email`, `Season_Text`, `Welcome_Text`, `Information_Text`, `Pay_Complete_Message`, `Pay_By_Check_Message`, `Paypal_Account`, `Return_URL`, `IPN_URL`, `Paypal_URL` FROM `Reg_Setup` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year'"; print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Secure_URL, \$Org_Dir, \$Reg_File, \$Reg_Admin_File, \$Org_Caps, \$Home_Page_URL, \$Default_State, \$Min_Partial_Pay, \$Reply_To, \$From, \$Org_Full_Name_For_Email, \$Season_Text, \$Welcome_Text, \$Information_Text, \$Pay_Complete_Message, \$Pay_By_Check_Message, \$Paypal_Account, \$Return_URL, \$IPN_URL, \$Paypal_URL ); while($sth->fetch()) { $min_partial_pay = $Min_Partial_Pay; $reply_to = $Reply_To; $from = $From; $org_full_name_for_email = $Org_Full_Name_For_Email; $season_text = $Season_Text; $welcome_text = $Welcome_Text; $information_text = $Information_Text; $pay_complete_message = $Pay_Complete_Message; $pay_by_check_message = $Pay_By_Check_Message; $paypal_acc = $Paypal_Account; $return_url = $Return_URL; $thanks_url = "$Secure_URL/$Org_Dir/$Reg_File?action=pp"; $ipn_url = $IPN_URL; $base_reg_url = "$Secure_URL/$Org_Dir/$Reg_File"; $admin_reg_url = "$Secure_URL/$Org_Dir/$Reg_Admin_File"; $paypal_url = $Paypal_URL; $default_state = $Default_State; $home_page_url = $Home_Page_URL; } $sth->finish(); $dbh->disconnect; } ############################################ # Get player info by key ############################################ sub get_player_info_by_key{ my $player_key = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT * FROM `Reg_Player_Link` WHERE `Key` = '$player_key' AND `Active` = '1' AND `Reg_Year` = '$reg_year' ORDER BY `Key`"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$Org_ID, \$Reg_Year, \$Firstname, \$Lastname, \$Account_ID, \$Paid, \$Active, \$Reg_Date); $user_number = 1; while($sth->fetch()) { $return_hash{"KEY"} = $Key; $return_hash{"ORG_ID"} = $Org_ID; $return_hash{"REG_YEAR"} = $Reg_Year; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"ACCOUNT_ID"} = $Account_ID; $return_hash{"PAID"} = $Paid; $return_hash{"ACTIVE"} = $Active; $return_hash{"REG_DATE"} = $Reg_Date; $user_number++; } $dbh->disconnect; $sth->finish(); return %return_hash; } ################################################################ ### Get the HTML user table show in upper left corner ################################################################ sub get_account_table{ my $user_key = shift; my %user_info = get_account_info($user_key); my $return_html = <<__HTML__;
Account Owner
$user_info{"FIRSTNAME"} $user_info{"LASTNAME"}
$user_info{"EMAIL"}
$user_info{"ADDRESS1"}
$user_info{"ADDRESS2"}
$user_info{"CITY"}, $user_info{"STATE"} $user_info{"ZIP_CODE"}
__HTML__ return $return_html; } ############################################ # Get adjustment tabel cell for payment screen ############################################ sub get_fees_table_cell_paypal_string_and_total{ my $player_key = shift; my $style = shift; my $return_cell = ""; my $paypal_string = ""; my $total = 0; my $total_fee = 0; my $total_paid = 0; my %return_hash = (); my %total_due = 0; my %adjustment_info = (); my $return_string = ""; my $check_id = ""; my $plus_minus = ""; my $first = 1; ############################################ #Get the adjustments for that player ############################################ ($total, $total_fee, $total_paid, %adjustment_info) = get_adjustment_info($player_key); ############################################ # Loop through all the adjustments to get information about the fees ############################################ foreach my $count (sort {$a <=> $b} (keys %adjustment_info)){ ############################################ # If the UPDATE ID is -1 or -3 it was an autmated fee. # So we need to lookup what the fee is using the CHECK_ID field ############################################ if(($adjustment_info{$count}{"UPDATE_ID"} == -1)||($adjustment_info{$count}{"UPDATE_ID"} == -3)){ $checkout_override = get_checkout_override($adjustment_info{$count}{"CHECK_ID"}, $player_key); if($checkout_override eq ""){ $check_id = $input_value = get_input_options($adjustment_info{$count}{"CHECK_ID"}, $player_key); }else{ $check_id = $checkout_override; } }elsif($adjustment_info{$count}{"UPDATE_ID"} == -5){ #Multiplayer Discount $check_id = get_multiplayer_discount_description($adjustment_info{$count}{"CHECK_ID"}); }else{ $check_id = $adjustment_info{$count}{"CHECK_ID"}; } ############################################ # This is to get the proper + and - for the paypal and pay table cell # because a - number would look like $-10 we just strip it and make it -$10 # And then for paypal we do not want a + sign to start with. ############################################ my $adjustment_amount = $adjustment_info{$count}{"AMOUNT"} + 0; my $abs_adjustment_amount = abs($adjustment_amount); $adjustment_amount = sprintf("%.2f", $adjustment_amount); my $display_plus_minus = ""; if(!(($adjustment_info{$count}{"UPDATE_ID"} == -2)||($adjustment_info{$count}{"UPDATE_ID"} == -3))){ if($adjustment_amount >= 0){ if($first == 0){ $plus_minus = " + "; } ############################################ # Set string to first so we do not add a plus or minus in first item ############################################ $first = 0; }else{ $plus_minus = " - "; $display_plus_minus = "-"; } if(($plus_minus ne ' - ')||($adjustment_info{$count}{"UPDATE_ID"} == -5)){ #Only show fees and multiplayer discounts ############################################ # Get the paypal string ############################################ $paypal_string .= $plus_minus . '$' . $abs_adjustment_amount . " " . $check_id; ############################################ # This creates the cell for the pay table ############################################ $abs_adjustment_amount = sprintf("%.2f", $abs_adjustment_amount); $return_cell .= $display_plus_minus . '$' . $abs_adjustment_amount . " " . $check_id . "
"; #$return_cell .= '$' . $abs_adjustment_amount . " " . $check_id . "
"; } } } ############################################ # Calculate return value and set return hash ############################################ $abs_total_paid = abs($total_paid); $total_due = $total_fee + $total_paid; $total_fee = sprintf("%.2f", $total_fee); $total_paid = sprintf("%.2f", $total_paid); $total_due = sprintf("%.2f", $total_due); $abs_total_paid = sprintf("%.2f", $abs_total_paid); #print "TOTAL PAID: $total_due
\n"; $return_hash{"FEES_CELL"} = "
" . $return_cell . "\$" . $total_fee . "\$" . $abs_total_paid . "\$" . $total_due . "
\n"; $checkout_header .= "\n"; return $checkout_header; } ############################################ # Return html for paypal that wont change ############################################ sub get_paypal_const{ my $pay_pal = "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; return $pay_pal; } sub get_checkout_row_for_player_and_total_due_and_pay_pal{ my $player_key = shift; my $first_name = shift; my $last_name = shift; my $style = shift; my $player_row = ""; my %checkout_hash = get_fees_table_cell_paypal_string_and_total($player_key, $style); $player_row .= "\n"; $player_row .= $checkout_hash{"FEES_CELL"} . $checkout_hash{"TOTAL_FEE_CELL"} . $checkout_hash{"TOTAL_PAID_CELL"} . $checkout_hash{"TOTAL_DUE_CELL"} . ""; #print "A_DUE: $amount_due
\n"; return $player_row, %checkout_hash; } ############################################ # This creates the paypal and html for the checkout table. ############################################ sub get_checkout_table{ my $user_key = shift; my $by_check = shift; my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my $pay_pal_count = 1; my $num_players = 0; my $total_cost = 0; my $walk_in_fee = 0; my $walk_in_amount = 25; my $adjustment_string = ""; if($by_check == 0){ $transaction_id = get_transaction_id(); } my $user_table = get_checkout_header("Registered Players"); my $pay_pal = get_paypal_const(); ############################################ # Loop through players to create the display cell, paypal info and calculate totals ############################################ foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $fees_cell = ""; my $total = 0; my $player_total = 0; # this is just in case there are other adjustments my $player_key = $player_info{$user_number}{"KEY"}; #my $amount_paid = $player_info{$user_number}{"PAID"}; ############################################ # Get the cell with a list of what is due for player, plus the paypal string # that gets sent to have an itemized list on pay pal. ############################################ my ($player_row, %checkout_hash) = get_checkout_row_for_player_and_total_due_and_pay_pal($player_key, $player_info{$user_number}{"FIRSTNAME"}, $player_info{$user_number}{"LASTNAME"}, "cal_events3"); my $amount_due = $checkout_hash{"TOTAL_DUE"}; my $paypal_string = $checkout_hash{"PAYPAL_STRING"}; my $total_paid = $checkout_hash{"TOTAL_PAID"}; $user_table .= $player_row; #$amount_due = .02; ############################################ # Store temporary paypal record. This will not be valid until the paypal tx is finished. ############################################ if($by_check == 0){ insert_tmp_paypal($user_key, $player_key, $amount_due, $transaction_id); } ############################################ # Add player specific paypal info ############################################ $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal_count++; ############################################ # Keep running total of amount due for user ############################################ $total_cost = $amount_due + $total_cost; } ############################################ # Finish user table ############################################ $total_cost = sprintf("%.2f", $total_cost); $user_table .= "\n"; $user_table .= "
$header
NameFeeTotalPaidDue
$first_name $last_name
TOTAL DUE: \$$total_cost
\n"; ############################################ # If its not pay by check, create form for submitting ############################################ if($by_check != 1){ $user_table .= "\n"; $user_table .= ""; $user_table .= "\n"; $user_table .= "\n"; } ############################################ # If its not pay by check, give them thier payment options. Notice that # this is stored in the pay_pal portion. I think this is becuase it gets # printed to the screen after the others. ############################################ $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal .= "
 Credit Card Payment Optionsx
\n"; $pay_pal .= "

\n"; $pay_pal .= "
\n"; $pay_pal .= "\n"; ############################################ # If it is pay by check. Display where to send it. Stored in var ############################################ if($by_check == 1){ $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $this_action = "partial"; }else{ $user_table .= "\n"; $user_table .= "\n"; $this_action = "verify_partial"; } $user_table .= ""; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "
$pay_by_check_message
\n"; if($org_id == 167){ # Plymouth required forms $user_table .= "
Print Registration Confirmation and Player Forms

\n"; } $user_table .= "
\n"; #$partial_form = "\n"; $user_table .= ""; $user_table .= "\n"; $user_table .= "
\n
"; } return $user_table, $pay_pal; } sub get_num_players_and_total_cost{ my $user_key = shift; my %player_info = get_player_info($user_key); my $num_players = 0; my $total_cost = 0; my $player_min = 99999; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $player_total = 0; my %adjustment_info = (); my $player_key = $player_info{$user_number}{"KEY"}; my $amount_paid = $player_info{$user_number}{"PAID"}; ($player_total, %adjustment_info) = get_adjustment_info($player_key); $player_total = $player_total - $amount_paid; if($player_total < $player_min){if($player_total != 0){$player_min = $player_total;}} $total_cost = $player_total + $total_cost; } return $num_players, $total_cost, $player_min; } ############################################ # This creates the paypal and html for the partial_checkout table. ############################################ sub get_partial_checkout_table{ my $user_key = shift; my $by_check = shift; my $partial = shift; my ($total_num_players, $max_total_cost, $player_min) = get_num_players_and_total_cost($user_key); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my $pay_pal_count = 1; my $num_players = 0; my $total_cost = 0; my $balance = 0; $transaction_id = get_transaction_id(); my $user_table = get_checkout_header("Registered Players"); my $pay_pal = get_paypal_const(); ############################################ # Loop through players to create the display cell, paypal info and calculate totals ############################################ foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; $player_key = $player_info{$user_number}{"KEY"}; ############################################ # Get the cell with a list of what is due for player, plus the paypal string # that gets sent to have an itemized list on pay pal. ############################################ my ($player_row, %checkout_hash) = get_checkout_row_for_player_and_total_due_and_pay_pal($player_key, $player_info{$user_number}{"FIRSTNAME"}, $player_info{$user_number}{"LASTNAME"}, "cal_events3"); my $amount_due = $checkout_hash{"TOTAL_DUE"}; my $paypal_string = $checkout_hash{"PAYPAL_STRING"}; my $total_paid = $checkout_hash{"TOTAL_PAID"}; $user_table .= $player_row; ############################################ # Calculate what the player owes and fill that cell Also, do some conversions to # two decimal places ############################################ $max_pay = $amount_due; my $amount_to_deduct = get_amount_to_deduct($partial, ($total_num_players - $num_players + 1), $total_cost, $max_pay, $player_min); #$amount_to_deduct = .02; ############################################ # Store temporary paypal record. This will not be valid until the paypal tx is finished. ############################################ insert_tmp_paypal($user_key, $player_key, $amount_to_deduct, $transaction_id); $balance = $balance + $amount_due; ############################################ # Add player specific paypal info ############################################ $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal_count++; ############################################ # Keep running total of amount due for user ############################################ $total_cost = $amount_to_deduct + $total_cost; } ############################################ # Finish user table # if by_check equals 2, then we are confirming the payment ############################################ $total_remaining = $balance - $total_cost; $total_remaining = sprintf("%.2f", $total_remaining); $balance = sprintf("%.2f", $balance); $total_cost = sprintf("%.2f", $total_cost); if($by_check == 2){ $user_table .= "
Balance: \$$balance
TOTAL REMAINING After Payment: \$$total_remaining
Confirm Amount to Pay Now: \$$total_cost
Balance: \$$balance
Enter the Partial Amount You Want to Pay: \$
\n"; $pay_pal .= "\n"; if($by_check == 2){ $pay_pal .= "\n"; }else{ } $pay_pal .= "
\n"; if($by_check == 1){ $user_table .= ""; }elsif($Input_Type == 2){ #INPUT $input_value = get_input_text($Key, $player_id); }elsif($Input_Type == 3){ #Select Dropdown $input_value = get_input_options($Key, $player_id); }elsif($Input_Type == 4){ #Date $input_value = get_input_date($Key, $player_id); $input_value = get_view_date_format($input_value); }elsif($Input_Type == 5){ #Radio $input_value = get_input_options($Key, $player_id); }elsif($Input_Type == 6){ #Textarea $input_value = get_input_longtext($Key, $player_id); }elsif($Input_Type == 7){ #CheckBox $input_value = get_input_checked($Key, $player_id); $checked = ""; if($input_value == 1){ $checked = "CHECKED"; } $input_value = $checked; }elsif($Input_Type == 10){ #Select Dropdown Long value with payment attached $input_value = get_input_options($Key, $player_id); }elsif($Input_Type == 11){ #Radio with payment attached $input_value = get_input_options($Key, $player_id); } return $input_value; } sub get_input_date{ my $reg_id = shift; my $player_id = shift; my $input_text = ""; my $dbh = get_dbh(); my $query = "SELECT `Input_Date` FROM Reg_Input_Date WHERE `Reg_ID` = '$reg_id' AND `Player_ID` = '$player_id';"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Input_Date); while($sth->fetch()) { $input_date = $Input_Date; } $sth->finish(); $dbh->disconnect; return $input_date; } sub get_input_longtext{ my $reg_id = shift; my $player_id = shift; my $input_text = ""; my $dbh = get_dbh(); my $query = "SELECT `Input_Longtext` FROM Reg_Input_Longtext WHERE `Reg_ID` = '$reg_id' AND `Player_ID` = '$player_id';"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Input_Text); while($sth->fetch()) { $input_text = $Input_Text; } $sth->finish(); $dbh->disconnect; return $input_text; } sub get_input_text{ my $reg_id = shift; my $player_id = shift; my $input_text = ""; my $dbh = get_dbh(); my $query = "SELECT `Input_Text` FROM Reg_Input_Text WHERE `Reg_ID` = '$reg_id' AND `Player_ID` = '$player_id';"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Input_Text); while($sth->fetch()) { $input_text = $Input_Text; } $sth->finish(); $dbh->disconnect; return $input_text; } sub get_input_checked{ my $reg_id = shift; my $player_id = shift; my $input_value = ""; my $dbh = get_dbh(); my $query = "SELECT `Input_Option` FROM Reg_Input_Options WHERE `Reg_ID` = '$reg_id' AND `Player_ID` = '$player_id';"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Input_Value); while($sth->fetch()) { $input_value = $Input_Value; } $sth->finish(); $dbh->disconnect; return $input_value; } sub get_input_options{ my $reg_id = shift; my $player_id = shift; my $input_value = ""; my $dbh = get_dbh(); my $query = "SELECT a.`Option` FROM Reg_Options a, Reg_Input_Options b WHERE b.`Reg_ID` = '$reg_id' AND b.`Player_ID` = '$player_id' AND b.`Input_Option` = a.`Key`;"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Input_Value); while($sth->fetch()) { $input_value = $Input_Value; } $sth->finish(); $dbh->disconnect; return $input_value; } ################################### # Get parameter for DB ################################### sub get_param{ my $paramter = shift; my $value = param($paramter); $value =~ s/\'/''/g; $value =~ s/\"//g; $value =~ s/\\//g; return $value; } ################################### # Update Player Name ################################### sub update_player_name{ my $player_key = shift; my $first_name = shift; my $last_name = shift; my $query = "UPDATE Reg_Player_Link SET `Firstname` = '$first_name', `Lastname` = '$last_name' WHERE `Key` = '$player_key';"; #print "$query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $player_key; } ################################### # Set Player Active to 0 ################################### sub remove_player{ my $player_key = shift; my $query = "UPDATE Reg_Player_Link SET `Active` = '0' WHERE `Key` = '$player_key';"; #print "$query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $player_key; } ############################################ # Get how much the player is due for a specific field ############################################ sub get_checkout_override{ my $option_id = shift; my $player_id = shift; my $checkout_override = ""; my $dbh = get_dbh(); #my $query = "SELECT `Checkout_Override` FROM `Reg_Payment_Definition` WHERE `Option_ID` = '$option_id' ;"; my $query = "SELECT a.`Checkout_Override` FROM Reg_Payment_Definition a, Reg_Input_Options b WHERE b.`Reg_ID` = '$option_id' AND b.`Player_ID` = '$player_id' AND b.`Input_Option` = a.`Option_ID`;"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Checkout_Override); while($sth->fetch()) { $checkout_override = $Checkout_Override; } $sth->finish(); $dbh->disconnect; return $checkout_override; } ############################################ # Get how much the player is due for a specific field ############################################ sub get_option_payment_amount{ my $option_id = shift; my $amount = 0; my $dbh = get_dbh(); my $query = "SELECT `Amount` FROM `Reg_Payment_Definition` WHERE `Option_ID` = '$option_id' ;"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Amount); while($sth->fetch()) { $amount = $Amount; } $sth->finish(); $dbh->disconnect; return $amount; } ################################################################ ### Get params and update DB ################################################################ sub get_player_params_and_update_database{ my $org_id = shift; my $reg_year = shift; my $player_id = shift; my $user_id = shift; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key`,`Description_Text`,`Input_Type`,`Selection_Link`,`Validation_Link`,`Required`,`Order` FROM `Reg_Definition` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Description_Text,\$Input_Type,\$Selection_Link,\$Validation_Link,\$Required,\$Order); while($sth->fetch()) { my $reg_id = "REG" . $Key; my $required = ""; if($Input_Type == 1){ # HEADER }elsif($Input_Type == 2){ #INPUT $return_hash{$reg_id} = get_param($reg_id); insert_text($Key, $player_id, $return_hash{$reg_id}); }elsif($Input_Type == 3){ #Select Dropdown $return_hash{$reg_id} = get_param($reg_id); insert_option($Key, $player_id, $return_hash{$reg_id}); }elsif($Input_Type == 4){ #Date my $dob1 = get_param('dob1'); my $dob2 = get_param('dob2'); my $dob3 = get_param('dob3'); my $dob = $dob1 . "/" . $dob2 . "/" . $dob3; $dob = get_db_date_format($dob); $return_hash{$reg_id} = $dob; insert_date($Key, $player_id, $return_hash{$reg_id}); #my $dob = get_param($reg_id); #$dob = get_db_date_format($dob); #$return_hash{$reg_id} = $dob; #insert_date($Key, $player_id, $return_hash{$reg_id}); }elsif($Input_Type == 5){ #Radio $return_hash{$reg_id} = get_param($reg_id); insert_option($Key, $player_id, $return_hash{$reg_id}); }elsif($Input_Type == 6){ #Textarea $return_hash{$reg_id} = get_param($reg_id); insert_longtext($Key, $player_id, $return_hash{$reg_id}); }elsif($Input_Type == 7){ #CheckBox my $check_box = get_param($reg_id); if($check_box eq "on"){ $check_box = 1; }else{ $check_box = 0; } $return_hash{$reg_id} = $check_box; insert_option($Key, $player_id, $return_hash{$reg_id}); }elsif($Input_Type == 10){ #Select Dropdown with payment attached $return_hash{$reg_id} = get_param($reg_id); insert_option($Key, $player_id, $return_hash{$reg_id}); update_adjustment_table_from_input($return_hash{$reg_id}, $user_id, $player_id, $Key); }elsif($Input_Type == 11){ #Radio with payment attached $return_hash{$reg_id} = get_param($reg_id); insert_option($Key, $player_id, $return_hash{$reg_id}); my $player_amount_due = get_option_payment_amount($return_hash{$reg_id}); update_adjustment_table_from_input($return_hash{$reg_id}, $user_id, $player_id, $Key); } } # disconnect from database $sth->finish(); $dbh->disconnect; } sub update_adjustment_table_from_input{ my $option_id = shift; my $user_id = shift; my $player_id = shift; my $reg_def_id = shift; # The reg definition id gets inserted as the check id my $player_amount_due = get_option_payment_amount($option_id); my $update = check_if_its_an_update_for_that_user($user_id, $reg_def_id, $player_id, $player_amount_due); if(($player_amount_due >= 0)&&($update == 1)){ # -1 means no update insert_adjustment($user_id, $player_id, $player_amount_due, $reg_def_id, -1); #-1 just means that its an auto update and it should get the text for trx from reg definition } } sub check_if_its_an_update_for_that_user{ my $user_id = shift; my $reg_def_id = shift; my $player_id = shift; my $new_amount_due = shift; my $update = 1; my $dbh = get_dbh(); my $query = "SELECT `Key` , `Account_ID`, `Amount`, `Check_ID`, `Date` FROM Reg_All_Transaction WHERE `Check_ID` = '$reg_def_id' AND `Player_ID` = '$player_id' AND `Update_Account_ID` = '-1'"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key,\$Account_ID,\$Amount,\$Check_ID,\$Date); while($sth->fetch()) { #$amount = 0 - $Amount; $Amount = sprintf("%.2f",$Amount); $new_amount_due = sprintf("%.2f",$new_amount_due); print "NEW: $new_amount_due - OLD: $Amount
\n"; print "NEW: $reg_def_id - OLD: $Check_ID
\n"; if($new_amount_due != $Amount){ my $option_change_amount = 0 - $Amount; insert_adjustment($user_id, $player_id, $option_change_amount, "Option Change", -2); #-2 just means that its an Option Change update_adjustment_account_to_show_change($Key); }else{ $update = 0; } } $sth->finish(); $dbh->disconnect; return $update; } sub update_adjustment_account_to_show_change{ my $key = shift; my $dbh = get_dbh(); my $query = "UPDATE Reg_All_Transaction SET `Update_Account_ID` = '-3' WHERE `Key` = '$key' LIMIT 1"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; } ################################################################ ### Update adjustemnt ################################################################ sub insert_adjustment{ my $user_id = shift; my $player_key = shift; my $amount = shift; my $check_notes = shift; my $update_account = shift; #my $update_account = get_player_id_from_cookie(); my $account_id = get_account_id_by_player_key($player_key); my $date = get_date_time(); my $query = "INSERT INTO Reg_All_Transaction (`Key` , `Account_ID` , `Player_ID` , `Update_Account_ID`, `Amount`, `Check_ID`, `Date`) VALUES ('', '$user_id', '$player_key', '$update_account', '$amount', '$check_notes', '$date')"; #print "$query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $player_key; } ################################################################ # Get the reg form - READ ONLY ################################################################ sub get_read_only_reg_form{ my $org_id = shift; my $reg_year = shift; my $form_name = shift; my $player_id = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key`,`Description_Text`,`Input_Type`,`Selection_Link`,`Validation_Link`,`Required`,`Order` FROM `Reg_Definition` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Description_Text,\$Input_Type,\$Selection_Link,\$Validation_Link,\$Required,\$Order); while($sth->fetch()) { my $reg_id = "REG" . $Key; my $required = ":"; #if($Required == 1){ # $required = "*"; # ($return_hash{$Order}{"JSCRIPT_VARS"}, $return_hash{$Order}{"JSCRIPT_COMPARE"}) = get_required_js($Input_Type,$form_name,$reg_id);; #} if($Input_Type == 1){ # HEADER $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 2){ #INPUT TEXT $input_value = get_input_text($Key, $player_id); $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 3){ #Select Dropdown $input_value = get_input_options($Key, $player_id); $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 4){ #Date $input_value = get_input_date($Key, $player_id); $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 5){ #Radio $input_value = get_input_options($Key, $player_id); my $radio_button = ""; $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 6){ #Textarea $input_value = get_input_longtext($Key, $player_id); $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 7){ #CheckBox $input_value = get_input_checked($Key, $player_id); $checked = ""; if($input_value == 1){ $checked = "CHECKED"; } $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 10){ #Select Dropdown Long dropdown and payment attached $input_value = get_input_options($Key, $player_id); $return_hash{$Order}{"HTML"} = ""; }elsif($Input_Type == 11){ #Radio with payment attached $input_value = get_input_options($Key, $player_id); my $radio_button = ""; $return_hash{$Order}{"HTML"} = ""; } } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ################################################################ # This just gets the javascript for required fields ################################################################ sub get_required_js{ my $Input_Type = shift; my $form_name = shift; my $reg_id = shift; if(($Input_Type == 5)||($Input_Type == 11)){ # 5 is radio, 11 is radio with payment my $radio_check = "var $reg_id = 0;\n"; $radio_check .= "var unused = 0;\n"; $radio_check .= "for(i=0;iprepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Description_Text,\$Input_Type,\$Selection_Link,\$Validation_Link,\$Required,\$Order); while($sth->fetch()) { my $reg_id = "REG" . $Key; my $required = ""; if($Required == 1){ $required = "*"; ($return_hash{$Order}{"JSCRIPT_VARS"}, $return_hash{$Order}{"JSCRIPT_COMPARE"}) = get_required_js($Input_Type,$form_name,$reg_id);; } $return_hash{$Order}{"HTML"} = get_reg_cell_with_update($Input_Type, $Key, $reg_id, $Description_Text, $required, $player_id); } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ################################################################ ### Primary Reg form radio buttons ################################################################ sub get_radio_button{ my $reg_key = shift; my $reg_id = shift; my $selected_option = shift; if(!(defined($selected_option))){ $selected_option = 0; } #print "SELECTED: $selected_option
\n"; ###### Just used Reg Options instead of new table. my $query = "SELECT `Key`,`Option` FROM `Reg_Options` WHERE `Reg_ID` = '$reg_key' ORDER BY `Order`;"; my $options = ""; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); my $selected = ""; #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Option); while($sth->fetch()) { $selected = ""; if($selected_option == $Key){ $selected = "checked=\"checked\""; } $options .= " $Option
\n"; } $sth->finish(); $dbh->disconnect; return $options; } ################################################################ ### Get Options for Reg form Select-Options input ################################################################ sub get_options{ my $reg_key = shift; my $selected_option = shift; if(!(defined($selected_option))){ $selected_option = 0; } #print "SELECTED OPTION: $selected_option
\n"; my $query = "SELECT `Key`,`Option` FROM `Reg_Options` WHERE `Reg_ID` = '$reg_key' ORDER BY `Order`;"; my $options = ""; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); my $selected = ""; #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Option); while($sth->fetch()) { $selected = ""; if($selected_option == $Key){ $selected = "SELECTED"; } $options .= " \n"; } $sth->finish(); $dbh->disconnect; return $options; } sub get_account_value{ my $user_key = shift; my $account_prefill_value = shift; my %account_hash = (); my $return_value = ""; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Firstname`, a.`Lastname`, a.`email`, a.`Home_Phone`, a.`Work_Phone`, a.`Mobile_Phone`, a.`Zip_Code`, b.`Address1`, b.`Address2`, b.`City`, b.`State` FROM `Account_Info` a, `Account_Extra_Info` b WHERE a.`Key` = '$user_key' AND a.`Key` = b.`Account_ID`;"; my $sth = $dbh->prepare($query); #print "$query
$account_prefill_value
\n"; $sth->execute(); $sth->bind_columns(\$Firstname, \$Lastname, \$Email, \$Home_Phone, \$Work_Phone, \$Mobile_Phone, \$Zip_Code, \$Address1, \$Address2, \$City, \$State); # for the account_prefill while($sth->fetch()) { $account_hash{"Firstname"} = $Firstname; $account_hash{"Lastname"} = $Lastname; $account_hash{"Email"} = $Email; $account_hash{"Home_Phone"} = $Home_Phone; $account_hash{"Work_Phone"} = $Work_Phone; $account_hash{"Mobile_Phone"} = $Mobile_Phone; $account_hash{"Zip_Code"} = $Zip_Code; $account_hash{"Address1"} = $Address1; $account_hash{"Address2"} = $Address2; $account_hash{"City"} = $City; $account_hash{"State"} = $State; } # disconnect from database $sth->finish(); $dbh->disconnect; $return_value = $account_hash{$account_prefill_value}; return $return_value; } sub get_first_player{ my $user_key = shift; my $dbh = get_dbh(); my $return_key = 0; ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key` FROM `Reg_Player_Link` WHERE `Account_ID` = '$user_key' AND `Active` = '1' ORDER BY `Key`;"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); # for the account_prefill my $first_player = 1; while($sth->fetch()) { if($first_player == 1){ $return_key = $Key; } $first_player = 0; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_key; } sub get_option_months{ my $selected_month = shift; my @months = (); my $i = 0; # $months[1] = "January"; $months[2] = "February"; $months[3] = "March"; $months[4] = "April"; $months[5] = "May"; $months[6] = "June"; $months[7] = "July"; $months[8] = "August"; $months[9] = "September"; $months[10] = "October"; $months[11] = "November"; $months[12] = "December"; for($i = 1; $i < 13; $i++){ my $selected = ""; if($i == $selected_month){ $selected = "SELECTED"; } $return_options .= ""; } return $return_options; } sub get_option_days{ my $selected_day = shift; my $i = 0; my $return_days = ""; for($i = 1;$i <= 31; $i++){ my $selected = ""; if($i == $selected_day){ $selected = "SELECTED"; } $return_days .= "\n"; } return $return_days; } sub get_option_years{ my $selected_year = shift; my $i = 0; my $return_years = ""; my $current_date = get_date_time(); ($current_year, $junk, $junk) = split(/-/,$current_date); my $stop_year = $current_year - 100; for($i = $current_year;$i > $stop_year; $i--){ my $selected = ""; if($i == $selected_year){ $selected = "SELECTED"; } $return_years .= "\n"; } return $return_years; } ################################################################ ### Primary Reg form ################################################################ sub get_reg_cell{ my $user_key = shift; my $Input_Type = shift; my $Key = shift; my $reg_id = shift; my $Description_Text = shift; my $required = shift; my $default_value = shift; my $account_prefill_value = shift; my $player_prefill_value = shift; my $first_player_id = get_first_player($user_key); my $return_html = ""; if($Input_Type == 1){ # HEADER $return_html = "
"; }elsif($Input_Type == 2){ #INPUT my $value = ""; ####################################### # Check for defaults ####################################### if($account_prefill_value ne ""){ @values = split(/,/,$account_prefill_value); my $space = ""; # just because we dont wont a space the first time through foreach(@values){ $tmp_value = get_account_value($user_key, $_); #print "TV: $tmp_value
\n"; $value = $value . $space . $tmp_value; $space = " "; } }elsif($player_prefill_value != 0){ if($first_player_id != 0){ $value = $input_value = get_input_text($Key, $first_player_id); } }elsif($default_value ne ""){ $value = $default_value; } $return_html = ""; }elsif($Input_Type == 3){ #Select Dropdown ####################################### # Check for defaults ####################################### $input_value = 0; if($player_prefill_value != 0){ if($first_player_id != 0){ $input_value = get_input_checked($Key, $first_player_id); } }elsif($default_value ne ""){ $input_value = $default_value; } my $select = ""; $return_html = $select; }elsif($Input_Type == 4){ #Date my $month_options = get_option_months(0); my $days_options = get_option_days(0); my $year_options = get_option_years(0); $return_html = "\n"; }elsif($Input_Type == 94){ #Date $return_html = ""; }elsif($Input_Type == 5){ #Radio ####################################### # Check for defaults ####################################### $input_value = 0; if($player_prefill_value != 0){ if($first_player_id != 0){ $input_value = get_input_checked($Key, $first_player_id); } }elsif($default_value ne ""){ $input_value = $default_value; } my $radio_button = ""; $return_html = $radio_button; }elsif($Input_Type == 6){ #Textarea $return_html = ""; }elsif($Input_Type == 7){ #CheckBox $return_html = ""; }elsif($Input_Type == 10){ # Dropdown with payment and long my $select = ""; $return_html = $select; }elsif($Input_Type == 11){ #Radio with payment attached my $radio_button = ""; $return_html = $radio_button; } return $return_html; } ################################################################ ### Get registration form ################################################################ sub get_reg_form{ my $org_id = shift; my $reg_year = shift; my $form_name = shift; my $user_key = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key`,`Description_Text`,`Input_Type`,`Selection_Link`,`Validation_Link`,`Required`,`Default_Value`, `Account_Prefill_Value`, `Player_Prefill_Value`, `Order` FROM `Reg_Definition` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Description_Text,\$Input_Type,\$Selection_Link,\$Validation_Link,\$Required, \$Default_Value, \$Account_Prefill_Value, \$Player_Prefill_Value, \$Order); while($sth->fetch()) { my $reg_id = "REG" . $Key; my $required = ""; if($Required == 1){ $required = "*"; ($return_hash{$Order}{"JSCRIPT_VARS"}, $return_hash{$Order}{"JSCRIPT_COMPARE"}) = get_required_js($Input_Type,$form_name,$reg_id);; } $return_hash{$Order}{"HTML"} = get_reg_cell($user_key, $Input_Type, $Key, $reg_id, $Description_Text, $required, $Default_Value, $Account_Prefill_Value, $Player_Prefill_Value); } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ################################################################ ### Get registration cells with values included ################################################################ sub get_reg_cell_with_update{ my $Input_Type = shift; my $Key = shift; my $reg_id = shift; my $Description_Text = shift; my $required = shift; my $player_id = shift; my $return_html = ""; if($Input_Type == 1){ # HEADER $return_html = ""; }elsif($Input_Type == 2){ #INPUT $input_value = get_input_text($Key, $player_id); $return_html = ""; }elsif($Input_Type == 3){ #Select Dropdown $input_value = get_input_checked($Key, $player_id); my $select = ""; $return_html = $select; }elsif($Input_Type == 4){ #Date $input_value = get_input_date($Key, $player_id); my($month, $day, $year) = get_month_day_year($input_value); my $month_options = get_option_months($month); my $days_options = get_option_days($day); my $year_options = get_option_years($year); $return_html = "\n"; }elsif($Input_Type == 94){ #Date $input_value = get_input_date($Key, $player_id); $input_value = get_view_date_format($input_value); $return_html = ""; }elsif($Input_Type == 5){ #Radio $input_value = get_input_checked($Key, $player_id); my $radio_button = ""; $return_html = $radio_button; }elsif($Input_Type == 6){ #Textarea $input_value = get_input_longtext($Key, $player_id); $return_html = ""; }elsif($Input_Type == 7){ #CheckBox $input_value = get_input_checked($Key, $player_id); $checked = ""; if($input_value == 1){ $checked = "CHECKED"; } $return_html = ""; }elsif($Input_Type == 10){ #Select Dropdown with payment attached $input_value = get_input_checked($Key, $player_id); my $select = ""; $return_html = $select; }elsif($Input_Type == 11){ #Radio with payment attached $input_value = get_input_checked($Key, $player_id); my $radio_button = ""; $return_html = $radio_button; } return $return_html; } ################################################################ ### Create new player in db ################################################################ sub create_new_player{ my $org_id = shift; my $reg_year = shift; my $user_key = param(userkey); my $first_name = get_param('fname'); my $last_name = get_param('lname'); my %return_hash = (); my $player_id = link_new_player($user_key, $first_name, $last_name); get_player_params_and_update_database($org_id, $reg_year, $player_id, $user_key); return $player_id; } ################################################################ ### Covert the date to use in database ################################################################ sub get_db_date_format{ my $date = shift; my($month, $day, $year) = split(/\//,$date); $date = "$year-$month-$day"; return $date; } ################################################################ ### Create the date to viewable format ################################################################ sub get_view_date_format{ my $date = shift; my($year, $month, $day) = split(/-/,$date); $date = "$month/$day/$year"; return $date; } ################################################################ ### Create the date to viewable format ################################################################ sub get_month_day_year{ my $date = shift; my($year, $month, $day) = split(/-/,$date); return $month,$day,$year; } ######################################### # Insert item to the Reg_Input_Longtext table ######################################### sub insert_longtext{ my $reg_id = shift; my $player_id = shift; my $insert_lt = shift; my $query = "REPLACE INTO Reg_Input_Longtext (`Reg_ID`,`Player_ID`, `Input_Longtext`) VALUES ('$reg_id', '$player_id', '$insert_lt');"; #print "QUERY: $query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $user_id; } ######################################### # Insert item to the Reg_Input_Date table ######################################### sub insert_date{ my $reg_id = shift; my $player_id = shift; my $insert_date = shift; my $query = "REPLACE INTO Reg_Input_Date (`Reg_ID`,`Player_ID`, `Input_Date`) VALUES ('$reg_id', '$player_id', '$insert_date');"; #print "QUERY: $query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $user_id; } ######################################### # Insert item to insert_option table ######################################### sub insert_option{ my $reg_id = shift; my $player_id = shift; my $insert_option = shift; my $query = "REPLACE INTO Reg_Input_Options (`Reg_ID`,`Player_ID`, `Input_Option`) VALUES ('$reg_id', '$player_id', '$insert_option');"; #print "QUERY: $query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $user_id; } ######################################### # Insert item to the Reg_Input_Text table ######################################### sub insert_text{ my $reg_id = shift; my $player_id = shift; my $insert_text = shift; my $query = "REPLACE INTO Reg_Input_Text (`Reg_ID`,`Player_ID`, `Input_Text`) VALUES ('$reg_id', '$player_id', '$insert_text');"; #print "QUERY: $query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $user_id; } ######################################### # Link a player to account in the Reg_player_link table ######################################### sub link_new_player{ my $user_key = shift; my $first_name = shift; my $last_name = shift; my $reg_date = get_date_time(); my $query = "INSERT INTO Reg_Player_Link (`Key`, `Org_ID`, `Reg_Year`, `Account_ID`, `Firstname`, `Lastname`, `Active`, `Reg_Date`) VALUES ('', '$org_id', '$reg_year', '$user_key','$first_name','$last_name', '1', '$reg_date');"; #print "QUERY: $query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); ######################################### # Get the ID of the just inserted event ######################################### my $query2 = "SELECT LAST_INSERT_ID( );"; $sth = $dbh->prepare($query2); $sth->execute(); # assign fields to variables $sth->bind_columns(\$last_insert_id); while($sth->fetch()) { $user_id = $last_insert_id; } #print "$query
\n"; $sth->finish(); $dbh->disconnect; return $user_id; } ######################################### # Gets Temp password for email ######################################### sub get_tmp_pw{ #my $tmp_pw = "123test"; my $tmp_pw = generate_random_string_pw(6); return $tmp_pw; } ######################################### # Generates random string for temp password ######################################### sub generate_random_string_pw{ $length = shift; $rand_string = ""; $possible = '23456789'; while (length($rand_string) < $length) { $rand_string .= substr($possible, (int(rand(length($possible)))), 1); } return $rand_string; } ######################################### # Generates random string for temp token ######################################### sub get_tmp_string{ #my $tmp_string = "123test"; my $tmp_string = generate_random_string(20); my $random_string_exists = get_email_by_x($tmp_string); my $count = 1; while($random_string_exists ne ""){ $random_string_exists = get_email_by_x($tmp_string); $count++; if($count > 10){ $random_string_exists = ""; } } return $tmp_string; } ######################################### # Check if tmp password is correct ######################################### sub check_tmp_password{ my $email = shift; my $pw = shift; my $tmp_string = shift; my $tmp_pw = 0; my $valid_tmp_pw = 0; my $dbh = get_dbh(); my $query = "SELECT `Key`, `Tmp_Password` FROM `Account_TMP_Password` WHERE `Email` = '$email' AND `Tmp_String` = '$tmp_string';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$Tmp_Password); while($sth->fetch()) { $tmp_pw = $Tmp_Password; $key = $Key; } if($tmp_pw eq $pw){ $valid_tmp_pw = 1; }else{ if($tmp_pw == 0){ $valid_tmp_pw = 2; } } $sth->finish(); $dbh->disconnect; return $valid_tmp_pw; } ######################################### # Check if tmp password exist ######################################### sub check_tmp_password_exist{ my $email = shift; my $valid_tmp_string = ""; my $dbh = get_dbh(); my $query = "SELECT `Tmp_String`, `Tmp_Password` FROM `Account_TMP_Password` WHERE `Email` = '$email';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Tmp_String, \$Tmp_Password); while($sth->fetch()) { $valid_tmp_string = $Tmp_String; $tmp_password = $Tmp_Password; } $sth->finish(); $dbh->disconnect; return $valid_tmp_string, $tmp_password; } ######################################### # Set the account tmp password ######################################### sub set_account_tmp_password{ my $email = shift; my $tmp_string = ""; my $pw = ""; my $date_time = ""; $date_time = get_date_time(); ($tmp_string, $pw) = check_tmp_password_exist($email); #print "TS: $tmp_string - PW: $pw
\n"; if($tmp_string eq ""){ $pw = get_tmp_pw(); $tmp_string = get_tmp_string(); my $dbh = get_dbh(); my $query = "INSERT INTO `Account_TMP_Password` ( `Key` , `Email` , `Tmp_Password` , `Tmp_String` , `Date`) VALUES ('', '$email', '$pw', '$tmp_string', '$date_time');"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; } return $pw, $tmp_string, $date_time; } ######################################### # Send temp password to users ######################################### sub send_tmppw{ my $email = shift;; my $sendmail = "/bin/sendmail.localhost -t"; #my $reply_to = "Reply-to: jeremy\@hometeamz.com"; my $subject = "Account Password for $org_full_name_for_email Registration"; my $to = "$email"; #my $to = "jeremymclean\@gmail.com"; #my $from = "jeremy\@hometeamz.com"; my ($pw, $tmp_string, $date_time) = set_account_tmp_password($email); #print "PASS: $pw
\n" my $found_email = 0; if($pw ne ""){ $found_email = 1; my %user_info = get_account_info_by_email($email); $content = "Welcome,

\n\nThank you for registering with $org_full_name_for_email

\n\n"; $content .= "Please use the temporary password provided below to validate your new account.

\n"; $content .= "Your temporary password is: $pw
\nYour login is: $email

\n\n"; $content .= "To proceed directly to the account verification window, please follow this link\n"; $content .= "\n"; #print "HEY
\n"; open(SENDMAIL, "|$sendmail -f $from") or die "Cannot open $sendmail: $!"; print SENDMAIL "To: $to\n"; #print SENDMAIL "bcc: $bcc\n"; print SENDMAIL "Subject: $subject\n"; print SENDMAIL "Content-type: text/html\n\n"; print SENDMAIL $content; close(SENDMAIL); } print "$to $pw $from $content
\n"; return $found_email, $tmp_string; } ############################################ # Get account info by email ############################################ sub get_account_info_by_email{ my $email = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Key`, a.`email`, a.`Firstname`, a.`Lastname`, a.`Home_Phone`, a.`Work_Phone`, a.`Mobile_Phone`, a.`Zip_Code`, b.`Address1`, b.`Address2`, b.`City`, b.`State` FROM `Account_Info` a, `Account_Extra_Info` b WHERE b.`Account_ID` = a.`Key` and (a.`email` = '$email' OR a.`Login` = '$email')"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$email, \$Firstname, \$Lastname, \$Home_Phone, \$Work_Phone,\$Mobile_Phone, \$Zip_Code, \$Address1, \$Address2, \$City, \$State); while($sth->fetch()) { $return_hash{"KEY"} = $Key; $return_hash{"EMAIL"} = $email; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"HOMEPHONE"} = $Home_Phone; $return_hash{"WORK_PHONE"} = $Work_Phone; $return_hash{"MOBILE_PHONE"} = $Mobile_Phone; $return_hash{"ZIP_CODE"} = $Zip_Code; $return_hash{"ADDRESS1"} = $Address1; $return_hash{"ADDRESS2"} = $Address2; $return_hash{"CITY"} = $City; $return_hash{"STATE"} = $State; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ######################################### # Set the account password to user ######################################### sub send_pw{ my $email = param('email'); my $sendmail = "/bin/sendmail.localhost -t"; my $subject = "Password Reminder for $org_full_name_for_email"; my $to = "$email"; #my $to = "jeremymclean\@gmail.com"; #my $from = "jeremy\@hometeamz.com"; my $pw = get_pw_by_email($email); my $found_email = 0; if($pw eq ""){ #print "PW2: $pw
\n"; }else{ #print "PW: $pw
\n"; $found_email = 1; my %user_info = get_account_info_by_email($email); $content = "Hello $user_info{\"FIRSTNAME\"} $user_info{\"LASTNAME\"},\n\n"; $content .= "You have requested a password reminder from $org_full_name_for_email.\n\n"; $content .= "Your information is:\nLogin: $user_info{\"EMAIL\"}\nPassword: $pw \n"; open(SENDMAIL, "|$sendmail -f $from") or die "Cannot open $sendmail: $!"; print SENDMAIL "To: $to\n"; print SENDMAIL "bcc: $bcc\n"; print SENDMAIL "Subject: $subject\n"; print SENDMAIL "Content-type: text/plain\n\n"; print SENDMAIL $content; close(SENDMAIL); #print $content; } return $found_email; } ################################################################ ### This section prints the stylesheet as well as some ### Javascript functions ################################################################ sub print_style2{ $league_only = shift; $menu_text_color = "#ffffff"; $menu_bg_color = "#999999"; $menu_border_color = "#ffffff"; $menu_head_text_color = "#ffffff"; $menu_head_bg_color = "#686b6e"; $menu_padding = "2"; #$menu_color_hover = "#ffffff"; #$menu_color_hover = "yellow"; $menu_color_hover = "#ffffff"; $menu_bg_color_hover = "#686b6e"; $bare_domain = $hometeamz_url; $bare_domain = "hometeamzonline.com"; $bare_domain =~ s/www\.//; if($league_only == 1){ $bg_url = ""; }else{ $bg_url = "$teamdata/hometeamz/bg_right3.gif"; } #$style_sheet = "$lib/ht.css"; print <<__HTML__; __HTML__ add_to_hit_counter($org_id); } ################################################################ ### This prints the left hand column ################################################################ sub print_reg_info{ print "
\n"; print_text_info_box("Registration", "$welcome_text"); #print_text_info_box("Program", "Baseball &
Softball"); print_text_info_box("Season", "$season_text"); #print_text_info_box("Registration Fees", "Baseball - \$145
Early Bird discount. Register by Dec 15 and get \$25 off registration."); print_text_info_box("Information", "$information_text"); #print_text_info_box("About Homteamz", "Hometeamz.com provides online league services for community sports programs.
More Info"); print <<__HTML__;
__HTML__ print "
\n"; } ################################################################ ### These are the text boxes on the left side ################################################################ sub print_text_info_box{ my $title = shift; my $text = shift; my $font_size = "10pt"; my $font_color = "black"; my $text_align = "center"; my $header_color = "#686b6e"; #my $header_color = "#666699"; my $body_color = "#ffffff"; print <<__HTML__;
$pay_by_check_message\n"; } return $user_table, $pay_pal, $balance; } ############################################ # Get the Registration values by player ############################################ sub get_reg_values_by_player{ my $org_id = shift; my $reg_year = shift; my $player_id = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key`,`Description_Text`,`Input_Type`,`Selection_Link`,`Validation_Link`,`Required`,`Order` FROM `Reg_Definition` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Description_Text,\$Input_Type,\$Selection_Link,\$Validation_Link,\$Required,\$Order); while($sth->fetch()) { $return_hash{$Key} = get_cell_value($Input_Type,$Key,$player_id); } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ############################################ # Get value for a cell ############################################ sub get_cell_value{ my $Input_Type = shift; my $Key = shift; my $player_id = shift; my $return_html = ""; if($Input_Type == 1){ # HEADER $return_html = "
$Description_Text
$Description_Text
$Description_Text $required$input_value
$Description_Text $required$input_value
$Description_Text $required$input_value
$Description_Text $required\n"; $radio_button .= get_radio_button($Key, $reg_id, $input_value); $radio_button .= "
$Description_Text $required$input_value
$Description_Text $required
$Description_Text $required
$Description_Text $required$input_value
$Description_Text $required\n"; $radio_button .= get_radio_button($Key, $reg_id, $input_value); $radio_button .= "
$Description_Text $required$input_value
$Description_Text
$Description_Text $required
$Description_Text $required
$Description_Text $required "; $return_html .= ""; $return_html .= ""; $return_html .= ""; $return_html .= "
$Description_Text $required
$Description_Text $required\n"; $radio_button .= get_radio_button($Key, $reg_id, $input_value); $radio_button .= "
$Description_Text $required
$Description_Text $required
$Description_Text $required
$Description_Text $required\n"; $radio_button .= get_radio_button($Key, $reg_id); $radio_button .= "
$Description_Text
$Description_Text $required
$Description_Text $required
$Description_Text $required "; $return_html .= ""; $return_html .= ""; $return_html .= ""; $return_html .= "
$Description_Text $required
$Description_Text $required\n"; $radio_button .= get_radio_button($Key, $reg_id, $input_value); $radio_button .= "
$Description_Text $required
$Description_Text $required
$Description_Text $required
$Description_Text $required\n"; $radio_button .= get_radio_button($Key, $reg_id, $input_value); $radio_button .= "
$title
$text

__HTML__ } ################################################################ ### Print extra style for reg pages. ################################################################ sub print_reg_style{ print <<__HTML__; __HTML__ } 1;